all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#46558: Interaction between font-lock-extend-region-wholelines and font-lock-extend-region-multiline
@ 2021-02-16 12:13 Sébastien Miquel
  2022-06-17 15:19 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: Sébastien Miquel @ 2021-02-16 12:13 UTC (permalink / raw)
  To: 46558

Hi,

In org-mode, blocks are fontified with the font-lock-multiline
property. When editing the line right before a block, the whole block
is needlessly refontified (use highlight-refontification-mode to
check).

This is because the font-lock-extend-region-wholelines extends the
region to the beginning of the next line, which has the
font-lock-multiline property. Then font-lock-extend-region-multiline
extends the region to the end of the block.

If a second block follows the first one, with no empty line between,
it is refontified as well.

Maybe font-lock-extend-region-multiline should check if the char
right before font-lock-end has the font-lock-multiline property as
well before extending the region. I've tried it, and haven't found any
issue in this use case.

-- 
Sébastien Miquel






^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#46558: Interaction between font-lock-extend-region-wholelines and font-lock-extend-region-multiline
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-17 15:19 UTC (permalink / raw)
  To: Sébastien Miquel; +Cc: 46558

Sébastien Miquel <sebastien.miquel@posteo.eu> writes:

> Maybe font-lock-extend-region-multiline should check if the char
> right before font-lock-end has the font-lock-multiline property as
> well before extending the region. I've tried it, and haven't found any
> issue in this use case.

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

Do you have a patch to propose here, by any chance?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#46558: Interaction between font-lock-extend-region-wholelines and font-lock-extend-region-multiline
  2022-06-17 15:19 ` Lars Ingebrigtsen
@ 2022-06-19 12:56   ` Sébastien Miquel
  2022-06-19 13:13     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: Sébastien Miquel @ 2022-06-19 12:56 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 46558

[-- 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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#46558: Interaction between font-lock-extend-region-wholelines and font-lock-extend-region-multiline
  2022-06-19 12:56   ` Sébastien Miquel
@ 2022-06-19 13:13     ` Lars Ingebrigtsen
  0 siblings, 0 replies; 4+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-19 13:13 UTC (permalink / raw)
  To: Sébastien Miquel; +Cc: 46558

Sébastien Miquel <sebastien.miquel@posteo.eu> writes:

>> Do you have a patch to propose here, by any chance?
>
> Here's what I had in mind.

Thanks; pushed to Emacs 29.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-06-19 13:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2022-06-19 13:13     ` Lars Ingebrigtsen

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.