Mercurial > emacs
comparison lisp/outline.el @ 55228:53c5c7a2f4a8
(outline-next-preface, outline-show-heading): Don't leave unhidden blank line before heading.
(outline-end-of-subtree): Include last newline into subtree.
(hide-entry): Leave point at beginning of heading instead of end.
(outline-up-heading): Push mark for the first call of successive command calls.
author | Juri Linkov <juri@jurta.org> |
---|---|
date | Thu, 29 Apr 2004 15:34:21 +0000 |
parents | cb1748b5a52b |
children | 8362eef794e3 |
comparison
equal
deleted
inserted
replaced
55227:193a4c332536 | 55228:53c5c7a2f4a8 |
---|---|
347 If there's no following heading line, stop before the newline | 347 If there's no following heading line, stop before the newline |
348 at the end of the buffer." | 348 at the end of the buffer." |
349 (if (re-search-forward (concat "\n\\(?:" outline-regexp "\\)") | 349 (if (re-search-forward (concat "\n\\(?:" outline-regexp "\\)") |
350 nil 'move) | 350 nil 'move) |
351 (goto-char (match-beginning 0))) | 351 (goto-char (match-beginning 0))) |
352 (if (and (bolp) (not (bobp))) | 352 (if (and (bolp) (eobp) (not (bobp))) |
353 (forward-char -1))) | 353 (forward-char -1))) |
354 | 354 |
355 (defun outline-next-heading () | 355 (defun outline-next-heading () |
356 "Move to the next (possibly invisible) heading line." | 356 "Move to the next (possibly invisible) heading line." |
357 (interactive) | 357 (interactive) |
704 | 704 |
705 (defun hide-entry () | 705 (defun hide-entry () |
706 "Hide the body directly following this heading." | 706 "Hide the body directly following this heading." |
707 (interactive) | 707 (interactive) |
708 (outline-back-to-heading) | 708 (outline-back-to-heading) |
709 (outline-end-of-heading) | |
710 (save-excursion | 709 (save-excursion |
710 (outline-end-of-heading) | |
711 (outline-flag-region (point) (progn (outline-next-preface) (point)) t))) | 711 (outline-flag-region (point) (progn (outline-next-preface) (point)) t))) |
712 | 712 |
713 (defun show-entry () | 713 (defun show-entry () |
714 "Show the body directly following this heading. | 714 "Show the body directly following this heading. |
715 Show the heading too, if it is currently invisible." | 715 Show the heading too, if it is currently invisible." |
767 (interactive) | 767 (interactive) |
768 (outline-flag-subtree nil)) | 768 (outline-flag-subtree nil)) |
769 | 769 |
770 (defun outline-show-heading () | 770 (defun outline-show-heading () |
771 "Show the current heading and move to its end." | 771 "Show the current heading and move to its end." |
772 (outline-flag-region (- (point) | 772 (outline-flag-region (- (point) (if (bobp) 0 1)) |
773 (if (bobp) 0 | |
774 (if (eq (char-before (1- (point))) ?\n) | |
775 2 1))) | |
776 (progn (outline-end-of-heading) (point)) | 773 (progn (outline-end-of-heading) (point)) |
777 nil)) | 774 nil)) |
778 | 775 |
779 (defun hide-sublevels (levels) | 776 (defun hide-sublevels (levels) |
780 "Hide everything but the top LEVELS levels of headers, in whole buffer." | 777 "Hide everything but the top LEVELS levels of headers, in whole buffer." |
838 (setq first nil) | 835 (setq first nil) |
839 (outline-next-heading)) | 836 (outline-next-heading)) |
840 (if (bolp) | 837 (if (bolp) |
841 (progn | 838 (progn |
842 ;; Go to end of line before heading | 839 ;; Go to end of line before heading |
843 (forward-char -1) | 840 (forward-char -1))))) |
844 (if (bolp) | |
845 ;; leave blank line before heading | |
846 (forward-char -1)))))) | |
847 | 841 |
848 (defun show-branches () | 842 (defun show-branches () |
849 "Show all subheadings of this heading, but not their bodies." | 843 "Show all subheadings of this heading, but not their bodies." |
850 (interactive) | 844 (interactive) |
851 (show-children 1000)) | 845 (show-children 1000)) |
882 (defun outline-up-heading (arg &optional invisible-ok) | 876 (defun outline-up-heading (arg &optional invisible-ok) |
883 "Move to the visible heading line of which the present line is a subheading. | 877 "Move to the visible heading line of which the present line is a subheading. |
884 With argument, move up ARG levels. | 878 With argument, move up ARG levels. |
885 If INVISIBLE-OK is non-nil, also consider invisible lines." | 879 If INVISIBLE-OK is non-nil, also consider invisible lines." |
886 (interactive "p") | 880 (interactive "p") |
881 (and (eq this-command 'outline-up-heading) | |
882 (or (eq last-command 'outline-up-heading) (push-mark))) | |
887 (outline-back-to-heading invisible-ok) | 883 (outline-back-to-heading invisible-ok) |
888 (let ((start-level (funcall outline-level))) | 884 (let ((start-level (funcall outline-level))) |
889 (if (eq start-level 1) | 885 (if (eq start-level 1) |
890 (error "Already at top level of the outline")) | 886 (error "Already at top level of the outline")) |
891 (while (and (> start-level 1) (> arg 0) (not (bobp))) | 887 (while (and (> start-level 1) (> arg 0) (not (bobp))) |