From: Harald Hanche-Olsen Date: Fri, 4 Jun 2021 09:09:46 +0000 (+0200) Subject: Add a new `server-edit-abort' command X-Git-Tag: emacs-28.0.90~2197 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9136c064d66a1d4ea69472ffe25662a8874f7ba6;p=emacs.git Add a new `server-edit-abort' command * doc/emacs/misc.texi (Invoking emacsclient): Document it (bug#11358). * lisp/server.el (server-edit): Mention it in the doc string. (server-edit-abort): New command. Copyright-paperwork-exempt: yes --- diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi index c8027792505..aed9fa9c665 100644 --- a/doc/emacs/misc.texi +++ b/doc/emacs/misc.texi @@ -1864,6 +1864,12 @@ it to exit. Programs that use @env{EDITOR} usually wait for the editor---in this case @command{emacsclient}---to exit before doing something else. +@findex server-edit-abort + If you want to abandon the edit instead, use the @kbd{M-x +server-edit-abort} command. This sends a message back to the +@command{emacsclient} program, telling it to exit, but doesn't save +any files. + You can also call @command{emacsclient} with multiple file name arguments: @samp{emacsclient @var{file1} @var{file2} ...} tells the Emacs server to visit @var{file1}, @var{file2}, and so forth. Emacs diff --git a/etc/NEWS b/etc/NEWS index 675925906cb..c272d279b8e 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -510,6 +510,12 @@ When emacsclient connects, Emacs will (by default) output a message about how to exit the client frame. If 'server-client-instructions' is set to nil, this message is inhibited. ++++ +*** New command 'server-edit-abort'. +This command (not bound to any key by default) can be used to abort +an edit instead of marking it as "Done" (which the 'C-x #' command +does). + ** Perl mode --- diff --git a/lisp/server.el b/lisp/server.el index 17332a2b0a1..3205ba182ee 100644 --- a/lisp/server.el +++ b/lisp/server.el @@ -1603,7 +1603,9 @@ prevent a backup for it.) The variable `server-temp-file-regexp' controls which filenames are considered temporary. If invoked with a prefix argument, or if there is no server process running, -starts server process and that is all. Invoked by \\[server-edit]." +starts server process and that is all. Invoked by \\[server-edit]. + +To abort an edit instead of saying \"Done\", use \\[server-edit-abort]." (interactive "P") (cond ((or arg @@ -1613,6 +1615,17 @@ starts server process and that is all. Invoked by \\[server-edit]." (server-clients (apply #'server-switch-buffer (server-done))) (t (message "No server editing buffers exist")))) +(defun server-edit-abort () + "Abort editing the current client buffer." + (interactive) + (if server-clients + (mapc (lambda (proc) + (server-send-string + proc (concat "-error " + (server-quote-arg "Aborted by the user")))) + server-clients) + (message "This buffer has no clients"))) + (defun server-switch-buffer (&optional next-buffer killed-one filepos this-frame-only) "Switch to another buffer, preferably one that has a client.