branch: elpa/with-editor commit 7344bb67855278e3884e970b681c5aae09717920 Author: Jonas Bernoulli <jo...@bernoul.li> Commit: Jonas Bernoulli <jo...@bernoul.li>
with-editor-return: Make sure process buffer is killed If there is a client but it is not live anymore, likely because an error occurred while responding to the edit request, then `server-delete-client' will never be called, while we relied on that killing the buffer. --- lisp/with-editor.el | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lisp/with-editor.el b/lisp/with-editor.el index 3db54042aa..0b9bcc421f 100644 --- a/lisp/with-editor.el +++ b/lisp/with-editor.el @@ -366,10 +366,14 @@ And some tools that do not handle $EDITOR properly also break." (cond (cancel (save-buffer) (if clients - (dolist (client clients) - (ignore-errors - (server-send-string client "-error Canceled by user")) - (delete-process client)) + (let ((buf (current-buffer))) + (dolist (client clients) + (message "client %S" client) + (ignore-errors + (server-send-string client "-error Canceled by user")) + (delete-process client)) + (when (buffer-live-p buf) + (kill-buffer buf))) ;; Fallback for when emacs was used as $EDITOR ;; instead of emacsclient or the sleeping editor. ;; See https://github.com/magit/magit/issues/2258.