changeset 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 70e00d4c1216
children a4103f62dec5
files lisp/ChangeLog lisp/outline.el
diffstat 2 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Mon Feb 19 15:46:25 2007 +0000
+++ b/lisp/ChangeLog	Mon Feb 19 18:48:58 2007 +0000
@@ -1,5 +1,7 @@
 2007-02-19  Stefan Monnier  <monnier@iro.umontreal.ca>
 
+	* outline.el (hide-sublevels): Keep empty last line, if available.
+
 	* buff-menu.el (list-buffers-noselect): Use explicit unicode code
 	rather than the corresponding unicode char, to make the code
 	more readable.
--- a/lisp/outline.el	Mon Feb 19 15:46:25 2007 +0000
+++ b/lisp/outline.el	Mon Feb 19 18:48:58 2007 +0000
@@ -856,19 +856,25 @@
 		 (t 1))))
   (if (< levels 1)
       (error "Must keep at least one level of headers"))
-  (let (outline-view-change-hook)
-    (save-excursion
-      (goto-char (point-min))
-      ;; Skip the prelude, if any.
-      (unless (outline-on-heading-p t) (outline-next-heading))
+  (save-excursion
+    (let* (outline-view-change-hook
+           (beg (progn
+                  (goto-char (point-min))
+                  ;; Skip the prelude, if any.
+                  (unless (outline-on-heading-p t) (outline-next-heading))
+                  (point)))
+           (end (progn
+                  (goto-char (point-max))
+                  ;; Keep empty last line, if available.
+                  (if (bolp) (1- (point)) (point)))))
       ;; First hide everything.
-      (outline-flag-region (point) (point-max) t)
+      (outline-flag-region beg end t)
       ;; Then unhide the top level headers.
       (outline-map-region
        (lambda ()
 	 (if (<= (funcall outline-level) levels)
 	     (outline-show-heading)))
-       (point) (point-max))))
+       beg end)))
   (run-hooks 'outline-view-change-hook))
 
 (defun hide-other ()