From 785f003de527487d1557cb724dd4b8867b5ea657 Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Fri, 13 May 2022 21:30:46 +0800 Subject: [PATCH] org-fold-show-entry: Do not fold drawers unless requested * lisp/org-fold.el (org-fold-show-entry): Do not fold drawers in the unfolded entry unless the new optional argument is non-nil. Folding the drawers was introduced in 1027e0256903bc2, but does not follow the function docstring. Moreover, folding drawers creates unexpected behaviour in some cases. See https://orgmode.org/list/m2a6bl4mmr.fsf@andrew.cmu.edu * etc/ORG-NEWS (~org-fold-show-entry~ does not fold drawers by default anymore): Document the change. * lisp/org-agenda.el (org-agenda-show): (org-agenda-show-and-scroll-up): (org-agenda-show-1): * lisp/org-compat.el (outline-toggle-children): * lisp/org.el (org-move-subtree-down): (org-return): Explicitly request folding drawers inside the revealed entry in the places where it appears to make sense. * lisp/org-timer.el (org-timer--get-timer-title): Do not unfold entry at all. This is a noninteractive function. --- etc/ORG-NEWS | 7 +++++++ lisp/org-agenda.el | 6 +++--- lisp/org-compat.el | 2 +- lisp/org-fold.el | 4 ++-- lisp/org-timer.el | 1 - lisp/org.el | 4 ++-- 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 478fcf95c..baa23295e 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -252,6 +252,13 @@ instance, includes all available items in the printed bibliography. ** New functions and changes in function arguments +*** ~org-fold-show-entry~ does not fold drawers by default anymore + +~org-fold-show-entry~ now accepts an optional argument HIDE-DRAWERS. +When the argument is non-nil, the function folds all the drawers +inside entry. This was the default previously. + +Now, ~org-fold-show-entry~ does not fold drawers by default. *** New function ~org-element-cache-map~ for quick mapping across Org elements diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 0e189b007..d48a8a24a 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -9753,7 +9753,7 @@ if it was hidden in the outline." (interactive "P") (let ((win (selected-window))) (org-agenda-goto t) - (when full-entry (org-fold-show-entry)) + (when full-entry (org-fold-show-entry 'hide-drawers)) (select-window win))) (defvar org-agenda-show-window nil) @@ -9772,7 +9772,7 @@ fold drawers." (select-window org-agenda-show-window) (ignore-errors (scroll-up))) (org-agenda-goto t) - (org-fold-show-entry) + (org-fold-show-entry 'hide-drawers) (if arg (org-cycle-hide-drawers 'children) (org-with-wide-buffer (narrow-to-region (org-entry-beginning-position) @@ -9816,7 +9816,7 @@ if it was hidden in the outline." ((and (called-interactively-p 'any) (= more 1)) (message "Remote: show with default settings")) ((= more 2) - (org-fold-show-entry) + (org-fold-show-entry 'hide-drawers) (org-fold-show-children) (save-excursion (org-back-to-heading) diff --git a/lisp/org-compat.el b/lisp/org-compat.el index 823f64a20..ef4f4e0d1 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -1517,7 +1517,7 @@ key." (if (not (org-fold-folded-p (line-end-position))) (org-fold-hide-subtree) (org-fold-show-children) - (org-fold-show-entry)))) + (org-fold-show-entry 'hide-drawers)))) ad-do-it)) ;; TODO: outline-headers-as-kill diff --git a/lisp/org-fold.el b/lisp/org-fold.el index 5039bb744..49a599ae4 100644 --- a/lisp/org-fold.el +++ b/lisp/org-fold.el @@ -519,7 +519,7 @@ of the current heading, or to 1 if the current line is not a heading." (if (and (bolp) (not (bobp)) (outline-invisible-p (1- (point)))) (org-fold-region (max (point-min) (1- (point))) (point) nil))))) -(defun org-fold-show-entry () +(defun org-fold-show-entry (&optional hide-drawers) "Show the body directly following its heading. Show the heading too, if it is currently invisible." (interactive) @@ -534,7 +534,7 @@ Show the heading too, if it is currently invisible." (point-max))) nil 'outline) - (org-cycle-hide-drawers 'children))) + (when hide-drawers (org-cycle-hide-drawers 'children)))) (defalias 'org-fold-show-hidden-entry #'org-fold-show-entry "Show an entry where even the heading is hidden.") diff --git a/lisp/org-timer.el b/lisp/org-timer.el index 0b33b2323..c89e05360 100644 --- a/lisp/org-timer.el +++ b/lisp/org-timer.el @@ -478,7 +478,6 @@ Try to use an Org header, otherwise use the buffer name." (with-current-buffer (marker-buffer marker) (org-with-wide-buffer (goto-char hdmarker) - (org-fold-show-entry) (or (ignore-errors (org-get-heading)) (buffer-name (buffer-base-buffer)))))))) ((derived-mode-p 'org-mode) diff --git a/lisp/org.el b/lisp/org.el index 937892ef3..c3354467e 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -6911,7 +6911,7 @@ case." (move-marker ins-point nil) (if folded (org-fold-subtree t) - (org-fold-show-entry) + (org-fold-show-entry 'hide-drawers) (org-fold-show-children)) (org-clean-visibility-after-subtree-move) ;; move back to the initial column we were at @@ -17447,7 +17447,7 @@ object (e.g., within a comment). In these case, you need to use (org-auto-align-tags (org-align-tags)) (t (org--align-tags-here tags-column))) ;preserve tags column (end-of-line) - (org-fold-show-entry) + (org-fold-show-entry 'hide-drawers) (org--newline indent arg interactive) (when string (save-excursion (insert (org-trim string)))))) ;; In a list, make sure indenting keeps trailing text within.