emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-24 b3910f6: outline.el: Fix subtree movement.


From: Stephen Berman
Subject: [Emacs-diffs] emacs-24 b3910f6: outline.el: Fix subtree movement.
Date: Thu, 27 Nov 2014 10:04:27 +0000

branch: emacs-24
commit b3910f653938fc8625f4e0c970123e826bbf427e
Author: Stephen Berman <address@hidden>
Date:   Thu Nov 27 11:03:58 2014 +0100

    outline.el: Fix subtree movement.
    
    Fixes: debbugs:19102
    
    Co-authored-by: Stefan Monnier <address@hidden>
    * outline.el (outline-move-subtree-down): Make sure we can move
    forward to find the end of the subtree and the insertion point.
---
 lisp/ChangeLog  |    7 +++++++
 lisp/outline.el |   17 +++++++++++------
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index d88ecfe..8c48019 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
+2014-11-27  Stephen Berman  <address@hidden>
+           Stefan Monnier  <address@hidden>
+
+       * outline.el (outline-move-subtree-down): Make sure we can move
+       forward to find the end of the subtree and the insertion point
+       (bug#19102).
+
 2014-11-27  Leonard Randall  <address@hidden>
 
        * textmodes/reftex-parse.el (reftex-using-biblatex-p): Make search
diff --git a/lisp/outline.el b/lisp/outline.el
index c7cad31..61ee7ff 100644
--- a/lisp/outline.el
+++ b/lisp/outline.el
@@ -649,27 +649,32 @@ the match data is set appropriately."
                   'outline-get-last-sibling))
        (ins-point (make-marker))
        (cnt (abs arg))
+       ;; Make sure we can move forward to find the end of the
+       ;; subtree and the insertion point.
+       (maybe-forward-char (lambda ()
+                             (if (eq (char-after) ?\n) (forward-char 1)
+                               (if (and (eobp) (not (bolp))) (insert "\n")))))
        beg end folded)
-    ;; Select the tree
+    ;; Select the tree.
     (outline-back-to-heading)
     (setq beg (point))
     (save-match-data
       (save-excursion (outline-end-of-heading)
                      (setq folded (outline-invisible-p)))
       (outline-end-of-subtree))
-    (if (= (char-after) ?\n) (forward-char 1))
+    (funcall maybe-forward-char)
     (setq end (point))
-    ;; Find insertion point, with error handling
+    ;; Find insertion point, with error handling.
     (goto-char beg)
     (while (> cnt 0)
       (or (funcall movfunc)
          (progn (goto-char beg)
-                (error "Cannot move past superior level")))
+                (user-error "Cannot move past superior level")))
       (setq cnt (1- cnt)))
     (if (> arg 0)
-       ;; Moving forward - still need to move over subtree
+       ;; Moving forward - still need to move over subtree.
        (progn (outline-end-of-subtree)
-              (if (= (char-after) ?\n) (forward-char 1))))
+              (funcall maybe-forward-char)))
     (move-marker ins-point (point))
     (insert (delete-and-extract-region beg end))
     (goto-char ins-point)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]