]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/progmodes/sh-script.el: Fix indentation rule of "| while".
authorStefan Monnier <monnier@iro.umontreal.ca>
Thu, 4 Dec 2014 15:09:08 +0000 (10:09 -0500)
committerStefan Monnier <monnier@iro.umontreal.ca>
Thu, 4 Dec 2014 15:09:08 +0000 (10:09 -0500)
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
lisp/progmodes/sh-script.el
test/indent/shell.sh

index 12e5ef0e34675fd116871f584b8c1028a692d70c..26b09a68d02fd4d779ffc000316a10ab2490dcbc 100644 (file)
@@ -1,3 +1,9 @@
+2014-12-04  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * 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  <monnier@iro.umontreal.ca>
 
        * simple.el (newline): Place the hook buffer-locally,
index 724d22ab69b633201d44b22d25587a28ed38c98e..1165144d05c8c2739f1975aaa691c7c969e85faa 100644 (file)
@@ -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.
index e3619057d6ef09143eb46582541695bc24b58984..14f67744ff2565c27079c8ef4adfe5c14e0f1342 100755 (executable)
@@ -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