summaryrefslogtreecommitdiff
path: root/lisp/outline.el
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2014-11-28 22:55:31 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2014-11-28 23:07:16 -0800
commit0cce3623b169732a51f055a86fc926313b11a5ee (patch)
tree17154977d6e77f604ede0b82f89b2aeb6925310a /lisp/outline.el
parent9875d23d86c0668b1e697b67a394560d66c7826d (diff)
parent6b765b8facbdbb03f28028007885236601652515 (diff)
downloademacs-0cce3623b169732a51f055a86fc926313b11a5ee.tar.gz
Merge branch 'emacs-24'.
Diffstat (limited to 'lisp/outline.el')
-rw-r--r--lisp/outline.el17
1 files changed, 11 insertions, 6 deletions
diff --git a/lisp/outline.el b/lisp/outline.el
index c7cad31f572..61ee7ff0f9f 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)