summaryrefslogtreecommitdiff
path: root/lisp/progmodes/sh-script.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2022-05-12 18:16:43 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2022-05-12 18:16:43 +0200
commit7a8bed255398e181378f59262534c7a36ec43ddb (patch)
tree9f53cda8d00b856b547568bbb1fd57fe27319bd2 /lisp/progmodes/sh-script.el
parentc8d7a27438b294e20ca0f8f6f1dd74d4a273dc96 (diff)
downloademacs-7a8bed255398e181378f59262534c7a36ec43ddb.tar.gz
Add new user option 'sh-indent-statement-after-and'
* lisp/progmodes/sh-script.el (sh-indent-statement-after-and): New user option (bug#22645). (sh-smie-sh-rules): Use it.
Diffstat (limited to 'lisp/progmodes/sh-script.el')
-rw-r--r--lisp/progmodes/sh-script.el10
1 files changed, 8 insertions, 2 deletions
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index 9151fd0a340..379224dbced 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -641,7 +641,11 @@ implemented as aliases. See `sh-feature'."
:version "24.4" ; bash4 additions
:group 'sh-script)
-
+(defcustom sh-indent-statement-after-and t
+ "How to indent statements following &&.
+If t, indent to the &&. If nil, indent to the parent."
+ :type 'boolean
+ :version "29.1")
(defcustom sh-leading-keywords
'((bash sh-append sh
@@ -1990,7 +1994,9 @@ May return nil if the line should not be treated as continued."
(current-column)
(smie-indent-calculate)))))
(`(:before . ,(or "|" "&&" "||"))
- (unless (smie-rule-parent-p token)
+ (when (and (not (smie-rule-parent-p token))
+ (or (not (equal token "&&"))
+ sh-indent-statement-after-and))
(smie-backward-sexp token)
`(column . ,(+ (funcall smie-rules-function :elem 'basic)
(smie-indent-virtual)))))