unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Sébastien Miquel" <sebastien.miquel@posteo.eu>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 46558@debbugs.gnu.org
Subject: bug#46558: Interaction between font-lock-extend-region-wholelines and font-lock-extend-region-multiline
Date: Sun, 19 Jun 2022 12:56:24 +0000	[thread overview]
Message-ID: <addaed2e-adf4-91d1-e71c-35e08ca64034@posteo.eu> (raw)
In-Reply-To: <877d5f71wn.fsf@gnus.org>

[-- Attachment #1: Type: text/plain, Size: 136 bytes --]

Hi,

Lars Ingebrigtsen writes:
> Do you have a patch to propose here, by any chance?

Here's what I had in mind.

-- 
Sébastien Miquel

[-- Attachment #2: 0001-Small-fix-in-font-lock-extend-region-multiline-Bug-4.patch --]
[-- Type: text/x-patch, Size: 1815 bytes --]

From 57a5a959c5e5f9041c76faa0842ff999e59d78bc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Miquel?= <sebastien.miquel@posteo.eu>
Date: Sun, 19 Jun 2022 14:38:54 +0200
Subject: [PATCH] Small fix in font-lock-extend-region-multiline (Bug#46558)

* lisp/font-lock.el (font-lock-extend-region-multiline): Do not extend
the region if `font-lock-multiline' starts at `font-lock-end'.
---
 lisp/font-lock.el | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/lisp/font-lock.el b/lisp/font-lock.el
index 488874a175..df0a26f4d0 100644
--- a/lisp/font-lock.el
+++ b/lisp/font-lock.el
@@ -1245,12 +1245,17 @@ Put first the functions more likely to cause a change and cheaper to compute.")
       (setq font-lock-beg (or (previous-single-property-change
                                font-lock-beg 'font-lock-multiline)
                               (point-min))))
-    ;;
-    (when (get-text-property font-lock-end 'font-lock-multiline)
-      (setq changed t)
-      (setq font-lock-end (or (text-property-any font-lock-end (point-max)
-                                                 'font-lock-multiline nil)
-                              (point-max))))
+    ;; If `font-lock-multiline' starts at `font-lock-end', do not
+    ;; extend the region.
+    (let ((before-end (max (point-min) (1- font-lock-end)))
+          (new-end nil))
+      (when (get-text-property before-end 'font-lock-multiline)
+        (setq new-end (or (text-property-any before-end (point-max)
+                                             'font-lock-multiline nil)
+                          (point-max)))
+        (when (/= new-end font-lock-end)
+          (setq changed t)
+          (setq font-lock-end new-end))))
     changed))

 (defun font-lock-extend-region-wholelines ()
-- 
2.36.1

  reply	other threads:[~2022-06-19 12:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-16 12:13 bug#46558: Interaction between font-lock-extend-region-wholelines and font-lock-extend-region-multiline Sébastien Miquel
2022-06-17 15:19 ` Lars Ingebrigtsen
2022-06-19 12:56   ` Sébastien Miquel [this message]
2022-06-19 13:13     ` Lars Ingebrigtsen

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=addaed2e-adf4-91d1-e71c-35e08ca64034@posteo.eu \
    --to=sebastien.miquel@posteo.eu \
    --cc=46558@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    /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).