all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] Show hidden drawers when org-cycle on headlines
@ 2020-04-11  8:43 stardiviner
  2020-04-11 16:05 ` Nicolas Goaziou
                   ` (2 more replies)
  0 siblings, 3 replies; 22+ messages in thread
From: stardiviner @ 2020-04-11  8:43 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 392 bytes --]


I think the hidden drawers info is useful for users, this should be
shown when org-cycle on headlines.

Here is the patch.

-- 
[ stardiviner ]
       I try to make every word tell the meaning what I want to express.

       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner, Matrix: stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
      

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-org.el-Rename-org-cycle-hide-drawers-to-org-cycle-to.patch --]
[-- Type: text/x-patch, Size: 5059 bytes --]

From 98e3ece4d2bd6f7c7ccd0ecf70dc327a01bff8bd Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
Date: Sat, 11 Apr 2020 13:16:02 +0800
Subject: [PATCH] org.el: Rename org-cycle-hide-drawers to
 org-cycle-toggle-drawers

* lisp/org.el (org-cycle-toggle-drawers): Make function toggle
show/hide drawers.

* lisp/org-agenda.el (org-cycle-toggle-drawers): updated renamed
functions.

* etc/ORG-NEWS: mention incompatible changes.
---
 etc/ORG-NEWS       |  9 +++++++++
 lisp/org-agenda.el |  4 ++--
 lisp/org.el        | 26 +++++++++++++++++++++-----
 3 files changed, 32 insertions(+), 7 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index e90ac60e3..244c30be4 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -80,6 +80,11 @@ resulting <div> will be ~<div id="outline-container-my-headline">~.
 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


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 515 bytes --]

^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2020-04-19 11:32 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-11  8:43 [PATCH] Show hidden drawers when org-cycle on headlines stardiviner
2020-04-11 16:05 ` Nicolas Goaziou
2020-04-13  3:29   ` stardiviner
2020-04-13  8:06     ` Nicolas Goaziou
2020-04-13 16:28       ` stardiviner
2020-04-13  9:12     ` Ihor Radchenko
2020-04-13 16:31       ` [SOLVED] " stardiviner
2020-04-13 16:58         ` Ihor Radchenko
2020-04-13 20:00           ` Nicolas Goaziou
2020-04-13 23:19             ` Tim Cross
2020-04-14  3:18             ` Ihor Radchenko
2020-04-14 12:58               ` Nicolas Goaziou
2020-04-14 13:57                 ` Ihor Radchenko
2020-04-14  5:21             ` stardiviner
2020-04-14 12:55               ` Nicolas Goaziou
2020-04-15  1:13                 ` stardiviner
2020-04-18 17:48                   ` Nicolas Goaziou
2020-04-19  9:10                     ` stardiviner
2020-04-19 10:31                       ` Nicolas Goaziou
2020-04-19 11:31                         ` stardiviner
2020-04-13 20:52 ` Samuel Wales
2020-04-15  1:26 ` [SOLUTION] " stardiviner

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.