]> code.delx.au - gnu-emacs/blobdiff - lisp/server.el
*** empty log message ***
[gnu-emacs] / lisp / server.el
index 5a8720e377e74c599cab616ea2691774af1c9069..4a133f529c01da41e6976a4bcd4b9b1585e32bae 100644 (file)
@@ -195,6 +195,10 @@ Prefix arg means just kill any existing server communications subprocess."
       (setq server-process (start-process "server" nil server-program)))
     (set-process-sentinel server-process 'server-sentinel)
     (set-process-filter server-process 'server-process-filter)
+    ;; We must receive file names without being decoded.  Those are
+    ;; decoded by server-process-filter accoding to
+    ;; file-name-coding-system.
+    (set-process-coding-system server-process 'raw-text 'raw-text)
     (process-kill-without-query server-process)))
 \f
 ;Process a request from the server to edit some files.
@@ -206,6 +210,9 @@ Prefix arg means just kill any existing server communications subprocess."
   ;; process each line individually.
   (while (string-match "\n" string)
     (let ((request (substring string 0 (match-beginning 0)))
+         (coding-system (and default-enable-multibyte-characters
+                             (or file-name-coding-system
+                                 default-file-name-coding-system)))
          client nowait
          (files nil)
          (lineno 1))
@@ -242,18 +249,28 @@ Prefix arg means just kill any existing server communications subprocess."
                                 (setq arg (replace-match "-" t t arg)))
                                (t
                                 (setq arg (replace-match " " t t arg))))))
+                     ;; Now decode the file name if necessary.
+                     (if coding-system
+                         (setq arg (decode-coding-string arg coding-system)))
                      (setq files
                            (cons (list arg lineno)
                                  files))
                      (setq lineno 1)))))
              (server-visit-files files client nowait)
              ;; CLIENT is now a list (CLIENTNUM BUFFERS...)
-             (or nowait
-                 (setq server-clients (cons client server-clients)))
-             (server-switch-buffer (nth 1 client))
-             (run-hooks 'server-switch-hook)
-             (message (substitute-command-keys
-                       "When done with a buffer, type \\[server-edit]")))))))
+             (if (null (cdr client))
+                 ;; This client is empty; get rid of it immediately.
+                 (progn
+                   (send-string server-process 
+                                (format "Close: %s Done\n" (car client)))
+                   (server-log (format "Close empty client: %s Done\n" (car client))))
+               ;; We visited some buffer for this client.
+               (or nowait
+                   (setq server-clients (cons client server-clients)))
+               (server-switch-buffer (nth 1 client))
+               (run-hooks 'server-switch-hook)
+               (message (substitute-command-keys
+                         "When done with a buffer, type \\[server-edit]"))))))))
   ;; Save for later any partial line that remains.
   (setq server-previous-string string))