emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sh-script fontification errors (error during display messages)


From: Michael Mauger
Subject: sh-script fontification errors (error during display messages)
Date: Fri, 14 Oct 2005 01:47:29 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]