From: Lars Ingebrigtsen Date: Thu, 12 May 2022 16:16:43 +0000 (+0200) Subject: Add new user option 'sh-indent-statement-after-and' X-Git-Tag: emacs-29.0.90~1910^2~754 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7a8bed255398e181378f59262534c7a36ec43ddb;p=emacs.git 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. --- diff --git a/etc/NEWS b/etc/NEWS index 3bdc497f18a..e09834c0568 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -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 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)))))