GNU bug report logs - #25841
25.2; Highlighting not being updated in some modes.

Previous Next

Package: emacs;

Reported by: Paul Whittaker <emacs <at> pdw.org.uk>

Date: Wed, 22 Feb 2017 21:46:02 UTC

Severity: minor

Tags: notabug

Found in version 25.2

Done: Stefan Kangas <stefan <at> marxist.se>

Bug is archived. No further changes may be made.

Full log


Message #14 received at 25841 <at> debbugs.gnu.org (full text, mbox):

From: Stephen Berman <stephen.berman <at> gmx.net>
To: Paul Whittaker <emacs <at> pdw.org.uk>
Cc: Glenn Morris <rgm <at> gnu.org>, 25841 <at> debbugs.gnu.org
Subject: Re: bug#25841: 25.2; Highlighting not being updated in some modes.
Date: Thu, 23 Feb 2017 16:00:04 +0100
On Thu, 23 Feb 2017 12:21:38 +0000 Paul Whittaker <emacs <at> pdw.org.uk> wrote:

> On 22/02/17 22:02, Glenn Morris wrote:
>> This is the documented way highlight-regexp behaves:
>>
>>     Use Font lock mode, if enabled, to highlight REGEXP.  Otherwise,
>>     use overlays for highlighting.  If overlays are used, the
>>     highlighting will not update as you type.
>
> Thanks, I'd missed that.
>
> I'm trying to get dynamic (non-overlay) highlighting working in a plain
> text mode.  That documentation makes me think that I just need to enable
> font-lock mode, but doing that doesn't appear to make any difference.
>
>   emacs -Q
>   M-x fundamental-mode RET
>   M-1 M-x font-lock-mode RET
>   M-x highlight-regexp RET foo RET hi-yellow RET
>
>   f o o SPC b a r  ;; Not highlighted, as before.
>
> Would you expect that to work, or is there something else that I'm
> missing here?  Apologies if this is a stupid question: I suspect I'm not
> seeing all of the picture.

I can't explain how font-lock works, but by experimenting it appears you
have to set font-lock-defaults to a non-nil value in the buffer (it
seems before enabling font-lock-mode, though there's an interaction I
don't understand).  Here's a recipe:

0. emacs -Q
1. C-x b a RET ; Switch to new buffer "a".
2. Enter some text, e.g. "foo".
3. M-x font-lock-mode RET ; Disable font-lock-mode in the buffer --
                          ; by default it's enabled globally .
4. M-: (setq-local font-lock-defaults (list 'bla)) RET
5. M-x font-lock-mode RET ; Re-enable font-lock-mode.  On one test I
                          ; thought this was sufficient, but on
                          ; subsequent repetition I've consistently
                          ; gotten a void variable error and had to
                          ; disable and then re-enable font-lock-mode
                          ; again. 
6. M-x highlight-regexp (or M-s h r) RET foo RET hi-yellow RET
=> Now "foo" is highlighted, and deleting a letter from it unhighlights
   it.

Steve Berman




This bug report was last modified 5 years and 337 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.