changeset 6176:1dbec303c87b

(kill-emacs-query-functions, kill-buffer-query-functions): Add functions to these lists. (server-program): Add exec-directory to value. Use expand-file-name. (server-buffer-done): If buffer is dead, don't bury it. (server-done): If we kill the old buffer, and server-buffer-done gives us nil, return the new current buffer.
author Richard M. Stallman <rms@gnu.org>
date Thu, 03 Mar 1994 19:23:59 +0000
parents 340f5eb2e8b6
children ac2ef13dca1b
files lisp/server.el
diffstat 1 files changed, 26 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/server.el	Thu Mar 03 19:17:47 1994 +0000
+++ b/lisp/server.el	Thu Mar 03 19:23:59 1994 +0000
@@ -73,7 +73,7 @@
 
 ;;; Code:
 
-(defvar server-program (concat exec-directory "emacsserver")
+(defvar server-program (expand-file-name "emacsserver" exec-directory)
   "*The program to use as the edit server.")
 
 (defvar server-visit-hook nil
@@ -95,6 +95,7 @@
 
 (defvar server-buffer-clients nil
   "List of clientids for clients requesting editing of current buffer.")
+(make-variable-buffer-local 'server-buffer-clients)
 ;; Changing major modes should not erase this local.
 (put 'server-buffer-clients 'permanent-local t)
 
@@ -108,9 +109,6 @@
 which are deleted and reused after each edit
 by the programs that invoke the emacs server.")
 
-(make-variable-buffer-local 'server-buffer-clients)
-(put 'server-buffer-clients 'permanent-local t)
-(setq-default server-buffer-clients nil)
 (or (assq 'server-buffer-clients minor-mode-alist)
     (setq minor-mode-alist (cons '(server-buffer-clients " Server") minor-mode-alist)))
 
@@ -249,10 +247,11 @@
 	  (setq server-clients (delq client server-clients))))
       (setq old-clients (cdr old-clients)))
     (if (buffer-name buffer)
-	(save-excursion
-	  (set-buffer buffer)
-	  (setq server-buffer-clients nil)))
-    (bury-buffer buffer)
+	(progn
+	  (save-excursion
+	    (set-buffer buffer)
+	    (setq server-buffer-clients nil))
+	  (bury-buffer buffer)))
     next-buffer))
 
 (defun server-temp-file-p (buffer)
@@ -270,18 +269,34 @@
 Then bury it, and return a suggested buffer to select next."
   (let ((buffer (current-buffer)))
     (if server-buffer-clients
-	(progn
+	(let (suggested-buffer)
  	  (if (server-temp-file-p buffer)
 	      ;; For a temp file, save, and do make a non-numeric backup
 	      ;; (unless make-backup-files is nil).
 	      (let ((version-control nil)
 		    (buffer-backed-up nil))
 		(save-buffer)
-		(kill-buffer buffer))
+		(kill-buffer buffer)
+		(setq suggested-buffer (current-buffer)))
 	    (if (and (buffer-modified-p)
 		     (y-or-n-p (concat "Save file " buffer-file-name "? ")))
 		(save-buffer buffer)))
-	  (server-buffer-done buffer)))))
+	  (or (server-buffer-done buffer) suggested-buffer)))))
+
+;; If a server buffer is killed, release its client.
+;; I'm not sure this is really a good idea--do you want the client
+;; to proceed using whatever is on disk in that file?
+(add-hook 'kill-buffer-query-functions
+ 	  (function
+ 	   (lambda ()
+	     (or (not server-buffer-clients)
+		 (yes-or-no-p "Buffer `%s' still has clients; kill it? ")))))
+
+(add-hook 'kill-emacs-query-functions
+ 	  (function
+ 	   (lambda ()
+	     (or (not server-clients)
+		 (yes-or-no-p "Server buffers are still have clients; exit anyway? ")))))
 
 (defun server-edit (&optional arg)
   "Switch to next server editing buffer; say \"Done\" for current buffer.