sh-script.el: Add support for case FOO {...}
(bug#55764)
* lisp/progmodes/sh-script.el (sh-font-lock-paren): Also recognize `FOO)` after `{`. (sh-smie-sh-rules): Make `for` rule apply to `case FOO { ...}` as well. * test/manual/indent/shell.sh: Add new test case.
This commit is contained in:
parent
bfb486d802
commit
eac3f2a807
2 changed files with 11 additions and 3 deletions
|
@ -1054,7 +1054,8 @@ subshells can nest."
|
|||
;; a normal command rather than the real `in' keyword.
|
||||
;; I.e. we should look back to try and find the
|
||||
;; corresponding `case'.
|
||||
(and (looking-at ";\\(?:;&?\\|[&|]\\)\\|\\_<in")
|
||||
;; Also recognize OpenBSD's case X { ... } (bug#55764).
|
||||
(and (looking-at ";\\(?:;&?\\|[&|]\\)\\|\\_<in\\|.{")
|
||||
;; ";; esac )" is a case that looks
|
||||
;; like a case-pattern but it's really just a close
|
||||
;; paren after a case statement. I.e. if we skipped
|
||||
|
@ -2057,9 +2058,9 @@ May return nil if the line should not be treated as continued."
|
|||
(sh-var-value 'sh-indent-for-case-label)))
|
||||
(`(:before . ,(or "(" "{" "[" "while" "if" "for" "case"))
|
||||
(cond
|
||||
((and (equal token "{") (smie-rule-parent-p "for"))
|
||||
((and (equal token "{") (smie-rule-parent-p "for" "case"))
|
||||
(let ((data (smie-backward-sexp "in")))
|
||||
(when (equal (nth 2 data) "for")
|
||||
(when (member (nth 2 data) '("for" "case"))
|
||||
`(column . ,(smie-indent-virtual)))))
|
||||
((not (smie-rule-prev-p "&&" "||" "|"))
|
||||
(when (smie-rule-hanging-p)
|
||||
|
|
|
@ -189,3 +189,10 @@ bar () {
|
|||
|
||||
fi
|
||||
}
|
||||
|
||||
case $i { # Bug#55764
|
||||
*pattern)
|
||||
(cd .; echo hi);
|
||||
do1 ;;
|
||||
*pattern2) do2 ;;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue