Search code examples
emacsmousekey-bindings

The best way to set a key to do nothing


My touchpad occasionally issues [mouse-12] events which results in annoying flickering and a repeating <mouse-12> is undefined message.

According to elisp conventions, what is the best way to do nothing?

(global-set-key [mouse-12] 'WHAT-TO-INSERT-HERE?)

Solution

  • That would be the ignore function:

    ignore is an interactive compiled Lisp function in ‘subr.el’.
    
    It is bound to <mouse-movement>, <bottom-divider> <mouse-1>,
    <right-divider> <mouse-1>.
    
    (ignore &rest IGNORE)
    
    Do nothing and return nil.
    This function accepts any number of arguments, but ignores them.
    

    If it's good enough for the mouse-movement event, it should be good enough for the touchpad:

    (global-set-key [mouse-12] 'ignore)