comparison lisp/outline.el @ 76024:00669875e4fe

(hide-sublevels): Keep empty last line, if available.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 19 Feb 2007 18:48:58 +0000
parents 6e4c04850090
children 54e83bd9ac02 dd7c098af727
comparison
equal deleted inserted replaced
76023:70e00d4c1216 76024:00669875e4fe
854 (looking-at outline-regexp)) 854 (looking-at outline-regexp))
855 (funcall outline-level)) 855 (funcall outline-level))
856 (t 1)))) 856 (t 1))))
857 (if (< levels 1) 857 (if (< levels 1)
858 (error "Must keep at least one level of headers")) 858 (error "Must keep at least one level of headers"))
859 (let (outline-view-change-hook) 859 (save-excursion
860 (save-excursion 860 (let* (outline-view-change-hook
861 (goto-char (point-min)) 861 (beg (progn
862 ;; Skip the prelude, if any. 862 (goto-char (point-min))
863 (unless (outline-on-heading-p t) (outline-next-heading)) 863 ;; Skip the prelude, if any.
864 (unless (outline-on-heading-p t) (outline-next-heading))
865 (point)))
866 (end (progn
867 (goto-char (point-max))
868 ;; Keep empty last line, if available.
869 (if (bolp) (1- (point)) (point)))))
864 ;; First hide everything. 870 ;; First hide everything.
865 (outline-flag-region (point) (point-max) t) 871 (outline-flag-region beg end t)
866 ;; Then unhide the top level headers. 872 ;; Then unhide the top level headers.
867 (outline-map-region 873 (outline-map-region
868 (lambda () 874 (lambda ()
869 (if (<= (funcall outline-level) levels) 875 (if (<= (funcall outline-level) levels)
870 (outline-show-heading))) 876 (outline-show-heading)))
871 (point) (point-max)))) 877 beg end)))
872 (run-hooks 'outline-view-change-hook)) 878 (run-hooks 'outline-view-change-hook))
873 879
874 (defun hide-other () 880 (defun hide-other ()
875 "Hide everything except current body and parent and top-level headings." 881 "Hide everything except current body and parent and top-level headings."
876 (interactive) 882 (interactive)