When I quit ediff with q I get asked if I really want to quit. I'd rather it quit immediately. There is nothing obvious under customization. There is a solution here which seems to work by redefining the q key, but I'm not sure of the details of how the function works. What's the simplest way to get quit to really mean quit?
3 Answers
You can advise ediff-quit
so it dynamically rebinds y-or-n-p
to a function that returns t
.
(defun disable-y-or-n-p (orig-fun &rest args)
(cl-letf (((symbol-function 'y-or-n-p) (lambda (prompt) t)))
(apply orig-fun args)))
(advice-add 'ediff-quit :around #'disable-y-or-n-p)
This is more robust to upstream changes than redefining ediff-quit
.

- 166
- 1
- 5
-
If it would notify that if any differed buffer changed, it would be perfect. – CodyChan Oct 17 '16 at 03:36
Unfortunately I think you do have to either rebind q or adjust the source of ediff-quit
. As is apparent in the source of ediff-quit
the prompt always happens.
(defun ediff-quit (reverse-default-keep-variants)
"Finish an Ediff session and exit Ediff.
Unselects the selected difference, if any, restores the read-only and modified
flags of the compared file buffers, kills Ediff buffers for this session
\(but not buffers A, B, C\).
If `ediff-keep-variants' is nil, the user will be asked whether the buffers
containing the variants should be removed \(if they haven't been modified\).
If it is t, they will be preserved unconditionally. A prefix argument,
temporarily reverses the meaning of this variable."
(interactive "P")
(ediff-barf-if-not-control-buffer)
(let ((ctl-buf (current-buffer))
(ctl-frm (selected-frame))
(minibuffer-auto-raise t))
(if (y-or-n-p (format "Quit this Ediff session%s? "
(if (ediff-buffer-live-p ediff-meta-buffer)
" & show containing session group" "")))
(progn
(message "")
(set-buffer ctl-buf)
(ediff-really-quit reverse-default-keep-variants))
(select-frame ctl-frm)
(raise-frame ctl-frm)
(message ""))))
I would suggest redefining ediff-quit
in your .emacs
and submitting a patch to the source adding a customization variable.
Remember that the implementation source in emacs is always a few keystrokes away. Presuming the elisp sources are installed, type C-h f, enter the function name and follow the link to where it is defined.

- 4,169
- 20
- 41
I use the following rebind of q in ediff. If any of the buffers are modified, it asks if they are to be saved, then it just quits. If no buffers are modified, it just quits.
(add-hook 'ediff-startup-hook
(lambda ()
(local-set-key (kbd"q") 'my-ediff-quit)))
(defun my-ediff-quit ()
"If any of the ediff buffers have been modified, ask if changes
should be saved. Then quit ediff normally, without asking for
confirmation"
(interactive)
(ediff-barf-if-not-control-buffer)
(let* ((buf-a ediff-buffer-A)
(buf-b ediff-buffer-B)
(buf-c ediff-buffer-C)
(ctl-buf (current-buffer))
(modified (remove-if-not 'buffer-modified-p
(list buf-a buf-b buf-c))))
(let ((save (if modified (yes-or-no-p "Save changes?")nil)))
(loop for buf in modified do
(progn
(set-buffer buf)
(if save
(save-buffer)
(set-buffer-modified-p nil))))
(set-buffer ctl-buf)
(ediff-really-quit nil))))

- 719
- 5
- 11