2

I often run into an issue where I will click in a Emacs frame to make it active and accidentally slide my cursor so that it changes from a click to a drag. This means that some text is highlighted which can change behavior of the next commands I run (I am using evil-mode, so this puts me into visual state, but this is applicable outside of evil mode as well).

I don't want to completely disable the mouse, as I find it quite useful I just want to disable selecting text on a drag operation. I tried the following, but it lead to weird behavior (when the pointer leaving frames it will select text and it will still select one character sometimes).

(define-key evil-motion-state-map [down-mouse-1] 'ignore)

Is there a way to accomplish disabling drag to select (in evil specifically or outside)?

3
  • Because I have emacs full screen (with multiple monitors) and so there is no title bar or edge :) Feb 8, 2019 at 19:54
  • Also I will often click on the window I want to select. Feb 8, 2019 at 22:25
  • I find the down-mouse-1 binding confusing. Perhaps emacs.stackexchange.com/a/64966/454 helps to clarify things?
    – phils
    Jul 6, 2021 at 8:37

1 Answer 1

0

If I understand you correctly, you want to set the point on click but not set the region on drag.

You can enable this behaviour globally with:

(progn
  (global-set-key [mouse-1] 'mouse-set-point)
  (global-unset-key [down-mouse-1])
  (global-unset-key [drag-mouse-1]))
1
  • Why unbind down-mouse-1?
    – phils
    Jul 6, 2021 at 8:36

Your Answer

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

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