diff lisp/server.el @ 91085:880960b70474

Merge from emacs--devo--0 Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-283
author Miles Bader <miles@gnu.org>
date Sun, 11 Nov 2007 00:56:44 +0000
parents 1251cabc40b7 e83e0513df1b
children 53108e6cea98
line wrap: on
line diff
--- a/lisp/server.el	Fri Nov 09 14:52:32 2007 +0000
+++ b/lisp/server.el	Sun Nov 11 00:56:44 2007 +0000
@@ -239,7 +239,7 @@
        (progn ,@body))))
 
 (defun server-delete-client (proc &optional noframe)
-  "Delete CLIENT, including its buffers, terminals and frames.
+  "Delete PROC, including its buffers, terminals and frames.
 If NOFRAME is non-nil, let the frames live.  (To be used from
 `delete-frame-functions'.)"
   (server-log (concat "server-delete-client" (if noframe " noframe"))
@@ -294,8 +294,7 @@
 
 (defun server-log (string &optional client)
   "If a *server* buffer exists, write STRING to it for logging purposes.
-If CLIENT is non-nil, add a description of it to the logged
-message."
+If CLIENT is non-nil, add a description of it to the logged message."
   (when (get-buffer "*server*")
     (with-current-buffer "*server*"
       (goto-char (point-max))
@@ -484,6 +483,7 @@
 	  (add-hook 'delete-frame-functions 'server-handle-delete-frame)
 	  (add-hook 'kill-buffer-query-functions 'server-kill-buffer-query-function)
 	  (add-hook 'kill-emacs-query-functions 'server-kill-emacs-query-function)
+	  (add-hook 'kill-emacs-hook (lambda () (server-mode -1))) ;Cleanup upon exit.
 	  (setq server-process
 		(apply #'make-network-process
 		       :name server-name
@@ -572,7 +572,7 @@
                "BAUDRATE" "COLUMNS" "ESCDELAY" "HOME" "LINES"
                "NCURSES_ASSUMED_COLORS" "NCURSES_NO_PADDING"
                "NCURSES_NO_SETBUF" "TERM" "TERMCAP" "TERMINFO"
-               "TERMINFO_DIRS" "TERMPATH" 
+               "TERMINFO_DIRS" "TERMPATH"
                ;; rxvt wants these
                "COLORFGBG" "COLORTERM")
            (make-frame-on-tty tty type
@@ -590,7 +590,7 @@
                                 ;; C functions `child_setup' and
                                 ;; `getenv_internal' accordingly.
                                 (environment . ,(process-get proc 'env)))))))
-  
+
     ;; ttys don't use the `display' parameter, but callproc.c does to set
     ;; the DISPLAY environment on subprocesses.
     (set-frame-parameter frame 'display
@@ -737,7 +737,7 @@
   on this tty until it gets a -resume command.
 
 `-resume'
-  Resume this tty frame. The client sends this string when it
+  Resume this tty frame.  The client sends this string when it
   gets the SIGCONT signal and it is the foreground process on its
   controlling tty.
 
@@ -753,9 +753,8 @@
   used to forward window change signals to it.
 
 `-window-system-unsupported'
-  Signals that the server does not
-  support creating X frames; the client must try again with a tty
-  frame.
+  Signals that the server does not support creating X frames;
+  the client must try again with a tty frame.
 
 `-print STRING'
   Print STRING on stdout.  Used to send values
@@ -765,8 +764,8 @@
   Signal an error (but continue processing).
 
 `-suspend'
-  Suspend this terminal, i.e., stop the client process.  Sent
-  when the user presses C-z."
+  Suspend this terminal, i.e., stop the client process.
+  Sent when the user presses C-z."
   (server-log (concat "Received " string) proc)
   ;; First things first: let's check the authentication
   (unless (process-get proc :authenticated)
@@ -793,7 +792,7 @@
             ;; Save for later any partial line that remains.
             (when (> (length string) 0)
               (process-put proc 'previous-string string))
-            
+
           ;; In earlier versions of server.el (where we used an `emacsserver'
           ;; process), there could be multiple lines.  Nowadays this is not
           ;; supported any more.
@@ -931,7 +930,7 @@
 
 		 ;; Unknown command.
 		 (t (error "Unknown command: %s" arg)))))
-            
+
             (setq frame
                   (case tty-name
                     ((nil) (if display (server-select-display display)))
@@ -967,7 +966,7 @@
                   (run-hooks 'post-command-hook)))))
 
         (mapc 'funcall (nreverse commands))
-              
+
         ;; Delete the client if necessary.
         (cond
          (nowait
@@ -1008,8 +1007,8 @@
 `server-visit-files'."
   (goto-line (nth 1 file-line-col))
   (let ((column-number (nth 2 file-line-col)))
-    (if (> column-number 0)
-	(move-to-column (1- column-number)))))
+    (when (> column-number 0)
+      (move-to-column (1- column-number)))))
 
 (defun server-visit-files (files proc &optional nowait)
   "Find FILES and return a list of buffers created.
@@ -1159,7 +1158,7 @@
 			   (buffer-name (current-buffer))))))
 
 (defun server-kill-emacs-query-function ()
-  "Ask before exiting Emacs it has live clients."
+  "Ask before exiting Emacs if it has live clients."
   (or (not server-clients)
       (let (live-client)
 	(dolist (proc server-clients live-client)
@@ -1285,17 +1284,17 @@
 
 (define-key ctl-x-map "#" 'server-edit)
 
-(defun server-unload-hook ()
+(defun server-unload-function ()
   "Unload the server library."
   (server-mode -1)
-  (remove-hook 'suspend-tty-functions 'server-handle-suspend-tty)
-  (remove-hook 'delete-frame-functions 'server-handle-delete-frame)
-  (remove-hook 'kill-buffer-query-functions 'server-kill-buffer-query-function)
-  (remove-hook 'kill-emacs-query-functions 'server-kill-emacs-query-function)
-  (remove-hook 'kill-buffer-hook 'server-kill-buffer))
+  (substitute-key-definition 'server-edit nil ctl-x-map)
+  (save-current-buffer
+    (dolist (buffer (buffer-list))
+      (set-buffer buffer)
+      (remove-hook 'kill-buffer-hook 'server-kill-buffer t)))
+  ;; continue standard unloading
+  nil)
 
-(add-hook 'kill-emacs-hook (lambda () (server-mode -1))) ;Cleanup upon exit.
-(add-hook 'server-unload-hook 'server-unload-hook)
 
 (provide 'server)