[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 9136c06 1/2: Add a new `server-edit-abort' command
From: |
Lars Ingebrigtsen |
Subject: |
master 9136c06 1/2: Add a new `server-edit-abort' command |
Date: |
Fri, 4 Jun 2021 06:01:52 -0400 (EDT) |
branch: master
commit 9136c064d66a1d4ea69472ffe25662a8874f7ba6
Author: Harald Hanche-Olsen <harald.hanche-olsen@ntnu.no>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
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
---
doc/emacs/misc.texi | 6 ++++++
etc/NEWS | 6 ++++++
lisp/server.el | 15 ++++++++++++++-
3 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi
index c802779..aed9fa9 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 6759259..c272d27 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 17332a2..3205ba1 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.