From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-orgmode@gnu.org
Subject: Minor patch
Date: Wed, 13 Mar 2024 08:32:19 -0400 [thread overview]
Message-ID: <jwv4jdanwqg.fsf-monnier+emacs@gnu.org> (raw)
[-- 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
next reply other threads:[~2024-03-13 12:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-13 12:32 Stefan Monnier [this message]
2024-03-13 13:33 ` Minor patch Ihor Radchenko
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.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwv4jdanwqg.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-orgmode@gnu.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/org-mode.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).