forked from mirrors/org-mode
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.
This commit is contained in:
parent
5d3173cb04
commit
ebbef7b30c
|
@ -298,14 +298,15 @@ means that the buffer should stay alive during the operation,
|
||||||
because otherwise all these markers will point to nowhere."
|
because otherwise all these markers will point to nowhere."
|
||||||
(declare (debug (form body)) (indent 1))
|
(declare (debug (form body)) (indent 1))
|
||||||
(org-with-gensyms (data specs markers?)
|
(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)
|
(,markers? ,use-markers)
|
||||||
(,data
|
(,data
|
||||||
(org-with-wide-buffer
|
(org-with-wide-buffer
|
||||||
(let ((pos (point-min))
|
(let (data-val)
|
||||||
data-val)
|
(dolist (spec ,specs)
|
||||||
|
(let ((pos (point-min)))
|
||||||
(while (< pos (point-max))
|
(while (< pos (point-max))
|
||||||
(dolist (spec (org-fold-get-folding-spec 'all pos))
|
(when (org-fold-get-folding-spec spec pos)
|
||||||
(let ((region (org-fold-get-region-at-point spec pos)))
|
(let ((region (org-fold-get-region-at-point spec pos)))
|
||||||
(if ,markers?
|
(if ,markers?
|
||||||
(push (list (copy-marker (car region))
|
(push (list (copy-marker (car region))
|
||||||
|
@ -314,11 +315,11 @@ because otherwise all these markers will point to nowhere."
|
||||||
data-val)
|
data-val)
|
||||||
(push (list (car region) (cdr region) spec)
|
(push (list (car region) (cdr region) spec)
|
||||||
data-val))))
|
data-val))))
|
||||||
(setq pos (org-fold-next-folding-state-change nil pos)))))))
|
(setq pos (org-fold-next-folding-state-change spec pos)))))
|
||||||
|
data-val))))
|
||||||
(unwind-protect (progn ,@body)
|
(unwind-protect (progn ,@body)
|
||||||
(org-with-wide-buffer
|
(org-with-wide-buffer
|
||||||
(dolist (spec ,specs)
|
(org-fold-region (point-min) (point-max) nil)
|
||||||
(org-fold-region (point-min) (point-max) nil spec))
|
|
||||||
(pcase-dolist (`(,beg ,end ,spec) (delq nil ,data))
|
(pcase-dolist (`(,beg ,end ,spec) (delq nil ,data))
|
||||||
(org-fold-region beg end t spec)
|
(org-fold-region beg end t spec)
|
||||||
(when ,markers?
|
(when ,markers?
|
||||||
|
@ -331,7 +332,7 @@ means that the buffer may change while running BODY, but it also
|
||||||
means that the buffer should stay alive during the operation,
|
means that the buffer should stay alive during the operation,
|
||||||
because otherwise all these markers will point to nowhere."
|
because otherwise all these markers will point to nowhere."
|
||||||
(declare (debug (form body)) (indent 1))
|
(declare (debug (form body)) (indent 1))
|
||||||
`(when (eq org-fold-core-style 'text-properties)
|
`(if (eq org-fold-core-style 'text-properties)
|
||||||
(org-fold-save-outline-visibility--text-properties ,use-markers ,@body)
|
(org-fold-save-outline-visibility--text-properties ,use-markers ,@body)
|
||||||
(org-fold-save-outline-visibility--overlays ,use-markers ,@body)))
|
(org-fold-save-outline-visibility--overlays ,use-markers ,@body)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue