diff options
| author | Stefan Monnier | 2014-12-04 10:09:08 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2014-12-04 10:09:08 -0500 |
| commit | e3c24b171bfff16fb808cb02d3fc5eaff017c1bc (patch) | |
| tree | 36899d349d406a88d8f3d53a999dbe93ed1891c2 | |
| parent | d9d383147219f8e6a90d4c177e1b454e19acfac9 (diff) | |
| download | emacs-e3c24b171bfff16fb808cb02d3fc5eaff017c1bc.tar.gz emacs-e3c24b171bfff16fb808cb02d3fc5eaff017c1bc.zip | |
* 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".
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/progmodes/sh-script.el | 4 | ||||
| -rwxr-xr-x | test/indent/shell.sh | 11 |
3 files changed, 19 insertions, 2 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 12e5ef0e346..26b09a68d02 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2014-12-04 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * progmodes/sh-script.el (sh-smie-sh-rules): Go back to the beginning | ||
| 4 | of the whole pipe when indenting an opening keyword after a |. | ||
| 5 | Generalize this treatment to opening keywords like "while" (bug#18031). | ||
| 6 | |||
| 1 | 2014-12-01 Stefan Monnier <monnier@iro.umontreal.ca> | 7 | 2014-12-01 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 8 | ||
| 3 | * simple.el (newline): Place the hook buffer-locally, | 9 | * simple.el (newline): Place the hook buffer-locally, |
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index 724d22ab69b..1165144d05c 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." | |||
| 1988 | (and (numberp indent) (numberp initial) | 1988 | (and (numberp indent) (numberp initial) |
| 1989 | (<= indent initial))))) | 1989 | (<= indent initial))))) |
| 1990 | `(column . ,(+ initial sh-indentation))) | 1990 | `(column . ,(+ initial sh-indentation))) |
| 1991 | (`(:before . ,(or `"(" `"{" `"[")) | 1991 | (`(:before . ,(or `"(" `"{" `"[" "while" "if" "for" "case")) |
| 1992 | (if (not (smie-rule-prev-p "&&" "||" "|")) | 1992 | (if (not (smie-rule-prev-p "&&" "||" "|")) |
| 1993 | (when (smie-rule-hanging-p) | 1993 | (when (smie-rule-hanging-p) |
| 1994 | (smie-rule-parent)) | 1994 | (smie-rule-parent)) |
| 1995 | (unless (smie-rule-bolp) | 1995 | (unless (smie-rule-bolp) |
| 1996 | (smie-backward-sexp 'halfexp) | 1996 | (while (equal "|" (nth 2 (smie-backward-sexp 'halfexp)))) |
| 1997 | `(column . ,(smie-indent-virtual))))) | 1997 | `(column . ,(smie-indent-virtual))))) |
| 1998 | ;; FIXME: Maybe this handling of ;; should be made into | 1998 | ;; FIXME: Maybe this handling of ;; should be made into |
| 1999 | ;; a smie-rule-terminator function that takes the substitute ";" as arg. | 1999 | ;; a smie-rule-terminator function that takes the substitute ";" as arg. |
diff --git a/test/indent/shell.sh b/test/indent/shell.sh index e3619057d6e..14f67744ff2 100755 --- a/test/indent/shell.sh +++ b/test/indent/shell.sh | |||
| @@ -54,6 +54,17 @@ filter_3 () # bug#17842 | |||
| 54 | grep -v "^," | sort -t, -k2,2 | 54 | grep -v "^," | sort -t, -k2,2 |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | foo | bar | { | ||
| 58 | toto | ||
| 59 | } | ||
| 60 | |||
| 61 | grep -e "^$userregexp:" /etc/passwd | cut -d : -f 1 | while read user ; do | ||
| 62 | print -u2 "user=$user" # bug#18031 | ||
| 63 | sudo -U $user -ll | while read line ; do | ||
| 64 | : | ||
| 65 | done | ||
| 66 | done | ||
| 67 | |||
| 57 | echo -n $(( 5 << 2 )) | 68 | echo -n $(( 5 << 2 )) |
| 58 | # This should not be treated as a heredoc (bug#12770). | 69 | # This should not be treated as a heredoc (bug#12770). |
| 59 | 2 | 70 | 2 |