[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master eac3f2a8077: sh-script.el: Add support for `case FOO {...}` (bug#
From: |
Stefan Monnier |
Subject: |
master eac3f2a8077: sh-script.el: Add support for `case FOO {...}` (bug#55764) |
Date: |
Thu, 11 Jan 2024 22:12:45 -0500 (EST) |
branch: master
commit eac3f2a80778b3904c55ae7b65ff862a79eebf2a
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
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.
---
lisp/progmodes/sh-script.el | 7 ++++---
test/manual/indent/shell.sh | 7 +++++++
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index 0562415b4e5..2a650fe0ea6 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -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)
diff --git a/test/manual/indent/shell.sh b/test/manual/indent/shell.sh
index 5b3fb0e66fb..42a981d312e 100755
--- a/test/manual/indent/shell.sh
+++ b/test/manual/indent/shell.sh
@@ -189,3 +189,10 @@ bar () {
fi
}
+
+case $i { # Bug#55764
+ *pattern)
+ (cd .; echo hi);
+ do1 ;;
+ *pattern2) do2 ;;
+}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master eac3f2a8077: sh-script.el: Add support for `case FOO {...}` (bug#55764),
Stefan Monnier <=