[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 422fdab: Handle "Before first headings" error in outline-cycle
From: |
Lars Ingebrigtsen |
Subject: |
master 422fdab: Handle "Before first headings" error in outline-cycle |
Date: |
Mon, 19 Oct 2020 04:46:00 -0400 (EDT) |
branch: master
commit 422fdabe7bcaa9eac9aa5ae688ccf9f30cf6765c
Author: Yuan Fu <casouri@gmail.com>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Handle "Before first headings" error in outline-cycle
* lisp/outline.el (outline-before-first-heading): New error.
(outline-back-to-heading): Signal the new error.
(outline-cycle): Ignore the error.
(outline-cycle-buffer): Simply pass 1 to 'outline-hide-sublevels'
(bug#41130).
---
lisp/outline.el | 40 +++++++++++++++++++---------------------
1 file changed, 19 insertions(+), 21 deletions(-)
diff --git a/lisp/outline.el b/lisp/outline.el
index a4ce9af..b9806bc 100644
--- a/lisp/outline.el
+++ b/lisp/outline.el
@@ -402,6 +402,8 @@ at the end of the buffer."
If POS is nil, use `point' instead."
(eq (get-char-property (or pos (point)) 'invisible) 'outline))
+(define-error 'outline-before-first-heading "Before first heading")
+
(defun outline-back-to-heading (&optional invisible-ok)
"Move to previous heading line, or beg of this line if it's a heading.
Only visible heading lines are considered, unless INVISIBLE-OK is non-nil."
@@ -412,7 +414,7 @@ Only visible heading lines are considered, unless
INVISIBLE-OK is non-nil."
(while (not found)
(or (re-search-backward (concat "^\\(?:" outline-regexp "\\)")
nil t)
- (error "Before first heading"))
+ (signal 'outline-before-first-heading nil))
(setq found (and (or invisible-ok (not (outline-invisible-p)))
(point)))))
(goto-char found)
@@ -1167,19 +1169,21 @@ Return either 'hide-all, 'headings-only, or 'show-all."
`Headings only' means show sub headings but not their bodies.
`Show all' means show all subheadings and their bodies."
(interactive)
- (pcase (outline--cycle-state)
- ('hide-all
- (if (outline-has-subheading-p)
- (progn (outline-show-children)
- (message "Only headings"))
- (outline-show-subtree)
- (message "Show all")))
- ('headings-only
- (outline-show-subtree)
- (message "Show all"))
- ('show-all
- (outline-hide-subtree)
- (message "Hide all"))))
+ (condition-case nil
+ (pcase (outline--cycle-state)
+ ('hide-all
+ (if (outline-has-subheading-p)
+ (progn (outline-show-children)
+ (message "Only headings"))
+ (outline-show-subtree)
+ (message "Show all")))
+ ('headings-only
+ (outline-show-subtree)
+ (message "Show all"))
+ ('show-all
+ (outline-hide-subtree)
+ (message "Hide all")))
+ (outline-before-first-heading nil)))
(defvar-local outline--cycle-buffer-state 'show-all
"Internal variable used for tracking buffer cycle state.")
@@ -1189,13 +1193,7 @@ Return either 'hide-all, 'headings-only, or 'show-all."
(interactive)
(pcase outline--cycle-buffer-state
('show-all
- (save-excursion
- (let ((start-point (point)))
- (while (not (eq (point) start-point))
- (outline-up-heading 1))
- (outline-hide-sublevels
- (progn (outline-back-to-heading)
- (funcall 'outline-level)))))
+ (outline-hide-sublevels 1)
(setq outline--cycle-buffer-state 'top-level)
(message "Top level headings"))
('top-level
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 422fdab: Handle "Before first headings" error in outline-cycle,
Lars Ingebrigtsen <=