Hi,
Léo Ackermann writes:
@EricSFrada, would you mind sharing your code for your proof sections ?
This functionality is now built-in: headings with an `ignore' tag do not get
exported (their contents do). For very large proof, this seems like the
right
thing to do.
In small to moderate sized blocks, the delay can still be noticeable and
ought
to be fixed. Attached is a patch that seems to resolve this issue. I haven't
noticed any drawbacks so far.
Regards,
--
Sébastien Miquel
>From d843bdc5887a6e50a57e349128ebbe032086dc17 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Miquel?= <sebastien.miq...@posteo.eu>
Date: Sun, 27 Jun 2021 16:24:22 +0200
Subject: [PATCH] WIP : do not refontify special blocks
---
lisp/org.el | 99 ++++++++++++++++++++++++++++++++++-------------------
1 file changed, 64 insertions(+), 35 deletions(-)
diff --git a/lisp/org.el b/lisp/org.el
index 1bd9e02eb..9fd3f8514 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5265,22 +5265,32 @@ by a #."
(org-fontify-meta-lines-and-blocks-1 limit)
(error (message "Org mode fontification error in %S at %d"
(current-buffer)
- (line-number-at-pos)))))
+ (line-number-at-pos))))
+ nil)
(defun org-fontify-meta-lines-and-blocks-1 (limit)
"Fontify #+ lines and blocks."
- (let ((case-fold-search t))
- (when (re-search-forward
- (rx bol (group (zero-or-more (any " \t")) "#"
- (group (group (or (seq "+" (one-or-more (any "a-zA-Z")) (optional ":"))
- (any " \t")
- eol))
- (optional (group "_" (group (one-or-more (any "a-zA-Z"))))))
- (zero-or-more (any " \t"))
- (group (group (zero-or-more (not (any " \t\n"))))
- (zero-or-more (any " \t"))
- (group (zero-or-more any)))))
- limit t)
+ (let* ((case-fold-search t)
+ (fl-beg (point))
+ (fl-end limit)
+ (fbeg (when (and (> fl-beg (point-min))
+ (get-text-property (1- fl-beg) 'font-lock-multiline-block))
+ (or (previous-single-property-change
+ fl-beg 'font-lock-multiline-block)
+ (point-min)))))
+ (when fbeg (goto-char fbeg))
+ (while (and (< (point) limit)
+ (re-search-forward
+ (rx bol (group (zero-or-more (any " \t")) "#"
+ (group (group (or (seq "+" (one-or-more (any "a-zA-Z")) (optional ":"))
+ (any " \t")
+ eol))
+ (optional (group "_" (group (one-or-more (any "a-zA-Z"))))))
+ (zero-or-more (any " \t"))
+ (group (group (zero-or-more (not (any " \t\n"))))
+ (zero-or-more (any " \t"))
+ (group (zero-or-more any)))))
+ limit t))
(let ((beg (match-beginning 0))
(end-of-beginline (match-end 0))
;; Including \n at end of #+begin line will include \n
@@ -5318,7 +5328,7 @@ by a #."
(remove-text-properties beg end-of-endline
'(display t invisible t intangible t)))
(add-text-properties
- beg end-of-endline '(font-lock-fontified t font-lock-multiline t))
+ beg end-of-endline '(font-lock-fontified t font-lock-multiline-block t))
(org-remove-flyspell-overlays-in beg bol-after-beginline)
(org-remove-flyspell-overlays-in nl-before-endline end-of-endline)
(cond
@@ -5327,7 +5337,8 @@ by a #."
(add-text-properties bol-after-beginline block-end '(src-block t)))
(quoting
(add-text-properties
- bol-after-beginline beg-of-endline
+ (max bol-after-beginline (or fl-beg bol-after-beginline))
+ (min beg-of-endline (or fl-end beg-of-endline))
(list 'face
(list :inherit
(let ((face-name
@@ -5426,26 +5437,41 @@ by a #."
(add-text-properties closing-start end '(invisible t)))
t)))))
-(defun org-fontify-extend-region (beg end _old-len)
- (let ((begin-re "\\(\\\\\\[\\|\\(#\\+begin_\\|\\\\begin{\\)\\S-+\\)")
- (end-re "\\(\\\\\\]\\|\\(#\\+end_\\|\\\\end{\\)\\S-+\\)")
- (extend
- (lambda (r1 r2 dir)
- (let ((re (replace-regexp-in-string
- "\\(begin\\|end\\)" r1
- (replace-regexp-in-string
- "[][]" r2
- (match-string-no-properties 0)))))
- (re-search-forward (regexp-quote re) nil t dir)))))
- (save-match-data
- (save-excursion
- (goto-char beg)
- (back-to-indentation)
- (cond ((looking-at end-re)
- (cons (or (funcall extend "begin" "[" -1) beg) end))
- ((looking-at begin-re)
- (cons beg (or (funcall extend "end" "]" 1) end)))
- (t (cons beg end)))))))
+(defun org-fontify-extend-region (bego endo _old-len)
+ (let* ((beg bego) (end endo)
+ (bol (save-excursion (goto-char beg) (point-at-bol)))
+ (eol (save-excursion (goto-char end) (point-at-eol))))
+ (let ((before-multi (and (> bol (point-min))
+ (get-text-property (1- bol) 'font-lock-multiline-block)))
+ (after-multi (get-text-property eol 'font-lock-multiline-block)))
+ (if before-multi
+ (unless after-multi
+ (setq beg (or (previous-single-property-change
+ bol 'font-lock-multiline-block)
+ (point-min))))
+ (when after-multi
+ (setq end (or (text-property-any eol (point-max)
+ 'font-lock-multiline-block nil)
+ (point-max))))))
+ (let ((begin-re "\\(\\\\\\[\\|\\(#\\+begin_\\|\\\\begin{\\)\\S-+\\)")
+ (end-re "\\(\\\\\\]\\|\\(#\\+end_\\|\\\\end{\\)\\S-+\\)")
+ (extend
+ (lambda (r1 r2 dir)
+ (let ((re (replace-regexp-in-string
+ "\\(begin\\|end\\)" r1
+ (replace-regexp-in-string
+ "[][]" r2
+ (match-string-no-properties 0)))))
+ (re-search-forward (regexp-quote re) nil t dir)))))
+ (save-match-data
+ (save-excursion
+ (goto-char beg)
+ (back-to-indentation)
+ (cond ((looking-at end-re)
+ (cons (or (funcall extend "begin" "[" -1) beg) end))
+ ((looking-at begin-re)
+ (cons beg (max end (or (funcall extend "end" "]" 1) end))))
+ (t (cons beg end))))))))
(defun org-activate-footnote-links (limit)
"Add text properties for footnotes."
@@ -5772,6 +5798,9 @@ needs to be inserted at a specific position in the font-lock sequence.")
'(org-font-lock-keywords t nil nil backward-paragraph))
(setq-local font-lock-extend-after-change-region-function
#'org-fontify-extend-region)
+ (setq-local font-lock-extra-managed-props
+ (append font-lock-extra-managed-props
+ '(font-lock-multiline-block)))
(kill-local-variable 'font-lock-keywords)
nil))
--
2.32.0