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

From: [email-masked]
Date: Thu, 07 Jul 2016 21:10:54 -0400

tags 4920 patch
quit

Stefan Monnier <[email-masked]> writes:

>>> Running (check-parens) fails on a bash script with case statements in
>>> because of the unmatched close ")".  Would it be possible to fix this,
>>> or tell me how to work around it?
>> I can't reproduce this: `M-x check-parens RET' on the following file
>> signals no error.  Please provice a more detailed bug report.
>
>> #!/bin/sh
>
>> case "$SYSNAME" in
>>     Darwin)
>> 	;;
>>     Linux)
>
> Those parentheses get a syntax-table property applied by
> font-lock-syntactic-keywords, which means that the behavior will be
> (hopefully) correct for the visible part of the text, and maybe for all
> the text before that, but not necessarily for the text after
> window-end.

Right, seems to easily reproducible with

    echo '#!/bin/sh' > bug-4920-check-parens.sh
    seq -f '# etc %.0f' 1000 >> bug-4920-check-parens.sh 
    cat >>bug-4920-check-parens.sh <<EOF
         case "$SYSNAME" in
          Darwin)
                # ssss
            ;;
              Linux)
    EOF
    emacs -Q bug-4920-check-parens.sh -f check-parens

And easily fixable by adding a syntax-propertize call at the beginning
of check-parens:

diff --git i/lisp/emacs-lisp/lisp.el w/lisp/emacs-lisp/lisp.el
index ea7cce6..9786429 100644
--- i/lisp/emacs-lisp/lisp.el
+++ w/lisp/emacs-lisp/lisp.el
@@ -719,2 +719,3 @@ check-parens
   (interactive)
+  (syntax-propertize (point-max))
   (condition-case data