emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/org 00adad9357: org-src: Fix invisible text in src bloc


From: ELPA Syncer
Subject: [elpa] externals/org 00adad9357: org-src: Fix invisible text in src block fontification
Date: Sun, 7 Aug 2022 06:57:45 -0400 (EDT)

branch: externals/org
commit 00adad9357b9123a7b11ecf12c148a5196debcb7
Author: Ihor Radchenko <yantar92@gmail.com>
Commit: Ihor Radchenko <yantar92@gmail.com>

    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
---
 lisp/org-src.el | 40 +++++++++++++++++++++++++++++++++++++---
 1 file changed, 37 insertions(+), 3 deletions(-)

diff --git a/lisp/org-src.el b/lisp/org-src.el
index 0249af60b2..e0cded9ed9 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]