emacs-31 b65f8ef93d0: (sh-font-lock-paren): Fix bug#81192

Stefan Monnier via Mailing list for Emacs changes <[email protected]> Sun, 26 Jul 2026 15:36:30 -0400 (EDT)
Newsgroups gmane.emacs.diffs
Message-ID <[email protected]>
branch: emacs-31
commit b65f8ef93d03f9d9d9d0504cd22938ad0b975e6a
Author: Stefan Monnier <[email protected]>
Commit: Stefan Monnier <[email protected]>

    (sh-font-lock-paren): Fix bug#81192
    
    Since commit 4e1fe56e316c turned several new chars into punctuations,
    they're not skipped by (skip-syntax-backward "w_") any more,
    so we need to skip them more explicitly instead when trying to
    skip a case pattern.
    
    * lisp/progmodes/sh-script.el (sh-font-lock-paren): Skip more
    punctuation chars.
    * test/lisp/progmodes/sh-script-resources/sh-indents.erts
    (sh-indents-case-pattern-bug#81192): New test.
---
 lisp/progmodes/sh-script.el                             |  2 +-
 test/lisp/progmodes/sh-script-resources/sh-indents.erts | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index 4d025eeb18d..0dd90aac42f 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -1037,7 +1037,7 @@ subshells can nest."
               ;; Skip through one pattern
               (while
                   (or (/= 0 (skip-syntax-backward "w_"))
-                      (/= 0 (skip-chars-backward "-$=?[]*@/\\\\"))
+                      (/= 0 (skip-chars-backward "-$=?[]*@/\\\\!%:.^~,"))
                       (and (sh-is-quoted-p (1- (point)))
                            (goto-char (- (point) 2)))
                       (when (memq (char-before) '(?\" ?\' ?\}))
diff --git a/test/lisp/progmodes/sh-script-resources/sh-indents.erts b/test/lisp/progmodes/sh-script-resources/sh-indents.erts
index 5a72df0e7ef..2bd09a9e9dd 100644
--- a/test/lisp/progmodes/sh-script-resources/sh-indents.erts
+++ b/test/lisp/progmodes/sh-script-resources/sh-indents.erts
@@ -49,3 +49,16 @@ Name: sh-indents5
 for i do echo 1; done
 for i; do echo 1; done
 =-=-=
+
+Name: sh-indents-case-pattern-bug#81192
+
+=-=
+case "$1" in
+    a:b)
+	echo "a b"
+	;;
+    *,*)
+	echo "other"
+	;;
+esac
+=-=-=