summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2016-10-18 09:52:39 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2018-01-10 15:58:21 +0100
commit4403d4685e19fb99ba9bfec2bd4ff6781c66981f (patch)
tree83d33ef7103823ca8ff9c2d187874adc6b1b5af4
parent4f74aa4c0eda8bb4b0a3ec89000d700572ce0105 (diff)
downloadorg-mode-4403d4685e19fb99ba9bfec2bd4ff6781c66981f.tar.gz
Give drawers their own invisibility spec
* lisp/org.el (org-mode): Add special invisibility spec for drawers. (org-show-set-visibility): Handle new invisibility spec. (org-clean-visibility-after-subtree-move): Fix argument for `org-cycle-hide-drawers'. `overview' is a no-op. (org-cycle-hook): (org-cycle-internal-local): (org-flag-drawer): (org-move-subtree-down): (org-show-entry): * lisp/org-agenda.el (org-agenda-clock-in): * lisp/org-clock.el (org-clock-goto): * lisp/org-feed.el (org-feed-update): * lisp/org-inlinetask.el (org-inlinetask-toggle-visibility): Do not hide drawers when expanding a headline. Drawers and headlines visibility are now unrelated. As a consequence, there is no need to hide drawers every time a headline is expanded.
-rw-r--r--lisp/org-agenda.el1
-rw-r--r--lisp/org-clock.el1
-rw-r--r--lisp/org-feed.el1
-rw-r--r--lisp/org-inlinetask.el3
-rw-r--r--lisp/org.el50
5 files changed, 22 insertions, 34 deletions
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index b2729c1..7ea9847 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -9338,7 +9338,6 @@ ARG is passed through to `org-deadline'."
(widen)
(goto-char pos)
(org-show-context 'agenda)
- (org-cycle-hide-drawers 'children)
(org-clock-in arg)
(setq newhead (org-get-heading)))
(org-agenda-change-all-lines newhead hdmarker))
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index af0ebaa..ed8f118 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -1778,7 +1778,6 @@ With prefix arg SELECT, offer recently clocked tasks for selection."
(goto-char m)
(org-show-entry)
(org-back-to-heading t)
- (org-cycle-hide-drawers 'children)
(recenter org-clock-goto-before-context)
(org-reveal)
(if recent
diff --git a/lisp/org-feed.el b/lisp/org-feed.el
index c3491d5..f3c8ab8 100644
--- a/lisp/org-feed.el
+++ b/lisp/org-feed.el
@@ -407,7 +407,6 @@ it can be a list structured like an entry in `org-feed-alist'."
(goto-char inbox-pos)
(outline-hide-subtree)
(org-show-children)
- (org-cycle-hide-drawers 'children)
;; Hooks and messages
(when org-feed-save-after-adding (save-buffer))
diff --git a/lisp/org-inlinetask.el b/lisp/org-inlinetask.el
index 4442052..5c2fd49 100644
--- a/lisp/org-inlinetask.el
+++ b/lisp/org-inlinetask.el
@@ -324,8 +324,7 @@ If the task has an end part, also demote it."
((= end start))
;; Inlinetask was folded: expand it.
((eq (get-char-property (1+ start) 'invisible) 'outline)
- (outline-flag-region start end nil)
- (org-cycle-hide-drawers 'children))
+ (outline-flag-region start end nil))
(t (outline-flag-region start end t)))))
(defun org-inlinetask-hide-tasks (state)
diff --git a/lisp/org.el b/lisp/org.el
index 143eceb..d9fa9a1 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -1414,7 +1414,6 @@ the values `folded', `children', or `subtree'."
:type 'hook)
(defcustom org-cycle-hook '(org-cycle-hide-archived-subtrees
- org-cycle-hide-drawers
org-cycle-show-empty-lines
org-optimize-window-after-visibility-change)
"Hook that is run after `org-cycle' has changed the buffer visibility.
@@ -5393,6 +5392,7 @@ The following commands are available:
(org-install-agenda-files-menu)
(when org-descriptive-links (add-to-invisibility-spec '(org-link)))
(add-to-invisibility-spec '(org-hide-block . t))
+ (add-to-invisibility-spec '(org-hide-drawer . t))
(setq-local outline-regexp org-outline-regexp)
(setq-local outline-level 'org-outline-level)
(setq bidi-paragraph-direction 'left-to-right)
@@ -6859,11 +6859,6 @@ Use `\\[org-edit-special]' to edit table.el tables"))
(org-show-entry)
(org-with-limited-levels (org-show-children))
(org-show-set-visibility 'canonical)
- ;; FIXME: This slows down the func way too much.
- ;; How keep drawers hidden in subtree anyway?
- ;; (when (memq 'org-cycle-hide-drawers org-cycle-hook)
- ;; (org-cycle-hide-drawers 'subtree))
-
;; Fold every list in subtree to top-level items.
(when (eq org-cycle-include-plain-lists 'integrate)
(save-excursion
@@ -7048,11 +7043,10 @@ This function is the default value of the hook `org-cycle-hook'."
(goto-char (point-min))
(while (re-search-forward re nil t)
(when (and (not (org-invisible-p))
- (save-excursion
- (goto-char (point-at-eol)) (org-invisible-p)))
+ (org-invisible-p (line-end-position)))
(outline-hide-entry))))
- (org-cycle-show-empty-lines 'overview)
- (org-cycle-hide-drawers 'overview)))))
+ (org-cycle-hide-drawers 'all)
+ (org-cycle-show-empty-lines 'overview)))))
(defun org-cycle-show-empty-lines (state)
"Show empty lines above all visible headlines.
@@ -7161,16 +7155,15 @@ show that drawer instead."
(org-element-at-point)))))
(when (memq (org-element-type drawer) '(drawer property-drawer))
(let ((post (org-element-property :post-affiliated drawer)))
- (save-excursion
- (outline-flag-region
- (progn (goto-char post) (line-end-position))
- (progn (goto-char (org-element-property :end drawer))
- (skip-chars-backward " \r\t\n")
- (line-end-position))
- flag))
+ (org-flag-region
+ (save-excursion (goto-char post) (line-end-position))
+ (save-excursion (goto-char (org-element-property :end drawer))
+ (skip-chars-backward " \t\n")
+ (line-end-position))
+ flag 'org-hide-drawer)
;; When the drawer is hidden away, make sure point lies in
;; a visible part of the buffer.
- (when (and flag (> (line-beginning-position) post))
+ (when (invisible-p (max (1- (point)) (point-min)))
(goto-char post))))))
(defun org-subtree-end-visible-p ()
@@ -8087,16 +8080,16 @@ case."
(setq beg (point))))
;; Find insertion point, with error handling
(while (> cnt 0)
- (or (and (funcall movfunc) (looking-at org-outline-regexp))
- (progn (goto-char beg0)
- (user-error "Cannot move past superior level or buffer limit")))
+ (unless (and (funcall movfunc) (looking-at org-outline-regexp))
+ (goto-char beg0)
+ (user-error "Cannot move past superior level or buffer limit"))
(setq cnt (1- cnt)))
(when (> arg 0)
;; Moving forward - still need to move over subtree
(org-end-of-subtree t t)
(save-excursion
(org-back-over-empty-lines)
- (unless (bolp) (insert "\n"))))
+ (or (bolp) (newline))))
(setq ne-ins (org-back-over-empty-lines))
(move-marker ins-point (point))
(setq txt (buffer-substring beg end))
@@ -8117,7 +8110,7 @@ case."
(when (and (< arg 0)
(org-first-sibling-p)
(> ne-ins ne-beg))
- ;; Move whitespace back to beginning.
+ ;; Move whitespace back to beginning
(save-excursion
(goto-char ins-end)
(let ((kill-whole-line t))
@@ -8127,10 +8120,9 @@ case."
(if folded
(outline-hide-subtree)
(org-show-entry)
- (org-show-children)
- (org-cycle-hide-drawers 'children))
+ (org-show-children))
(org-clean-visibility-after-subtree-move)
- ;; Move back to the initial column we were at.
+ ;; move back to the initial column we were at
(move-to-column col))))
(defvar org-subtree-clip ""
@@ -13286,7 +13278,8 @@ information."
;; If point is hidden within a drawer or a block, make sure to
;; expose it.
(dolist (o (overlays-at (point)))
- (when (memq (overlay-get o 'invisible) '(org-hide-block outline))
+ (when (memq (overlay-get o 'invisible)
+ '(org-hide-block org-hide-drawer outline))
(delete-overlay o)))
(unless (org-before-first-heading-p)
(org-with-limited-levels
@@ -23744,8 +23737,7 @@ Show the heading too, if it is currently invisible."
(concat "[\r\n]\\(" org-outline-regexp "\\)") nil t)
(match-beginning 1)
(point-max)))
- nil)
- (org-cycle-hide-drawers 'children))))
+ nil))))
(defun org-make-options-regexp (kwds &optional extra)
"Make a regular expression for keyword lines.