[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 37/38] org-fold-core-fontify-region: Fix cases when fontificat
From: |
Ihor Radchenko |
Subject: |
[PATCH v2 37/38] org-fold-core-fontify-region: Fix cases when fontification is not registered |
Date: |
Wed, 20 Apr 2022 21:28:37 +0800 |
* lisp/org-fold-core.el (org-fold-core-fontify-region): Handle FORCE
argument better. Skip unnecessary code parts when FORCE is non-nil.
Assign `fontified' text property manually in the actually fontified
regions. We cannot just supply correct return value since jit-lock
does not allow piecewise fontification.
---
lisp/org-fold-core.el | 51 +++++++++++++++++++++++--------------------
1 file changed, 27 insertions(+), 24 deletions(-)
diff --git a/lisp/org-fold-core.el b/lisp/org-fold-core.el
index edae316ff..d98eb6358 100644
--- a/lisp/org-fold-core.el
+++ b/lisp/org-fold-core.el
@@ -1436,40 +1436,43 @@ (defvar org-fold-core--force-fontification nil
(defun org-fold-core-fontify-region (beg end loudly &optional force)
"Run `font-lock-default-fontify-region' in visible regions."
(with-silent-modifications
- (let ((pos beg) next
- (force (or force org-fold-core--force-fontification))
- (org-fold-core--fontifying t)
- (skip-specs
- (let (result)
- (dolist (spec (org-fold-core-folding-spec-list))
- (when (and (not (org-fold-core-get-folding-spec-property spec
:visible))
- (org-fold-core-get-folding-spec-property spec
:font-lock-skip))
- (push spec result)))
- result)))
+ (let* ((pos beg) next
+ (force (or force org-fold-core--force-fontification))
+ (org-fold-core--fontifying t)
+ (skip-specs
+ (unless force
+ (let (result)
+ (dolist (spec (org-fold-core-folding-spec-list))
+ (when (and (not (org-fold-core-get-folding-spec-property
spec :visible))
+ (org-fold-core-get-folding-spec-property spec
:font-lock-skip))
+ (push spec result)))
+ result))))
;; Move POS to first visible point within BEG..END.
- (while (and (catch :found
- (dolist (spec (org-fold-core-get-folding-spec 'all pos))
- (when (org-fold-core-get-folding-spec-property spec
:font-lock-skip)
- (throw :found spec))))
- (< pos end))
- (setq pos (org-fold-core-next-folding-state-change nil pos end)))
+ (unless force
+ (while (and (catch :found
+ (dolist (spec (org-fold-core-get-folding-spec 'all pos))
+ (when (org-fold-core-get-folding-spec-property spec
:font-lock-skip)
+ (throw :found spec))))
+ (< pos end))
+ (setq pos (org-fold-core-next-folding-state-change nil pos end))))
(when force (setq pos beg next end))
(while (< pos end)
(unless force
- (setq next (org-fold-core-next-folding-state-change skip-specs pos
end)))
- ;; Move to the end of the region to be fontified.
- (while (and (not (catch :found
- (dolist (spec (org-fold-core-get-folding-spec 'all
next))
- (when (org-fold-core-get-folding-spec-property spec
:font-lock-skip)
- (throw :found spec)))))
- (< next end))
- (setq next (org-fold-core-next-folding-state-change nil next end)))
+ (setq next (org-fold-core-next-folding-state-change skip-specs pos
end))
+ ;; Move to the end of the region to be fontified.
+ (while (and (not (catch :found
+ (dolist (spec (org-fold-core-get-folding-spec 'all
next))
+ (when (org-fold-core-get-folding-spec-property
spec :font-lock-skip)
+ (throw :found spec)))))
+ (< next end))
+ (setq next (org-fold-core-next-folding-state-change nil next
end))))
(save-excursion
(font-lock-default-fontify-region pos next loudly)
(save-match-data
(unless (<= pos (point) next)
(run-hook-with-args 'org-fold-core-first-unfold-functions pos
next))))
(put-text-property pos next 'org-fold-core-fontified t)
+ (put-text-property pos next 'fontified t)
(setq pos next)))))
(defun org-fold-core-update-optimisation (beg end)
--
2.35.1
--
Ihor Radchenko,
PhD,
Center for Advancing Materials Performance from the Nanoscale (CAMP-nano)
State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong
University, Xi'an, China
Email: yantar92@gmail.com, ihor_radchenko@alumni.sutd.edu.sg
- [PATCH v2 27/38] Fix org-fold--hide-drawers--overlays---, (continued)
- [PATCH v2 27/38] Fix org-fold--hide-drawers--overlays---, Ihor Radchenko, 2022/04/20
- [PATCH v2 28/38] org-string-width: Handle undefined behaviour in older Emacs, Ihor Radchenko, 2022/04/20
- [PATCH v2 29/38] org-string-width: Work around `window-pixel-width' bug in old Emacs, Ihor Radchenko, 2022/04/20
- [PATCH v2 30/38] org-fold-show-set-visibility: Fix edge case when folded region is at BOB, Ihor Radchenko, 2022/04/20
- [PATCH v2 32/38] test-org/string-width: Add tests for strings with prefix properties, Ihor Radchenko, 2022/04/20
- [PATCH v2 31/38] org-fold-core: Fix fontification inside folded regions, Ihor Radchenko, 2022/04/20
- [PATCH v2 33/38] org--string-from-props: Fix handling folds in Emacs <28, Ihor Radchenko, 2022/04/20
- [PATCH v2 34/38] org-link-make-string: Throw error when both LINK and DESCRIPTION are empty, Ihor Radchenko, 2022/04/20
- [PATCH v2 35/38] test-ol/org-toggle-link-display: Fix compatibility with old Emacs, Ihor Radchenko, 2022/04/20
- [PATCH v2 36/38] org-macs.el: Fix fontification checks take 2---, Ihor Radchenko, 2022/04/20
- [PATCH v2 37/38] org-fold-core-fontify-region: Fix cases when fontification is not registered,
Ihor Radchenko <=
- [PATCH v2 38/38] org-agenda.el: Re-enable native compilation* lisp/org-agenda.el: Re-enable native compilation as it does not, Ihor Radchenko, 2022/04/20
- Re: [PATCH v2 00/38] Final call for comments: Merge org-fold feature branch, Bastien, 2022/04/20
- Re: [PATCH v2 00/38] Final call for comments: Merge org-fold feature branch, Ihor Radchenko, 2022/04/20
- Re: [PATCH v2 00/38] Final call for comments: Merge org-fold feature branch, Bastien, 2022/04/20
- Re: [PATCH v2 00/38] Final call for comments: Merge org-fold feature branch, Ihor Radchenko, 2022/04/21
- Re: [PATCH v2 00/38] Final call for comments: Merge org-fold feature branch, Bastien, 2022/04/21
- Re: [PATCH v2 00/38] Final call for comments: Merge org-fold feature branch, Ihor Radchenko, 2022/04/21
- Re: [PATCH v2 00/38] Final call for comments: Merge org-fold feature branch, Bastien, 2022/04/21
Re: [PATCH v2 00/38] Final call for comments: Merge org-fold feature branch, Kévin Le Gouguec, 2022/04/22