unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* sh-script fontification errors (error during display messages)
@ 2005-10-14  1:47 Michael Mauger
  2005-10-14  3:18 ` Michael Mauger
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Mauger @ 2005-10-14  1:47 UTC (permalink / raw)


I'm encountering the following error message while editing bash shell scripts 
(sh-script-mode) and have font-lock-mode enabled:

  Error during redisplay: (error No match 6 in highlight (6 font-lock-builtin-
face))

In addition, not all of the shell keywords get fontified.

For example, try the following script:
 #!/usr/bin/bash

 while true; do
     if false; then
 	echo "Hello"
     else
 	break
     fi
 done

You may see the "while", "do", ... keywords get fontified briefly before they 
revert to their un-fontified appearance.

I've tracked down the problem to line 1440 of lisp/progmodes/sh-script.el:

1426: (defun sh-font-lock-keywords-1 (&optional builtins)
1427:   "Function to get better fontification including keywords."
1428:   (let ((keywords (concat "\\([;(){}`|&]\\|^\\)[ \t]*\\(\\("
1429: 			  (regexp-opt (sh-feature sh-leading-keywords) t)
1430: 			  "[ \t]+\\)?"
1431: 			  (regexp-opt (append (sh-feature sh-leading-keywords)
1432: 					      (sh-feature sh-other-keywords))
1433: 				      t))))
1434:     (sh-font-lock-keywords
1435:      `(,@(if builtins
1436: 	     `((,(concat keywords "[ \t]+\\)?"
1437: 			 (regexp-opt (sh-feature sh-builtins) t)
1438: 			 "\\>")
1439: 		(2 font-lock-keyword-face nil t)
1440: 		(6 font-lock-builtin-face))
1441: 	       ,@(sh-feature sh-font-lock-keywords-var-2)))
1442: 	 (,(concat keywords "\\)\\>")
1443: 	  2 font-lock-keyword-face)
1444: 	 ,@(sh-feature sh-font-lock-keywords-var-1)))))

If I comment that line out (and insert the necessary closing paren), my scripts 
are fontified properly and there are no error messages generated.  

I'm not able to decypher what the line intended to do so I'm not sure how to 
fix it.  One thing I did notice was that in 2001 the regexp-opt was added to 
build the regexp for the builtins where previously (an inefficient) mapconcat 
expression had been used.  That could result in a change in the number of 
subpattern expressions (thus the 6th expression was no longer what it used to 
be).  However, undoing that change leads to no good in Mudville.  So I'm 
running with the line commented out, but ask that someone more familiar with 
the intent of that code take a look.  (Assuming others can duplicate my 
experience).

Since the code runs under jit-lock, I'm wondering if the recent tweaking of 
that code may have exacerbated this underlying issue...

I'm running a week old CVS snapshot on w32 (GNU Emacs 22.0.50.1 (i386-mingw-
nt5.1.2600) of 2005-10-09 on MMAUGXP).  

Thanks

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: sh-script fontification errors (error during display messages)
  2005-10-14  1:47 Michael Mauger
@ 2005-10-14  3:18 ` Michael Mauger
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Mauger @ 2005-10-14  3:18 UTC (permalink / raw)


I wrote:

> (Assuming others can duplicate my experience).
> 

Even I can't replicate this on an exact duplicate installation.  (I build, tar
and zip the install onto a memory stick which I use on two different machines.)
 I'll have to debug what happened.  

For now, ignore this noise unless you can duplicate my experience...

-- Michael

^ permalink raw reply	[flat|nested] 4+ messages in thread

* sh-script fontification errors (error during display messages)
@ 2005-10-15  8:28 martin rudalics
  0 siblings, 0 replies; 4+ messages in thread
From: martin rudalics @ 2005-10-15  8:28 UTC (permalink / raw)
  Cc: emacs-devel

Apparently the delimiters of the sixth group are missing.  Unless this
has been fixed already you could try:

(defun sh-font-lock-keywords-1 (&optional builtins)
   "Function to get better fontification including keywords."
   (let ((keywords (concat "\\([;(){}`|&]\\|^\\)[ \t]*\\(\\("
			  (regexp-opt (sh-feature sh-leading-keywords) t)
			  "[ \t]+\\)?"
			  (regexp-opt (append (sh-feature sh-leading-keywords)
					      (sh-feature sh-other-keywords))
				      t))))
     (sh-font-lock-keywords
      `(,@(if builtins
	     `((,(concat keywords "[ \t]+\\)?\\("
			 (regexp-opt (sh-feature sh-builtins) t)
			 "\\)\\>")
		(2 font-lock-keyword-face nil t)
		(6 font-lock-builtin-face))
	       ,@(sh-feature sh-font-lock-keywords-var-2)))
	 (,(concat keywords "\\)\\>")
	  2 font-lock-keyword-face)
	 ,@(sh-feature sh-font-lock-keywords-var-1)))))

^ permalink raw reply	[flat|nested] 4+ messages in thread

* sh-script fontification errors (error during display messages)
@ 2005-10-15 12:25 martin rudalics
  0 siblings, 0 replies; 4+ messages in thread
From: martin rudalics @ 2005-10-15 12:25 UTC (permalink / raw)
  Cc: emacs-devel

Please disregard my previous mail.  I mixed this up with the pre
regexp-opt version.  regexp-opt should duly insert the required
group delimiters.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-10-15 12:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-15 12:25 sh-script fontification errors (error during display messages) martin rudalics
  -- strict thread matches above, loose matches on Subject: below --
2005-10-15  8:28 martin rudalics
2005-10-14  1:47 Michael Mauger
2005-10-14  3:18 ` Michael Mauger

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).