Demi
Demi

Reputation: 3611

How can I disable the mouse in Emacs term modes?

I would like to disable the use of the mouse within Emacs's term mode. By this I mean that I want mouse clicks within the Emacs terminal window to have no effect; I want mouse clicks elsewhere to be unaffected.

Upvotes: 1

Views: 584

Answers (2)

sanityinc
sanityinc

Reputation: 15242

You can use my disable-mouse package to do this easily, either locally in a particular mode such as term-mode, or globally throughout Emacs.

Upvotes: 2

user2053036
user2053036

Reputation:

Have a look at this question which asks for disabling mouse globally. Here is a modified version to disable mouse only for term-mode

(eval-after-load "term"
  '(dolist (k '([mouse-1] [down-mouse-1] [drag-mouse-1] [double-mouse-1] [triple-mouse-1]  
           [mouse-2] [down-mouse-2] [drag-mouse-2] [double-mouse-2] [triple-mouse-2]
           [mouse-3] [down-mouse-3] [drag-mouse-3] [double-mouse-3] [triple-mouse-3]
           [mouse-4] [down-mouse-4] [drag-mouse-4] [double-mouse-4] [triple-mouse-4]
           [mouse-5] [down-mouse-5] [drag-mouse-5] [double-mouse-5] [triple-mouse-5]))
    (define-key term-raw-map k (lambda () 
                 (interactive) 
                 ;; ignore this
                 ))))

Do keep in mind that by disabling [mouse-1] you will not be able to select the terminal with mouse click, so you may want to avoid binding it.

EDIT: Wrapped the code in eval-after-load

Upvotes: 1

Related Questions