all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stephen Berman <stephen.berman@gmx.net>
To: Paul Whittaker <emacs@pdw.org.uk>
Cc: 25841@debbugs.gnu.org
Subject: bug#25841: 25.2; Highlighting not being updated in some modes.
Date: Thu, 23 Feb 2017 16:00:04 +0100	[thread overview]
Message-ID: <87ino1osuj.fsf@rosalinde> (raw)
In-Reply-To: <231f3b41-7ba1-58d9-a1d4-2e0af37d0ac7@drisq.com>

On Thu, 23 Feb 2017 12:21:38 +0000 Paul Whittaker <emacs@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





  reply	other threads:[~2017-02-23 15:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-22 21:39 bug#25841: 25.2; Highlighting not being updated in some modes Paul Whittaker
2017-02-22 22:02 ` Glenn Morris
2017-02-23 12:21   ` Paul Whittaker
2017-02-23 15:00     ` Stephen Berman [this message]
2019-08-21  2:09 ` Stefan Kangas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ino1osuj.fsf@rosalinde \
    --to=stephen.berman@gmx.net \
    --cc=25841@debbugs.gnu.org \
    --cc=emacs@pdw.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.