aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2008-09-06 17:17:05 +0000
committerChong Yidong2008-09-06 17:17:05 +0000
commitee0aed46c68a9335f34b1ee8410bfa54d08768f7 (patch)
tree47c17b77715155e681c92e48e489826d97529750
parenta5d059649e0544706cfaa808b0edde23ff169b30 (diff)
downloademacs-ee0aed46c68a9335f34b1ee8410bfa54d08768f7.tar.gz
emacs-ee0aed46c68a9335f34b1ee8410bfa54d08768f7.zip
(server-switch-buffer): New arg.
(server-execute): If reusing an existing window, set file position if required.
-rw-r--r--lisp/server.el18
1 files changed, 13 insertions, 5 deletions
diff --git a/lisp/server.el b/lisp/server.el
index ff2cb1241f2..0a8df5d9f47 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -986,7 +986,7 @@ The following commands are accepted by the client:
986 (message "%s" (substitute-command-keys 986 (message "%s" (substitute-command-keys
987 "When done with this frame, type \\[delete-frame]"))) 987 "When done with this frame, type \\[delete-frame]")))
988 ((not (null buffers)) 988 ((not (null buffers))
989 (server-switch-buffer (car buffers)) 989 (server-switch-buffer (car buffers) nil (cdr (car files)))
990 (run-hooks 'server-switch-hook) 990 (run-hooks 'server-switch-hook)
991 (unless nowait 991 (unless nowait
992 (message "%s" (substitute-command-keys 992 (message "%s" (substitute-command-keys
@@ -1206,14 +1206,18 @@ starts server process and that is all. Invoked by \\[server-edit]."
1206 (server-clients (apply 'server-switch-buffer (server-done))) 1206 (server-clients (apply 'server-switch-buffer (server-done)))
1207 (t (message "No server editing buffers exist")))) 1207 (t (message "No server editing buffers exist"))))
1208 1208
1209(defun server-switch-buffer (&optional next-buffer killed-one) 1209(defun server-switch-buffer (&optional next-buffer killed-one filepos)
1210 "Switch to another buffer, preferably one that has a client. 1210 "Switch to another buffer, preferably one that has a client.
1211Arg NEXT-BUFFER is a suggestion; if it is a live buffer, use it. 1211Arg NEXT-BUFFER is a suggestion; if it is a live buffer, use it.
1212 1212
1213KILLED-ONE is t in a recursive call if we have already killed one 1213KILLED-ONE is t in a recursive call if we have already killed one
1214temp-file server buffer. This means we should avoid the final 1214temp-file server buffer. This means we should avoid the final
1215\"switch to some other buffer\" since we've already effectively 1215\"switch to some other buffer\" since we've already effectively
1216done that." 1216done that.
1217
1218FILEPOS specifies a new buffer position for NEXT-BUFFER, if we
1219visit NEXT-BUFFER in an existing window. If non-nil, it should
1220be a cons cell (LINENUMBER . COLUMNNUMBER)."
1217 (if (null next-buffer) 1221 (if (null next-buffer)
1218 (progn 1222 (progn
1219 (let ((rest server-clients)) 1223 (let ((rest server-clients))
@@ -1238,10 +1242,14 @@ done that."
1238 (funcall server-window next-buffer) 1242 (funcall server-window next-buffer)
1239 (let ((win (get-buffer-window next-buffer 0))) 1243 (let ((win (get-buffer-window next-buffer 0)))
1240 (if (and win (not server-window)) 1244 (if (and win (not server-window))
1241 ;; The buffer is already displayed: just reuse the window. 1245 ;; The buffer is already displayed: just reuse the
1246 ;; window. If FILEPOS is non-nil, use it to replace the
1247 ;; window's own value of point.
1242 (progn 1248 (progn
1243 (select-window win) 1249 (select-window win)
1244 (set-buffer next-buffer)) 1250 (set-buffer next-buffer)
1251 (when filepos
1252 (server-goto-line-column filepos)))
1245 ;; Otherwise, let's find an appropriate window. 1253 ;; Otherwise, let's find an appropriate window.
1246 (cond ((window-live-p server-window) 1254 (cond ((window-live-p server-window)
1247 (select-window server-window)) 1255 (select-window server-window))