]> code.delx.au - gnu-emacs/blobdiff - lisp/outline.el
(blink-cursor-mode): Replace `emacs-quick-startup' with `no-blinking-cursor'.
[gnu-emacs] / lisp / outline.el
index 59aeb233fdd8a4fdd6c4f98065fe770ae6680cfa..89e9e193e9cdd81759e22490100772b000eb2a85 100644 (file)
@@ -216,6 +216,9 @@ in the file it applies to."
 (defvar outline-mode-hook nil
   "*This hook is run when outline mode starts.")
 
+(defvar outline-blank-line nil
+  "*Non-nil means to leave unhidden blank line before heading.")
+
 ;;;###autoload
 (define-derived-mode outline-mode text-mode "Outline"
   "Set major mode for editing outlines with selective display.
@@ -349,7 +352,7 @@ at the end of the buffer."
   (if (re-search-forward (concat "\n\\(?:" outline-regexp "\\)")
                         nil 'move)
       (goto-char (match-beginning 0)))
-  (if (and (bolp) (not (bobp)))
+  (if (and (bolp) (or outline-blank-line (eobp)) (not (bobp)))
       (forward-char -1)))
 
 (defun outline-next-heading ()
@@ -706,8 +709,8 @@ If FLAG is nil then text is shown, while if FLAG is t the text is hidden."
   "Hide the body directly following this heading."
   (interactive)
   (outline-back-to-heading)
-  (outline-end-of-heading)
   (save-excursion
+    (outline-end-of-heading)
     (outline-flag-region (point) (progn (outline-next-preface) (point)) t)))
 
 (defun show-entry ()
@@ -720,7 +723,7 @@ Show the heading too, if it is currently invisible."
                         (progn (outline-next-preface) (point)) nil)))
 
 (defun hide-body ()
-  "Hide all of buffer except headings."
+  "Hide all body lines in buffer, leaving all headings visible."
   (interactive)
   (hide-region-body (point-min) (point-max)))
 
@@ -735,7 +738,8 @@ Show the heading too, if it is currently invisible."
        (narrow-to-region start end)
        (goto-char (point-min))
        (if (outline-on-heading-p)
-           (outline-end-of-heading))
+           (outline-end-of-heading)
+         (outline-next-preface))
        (while (not (eobp))
          (outline-flag-region (point)
                               (progn (outline-next-preface) (point)) t)
@@ -770,9 +774,10 @@ Show the heading too, if it is currently invisible."
 (defun outline-show-heading ()
   "Show the current heading and move to its end."
   (outline-flag-region (- (point)
-                         (if (bobp) 0
-                           (if (eq (char-before (1- (point))) ?\n)
-                               2 1)))
+                         (if (bobp) 0
+                           (if (and outline-blank-line
+                                     (eq (char-before (1- (point))) ?\n))
+                               2 1)))
                       (progn (outline-end-of-heading) (point))
                       nil))
 
@@ -804,7 +809,7 @@ Show the heading too, if it is currently invisible."
     (save-excursion
       (outline-back-to-heading t)
       (show-entry)
-      (while (condition-case nil (progn (outline-up-heading 1) (not (bobp)))
+      (while (condition-case nil (progn (outline-up-heading 1 t) (not (bobp)))
               (error nil))
        (outline-flag-region (1- (point))
                             (save-excursion (forward-line 1) (point))
@@ -841,9 +846,9 @@ Show the heading too, if it is currently invisible."
        (progn
          ;; Go to end of line before heading
          (forward-char -1)
-         (if (bolp)
-             ;; leave blank line before heading
-             (forward-char -1))))))
+          (if (and outline-blank-line (bolp))
+             ;; leave blank line before heading
+             (forward-char -1))))))
 \f
 (defun show-branches ()
   "Show all subheadings of this heading, but not their bodies."
@@ -884,6 +889,8 @@ Default is enough to cause the following heading to appear."
 With argument, move up ARG levels.
 If INVISIBLE-OK is non-nil, also consider invisible lines."
   (interactive "p")
+  (and (eq this-command 'outline-up-heading)
+       (or (eq last-command 'outline-up-heading) (push-mark)))
   (outline-back-to-heading invisible-ok)
   (let ((start-level (funcall outline-level)))
     (if (eq start-level 1)