]> code.delx.au - gnu-emacs/blobdiff - lisp/server.el
Customize.
[gnu-emacs] / lisp / server.el
index d614e9c789bf85cb505c11b1266a10a363ebaa3b..dcd025b3d03c5c56a23c9580e498e4ba8ada7e1d 100644 (file)
@@ -147,20 +147,26 @@ Prefix arg means just kill any existing server communications subprocess."
       (progn
        (set-process-sentinel server-process nil)
        (condition-case () (delete-process server-process) (error nil))))
-  (condition-case () (delete-file "~/.emacs_server") (error nil))
+  ;; Delete the socket files made by previous server invocations.
   (let* ((sysname (system-name))
         (dot-index (string-match "\\." sysname)))
+    (condition-case ()
+       (delete-file (format "~/.emacs-server-%s" sysname))
+      (error nil))
     (condition-case ()
        (delete-file (format "/tmp/esrv%d-%s" (user-uid) sysname))
       (error nil))
     ;; In case the server file name was made with a domainless hostname,
     ;; try deleting that name too.
     (if dot-index
-       (condition-case ()
-           (delete-file (format "/tmp/esrv%d-%s" (user-uid)
-                                (substring sysname 0 dot-index)))
-         (error nil))))
-  ;; If we already had a server, clear out associated status.
+       (let ((shortname (substring sysname 0 dot-index)))
+         (condition-case ()
+             (delete-file (format "~/.emacs-server-%s" shortname))
+           (error nil))
+         (condition-case ()
+             (delete-file (format "/tmp/esrv%d-%s" (user-uid) shortname))
+           (error nil)))))
+  ;; If this Emacs already had a server, clear out associated status.
   (while server-clients
     (let ((buffer (nth 1 (car server-clients))))
       (server-buffer-done buffer)))
@@ -197,10 +203,10 @@ Prefix arg means just kill any existing server communications subprocess."
              (setq request (substring request (match-end 0)))
              (setq client (list (substring request 0 (string-match " " request))))
              (setq request (substring request (match-end 0)))
-             (setq foofoo request)
              (while (string-match "[^ ]+ " request)
                (let ((arg
-                      (substring request (match-beginning 0) (1- (match-end 0)))))
+                      (substring request (match-beginning 0) (1- (match-end 0))))
+                     (pos 0))
                  (setq request (substring request (match-end 0)))
                  (if (string-match "\\`-nowait" arg)
                      (setq nowait t)
@@ -210,6 +216,17 @@ Prefix arg means just kill any existing server communications subprocess."
                      ;; ARG is a file name.
                      ;; Collapse multiple slashes to single slashes.
                      (setq arg (command-line-normalize-file-name arg))
+                     ;; Undo the quoting that emacsclient does
+                     ;; for certain special characters.
+                     (while (string-match "&." arg pos)
+                       (setq pos (1+ (match-beginning 0)))
+                       (let ((nextchar (aref arg pos)))
+                         (cond ((= nextchar ?&)
+                                (setq arg (replace-match "&" t t arg)))
+                               ((= nextchar ?-)
+                                (setq arg (replace-match "-" t t arg)))
+                               (t
+                                (setq arg (replace-match " " t t arg))))))
                      (setq files
                            (cons (list arg lineno)
                                  files))
@@ -336,6 +353,7 @@ or nil.  KILLED is t if we killed the BUFFER (because it was a temp file)."
                    (buffer-backed-up nil))
                (save-buffer))
            (if (and (buffer-modified-p)
+                    buffer-file-name
                     (y-or-n-p (concat "Save file " buffer-file-name "? ")))
                (save-buffer buffer)))
          (server-buffer-done buffer)))))