Subject: Re: bug#49869: Revert buffer? Yes/No/Maybe

From: Gregory Heytings <[email-masked]>
Date: Wed, 04 Aug 2021 10:06:12 +0000

>> There is a new short keybinding to revert the current buffer - just 3 
>> keys: 'C-x x g'.  But then it asks for a confirmation with 4 keys: 'y e 
>> s RET' that is even longer than the command keys. This defeats the 
>> purpose of having the short key sequence. Does 'C-x x g' really need a 
>> confirmation?
>>
>> I propose to revert the buffer immediately after typing 'C-x x g'.
>
> I think I agree...  if the buffer hasn't been changed.  So we could bind 
> it to a new command, like revert-buffer-command, that would call 
> revert-buffer with NOCONFIRM if the buffer hasn't been edited?
>

What about:

(defun revert-buffer-short-confirm (&optional args)
   (interactive (list (not current-prefix-arg)))
   (cl-letf (((symbol-function 'yes-or-no-p) 'y-or-n-p))
     (revert-buffer args)))

(global-set-key (kbd "C-x x g") 'revert-buffer-short-confirm)

?