Explorar o código

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.
Ihor Radchenko %!s(int64=3) %!d(string=hai) anos
pai
achega
785f003de5
Modificáronse 6 ficheiros con 15 adicións e 9 borrados
  1. 7 0
      etc/ORG-NEWS
  2. 3 3
      lisp/org-agenda.el
  3. 1 1
      lisp/org-compat.el
  4. 2 2
      lisp/org-fold.el
  5. 0 1
      lisp/org-timer.el
  6. 2 2
      lisp/org.el

+ 7 - 0
etc/ORG-NEWS

@@ -252,6 +252,13 @@ instance,
 
 
 includes all available items in the printed bibliography.
 includes all available items in the printed bibliography.
 ** New functions and changes in function arguments
 ** 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
 *** New function ~org-element-cache-map~ for quick mapping across Org elements
 
 

+ 3 - 3
lisp/org-agenda.el

@@ -9753,7 +9753,7 @@ if it was hidden in the outline."
   (interactive "P")
   (interactive "P")
   (let ((win (selected-window)))
   (let ((win (selected-window)))
     (org-agenda-goto t)
     (org-agenda-goto t)
-    (when full-entry (org-fold-show-entry))
+    (when full-entry (org-fold-show-entry 'hide-drawers))
     (select-window win)))
     (select-window win)))
 
 
 (defvar org-agenda-show-window nil)
 (defvar org-agenda-show-window nil)
@@ -9772,7 +9772,7 @@ fold drawers."
 	  (select-window org-agenda-show-window)
 	  (select-window org-agenda-show-window)
 	  (ignore-errors (scroll-up)))
 	  (ignore-errors (scroll-up)))
       (org-agenda-goto t)
       (org-agenda-goto t)
-      (org-fold-show-entry)
+      (org-fold-show-entry 'hide-drawers)
       (if arg (org-cycle-hide-drawers 'children)
       (if arg (org-cycle-hide-drawers 'children)
 	(org-with-wide-buffer
 	(org-with-wide-buffer
 	 (narrow-to-region (org-entry-beginning-position)
 	 (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))
      ((and (called-interactively-p 'any) (= more 1))
       (message "Remote: show with default settings"))
       (message "Remote: show with default settings"))
      ((= more 2)
      ((= more 2)
-      (org-fold-show-entry)
+      (org-fold-show-entry 'hide-drawers)
       (org-fold-show-children)
       (org-fold-show-children)
       (save-excursion
       (save-excursion
 	(org-back-to-heading)
 	(org-back-to-heading)

+ 1 - 1
lisp/org-compat.el

@@ -1517,7 +1517,7 @@ key."
               (if (not (org-fold-folded-p (line-end-position)))
               (if (not (org-fold-folded-p (line-end-position)))
                   (org-fold-hide-subtree)
                   (org-fold-hide-subtree)
                 (org-fold-show-children)
                 (org-fold-show-children)
-                (org-fold-show-entry))))
+                (org-fold-show-entry 'hide-drawers))))
     ad-do-it))
     ad-do-it))
 
 
 ;; TODO: outline-headers-as-kill
 ;; TODO: outline-headers-as-kill

+ 2 - 2
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))))
       (if (and (bolp) (not (bobp)) (outline-invisible-p (1- (point))))
           (org-fold-region (max (point-min) (1- (point))) (point) nil)))))
           (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 body directly following its heading.
 Show the heading too, if it is currently invisible."
 Show the heading too, if it is currently invisible."
   (interactive)
   (interactive)
@@ -534,7 +534,7 @@ Show the heading too, if it is currently invisible."
  	 (point-max)))
  	 (point-max)))
      nil
      nil
      'outline)
      'outline)
-    (org-cycle-hide-drawers 'children)))
+    (when hide-drawers (org-cycle-hide-drawers 'children))))
 
 
 (defalias 'org-fold-show-hidden-entry #'org-fold-show-entry
 (defalias 'org-fold-show-hidden-entry #'org-fold-show-entry
   "Show an entry where even the heading is hidden.")
   "Show an entry where even the heading is hidden.")

+ 0 - 1
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)
 	(with-current-buffer (marker-buffer marker)
 	  (org-with-wide-buffer
 	  (org-with-wide-buffer
 	   (goto-char hdmarker)
 	   (goto-char hdmarker)
-	   (org-fold-show-entry)
 	   (or (ignore-errors (org-get-heading))
 	   (or (ignore-errors (org-get-heading))
 	       (buffer-name (buffer-base-buffer))))))))
 	       (buffer-name (buffer-base-buffer))))))))
    ((derived-mode-p 'org-mode)
    ((derived-mode-p 'org-mode)

+ 2 - 2
lisp/org.el

@@ -6911,7 +6911,7 @@ case."
      (move-marker ins-point nil)
      (move-marker ins-point nil)
      (if folded
      (if folded
 	 (org-fold-subtree t)
 	 (org-fold-subtree t)
-       (org-fold-show-entry)
+       (org-fold-show-entry 'hide-drawers)
        (org-fold-show-children))
        (org-fold-show-children))
      (org-clean-visibility-after-subtree-move)
      (org-clean-visibility-after-subtree-move)
      ;; move back to the initial column we were at
      ;; 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))
 	 (org-auto-align-tags (org-align-tags))
 	 (t (org--align-tags-here tags-column))) ;preserve tags column
 	 (t (org--align-tags-here tags-column))) ;preserve tags column
 	(end-of-line)
 	(end-of-line)
-	(org-fold-show-entry)
+	(org-fold-show-entry 'hide-drawers)
 	(org--newline indent arg interactive)
 	(org--newline indent arg interactive)
 	(when string (save-excursion (insert (org-trim string))))))
 	(when string (save-excursion (insert (org-trim string))))))
      ;; In a list, make sure indenting keeps trailing text within.
      ;; In a list, make sure indenting keeps trailing text within.