[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 7a8bed2553: Add new user option 'sh-indent-statement-after-and'
From: |
Lars Ingebrigtsen |
Subject: |
master 7a8bed2553: Add new user option 'sh-indent-statement-after-and' |
Date: |
Thu, 12 May 2022 12:17:39 -0400 (EDT) |
branch: master
commit 7a8bed255398e181378f59262534c7a36ec43ddb
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
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.
---
etc/NEWS | 9 +++++++++
lisp/progmodes/sh-script.el | 10 ++++++++--
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 3bdc497f18..e09834c056 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 9151fd0a34..379224dbce 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)))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 7a8bed2553: Add new user option 'sh-indent-statement-after-and',
Lars Ingebrigtsen <=