From 524ccf3adbea3f92c82ad2a6c5f0f4614792d368 Mon Sep 17 00:00:00 2001 From: Marco Wahl Date: Tue, 31 Dec 2019 13:55:12 +0100 Subject: [PATCH] org: Fix: keep archived subtrees hidden after C-c C-k * lisp/org.el (org-kill-note-or-show-branches): Hide archived subtrees. Report by Allen Li https://lists.gnu.org/archive/html/emacs-orgmode/2019-12/msg00396.html --- lisp/org.el | 12 +++++++++--- testing/lisp/test-org.el | 10 ++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 27aa0a263..0d709d0bf 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -18012,9 +18012,15 @@ Move point to the beginning of first heading or end of buffer." (let ((org-note-abort t)) (funcall org-finish-function)) (if (org-before-first-heading-p) - (org-show-branches-buffer) - (outline-hide-subtree) - (outline-show-branches)))) + (progn + (org-show-branches-buffer) + (org-hide-archived-subtrees (point-min) (point-max))) + (let ((beg (progn (outline-back-to-heading) (point))) + (end (progn (outline-end-of-subtree) (point)))) + (goto-char beg) + (outline-hide-subtree) + (outline-show-branches) + (org-hide-archived-subtrees beg end))))) (defun org-delete-indentation (&optional arg) "Join current line to previous and fix whitespace at join. diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index d5c8593a2..7d420b599 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -7257,6 +7257,16 @@ Contents (org-set-visibility-according-to-property) (invisible-p (point))))) +(ert-deftest test-org/visibility-show-branches () + "Test visibility of inline archived subtrees." + (org-test-with-temp-text + "* Foo +** Bar :ARCHIVE: +*** Baz +" + (org-kill-note-or-show-branches) + (should (org-invisible-p (- (point-max) 2))))) + ;;; Yank and Kill