aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/textmodes/outline.el44
1 files changed, 21 insertions, 23 deletions
diff --git a/lisp/textmodes/outline.el b/lisp/textmodes/outline.el
index f9717798b3d..b15f3b9b75f 100644
--- a/lisp/textmodes/outline.el
+++ b/lisp/textmodes/outline.el
@@ -320,26 +320,27 @@ at the end of the buffer."
320 "Non-nil if the character after point is visible." 320 "Non-nil if the character after point is visible."
321 (not (get-char-property (point) 'invisible))) 321 (not (get-char-property (point) 'invisible)))
322 322
323(defun outline-back-to-heading () 323(defun outline-back-to-heading (&optional invisible-ok)
324 "Move to previous heading line, or beg of this line if it's a heading. 324 "Move to previous heading line, or beg of this line if it's a heading.
325Only visible heading lines are considered." 325Only visible heading lines are considered, unless INVISIBLE-OK is non-nil."
326 (beginning-of-line) 326 (beginning-of-line)
327 (or (outline-on-heading-p) 327 (or (outline-on-heading-p t)
328 (let (found) 328 (let (found)
329 (save-excursion 329 (save-excursion
330 (while (not found) 330 (while (not found)
331 (or (re-search-backward (concat "^\\(" outline-regexp "\\)") 331 (or (re-search-backward (concat "^\\(" outline-regexp "\\)")
332 nil t) 332 nil t)
333 (error "before first heading")) 333 (error "before first heading"))
334 (setq found (and (outline-visible) (point))))) 334 (setq found (and (or invisible-ok (outline-visible)) (point)))))
335 (goto-char found) 335 (goto-char found)
336 found))) 336 found)))
337 337
338(defun outline-on-heading-p () 338(defun outline-on-heading-p (&optional invisible-ok)
339 "Return t if point is on a (visible) heading line." 339 "Return t if point is on a (visible) heading line.
340If INVISIBLE-OK is non-nil, an invisible heading line is ok too."
340 (save-excursion 341 (save-excursion
341 (beginning-of-line) 342 (beginning-of-line)
342 (and (bolp) (outline-visible) 343 (and (bolp) (or invisible-ok (outline-visible))
343 (looking-at outline-regexp)))) 344 (looking-at outline-regexp))))
344 345
345(defun outline-end-of-heading () 346(defun outline-end-of-heading ()
@@ -455,10 +456,13 @@ If FLAG is nil then text is shown, while if FLAG is t the text is hidden."
455 (outline-flag-region (point) (progn (outline-next-preface) (point)) t))) 456 (outline-flag-region (point) (progn (outline-next-preface) (point)) t)))
456 457
457(defun show-entry () 458(defun show-entry ()
458 "Show the body directly following this heading." 459 "Show the body directly following this heading.
460Show the heading too, if it is currently invisible."
459 (interactive) 461 (interactive)
460 (save-excursion 462 (save-excursion
461 (outline-flag-region (point) (progn (outline-next-preface) (point)) nil))) 463 (outline-back-to-heading t)
464 (outline-flag-region (1- (point))
465 (progn (outline-next-preface) (point)) nil)))
462 466
463(defun hide-body () 467(defun hide-body ()
464 "Hide all of buffer except headings." 468 "Hide all of buffer except headings."
@@ -526,22 +530,16 @@ If FLAG is nil then text is shown, while if FLAG is t the text is hidden."
526 (goto-char end))))) 530 (goto-char end)))))
527 531
528(defun hide-other () 532(defun hide-other ()
529 "Hide everything except for the current body and the parent headings." 533 "Hide everything except current body and parent and top-level headings."
530 (interactive) 534 (interactive)
531 (hide-sublevels 1) 535 (hide-sublevels 1)
532 (let ((last (point)) 536 (save-excursion
533 (pos (point))) 537 (outline-back-to-heading t)
534 (while (save-excursion 538 (show-entry)
535 (and (end-of-line 0) 539 (while (condition-case nil (progn (outline-up-heading 1) t) (error nil))
536 (not (outline-visible)))) 540 (outline-flag-region (1- (point))
537 (save-excursion 541 (save-excursion (forward-line 1) (point))
538 (beginning-of-line) 542 nil))))
539 (if (eq last (point))
540 (progn
541 (outline-next-heading)
542 (outline-flag-region last (point) nil))
543 (show-children)
544 (setq last (point)))))))
545 543
546(defun outline-flag-subtree (flag) 544(defun outline-flag-subtree (flag)
547 (save-excursion 545 (save-excursion