From 074ea1629c35d7ac886bbe8ba9a04d36076d8986 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sat, 9 May 2020 15:26:10 +0200 Subject: [PATCH] Deprecate `org-cycle-hide-drawers' * lisp/org.el (org-hide-drawer-all): New function. (org-cycle-hide-drawers): move... * lisp/org-compat.el (org-cycle-hide-drawers): ... here. * lisp/org-agenda.el (org-agenda-show-1): Remove use of `org-cycle-hide-drawers'. --- etc/ORG-NEWS | 5 +++++ lisp/org-agenda.el | 11 ++--------- lisp/org-compat.el | 19 +++++++++++++++++++ lisp/org.el | 39 ++++++++++++++------------------------- 4 files changed, 40 insertions(+), 34 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 6d07abdf8..da555ee4f 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -323,6 +323,11 @@ Functions in this hook are run after ~org-agenda-filter~ is called. ** Removed or renamed functions and variables *** Deprecated ~org-flag-dawer~ function Use ~org-hide-drawer-toggle~ instead. +*** Deprecated ~org-cycle-hide-drawers~ function + +Use new function ~org-hide-drawer-all~ instead. Note there is also +a new ~org-cycle-hide-property-drawers~ function. + *** Deprecated ~org-hide-block-toggle-maybe~ function Use ~org-hide-block-toggle~ instead. *** Deprecated ~org-hide-block-toggle-all~ function diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 93a44fdac..9c73d0d6c 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -9117,8 +9117,7 @@ The prefix arg selects the amount of information to display: 1 just show the entry according to defaults. 2 show the children view 3 show the subtree view -4 show the entire subtree and any LOGBOOK drawers -5 show the entire subtree and any drawers +4 show the entire subtree and any drawers With prefix argument FULL-ENTRY, make the entire entry visible if it was hidden in the outline." (interactive "p") @@ -9148,13 +9147,7 @@ if it was hidden in the outline." (org-back-to-heading) (run-hook-with-args 'org-cycle-hook 'subtree)) (message "Remote: SUBTREE")) - ((= more 4) - (outline-show-subtree) - (save-excursion - (org-back-to-heading) - (org-cycle-hide-drawers 'subtree '("LOGBOOK"))) - (message "Remote: SUBTREE AND LOGBOOK")) - ((> more 4) + ((> more 3) (outline-show-subtree) (message "Remote: SUBTREE AND ALL DRAWERS"))) (select-window win))) diff --git a/lisp/org-compat.el b/lisp/org-compat.el index 4a2683a6a..6159d5a18 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -663,6 +663,25 @@ region as a drawer without further ado." (when (invisible-p (max (1- (point)) (point-min))) (goto-char post))))))) +(defun org-cycle-hide-drawers (state &optional exceptions) + "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 +a list of strings specifying which drawers should not be hidden." + (declare (obsolete "use `org-hide-drawer' instead." "Org 9.4")) + (when (and (derived-mode-p 'org-mode) + (not (memq state '(overview folded contents)))) + (save-excursion + (let* ((globalp (eq state 'all)) + (beg (if globalp (point-min) (point))) + (end (if globalp (point-max) + (if (eq state 'children) + (save-excursion (outline-next-heading) (point)) + (org-end-of-subtree t))))) + (save-restriction + (narrow-to-region beg end) + (org-hide-drawer-all)))))) + (defun org-hide-block-toggle-maybe () "Toggle visibility of block at point. Unlike to `org-hide-block-toggle', this function does not throw diff --git a/lisp/org.el b/lisp/org.el index 32d26faa7..287fe30e8 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -6116,6 +6116,20 @@ Return a non-nil value when toggling is successful." (org-show-all '(blocks)) (org-block-map 'org-hide-block-toggle)) +(defun org-hide-drawer-all () + "Fold all drawers in the current buffer." + (org-show-all '(drawers)) + (save-excursion + (goto-char (point-min)) + (while (re-search-forward org-drawer-regexp nil t) + (let ((drawer (org-element-at-point))) + (when (memq (org-element-type drawer) '(drawer property-drawer)) + (org-hide-drawer-toggle t nil drawer) + ;; Make sure to skip drawer entirely or we might flag it + ;; another time when matching its ending line with + ;; `org-drawer-regexp'. + (goto-char (org-element-property :end drawer))))))) + (defun org-cycle-hide-property-drawers (state) "Re-hide all drawers after a visibility state change. STATE should be one of the symbols listed in the docstring of @@ -6136,31 +6150,6 @@ STATE should be one of the symbols listed in the docstring of ;; they can be swallowed once we hide the outline. (org-flag-region start end t 'outline))))))))) -(defun org-cycle-hide-drawers (state &optional exceptions) - "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 -a list of strings specifying which drawers should not be hidden." - (when (and (derived-mode-p 'org-mode) - (not (memq state '(overview folded contents)))) - (save-excursion - (let* ((globalp (eq state 'all)) - (beg (if globalp (point-min) (point))) - (end (if globalp (point-max) - (if (eq state 'children) - (save-excursion (outline-next-heading) (point)) - (org-end-of-subtree t))))) - (goto-char beg) - (while (re-search-forward org-drawer-regexp (max end (point)) t) - (unless (member-ignore-case (match-string 1) exceptions) - (let ((drawer (org-element-at-point))) - (when (memq (org-element-type drawer) '(drawer property-drawer)) - (org-hide-drawer-toggle t nil drawer) - ;; Make sure to skip drawer entirely or we might flag - ;; it another time when matching its ending line with - ;; `org-drawer-regexp'. - (goto-char (org-element-property :end drawer)))))))))) - ;;;; Visibility cycling (defvar-local org-cycle-global-status nil)