Mercurial > emacs
changeset 31008:ac8beefc28a9
(server-kill-new-buffers): New user option.
(server-existing-buffer): New buffer-local variable.
(server-visit-files): When using an existing buffer, set
server-existing-buffer to t.
(server-buffer-done): If server-kill-new-buffers is t, kill the
buffer, unless it was already present before visiting it with
Emacs server.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Mon, 21 Aug 2000 15:26:01 +0000 |
parents | 0e3404fe9965 |
children | 8c16eb0c611c |
files | lisp/server.el |
diffstat | 1 files changed, 44 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/server.el Mon Aug 21 14:45:04 2000 +0000 +++ b/lisp/server.el Mon Aug 21 15:26:01 2000 +0000 @@ -124,13 +124,29 @@ (defcustom server-temp-file-regexp "^/tmp/Re\\|/draft$" "*Regexp which should match filenames of temporary files which are deleted and reused after each edit -by the programs that invoke the emacs server." +by the programs that invoke the Emacs server." :group 'server :type 'regexp) +(defcustom server-kill-new-buffers t + "*Whether to kill buffers when done with them. +If non-nil, kill a buffer unless it already existed before editing +it with Emacs server. If nil, kill only buffers as specified by +`server-temp-file-regexp'. +Please note that only buffers are killed that still have a client, +i.e. buffers visited which \"emacsclient --no-wait\" are never killed in +this way." + :group 'server + :type 'boolean + :version "21.1") + (or (assq 'server-buffer-clients minor-mode-alist) (setq minor-mode-alist (cons '(server-buffer-clients " Server") minor-mode-alist))) +(defvar server-existing-buffer nil + "Non-nil means a server buffer existed before visiting a file.") +(make-variable-buffer-local 'server-existing-buffer) + ;; If a *server* buffer exists, ;; write STRING to it for logging purposes. (defun server-log (string) @@ -286,22 +302,24 @@ ;; if it happens to be one of those specified by the server. (unwind-protect (while files - ;; If there is an existing buffer modified or the file is modified, - ;; revert it. - ;; If there is an existing buffer with deleted file, offer to write it. + ;; If there is an existing buffer modified or the file is + ;; modified, revert it. If there is an existing buffer with + ;; deleted file, offer to write it. (let* ((filen (car (car files))) (obuf (get-file-buffer filen))) (if (and obuf (set-buffer obuf)) - (if (file-exists-p filen) - (if (or (not (verify-visited-file-modtime obuf)) - (buffer-modified-p obuf)) - (revert-buffer t nil)) - (if (y-or-n-p - (concat "File no longer exists: " - filen - ", write buffer to file? ")) - (write-file filen))) + (cond ((file-exists-p filen) + (if (or (not (verify-visited-file-modtime obuf)) + (buffer-modified-p obuf)) + (revert-buffer t nil))) + (t + (if (y-or-n-p + (concat "File no longer exists: " + filen + ", write buffer to file? ")) + (write-file filen)))) (set-buffer (find-file-noselect filen)) + (setq server-existing-buffer t) (run-hooks 'server-visit-hook))) (goto-line (nth 1 (car files))) (if (not nowait) @@ -364,10 +382,19 @@ ;; 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)))))) + (when (and (not killed) + server-kill-new-buffers + (save-excursion + (set-buffer buffer) + server-existing-buffer)) + (setq killed t) + (kill-buffer buffer)) + (unless killed + (if (server-temp-file-p buffer) + (progn + (kill-buffer buffer) + (setq killed t)) + (bury-buffer buffer))))))) (list next-buffer killed))) (defun server-temp-file-p (buffer)