* Minor patch
@ 2024-03-13 12:32 Stefan Monnier
2024-03-13 13:33 ` Ihor Radchenko
0 siblings, 1 reply; 2+ messages in thread
From: Stefan Monnier @ 2024-03-13 12:32 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 195 bytes --]
The minor patch below clarifies what the computation is about and
removes the assumption that point-min == 1, while arguably
making the the code ever so slightly more efficient.
Stefan
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-src-font-lock-fontify-block-Clarify-offset-compu.patch --]
[-- Type: text/x-diff, Size: 2148 bytes --]
From d386af0653ff75956cc20e0df8ddb5bfa86fec9d Mon Sep 17 00:00:00 2001
From: Stefan Monnier <monnier@iro.umontreal.ca>
Date: Wed, 13 Mar 2024 08:31:11 -0400
Subject: [PATCH] (org-src-font-lock-fontify-block): Clarify offset computation
* lisp/org-src.el (org-src-font-lock-fontify-block): Improve the translation
of local positions into org-buffer positions, and get rid of
assumption about the value of `point-min` while we're at it.
---
lisp/org-src.el | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/lisp/org-src.el b/lisp/org-src.el
index de8d6ee42c..bec13427c2 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -681,7 +681,9 @@ as `org-src-fontify-natively' is non-nil."
(unless (eq major-mode lang-mode) (funcall lang-mode))
(setq native-tab-width tab-width)
(font-lock-ensure)
- (let ((pos (point-min)) next)
+ (let ((pos (point-min)) next
+ ;; Difference between positions here and in org-buffer.
+ (offset (- start (point-min))))
(while (setq next (next-property-change pos))
;; Handle additional properties from font-lock, so as to
;; preserve, e.g., composition.
@@ -695,7 +697,7 @@ as `org-src-fontify-natively' is non-nil."
(when new-prop
(if (not (eq prop 'invisible))
(put-text-property
- (+ start (1- pos)) (1- (+ start next)) prop new-prop
+ (+ offset pos) (+ offset next) prop new-prop
org-buffer)
;; Special case. `invisible' text property may
;; clash with Org folding. Do not assign
@@ -727,7 +729,7 @@ as `org-src-fontify-natively' is non-nil."
(when invisibility-spec
(add-to-invisibility-spec invisibility-spec))
(put-text-property
- (+ start (1- pos)) (1- (+ start next))
+ (+ offset pos) (+ offset next)
'org-src-invisible new-prop
org-buffer)))))))
(setq pos next)))
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: Minor patch
2024-03-13 12:32 Minor patch Stefan Monnier
@ 2024-03-13 13:33 ` Ihor Radchenko
0 siblings, 0 replies; 2+ messages in thread
From: Ihor Radchenko @ 2024-03-13 13:33 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-orgmode
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> The minor patch below clarifies what the computation is about and
> removes the assumption that point-min == 1, while arguably
> making the the code ever so slightly more efficient.
Thanks!
Applied, onto main, with minor amendments to the commit message.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=2773904cf
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-03-13 13:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-13 12:32 Minor patch Stefan Monnier
2024-03-13 13:33 ` Ihor Radchenko
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.