X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/a0b5606ec769968b10c765f8ff50f312d691ef62..b3910f653938fc8625f4e0c970123e826bbf427e:/lisp/outline.el diff --git a/lisp/outline.el b/lisp/outline.el index 0ec5227a28..61ee7ff0f9 100644 --- a/lisp/outline.el +++ b/lisp/outline.el @@ -1,9 +1,9 @@ ;;; outline.el --- outline mode commands for Emacs -;; Copyright (C) 1986, 1993-1995, 1997, 2000-2013 Free Software +;; Copyright (C) 1986, 1993-1995, 1997, 2000-2014 Free Software ;; Foundation, Inc. -;; Maintainer: FSF +;; Maintainer: emacs-devel@gnu.org ;; Keywords: outlines ;; This file is part of GNU Emacs. @@ -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)