emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-24 e3c24b1 1/2: * lisp/progmodes/sh-script.el: Fix i


From: Stefan Monnier
Subject: [Emacs-diffs] emacs-24 e3c24b1 1/2: * lisp/progmodes/sh-script.el: Fix indentation rule of "| while".
Date: Thu, 04 Dec 2014 19:17:27 +0000

branch: emacs-24
commit e3c24b171bfff16fb808cb02d3fc5eaff017c1bc
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>

    * lisp/progmodes/sh-script.el: Fix indentation rule of "| while".
    
    Fixes: debbugs:18031
    
    * lisp/progmodes/sh-script.el (sh-smie-sh-rules): Go back to the beginning
    of the whole pipe when indenting an opening keyword after a |.
    Generalize this treatment to opening keywords like "while".
---
 lisp/ChangeLog              |    6 ++++++
 lisp/progmodes/sh-script.el |    4 ++--
 test/indent/shell.sh        |   11 +++++++++++
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 12e5ef0..26b09a6 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
+2014-12-04  Stefan Monnier  <address@hidden>
+
+       * progmodes/sh-script.el (sh-smie-sh-rules): Go back to the beginning
+       of the whole pipe when indenting an opening keyword after a |.
+       Generalize this treatment to opening keywords like "while" (bug#18031).
+
 2014-12-01  Stefan Monnier  <address@hidden>
 
        * simple.el (newline): Place the hook buffer-locally,
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index 724d22a..1165144 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -1988,12 +1988,12 @@ May return nil if the line should not be treated as 
continued."
                    (and (numberp indent) (numberp initial)
                         (<= indent initial)))))
      `(column . ,(+ initial sh-indentation)))
-    (`(:before . ,(or `"(" `"{" `"["))
+    (`(:before . ,(or `"(" `"{" `"[" "while" "if" "for" "case"))
      (if (not (smie-rule-prev-p "&&" "||" "|"))
          (when (smie-rule-hanging-p)
            (smie-rule-parent))
        (unless (smie-rule-bolp)
-        (smie-backward-sexp 'halfexp)
+        (while (equal "|" (nth 2 (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.
diff --git a/test/indent/shell.sh b/test/indent/shell.sh
index e361905..14f6774 100755
--- a/test/indent/shell.sh
+++ b/test/indent/shell.sh
@@ -54,6 +54,17 @@ filter_3 ()                     # bug#17842
        grep -v "^," | sort -t, -k2,2
 }
 
+foo | bar | {
+    toto
+}
+
+grep -e "^$userregexp:" /etc/passwd | cut -d :  -f 1 | while read user ; do
+    print -u2 "user=$user"      # bug#18031
+    sudo -U $user -ll | while read line ; do
+        :
+    done
+done
+
 echo -n $(( 5 << 2 ))
 # This should not be treated as a heredoc (bug#12770).
 2



reply via email to

[Prev in Thread] Current Thread [Next in Thread]