Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to auto say Yes when run a command in Emacs?

I had to run the command revert-buffer many times recently and really frustrated to say yes whenever emacs prompts this message Revert buffer from file abc.txt? (yes or no).

Is there anyway to auto say yes in this case?

like image 315
Truong Ha Avatar asked Dec 19 '22 23:12

Truong Ha


2 Answers

If it's just for interactive usage, I'd define an alternative function:

(defun my-revert-buffer-noconfirm ()
  "Call `revert-buffer' with the NOCONFIRM argument set."
  (interactive)
  (revert-buffer nil t))

Alternatively, as the revert-buffer docstring tells you, take a look at the revert-without-query variable, in case that's a nicer solution for you.

like image 56
phils Avatar answered Dec 29 '22 08:12

phils


On a related side note, many people have the following line in their .emacs that will make confirmations just a single keypress (just y or n):

(defalias 'yes-or-no-p 'y-or-n-p)
like image 27
Rörd Avatar answered Dec 29 '22 06:12

Rörd