Mercurial > emacs
diff lisp/server.el @ 21941:1baa3e876ad0
(server-buffer-done): Bind server-kill-buffer-running
around places that might kill the buffer.
Do something reasonable if server-done-hook kills the buffer.
(server-kill-buffer-running): Doc fix.
(server-kill-buffer): Do nothing unless server-buffer-clients.
(server-done): Doc fix.
(server-buffer-done): Test of for-killing was backwards.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 05 May 1998 00:39:35 +0000 |
parents | 142900099257 |
children | 3b77bf7b709e |
line wrap: on
line diff
--- a/lisp/server.el Mon May 04 22:42:59 1998 +0000 +++ b/lisp/server.el Tue May 05 00:39:35 1998 +0000 @@ -299,7 +299,8 @@ "Mark BUFFER as \"done\" for its client(s). This buries the buffer, then returns a list of the form (NEXT-BUFFER KILLED). NEXT-BUFFER is another server buffer, as a suggestion for what to select next, -or nil. KILLED is t if we killed BUFFER (because it was a temp file)." +or nil. KILLED is t if we killed BUFFER +\(typically, because it was visiting a temp file)." (let ((running (eq (process-status server-process) 'run)) (next-buffer nil) (killed nil) @@ -332,16 +333,24 @@ (setq server-clients (delq client server-clients)))) (setq old-clients (cdr old-clients))) (if (and (bufferp buffer) (buffer-name buffer)) - (progn + ;; We may or may not kill this buffer; + ;; if we do, do not call server-buffer-done recursively + ;; from kill-buffer-hook. + (let ((server-kill-buffer-running t)) (save-excursion (set-buffer buffer) (setq server-buffer-clients nil) (run-hooks 'server-done-hook)) - (if for-killing + ;; Notice whether server-done-hook killed the buffer. + (if (null (buffer-name buffer)) + (setq killed t) + ;; Don't bother killing or burying the buffer + ;; when we are called from kill-buffer. + (unless for-killing (if (server-temp-file-p buffer) (progn (kill-buffer buffer) (setq killed t)) - (bury-buffer buffer))))) + (bury-buffer buffer)))))) (list next-buffer killed))) (defun server-temp-file-p (buffer) @@ -358,7 +367,8 @@ "Offer to save current buffer, mark it as \"done\" for clients. This buries the buffer, then returns a list of the form (NEXT-BUFFER KILLED). NEXT-BUFFER is another server buffer, as a suggestion for what to select next, -or nil. KILLED is t if we killed the BUFFER (because it was a temp file)." +or nil. KILLED is t if we killed BUFFER +\(typically, because it was visiting a temp file)." (let ((buffer (current-buffer))) (if server-buffer-clients (progn @@ -400,7 +410,7 @@ (add-hook 'kill-emacs-query-functions 'server-kill-emacs-query-function) (defvar server-kill-buffer-running nil - "Non-nil while `server-kill-buffer' is running.") + "Non-nil while `server-kill-buffer' or `server-buffer-done' is running.") ;; When a buffer is killed, inform the clients. (add-hook 'kill-buffer-hook 'server-kill-buffer) @@ -408,9 +418,10 @@ ;; Prevent infinite recursion if user has made server-done-hook ;; call kill-buffer. (or server-kill-buffer-running - (let ((server-kill-buffer-running t)) - (when server-process - (server-buffer-done (current-buffer) t))))) + (and server-buffer-clients + (let ((server-kill-buffer-running t)) + (when server-process + (server-buffer-done (current-buffer) t)))))) (defun server-edit (&optional arg) "Switch to next server editing buffer; say \"Done\" for current buffer.