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
This commit is contained in:
Harald Hanche-Olsen 2021-06-04 11:09:46 +02:00 committed by Lars Ingebrigtsen
parent 6d1d048d65
commit 9136c064d6
3 changed files with 26 additions and 1 deletions

View file

@ -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

View file

@ -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
---

View file

@ -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.