emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Bug: org-src-font-lock-fontify-block should be wrapped with save-match-data [9.3.7 (9.3.7-4-gba6ca7-elpaplus @ mixed installation! /mnt/c/Users/toz/Weiterbildung/Soft/Emacs/ and /mnt/c/Users/toz/.emacs.d/elpa/org-plus-contrib-20200615/)
@ 2021-08-20 10:07 Tobias Zawada
  2021-08-23  7:45 ` Timothy
  0 siblings, 1 reply; 9+ messages in thread
From: Tobias Zawada @ 2021-08-20 10:07 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org

~org-src-font-lock-fontify-block~ modifies ~match-data~ through the
fontification of the temporary source buffer. But
~org-src-font-lock-fontify-block~ is also called in
~org-fontify-meta-lines-and-blocks-1~ by
~font-lock-fontify-region~. There it puts the text property
~font-lock-multiline~ on some text from the beginning up to the end of
the last match in the Org buffer. Since the source buffer is smaller than the Org buffer
~match-beginning~ is smaller than it should be.

This can slow down editing operations in org-mode with large source blocks to an extent to which
org-mode becomes unusable.

An easy workaround is:

#+begin_src emacs-lisp
(defun org+-with-save-match-data (fun &rest args)
  "Run FUN with ARGS but save `match-data'."
  (save-match-data
    (apply fun args)))

(advice-add 'org-src-font-lock-fontify-block :around #'org+-with-save-match-data)
#+end_src

Emacs  : GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0)
 of 2020-09-19
Package: Org mode version 9.3.7 (9.3.7-4-gba6ca7-elpaplus @ mixed installation! /mnt/c/Users/toz/Weiterbildung/Soft/Emacs/ and /mnt/c/Users/toz/.emacs.d/elpa/org-plus-contrib-20200615/)


^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: Bug: org-src-font-lock-fontify-block should be wrapped with save-match-data [9.3.7 (9.3.7-4-gba6ca7-elpaplus @ mixed installation! /mnt/c/Users/toz/Weiterbildung/Soft/Emacs/ and /mnt/c/Users/toz/.emacs.d/elpa/org-plus-contrib-20200615/)
@ 2021-08-25  4:05 Tobias Zawada
  0 siblings, 0 replies; 9+ messages in thread
From: Tobias Zawada @ 2021-08-25  4:05 UTC (permalink / raw)
  To: manikulin; +Cc: emacs-orgmode


Dear Timothy and Maxim,

the bug was caused by an advice. I am really sorry for the trouble I 
inflicted on you.
Next time I will test more carefully.

Btw, I corrected the real problem already in 
https://github.com/TobiasZawada/org-src-emph.

Regards,
Tobias Zawada


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

end of thread, other threads:[~2021-08-31 11:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-20 10:07 Bug: org-src-font-lock-fontify-block should be wrapped with save-match-data [9.3.7 (9.3.7-4-gba6ca7-elpaplus @ mixed installation! /mnt/c/Users/toz/Weiterbildung/Soft/Emacs/ and /mnt/c/Users/toz/.emacs.d/elpa/org-plus-contrib-20200615/) Tobias Zawada
2021-08-23  7:45 ` Timothy
2021-08-24 16:57   ` Maxim Nikulin
2021-08-25  8:07     ` What happened to ./contrib? Martin Steffen
2021-08-25  8:44       ` Tim Cross
2021-08-25 11:47       ` Maxim Nikulin
2021-08-25 11:56     ` Bug: org-src-font-lock-fontify-block should be wrapped with save-match-data [9.3.7 (9.3.7-4-gba6ca7-elpaplus @ mixed installation! /mnt/c/Users/toz/Weiterbildung/Soft/Emacs/ and /mnt/c/Users/toz/.emacs.d/elpa/org-plus-contrib-20200615/) Maxim Nikulin
2021-08-31 11:28       ` Timothy
  -- strict thread matches above, loose matches on Subject: below --
2021-08-25  4:05 Tobias Zawada

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).