[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: cwarn/font-lock problem under HP-UX 10.20
From: |
Klaus Zeitler |
Subject: |
Re: cwarn/font-lock problem under HP-UX 10.20 |
Date: |
05 Dec 2001 17:38:04 +0100 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 |
>>>>> "Eli" == Eli Zaretskii <eliz@is.elta.co.il> writes:
Eli>
Eli> On Mon, 3 Dec 2001, Klaus Zeitler wrote:
Eli>
>> 1. start emacs with -q
>> 2. M-x: global-font-lock-mode
>> 3. in scratch buffer execute (add-hook 'c-mode-hook 'turn-on-cwarn-mode)
>> 4. load e.g. the following buggy C file:
>>
>> 1 main ()
>> 2 {
>> 3 int x=5;
>> 4 if (x=1);
>> 5 {
>> 6 }
>> 7 }
>>
>> 5. in line 4 the "=" and the ";" should be highlighted with
>> font-lock-warning face, but they aren't
>>
>> 6. turn off cwarn-mode and turn it on again with twice
>> M-x cwarn-mode
>> now line 4 is correctly highlighted
>>
>>
>> When I execute the first 4 steps on my GNU/Linux PC line 4 is
>> correctly highlighted, but not under HP-UX. I'm puzzled, this
>> is the first time that syntax highlighting acts differently on
>> two OS.
Eli>
Eli> It's not system-dependent, I can reproduce it on MS-Windows at least.
Eli> I'm gueqsing that you have something on GNU/Linux that happens even in
Eli> "emacs -q" (have you tried "emacs -q --no-site-file"?).
Eli>
Eli> There's probably some subtle problem with regexps used by cwarn.
Eli> Could you please look?
no, --no-site-file doesn't change anything. I think it has something to do
with (font-lock-add-keywords nil ...).
The local variable font-lock-keywords doesn't contain the cwarn keywords when
the hook is used (under HP-UX 10.20 that is, and I'm pretty sure it'll work on
my GNU/Linux PC, I'll check tonight). I tried to debug this, but once I set
debug-on-entry to cwarn-font-lock-add-keywords everything works.
I've fixed it now by changing the last line in cwarn-font-lock-add-keywords
(defun cwarn-font-lock-add-keywords (&optional mode)
"Install keywords into major MODE, or into current buffer if nil."
(dolist (pair cwarn-font-lock-feature-keywords-alist)
(let ((feature (car pair))
(keywords (cdr pair)))
(if (not (listp keywords))
(setq keywords (symbol-value keywords)))
(if (cwarn-is-enabled (or mode major-mode) feature)
(font-lock-add-keywords mode keywords)))))
to
(defun cwarn-font-lock-add-keywords (&optional mode)
"Install keywords into major MODE, or into current buffer if nil."
(dolist (pair cwarn-font-lock-feature-keywords-alist)
(let ((feature (car pair))
(keywords (cdr pair)))
(if (not (listp keywords))
(setq keywords (symbol-value keywords)))
(if (cwarn-is-enabled (or mode major-mode) feature)
(font-lock-add-keywords (or mode major-mode) keywords)))))
now it works. But I remember vaguely that Stefan Monnier mentioned something
about not using (font-lock-add-keywords 'some-mode ...) and he recommended
(font-lock-add-keywords nil ...) in the mode-hook instead.
Klaus
--
------------------------------------------
| Klaus Zeitler Lucent Technologies |
| Email: kzeitler@lucent.com |
------------------------------------------
---
The shortest distance between two points
is under construction. -- Noelie Alito