diff lisp/simple.el @ 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 282ddc0ca465
children 27d7bc8db6b7
line wrap: on
line diff
--- 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.