]> code.delx.au - gnu-emacs/blobdiff - lisp/outline.el
*** empty log message ***
[gnu-emacs] / lisp / outline.el
index 579997754f2f3afda47dd701946a0fa0096952b0..92e521afc9f3bc6732ea31406a9663d963b30646 100644 (file)
@@ -10,7 +10,7 @@
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
@@ -712,7 +712,10 @@ If nil, `show-entry' is called to reveal the invisible text.")
 If FLAG is nil then text is shown, while if FLAG is t the text is hidden."
   (remove-overlays from to 'invisible 'outline)
   (when flag
-    (let ((o (make-overlay from to)))
+    ;; We use `front-advance' here because the invisible text begins at the
+    ;; very end of the heading, before the newline, so text inserted at FROM
+    ;; belongs to the heading rather than to the entry.
+    (let ((o (make-overlay from to nil 'front-advance)))
       (overlay-put o 'invisible 'outline)
       (overlay-put o 'isearch-open-invisible
                   (or outline-isearch-open-invisible-function
@@ -1000,7 +1003,8 @@ Stop at the first and last subheadings of a superior heading."
          (error "No following same-level heading"))))))
 
 (defun outline-get-next-sibling ()
-  "Move to next heading of the same level, and return point or nil if none."
+  "Move to next heading of the same level, and return point.
+If there is no such heading, return nil."
   (let ((level (funcall outline-level)))
     (outline-next-visible-heading 1)
     (while (and (not (eobp)) (> (funcall outline-level) level))
@@ -1026,15 +1030,18 @@ Stop at the first and last subheadings of a superior heading."
          (error "No previous same-level heading"))))))
 
 (defun outline-get-last-sibling ()
-  "Move to previous heading of the same level, and return point or nil if none."
-  (let ((level (funcall outline-level)))
+  "Move to previous heading of the same level, and return point.
+If there is no such heading, return nil."
+  (let ((opoint (point))
+       (level (funcall outline-level)))
     (outline-previous-visible-heading 1)
-    (while (and (> (funcall outline-level) level)
-               (not (bobp)))
-      (outline-previous-visible-heading 1))
-    (if (< (funcall outline-level) level)
-       nil
-        (point))))
+    (when (and (/= (point) opoint) (outline-on-heading-p))
+      (while (and (> (funcall outline-level) level)
+                 (not (bobp)))
+       (outline-previous-visible-heading 1))
+      (if (< (funcall outline-level) level)
+         nil
+        (point)))))
 \f
 (defun outline-headers-as-kill (beg end)
   "Save the visible outline headers in region at the start of the kill ring.