On Tue, 11 Jul 2017, Paul Rankin wrote: >>> >>> One overlooked thing about Tino's solution is that C-g is a keystroke and keyboard-quit is a function, which obviously aren't necessarily equivalent. What if the user remaps keyboard quit to "7"? >> I thought about that, but i discarded because i think binding something >> other that `keyboard-quit' to `C-g' is a misuse. The Emacs manual is full >> of mentions to `C-g' as `keyboard-quit'. >> There is even the following remark in the tips section: >> >> "don't bind a key sequence ending in @key{C-g}, since that >> is commonly used to cancel a key sequence." >> >> If a user want to ignore such kind of advice he/she should >> not expect everything will work the same. > > I'm gonna do this just to mess with you 😉 Thank you. Actually i feel quite boring now, so it's OK :-) >> Maybe we can fix this so that `register-read-with-preview' >> will work with `C-g' bound to `my-cool-foo-command'; but we >> cannot assure that no other Emacs part is affected because such >> misguided `C-g' binding. We must encourage users to follow >> good practices. > >the point about C-g is more what if the user *also* binds keyboard-quit >to "7". In this case the user expects 7 to call keyboard-quit, not just >C-g. I see. Good point! Paul, what do you think about this? --- a/lisp/register.el +++ b/lisp/register.el @@ -164,6 +164,9 @@ register-read-with-preview help-chars) (unless (get-buffer-window buffer) (register-preview buffer 'show-empty))) + (when (and (characterp last-input-event) + (eq 'keyboard-quit (key-binding (string last-input-event)))) + (keyboard-quit)) (if (characterp last-input-event) last-input-event (error "Non-character input-event"))) I) Note, that my patch won't work in case our fearless user bind "7" to ...: (lambda () (message "What the hell are you doing?") (keyboard-quit)) ... But i don't think we must protect about things like I).