Mercurial > emacs
comparison lisp/outline.el @ 55273:8362eef794e3
(outline-blank-line): New var.
(outline-next-preface, outline-show-heading)
(outline-end-of-subtree): Use it.
author | Juri Linkov <juri@jurta.org> |
---|---|
date | Sat, 01 May 2004 03:44:30 +0000 |
parents | 53c5c7a2f4a8 |
children | 21785c190853 4c90ffeb71c5 |
comparison
equal
deleted
inserted
replaced
55272:ee2b597412c9 | 55273:8362eef794e3 |
---|---|
213 (defvar outline-view-change-hook nil | 213 (defvar outline-view-change-hook nil |
214 "Normal hook to be run after outline visibility changes.") | 214 "Normal hook to be run after outline visibility changes.") |
215 | 215 |
216 (defvar outline-mode-hook nil | 216 (defvar outline-mode-hook nil |
217 "*This hook is run when outline mode starts.") | 217 "*This hook is run when outline mode starts.") |
218 | |
219 (defvar outline-blank-line nil | |
220 "*Non-nil means to leave unhidden blank line before heading.") | |
218 | 221 |
219 ;;;###autoload | 222 ;;;###autoload |
220 (define-derived-mode outline-mode text-mode "Outline" | 223 (define-derived-mode outline-mode text-mode "Outline" |
221 "Set major mode for editing outlines with selective display. | 224 "Set major mode for editing outlines with selective display. |
222 Headings are lines which start with asterisks: one for major headings, | 225 Headings are lines which start with asterisks: one for major headings, |
347 If there's no following heading line, stop before the newline | 350 If there's no following heading line, stop before the newline |
348 at the end of the buffer." | 351 at the end of the buffer." |
349 (if (re-search-forward (concat "\n\\(?:" outline-regexp "\\)") | 352 (if (re-search-forward (concat "\n\\(?:" outline-regexp "\\)") |
350 nil 'move) | 353 nil 'move) |
351 (goto-char (match-beginning 0))) | 354 (goto-char (match-beginning 0))) |
352 (if (and (bolp) (eobp) (not (bobp))) | 355 (if (and (bolp) (or outline-blank-line (eobp)) (not (bobp))) |
353 (forward-char -1))) | 356 (forward-char -1))) |
354 | 357 |
355 (defun outline-next-heading () | 358 (defun outline-next-heading () |
356 "Move to the next (possibly invisible) heading line." | 359 "Move to the next (possibly invisible) heading line." |
357 (interactive) | 360 (interactive) |
767 (interactive) | 770 (interactive) |
768 (outline-flag-subtree nil)) | 771 (outline-flag-subtree nil)) |
769 | 772 |
770 (defun outline-show-heading () | 773 (defun outline-show-heading () |
771 "Show the current heading and move to its end." | 774 "Show the current heading and move to its end." |
772 (outline-flag-region (- (point) (if (bobp) 0 1)) | 775 (outline-flag-region (- (point) |
776 (if (bobp) 0 | |
777 (if (and outline-blank-line | |
778 (eq (char-before (1- (point))) ?\n)) | |
779 2 1))) | |
773 (progn (outline-end-of-heading) (point)) | 780 (progn (outline-end-of-heading) (point)) |
774 nil)) | 781 nil)) |
775 | 782 |
776 (defun hide-sublevels (levels) | 783 (defun hide-sublevels (levels) |
777 "Hide everything but the top LEVELS levels of headers, in whole buffer." | 784 "Hide everything but the top LEVELS levels of headers, in whole buffer." |
835 (setq first nil) | 842 (setq first nil) |
836 (outline-next-heading)) | 843 (outline-next-heading)) |
837 (if (bolp) | 844 (if (bolp) |
838 (progn | 845 (progn |
839 ;; Go to end of line before heading | 846 ;; Go to end of line before heading |
840 (forward-char -1))))) | 847 (forward-char -1) |
848 (if (and outline-blank-line (bolp)) | |
849 ;; leave blank line before heading | |
850 (forward-char -1)))))) | |
841 | 851 |
842 (defun show-branches () | 852 (defun show-branches () |
843 "Show all subheadings of this heading, but not their bodies." | 853 "Show all subheadings of this heading, but not their bodies." |
844 (interactive) | 854 (interactive) |
845 (show-children 1000)) | 855 (show-children 1000)) |