changeset 107667:b6cc517c1044

Fix 2009-11-13 change to append-to-buffer (Bug#5749). * simple.el (append-to-buffer): Ensure that point is preserved if BUFFER is the current buffer. Suggested by YAMAMOTO Mitsuharu. (Bug#5749)
author Chong Yidong <cyd@stupidchicken.com>
date Wed, 24 Mar 2010 12:18:13 -0400
parents 22bf58a96b3a
children fd2cdc4e0e6a
files lisp/ChangeLog lisp/simple.el
diffstat 2 files changed, 13 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Wed Mar 24 11:57:16 2010 -0400
+++ b/lisp/ChangeLog	Wed Mar 24 12:18:13 2010 -0400
@@ -1,3 +1,9 @@
+2010-03-24  Chong Yidong  <cyd@stupidchicken.com>
+
+	* simple.el (append-to-buffer): Ensure that point is preserved if
+	BUFFER is the current buffer.  Suggested by YAMAMOTO Mitsuharu.
+	(Bug#5749)
+
 2010-03-24  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* progmodes/make-mode.el (makefile-rule-action-regex): Backtrack less.
--- a/lisp/simple.el	Wed Mar 24 11:57:16 2010 -0400
+++ b/lisp/simple.el	Wed Mar 24 12:18:13 2010 -0400
@@ -3473,12 +3473,13 @@
            (windows (get-buffer-window-list append-to t t))
            point)
       (with-current-buffer append-to
-	(setq point (point))
-	(barf-if-buffer-read-only)
-	(insert-buffer-substring oldbuf start end)
-	(dolist (window windows)
-	  (when (= (window-point window) point)
-	    (set-window-point window (point))))))))
+	(save-excursion
+	  (setq point (point))
+	  (barf-if-buffer-read-only)
+	  (insert-buffer-substring oldbuf start end)
+	  (dolist (window windows)
+	    (when (= (window-point window) point)
+	      (set-window-point window (point)))))))))
 
 (defun prepend-to-buffer (buffer start end)
   "Prepend to specified buffer the text of the region.