I have this in my .emacs file to disable mouse right clicks:

(put 'mouse-save-then-kill 'disabled "mouse-save-then-kill disabled\n")

How can I now disable the query generated by emacs to turn this command back on ("Do you want to use this command anyway? You can now type [y/n/SPC/!]") ?

2 Answers 2


Put this in your init file:

(setq disabled-command-function 'ignore)

By default, disabling a command means that you get that prompt when you try to use it.

But you can override this design by setting variable disabled-command-function to a function other than its default value, disabled-command-function.

You can see the code for disabling and enabling in library novice.el. You can find this out for yourself by doing C-h f disable-command and clicking the link to go to the file.

See also the Emacs manual, node Disabling.

Any non-nil value for property disabled for symbol mouse-save-then-kill means that that command is disabled. A nil value means that that command is enabled (is not disabled). But your use of a non-nil value does not mean that mouse right-clicking is disabled. It means only that command mouse-save-then-kill is disabled. It so happens that a right-click invokes that command by default.


Drew's answer solves your stated question so I would suggest accepting that; but my best guess is that something like this is what you're actually after:

(global-set-key [remap mouse-save-then-kill] 'ignore)

(to effectively disable all bindings for that command)

or maybe just:

(global-unset-key (kbd "<mouse-3>"))

(to remove just that specific binding)

or a more extreme approach:

(defalias 'mouse-save-then-kill 'ignore)

(to completely redefine the command, ensuring that it never does anything, no matter how it's called)

  • 1
    @Drew answers my question directly but yours is better for the behavior that I actually wanted.
    – hatmatrix
    Jul 19, 2016 at 11:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.