فهرست منبع

org-fold-save-outline-visibility: Make it work with 'text-properties

*
lisp/org-fold.el (org-fold-save-outline-visibility--text-properties):
Do not expand list of specs on compile time.  Simplify saving and
re-applying folds.

* lisp/org-fold.el (org-fold-save-outline-visibility): Fix typo when
-> if.
Ihor Radchenko 3 سال پیش
والد
کامیت
ebbef7b30c
1فایلهای تغییر یافته به همراه19 افزوده شده و 18 حذف شده
  1. 19 18
      lisp/org-fold.el

+ 19 - 18
lisp/org-fold.el

@@ -298,27 +298,28 @@ means that the buffer should stay alive during the operation,
 because otherwise all these markers will point to nowhere."
   (declare (debug (form body)) (indent 1))
   (org-with-gensyms (data specs markers?)
-    `(let* ((,specs ',(org-fold-core-folding-spec-list))
+    `(let* ((,specs (org-fold-core-folding-spec-list))
 	    (,markers? ,use-markers)
 	    (,data
              (org-with-wide-buffer
-              (let ((pos (point-min))
-		    data-val)
-		(while (< pos (point-max))
-                  (dolist (spec (org-fold-get-folding-spec 'all pos))
-                    (let ((region (org-fold-get-region-at-point spec pos)))
-		      (if ,markers?
-			  (push (list (copy-marker (car region))
-				      (copy-marker (cdr region) t)
-                                      spec)
-                                data-val)
-                        (push (list (car region) (cdr region) spec)
-			      data-val))))
-                  (setq pos (org-fold-next-folding-state-change nil pos)))))))
+              (let (data-val)
+                (dolist (spec ,specs)
+                  (let ((pos (point-min)))
+		    (while (< pos (point-max))
+                      (when (org-fold-get-folding-spec spec pos)
+                        (let ((region (org-fold-get-region-at-point spec pos)))
+		          (if ,markers?
+			      (push (list (copy-marker (car region))
+				          (copy-marker (cdr region) t)
+                                          spec)
+                                    data-val)
+                            (push (list (car region) (cdr region) spec)
+			          data-val))))
+                      (setq pos (org-fold-next-folding-state-change spec pos)))))
+                data-val))))
        (unwind-protect (progn ,@body)
 	 (org-with-wide-buffer
-	  (dolist (spec ,specs)
-	    (org-fold-region (point-min) (point-max) nil spec))
+	  (org-fold-region (point-min) (point-max) nil)
 	  (pcase-dolist (`(,beg ,end ,spec) (delq nil ,data))
 	    (org-fold-region beg end t spec)
 	    (when ,markers?
@@ -331,8 +332,8 @@ means that the buffer may change while running BODY, but it also
 means that the buffer should stay alive during the operation,
 because otherwise all these markers will point to nowhere."
   (declare (debug (form body)) (indent 1))
-  `(when (eq org-fold-core-style 'text-properties)
-     (org-fold-save-outline-visibility--text-properties ,use-markers ,@body)
+  `(if (eq org-fold-core-style 'text-properties)
+       (org-fold-save-outline-visibility--text-properties ,use-markers ,@body)
      (org-fold-save-outline-visibility--overlays ,use-markers ,@body)))
 
 ;;;; Changing visibility (regions, blocks, drawers, headlines)