Skip to content

Commit

Permalink
org-fold-show-entry: Do not fold drawers unless requested
Browse files Browse the repository at this point in the history
* 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 1027e02, 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.
  • Loading branch information
yantar92 committed Jul 31, 2022
1 parent a753d0d commit 785f003
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 9 deletions.
7 changes: 7 additions & 0 deletions etc/ORG-NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions lisp/org-agenda.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lisp/org-compat.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lisp/org-fold.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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.")
Expand Down
1 change: 0 additions & 1 deletion lisp/org-timer.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lisp/org.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 785f003

Please sign in to comment.