Mercurial > emacs
comparison lisp/server.el @ 83251:de637975e99a
On C-x C-c, restrict `save-some-buffers' to the client's buffers. (Reported by Han Boetes.)
* lisp/server.el (server-kill-emacs-query-function): Fix typo in docs.
(server-save-buffers-kill-display): If emacsclient was started with a
list of filenames to edit, then offer to save only these buffers.
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-291
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Thu, 10 Feb 2005 21:23:33 +0000 |
parents | 89ac10c67e45 |
children | bcf610fb9517 |
comparison
equal
deleted
inserted
replaced
83250:89ac10c67e45 | 83251:de637975e99a |
---|---|
920 (setq res nil))))) | 920 (setq res nil))))) |
921 (yes-or-no-p (format "Buffer `%s' still has clients; kill it? " | 921 (yes-or-no-p (format "Buffer `%s' still has clients; kill it? " |
922 (buffer-name (current-buffer)))))) | 922 (buffer-name (current-buffer)))))) |
923 | 923 |
924 (defun server-kill-emacs-query-function () | 924 (defun server-kill-emacs-query-function () |
925 "Ask before exiting Emacs it has are live clients." | 925 "Ask before exiting Emacs it has live clients." |
926 (or (not server-clients) | 926 (or (not server-clients) |
927 (let (live-client) | 927 (let (live-client) |
928 (dolist (client server-clients live-client) | 928 (dolist (client server-clients live-client) |
929 (if (memq t (mapcar 'buffer-live-p (server-client-get | 929 (if (memq t (mapcar 'buffer-live-p (server-client-get |
930 client 'buffers))) | 930 client 'buffers))) |
1029 | 1029 |
1030 (defun server-save-buffers-kill-display (&optional arg) | 1030 (defun server-save-buffers-kill-display (&optional arg) |
1031 "Offer to save each buffer, then kill the current connection. | 1031 "Offer to save each buffer, then kill the current connection. |
1032 If the current frame has no client, kill Emacs itself. | 1032 If the current frame has no client, kill Emacs itself. |
1033 | 1033 |
1034 With prefix arg, silently save all file-visiting buffers, then kill." | 1034 With prefix arg, silently save all file-visiting buffers, then kill. |
1035 | |
1036 If emacsclient was started with a list of filenames to edit, then | |
1037 only these files will be asked to be saved." | |
1035 (interactive "P") | 1038 (interactive "P") |
1036 (let ((proc (frame-parameter (selected-frame) 'client))) | 1039 (let ((proc (frame-parameter (selected-frame) 'client))) |
1037 (if (and proc) | 1040 (if proc |
1038 (progn | 1041 (let ((buffers (server-client-get proc 'buffers))) |
1039 (save-some-buffers arg t) | 1042 ;; If client is bufferless, emulate a normal Emacs session |
1043 ;; exit and offer to save all buffers. Otherwise, offer to | |
1044 ;; save only the buffers belonging to the client. | |
1045 (save-some-buffers arg | |
1046 (if buffers | |
1047 (lambda () (memq (current-buffer) buffers)) | |
1048 t)) | |
1040 (server-delete-client proc)) | 1049 (server-delete-client proc)) |
1041 (save-buffers-kill-emacs)))) | 1050 (save-buffers-kill-emacs)))) |
1042 | 1051 |
1043 (global-set-key "\C-x#" 'server-edit) | 1052 (global-set-key "\C-x#" 'server-edit) |
1044 | 1053 |