浏览代码

org-fold: Handle indirect buffer visibility

Ihor Radchenko 3 年之前
父节点
当前提交
cd83606cfd
共有 2 个文件被更改,包括 11 次插入2 次删除
  1. 4 1
      lisp/org-capture.el
  2. 7 1
      lisp/org.el

+ 4 - 1
lisp/org-capture.el

@@ -1171,7 +1171,10 @@ may have been stored before."
       (goto-char (point-min))
       (unless (org-at-heading-p) (outline-next-heading)))
      ;; Otherwise, insert as a top-level entry at the end of the file.
-     (t (goto-char (point-max))))
+     (t (goto-char (point-max))
+        ;; Make sure that last point is not folded.
+        (org-fold-core-cycle-over-indirect-buffers
+            (org-fold-region (max 1 (1- (point-max))) (point-max) nil))))
     (let ((origin (point)))
       (unless (bolp) (insert "\n"))
       (org-capture-empty-lines-before)

+ 7 - 1
lisp/org.el

@@ -5984,7 +5984,13 @@ frame is not changed."
 			     (number-to-string n))))))
       (setq n (1+ n)))
     (condition-case nil
-        (make-indirect-buffer buffer bname 'clone)
+        (let ((indirect-buffer (make-indirect-buffer buffer bname 'clone)))
+          ;; Decouple folding state.  We need to do it manually since
+          ;; `make-indirect-buffer' does not run
+          ;; `clone-indirect-buffer-hook'.
+          (org-fold-core-decouple-indirect-buffer-folds)
+          ;; Return the buffer.
+          indirect-buffer)
       (error (make-indirect-buffer buffer bname)))))
 
 (defun org-set-frame-title (title)