emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/server.el,v


From: Stefan Monnier
Subject: [Emacs-diffs] Changes to emacs/lisp/server.el,v
Date: Sat, 26 Jan 2008 21:54:47 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Stefan Monnier <monnier>        08/01/26 21:54:47

Index: server.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/server.el,v
retrieving revision 1.159
retrieving revision 1.160
diff -u -b -r1.159 -r1.160
--- server.el   25 Jan 2008 15:43:05 -0000      1.159
+++ server.el   26 Jan 2008 21:54:44 -0000      1.160
@@ -294,11 +294,20 @@
 (defvar server-log-time-function 'current-time-string
   "Function to generate timestamps for the *server* buffer.")
 
+(defconst server-buffer " *server*"
+  "Buffer used internally by Emacs's server.
+One use is to log the I/O for debugging purposes (see `server-log'),
+the other is to provide a current buffer in which the process filter can
+safely let-bind buffer-local variables like default-directory.")
+
+(defvar server-log nil
+  "If non-nil, log the server's inputs and outputs in the `server-buffer'.")
+
 (defun server-log (string &optional client)
-  "If a *server* buffer exists, write STRING to it for logging purposes.
+  "If `server-log' is non-nil, log STRING to `server-buffer'.
 If CLIENT is non-nil, add a description of it to the logged message."
-  (when (get-buffer "*server*")
-    (with-current-buffer "*server*"
+  (when server-log
+    (with-current-buffer (get-buffer-create server-buffer)
       (goto-char (point-max))
       (insert (funcall server-log-time-function)
              (cond
@@ -497,7 +506,7 @@
                       ;; Those are decoded by server-process-filter according
                       ;; to file-name-coding-system.
                       :coding 'raw-text
-                      ;; The rest of the args depends on the kind of socket 
used.
+                      ;; The other args depend on the kind of socket used.
                       (if server-use-tcp
                           (list :family nil
                                 :service t
@@ -928,17 +937,24 @@
                      (server-create-window-system-frame display nowait proc))
                     (t (server-create-tty-frame tty-name tty-type proc))))
 
-            (process-put proc 'continuation
+            (process-put
+             proc 'continuation
                          (lexical-let ((proc proc)
                                        (files files)
                                        (nowait nowait)
                                        (commands commands)
                                        (dontkill dontkill)
                                        (frame frame)
+                           (dir dir)
                                        (tty-name tty-name))
                            (lambda ()
+                 (with-current-buffer (get-buffer-create server-buffer)
+                   ;; Use the same cwd as the emacsclient, if possible, so
+                   ;; relative file names work correctly, even in `eval'.
+                   (let ((default-directory
+                           (if (file-directory-p dir) dir default-directory)))
                              (server-execute proc files nowait commands
-                                             dontkill frame tty-name))))
+                                     dontkill frame tty-name))))))
 
             (when (or frame files)
               (server-goto-toplevel proc))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]