will be ~
~.
You may want to check whether your HTML files are rendered differently
after this change.
+*** Renamed ~org-cycle-hide-drawers~ to ~org-cycle-toggle-drawers~
+
+Rename function after added a third optional argument changed function
+meaning. Now drawers will be expanded when ~org-cycle~ on headlines.
+
** New default settings for some options
These options now defaults to =t=:
@@ -294,6 +299,10 @@ HTML.
Functions in this hook are run after ~org-agenda-filter~ is called.
+*** New option ~org-show-drawer-on-cycle~
+
+Option to control whether expand hidden drawer when ~org-cycle~ on headlines.
+
** Removed or renamed functions and variables
*** Removed ~org-maybe-keyword-time-regexp~
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index ffb892b0c..e3dca49af 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -9104,7 +9104,7 @@ (defun org-agenda-show-and-scroll-up (&optional arg)
(ignore-errors (scroll-up)))
(org-agenda-goto t)
(org-show-entry)
- (if arg (org-cycle-hide-drawers 'children)
+ (if arg (org-cycle-toggle-drawers 'children nil t)
(org-with-wide-buffer
(narrow-to-region (org-entry-beginning-position)
(org-entry-end-position))
@@ -9164,7 +9164,7 @@ (defun org-agenda-show-1 (&optional more)
(outline-show-subtree)
(save-excursion
(org-back-to-heading)
- (org-cycle-hide-drawers 'subtree '("LOGBOOK")))
+ (org-cycle-toggle-drawers 'subtree '("LOGBOOK") t))
(message "Remote: SUBTREE AND LOGBOOK"))
((> more 4)
(outline-show-subtree)
diff --git a/lisp/org.el b/lisp/org.el
index 57682fd16..5d5e54574 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -6012,7 +6012,23 @@ (defun org-hide-block-all ()
;;;; Drawers visibility
-(defun org-cycle-hide-drawers (state &optional exceptions)
+(defcustom org-show-drawer-on-cycle nil
+ "Whether auto expand hidden drawers when `org-cycle' headlines."
+ :type 'boolean
+ :safe #'booleanp
+ :group 'org)
+
+(defun org-cycle-expand-drawer (state)
+ "Show hidden drawer of headline."
+ (org-cycle-toggle-drawers 'children))
+
+(defun org-enable-cycle-expand-drawer ()
+ (when org-show-drawer-on-cycle
+ (add-hook 'org-cycle-hook #'org-cycle-expand-drawer)))
+
+(add-hook 'org-mode-hook #'org-enable-cycle-expand-drawer)
+
+(defun org-cycle-toggle-drawers (state &optional exceptions flag)
"Re-hide all drawers after a visibility state change.
STATE should be one of the symbols listed in the docstring of
`org-cycle-hook'. When non-nil, optional argument EXCEPTIONS is
@@ -6031,7 +6047,7 @@ (defun org-cycle-hide-drawers (state &optional exceptions)
(unless (member-ignore-case (match-string 1) exceptions)
(let ((drawer (org-element-at-point)))
(when (memq (org-element-type drawer) '(drawer property-drawer))
- (org-flag-drawer t drawer)
+ (org-flag-drawer flag drawer)
;; Make sure to skip drawer entirely or we might flag
;; it another time when matching its ending line with
;; `org-drawer-regexp'.
@@ -6427,7 +6443,7 @@ (defun org-set-startup-visibility ()
(when org-hide-block-startup (org-hide-block-all))
(org-set-visibility-according-to-property)
(org-cycle-hide-archived-subtrees 'all)
- (org-cycle-hide-drawers 'all)
+ (org-cycle-toggle-drawers 'all nil t)
(org-cycle-show-empty-lines t)))
(defun org-set-visibility-according-to-property ()
@@ -6532,7 +6548,7 @@ (defun org-clean-visibility-after-subtree-move ()
(when (and (not (org-invisible-p))
(org-invisible-p (line-end-position)))
(outline-hide-entry))))
- (org-cycle-hide-drawers 'all)
+ (org-cycle-toggle-drawers 'all nil t)
(org-cycle-show-empty-lines 'overview)))))
(defun org-cycle-show-empty-lines (state)
@@ -8076,7 +8092,7 @@ (defun org-sort-entries
"(empty for default `sort-subr' predicate): ")
'allow-empty))))
((member dcst '(?p ?t ?s ?d ?c ?k)) '<))))
- (org-cycle-hide-drawers 'all)
+ (org-cycle-toggle-drawers 'all nil t)
(when restore-clock?
(move-marker org-clock-marker
(1+ (next-single-property-change
--
2.26.0