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

From: Jeremy Hall <[email-masked]>
Date: Mon, 16 Nov 2009 12:25:28 +0000

Hi, 

I have noticed that the behaviour is intermittent.  I have just tried a
file (at the start) when it fails.  The cursor is left on the bracket of
xxxx) .  I moved around the file a bit and it kept failing, then, at the
end of the file it worked.  After that, it worked every where in the
file.  

I see it calls (scan-sexps (point-min) (point-max)) in lisp.el,
so its clearly intended to work over over the entire buffer.

For info, my elisp is:-  (here I just want the function to be aborted
with a message, if the file is incorrect, before the indenting starts).

;;
;; Tidy whitespace in a source file.
;;
(defun jah-src-tidy ()
	"Tidy whitespace in a source file."
	(interactive)
	(jah-set-tabs)
	(message "Tidy leading tabs ...")
	(tabify (point-min) (point-max))
	(message "Tidy trailing whitespace ...")
	(delete-trailing-whitespace)
	(message "Check brackets and quotes ...")
	(save-excursion (check-parens))
	(message "Tidy indentation ...")
	(indent-region (point-min) (point-max))
	(message "Source tidy complete.")
	)

Thanks,
Jeremy

On Sat, 2009-11-14 at 13:11 -0500, Stefan Monnier wrote:
> >> 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.
> 
> 
>         Stefan
>