unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Juri Linkov <juri@linkov.net>
Cc: 39597@debbugs.gnu.org, "Kévin Le Gouguec" <kevin.legouguec@gmail.com>
Subject: bug#39597: 27.0.60: M-x occur adds fontification to fundamental-mode
Date: Tue, 18 Feb 2020 08:51:37 -0500	[thread overview]
Message-ID: <jwvlfp0gg49.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <8736b8eosv.fsf@mail.linkov.net> (Juri Linkov's message of "Tue,  18 Feb 2020 02:12:32 +0200")

Juri Linkov [2020-02-18 02:12:32] wrote:

>> I think commit fb16313025 (2018-12-18T23:10:09Z!juri@linkov.net) had an
>> unintended side-effect on fundamental-mode.  From emacs -Q:
>
> This commit contains this change:
>
> diff --git a/lisp/replace.el b/lisp/replace.el
> index dcae12e9b7..b8f231eb55 100644
> --- a/lisp/replace.el
> +++ b/lisp/replace.el
> @@ -1907,10 +1907,8 @@ occur-engine
>        global-matches)))
>  
>  (defun occur-engine-line (beg end &optional keep-props)
> -  (if (and keep-props (if (boundp 'jit-lock-mode) jit-lock-mode)
> -	   (text-property-not-all beg end 'fontified t))
> -      (if (fboundp 'jit-lock-fontify-now)
> -	  (jit-lock-fontify-now beg end)))
> +  (if (and keep-props font-lock-mode)
> +      (font-lock-ensure beg end))
>    (if (and keep-props (not (eq occur-excluded-properties t)))
>        (let ((str (buffer-substring beg end)))
>  	(remove-list-of-text-properties
>
>> - C-x b repro RET
>> - foo RET "bar" RET baz
>> - M-s o . RET
>>
>> In emacs 26.3, the Occur buffer pops up and not much else happens;
>> starting with emacs 27, font-lock-string-face is applied to "bar".
>>
>> I haven't dug much more than that; FWIW however, emacs 26.3 already
>> applied font-lock-string-face to double-quoted strings when running
>> (font-lock-ensure) in a fundamental buffer, so maybe the right fix
>> belongs e.g. somewhere in font-lock-set-defaults?
>
> Stefan, could you suggest what to do with font-lock-ensure
> to not highlight double-quoted strings in fundamental-mode?

Maybe something like the patch below?
I'm not sufficiently familiar with the design of `font-lock-specified-p`
to be completely sure where the check should be placed; this is my best guess.


        Stefan


diff --git a/lisp/font-lock.el b/lisp/font-lock.el
index 438511b647..bf045d9d7e 100644
--- a/lisp/font-lock.el
+++ b/lisp/font-lock.el
@@ -1139,9 +1139,10 @@ font-lock-ensure
   "Make sure the region BEG...END has been fontified.
 If the region is not specified, it defaults to the entire accessible
 portion of the buffer."
-  (font-lock-set-defaults)
-  (funcall font-lock-ensure-function
-           (or beg (point-min)) (or end (point-max))))
+  (when (font-lock-specified-p t)
+    (font-lock-set-defaults)
+    (funcall font-lock-ensure-function
+             (or beg (point-min)) (or end (point-max)))))
 
 (defun font-lock-default-fontify-buffer ()
   "Fontify the whole buffer using `font-lock-fontify-region-function'."






  reply	other threads:[~2020-02-18 13:51 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-14  8:18 bug#39597: 27.0.60: M-x occur adds fontification to fundamental-mode Kévin Le Gouguec
2020-02-18  0:12 ` Juri Linkov
2020-02-18 13:51   ` Stefan Monnier [this message]
2020-02-18 22:49     ` Juri Linkov
2020-02-20 14:54       ` Eli Zaretskii
2020-02-20 19:10         ` Kévin Le Gouguec
2020-02-20 19:58           ` Eli Zaretskii
2020-02-20 22:27             ` Kévin Le Gouguec
2020-02-21  7:40               ` Eli Zaretskii
2020-02-21 19:09                 ` Kévin Le Gouguec
2020-02-23  0:24                   ` Juri Linkov
2020-02-25 20:45                     ` Kévin Le Gouguec
2020-02-23  0:37                 ` Juri Linkov
2020-02-21  0:04         ` Juri Linkov
2020-02-19 18:57     ` Kévin Le Gouguec

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=jwvlfp0gg49.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=39597@debbugs.gnu.org \
    --cc=juri@linkov.net \
    --cc=kevin.legouguec@gmail.com \
    /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 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).