changeset 4500:56d7c4beae9f

(server-visit-files): Restore current-buffer by hand, not using save-excursion.
author Richard M. Stallman <rms@gnu.org>
date Mon, 09 Aug 1993 05:56:29 +0000
parents c7bfd863aefd
children 9352d7d021c2
files lisp/server.el
diffstat 1 files changed, 28 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/server.el	Mon Aug 09 05:45:12 1993 +0000
+++ b/lisp/server.el	Mon Aug 09 05:56:29 1993 +0000
@@ -196,30 +196,34 @@
 (defun server-visit-files (files client)
   "Finds FILES and returns the list CLIENT with the buffers nconc'd.
 FILES is an alist whose elements are (FILENAME LINENUMBER)."
-  (let (client-record)
-    (while files
-      (save-excursion
-	;; If there is an existing buffer modified or the file is modified,
-	;; revert it.
-	;; If there is an existing buffer with deleted file, offer to write it.
- 	(let* ((filen (car (car files)))
-	       (obuf (get-file-buffer filen)))
- 	  (if (and obuf (set-buffer obuf))
- 	      (if (file-exists-p filen)
- 		  (if (or (not (verify-visited-file-modtime obuf))
-			  (buffer-modified-p obuf))
-		      (revert-buffer t nil))
- 		(if (y-or-n-p
- 		     (concat "File no longer exists: "
- 			     filen
- 			     ", write buffer to file? "))
- 		    (write-file filen)))
- 	    (set-buffer (find-file-noselect filen))
-	    (run-hooks 'server-visit-hook)))
-	(goto-line (nth 1 (car files)))
-  	(setq server-buffer-clients (cons (car client) server-buffer-clients))
-  	(setq client-record (cons (current-buffer) client-record)))
-        (setq files (cdr files)))
+  (let (client-record (obuf (current-buffer)))
+    ;; Restore the current buffer afterward, but not using save-excursion,
+    ;; because we don't want to save point in this buffer
+    ;; if it happens to be one of those specified by the server.
+    (unwind-protect
+	(while files
+	  ;; If there is an existing buffer modified or the file is modified,
+	  ;; revert it.
+	  ;; If there is an existing buffer with deleted file, offer to write it.
+	  (let* ((filen (car (car files)))
+		 (obuf (get-file-buffer filen)))
+	    (if (and obuf (set-buffer obuf))
+		(if (file-exists-p filen)
+		    (if (or (not (verify-visited-file-modtime obuf))
+			    (buffer-modified-p obuf))
+			(revert-buffer t nil))
+		  (if (y-or-n-p
+		       (concat "File no longer exists: "
+			       filen
+			       ", write buffer to file? "))
+		      (write-file filen)))
+	      (set-buffer (find-file-noselect filen))
+	      (run-hooks 'server-visit-hook)))
+	  (goto-line (nth 1 (car files)))
+	  (setq server-buffer-clients (cons (car client) server-buffer-clients))
+	  (setq client-record (cons (current-buffer) client-record))
+	  (setq files (cdr files)))
+      (set-buffer obuf))
     (nconc client client-record)))
 
 (defun server-buffer-done (buffer)