1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-26 07:33:39 +00:00

org-src: Fix invisible text in src block fontification

* lisp/org-src.el (org-src-font-lock-fontify-block): If fontified text
has `invisible' text property, avoid interfering with Org folding
making the invisibility of lower priority compared to folding.

Fixes https://orgmode.org/list/87zgghrsd2.fsf@gmail.com
This commit is contained in:
Ihor Radchenko 2022-08-07 18:33:11 +08:00
parent a303a794f8
commit 00adad9357
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B

View File

@ -651,9 +651,43 @@ as `org-src-fontify-natively' is non-nil."
(dolist (prop (append '(font-lock-face face) font-lock-extra-managed-props))
(let ((new-prop (get-text-property pos prop)))
(when new-prop
(put-text-property
(+ start (1- pos)) (1- (+ start next)) prop new-prop
org-buffer))))
(if (not (eq prop 'invisible))
(put-text-property
(+ start (1- pos)) (1- (+ start next)) prop new-prop
org-buffer)
;; Special case. `invisible' text property may
;; clash with Org folding. Do not assign
;; `invisible' text property directly. Use
;; property alias instead.
(let ((invisibility-spec
(or
;; ATOM spec.
(and (memq new-prop buffer-invisibility-spec)
new-prop)
;; (ATOM . ELLIPSIS) spec.
(assq new-prop buffer-invisibility-spec))))
(with-current-buffer org-buffer
;; Add new property alias.
(unless (memq 'org-src-invisible
(cdr (assq 'invisible char-property-alias-alist)))
(setq-local
char-property-alias-alist
(cons (cons 'invisible
(nconc (cdr (assq 'invisible char-property-alias-alist))
'(org-src-invisible)))
(remove (assq 'invisible char-property-alias-alist)
char-property-alias-alist))))
;; Carry over the invisibility spec, unless
;; already present. Note that there might
;; be conflicting invisibility specs from
;; different major modes. We cannot do much
;; about this then.
(when invisibility-spec
(add-to-invisibility-spec invisibility-spec))
(put-text-property
(+ start (1- pos)) (1- (+ start next))
'org-src-invisible new-prop
org-buffer)))))))
(setq pos next)))
(set-buffer-modified-p nil))
;; Add Org faces.