Function: with-editor-return

with-editor-return is a byte-compiled function defined in with-editor.el.

Signature

(with-editor-return CANCEL)

Source Code

;; Defined in ~/.emacs.d/elpa/with-editor-20260301.1317/with-editor.el
(defun with-editor-return (cancel)
  (let ((winconf with-editor-previous-winconf)
        (clients server-buffer-clients)
        (dir default-directory)
        (pid with-editor--pid))
    (remove-hook 'kill-buffer-query-functions
                 #'with-editor-kill-buffer-noop t)
    (cond (cancel
           (save-buffer)
           (if clients
               (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.
             (ignore-errors (delete-file buffer-file-name))
             (kill-buffer)))
          (t
           (save-buffer)
           (if clients
               ;; Don't use `server-edit' because we do not want to
               ;; show another buffer belonging to another client.
               ;; See https://github.com/magit/magit/issues/2197.
               (server-done)
             (kill-buffer))))
    (when pid
      (let ((default-directory dir))
        (process-file "kill" nil nil nil
                      "-s" (if cancel "USR2" "USR1") pid)))
    (when (and winconf (eq (window-configuration-frame winconf)
                           (selected-frame)))
      (set-window-configuration winconf))))