As laptop touchpads seem to be steadily increasing in size, one unfortunate consequence is that it becomes increasingly harder to avoid touching them by accident while you type. Most systems have safeguards in place that disable the touchpad as you’re typing, but they always seem to fall short for me when it comes to Emacs. While in Emacs, my hands are permanently resting on the keyboard (and over the touchpad), so even if I stop typing for several seconds I don’t want the touchpad to reactivate.
There are ways to permanently deactivate the touchpad with a hotkey, but, so far, the solution that best fits my use-style is to disable it only inside Emacs.
(define-minor-mode disable-mouse-mode "A minor-mode that disables all mouse keybinds." :global t :lighter " ??" :keymap (make-sparse-keymap)) (dolist (type '(mouse down-mouse drag-mouse double-mouse triple-mouse)) (dolist (prefix '("" C- M- S- M-S- C-M- C-S- C-M-S-)) ;; Yes, I actually HAD to go up to 7 here. (dotimes (n 7) (let ((k (format "%s%s-%s" prefix type n))) (define-key disable-mouse-mode-map (vector (intern k)) #'ignore)))))
All we do here is define a minor-mode that binds all mouse-related keys to
ignore. This is a slight improvement over the code on this StackOverflow answer. Of course, let’s not forget to enable this.
Two relevant limitations:
原文时间: 2016-05-02 08:00
整理时间: 2016-05-12 02:04
本文由 Hick 整理，转载请保留以上信息;
The articles on this site come from Internet, thanks to all the original authors.
If anything about COPYRIGHT, or LEFT, please contact Emacsist at gmail dot com .