org-fold: Optimize fontification of link folds
* lisp/org-fold-core.el (org-fold-core--specs): Add new folding spec - :font-lock. When non-nil, enable re-fontification of the folds. (org-fold-core-region): Only trigger re-fontification when the folding spec has :font-lock property. * lisp/org-fold.el (org-fold-initialize): Only enable re-fontification of folded outlines, drawers, and blocks.
This commit is contained in:
parent
17072a4690
commit
b03ece433b
|
@ -381,6 +381,9 @@ The following properties are known:
|
||||||
`buffer-invisibility-spec' will be used as is.
|
`buffer-invisibility-spec' will be used as is.
|
||||||
Note that changing this property from nil to t may
|
Note that changing this property from nil to t may
|
||||||
clear the setting in `buffer-invisibility-spec'.
|
clear the setting in `buffer-invisibility-spec'.
|
||||||
|
- :font-lock :: non-nil means that newlines after the fold should
|
||||||
|
be re-fontified upon folding/unfolding. See
|
||||||
|
`org-activate-folds'.
|
||||||
- :alias :: a list of aliases for the SPEC-SYMBOL.
|
- :alias :: a list of aliases for the SPEC-SYMBOL.
|
||||||
- :fragile :: Must be a function accepting two arguments.
|
- :fragile :: Must be a function accepting two arguments.
|
||||||
Non-nil means that changes in region may cause
|
Non-nil means that changes in region may cause
|
||||||
|
@ -1043,18 +1046,19 @@ If SPEC-OR-ALIAS is omitted and FLAG is nil, unfold everything in the region."
|
||||||
;; last as per Emacs defaults. This makes :extend faces span
|
;; last as per Emacs defaults. This makes :extend faces span
|
||||||
;; past the ellipsis. See bug#65896. The face properties are
|
;; past the ellipsis. See bug#65896. The face properties are
|
||||||
;; assigned via `org-activate-folds'.
|
;; assigned via `org-activate-folds'.
|
||||||
(when (equal ?\n (char-after from))
|
(when (or (not spec) (org-fold-core-get-folding-spec-property spec :font-lock))
|
||||||
(font-lock-flush from (1+ from)))
|
(when (equal ?\n (char-after from))
|
||||||
(when (equal ?\n (char-after to))
|
(font-lock-flush from (1+ from)))
|
||||||
(font-lock-flush to (1+ to)))
|
(when (equal ?\n (char-after to))
|
||||||
(dolist (region (org-fold-core-get-regions :from from :to to :specs spec))
|
(font-lock-flush to (1+ to)))
|
||||||
(when (equal ?\n (char-after (cadr region)))
|
(dolist (region (org-fold-core-get-regions :from from :to to :specs spec))
|
||||||
(font-lock-flush (cadr region) (1+ (cadr region))))
|
(when (equal ?\n (char-after (cadr region)))
|
||||||
;; Re-fontify beginning of the fold - we may
|
(font-lock-flush (cadr region) (1+ (cadr region))))
|
||||||
;; unfold inside an existing fold, with FROM begin a newline
|
;; Re-fontify beginning of the fold - we may
|
||||||
;; after spliced fold.
|
;; unfold inside an existing fold, with FROM begin a newline
|
||||||
(when (equal ?\n (char-after (car region)))
|
;; after spliced fold.
|
||||||
(font-lock-flush (car region) (1+ (car region)))))
|
(when (equal ?\n (char-after (car region)))
|
||||||
|
(font-lock-flush (car region) (1+ (car region))))))
|
||||||
(when (eq org-fold-core-style 'overlays)
|
(when (eq org-fold-core-style 'overlays)
|
||||||
(if org-fold-core--keep-overlays
|
(if org-fold-core--keep-overlays
|
||||||
(mapc
|
(mapc
|
||||||
|
@ -1118,9 +1122,10 @@ If SPEC-OR-ALIAS is omitted and FLAG is nil, unfold everything in the region."
|
||||||
(remove-text-properties from to (list (org-fold-core--property-symbol-get-create spec) nil)))))
|
(remove-text-properties from to (list (org-fold-core--property-symbol-get-create spec) nil)))))
|
||||||
;; Re-calculate trailing faces for all the folds revealed
|
;; Re-calculate trailing faces for all the folds revealed
|
||||||
;; by unfolding or created by folding.
|
;; by unfolding or created by folding.
|
||||||
(dolist (region (org-fold-core-get-regions :from from :to to :specs spec))
|
(when (or (not spec) (org-fold-core-get-folding-spec-property spec :font-lock))
|
||||||
(when (equal ?\n (char-after (cadr region)))
|
(dolist (region (org-fold-core-get-regions :from from :to to :specs spec))
|
||||||
(font-lock-flush (cadr region) (1+ (cadr region)))))))))
|
(when (equal ?\n (char-after (cadr region)))
|
||||||
|
(font-lock-flush (cadr region) (1+ (cadr region))))))))))
|
||||||
|
|
||||||
(cl-defmacro org-fold-core-regions (regions &key override clean-markers relative)
|
(cl-defmacro org-fold-core-regions (regions &key override clean-markers relative)
|
||||||
"Fold every region in REGIONS list in current buffer.
|
"Fold every region in REGIONS list in current buffer.
|
||||||
|
|
|
@ -255,6 +255,7 @@ Also, see `org-fold-catch-invisible-edits'."
|
||||||
(:ellipsis . ,ellipsis)
|
(:ellipsis . ,ellipsis)
|
||||||
(:fragile . ,#'org-fold--reveal-outline-maybe)
|
(:fragile . ,#'org-fold--reveal-outline-maybe)
|
||||||
(:isearch-open . t)
|
(:isearch-open . t)
|
||||||
|
(:font-lock . t)
|
||||||
;; This is needed to make sure that inserting a
|
;; This is needed to make sure that inserting a
|
||||||
;; new planning line in folded heading is not
|
;; new planning line in folded heading is not
|
||||||
;; revealed. Also, the below combination of :front-sticky and
|
;; revealed. Also, the below combination of :front-sticky and
|
||||||
|
@ -267,6 +268,7 @@ Also, see `org-fold-catch-invisible-edits'."
|
||||||
(:ellipsis . ,ellipsis)
|
(:ellipsis . ,ellipsis)
|
||||||
(:fragile . ,#'org-fold--reveal-drawer-or-block-maybe)
|
(:fragile . ,#'org-fold--reveal-drawer-or-block-maybe)
|
||||||
(:isearch-open . t)
|
(:isearch-open . t)
|
||||||
|
(:font-lock . t)
|
||||||
(:front-sticky . t)
|
(:front-sticky . t)
|
||||||
(:alias . ( block center-block comment-block
|
(:alias . ( block center-block comment-block
|
||||||
dynamic-block example-block export-block
|
dynamic-block example-block export-block
|
||||||
|
@ -276,6 +278,7 @@ Also, see `org-fold-catch-invisible-edits'."
|
||||||
(:ellipsis . ,ellipsis)
|
(:ellipsis . ,ellipsis)
|
||||||
(:fragile . ,#'org-fold--reveal-drawer-or-block-maybe)
|
(:fragile . ,#'org-fold--reveal-drawer-or-block-maybe)
|
||||||
(:isearch-open . t)
|
(:isearch-open . t)
|
||||||
|
(:font-lock . t)
|
||||||
(:front-sticky . t)
|
(:front-sticky . t)
|
||||||
(:alias . (drawer property-drawer)))
|
(:alias . (drawer property-drawer)))
|
||||||
,org-link--description-folding-spec
|
,org-link--description-folding-spec
|
||||||
|
|
Loading…
Reference in New Issue