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.
This commit is contained in:
Lars Ingebrigtsen 2022-05-12 18:16:43 +02:00
parent c8d7a27438
commit 7a8bed2553
2 changed files with 17 additions and 2 deletions

View file

@ -799,6 +799,15 @@ so automatically.
* Changes in Specialized Modes and Packages in Emacs 29.1
** Shell Script Mode
---
*** New user option 'sh-indent-statement-after-and'.
This controls how statements like the following are indented:
foo &&
bar
---
*** New user option 'cperl-file-style'.
This option determines the indentation style to be used. It can also

View file

@ -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)))))