From 9e248ebdc71b051911ba1a68187d300bfff39fb3 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Fri, 20 Jun 2014 10:23:30 -0400 Subject: [PATCH] * lisp/progmodes/sh-script.el (sh-smie-sh-rules): For { after &&, don't align with the surrounding parent. Fixes: debbugs:17721 --- lisp/ChangeLog | 5 +++++ lisp/progmodes/sh-script.el | 6 +++++- test/indent/shell.sh | 8 ++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b7cd062d15c..81a8945be11 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2014-06-20 Stefan Monnier + + * progmodes/sh-script.el (sh-smie-sh-rules): For { after &&, don't + align with the surrounding parent (bug#17721). + 2014-06-20 Eli Zaretskii * textmodes/texinfo.el (texinfo-mode): Set skeleton-end-newline diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index f248494eed1..4db462594dc 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -1952,7 +1952,11 @@ May return nil if the line should not be treated as continued." (<= indent initial)) `(column . ,(+ initial sh-indentation))))) (`(:before . ,(or `"(" `"{" `"[")) - (if (smie-rule-hanging-p) (smie-rule-parent))) + (when (smie-rule-hanging-p) + (if (not (smie-rule-prev-p "&&" "||" "|")) + (smie-rule-parent) + (smie-backward-sexp 'halfexp) + `(column . ,(smie-indent-virtual))))) ;; FIXME: Maybe this handling of ;; should be made into ;; a smie-rule-terminator function that takes the substitute ";" as arg. (`(:before . ,(or `";;" `";&" `";;&")) diff --git a/test/indent/shell.sh b/test/indent/shell.sh index ed6bcf8da3a..8e831bb8f11 100755 --- a/test/indent/shell.sh +++ b/test/indent/shell.sh @@ -33,6 +33,14 @@ esac bar } +for foo in bar; do # bug#17721 + [ -e $foo ] && { + echo t + } && { + echo r + } +done + echo -n $(( 5 << 2 )) # This should not be treated as a heredoc (bug#12770). 2 -- 2.39.5