Subject: bug#4920: 23.1; (check-parens) problem with bash script case items unbalanced close paren

From: [email-masked]
Date: Sun, 10 Jul 2016 09:16:54 -0400

Stefan Monnier <[email-masked]> writes:

>>     emacs -Q bug-4920-check-parens.sh --eval '(setq parse-sexp-lookup-properties t)' -f check-parens
>
>> succeeds.  Should this variable be set by sh-mode along with the other
>> syntax propertize settings?
>
> Oh, yes, please, and thanks,

So it was already being set by sh-set-shell, but in only in case
sh-use-smie is nil.  Here is a patch to set it unconditionally.  I think
it's safe to apply to emacs-25 since I see that
parse-sexp-lookup-properties does get set to t at some point anyway (by
font-lock-fontify-syntactic-keywords-region I guess?), so this just
makes it happen a bit earlier.

>From 28e9ec947f1edf44947b50009b5f3fec23027f45 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <[email-masked]>
Date: Thu, 7 Jul 2016 21:14:48 -0400
Subject: [PATCH v1] Make sh-mode always use p-s-lookup-properties

This lets functions which rely on syntax-propertize for parsing
work correctly even before font lock has a chance to run.

* lisp/progmodes/sh-script.el (sh-set-shell): Set
parse-sexp-lookup-properties unconditionally (Bug #4920).
---
 lisp/progmodes/sh-script.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index 10e56d0..5288734 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -2430,8 +2430,8 @@ sh-set-shell
                       (funcall mksym "rules")
                       :forward-token  (funcall mksym "forward-token")
                       :backward-token (funcall mksym "backward-token")))
+        (setq-local parse-sexp-lookup-properties t)
         (unless sh-use-smie
-          (setq-local parse-sexp-lookup-properties t)
           (setq-local sh-kw-alist (sh-feature sh-kw))
           (let ((regexp (sh-feature sh-kws-for-done)))
             (if regexp
-- 
2.8.0