emacsmouseeventdired

Emacs disable mouse-1 in dired


In Emacs 23.2.1 in Dired mode the mouse-1 (left mouse button) performs visit file in other window. It also changes shape to a finger and highlights the filename when cursor hovers over the filename. How do I disable both visit file and filename highlighting ? I want mouse-1 to do its usual stuff: selecting text.

I can still select text if I start by clicking down in an area outside the filename or directory name. But I only want the filename marked, and not have a space in front included.


Solution

  • I just turn off mouse-1-click-follows-link by customizing it to nil. (You can also set it to a long time-limit value.)

    Or if you want to do that only for Dired buffers, you can do this:

    (add-hook 'dired-mode-hook
          (lambda ()
            (set (make-local-variable 'mouse-1-click-follows-link) nil)))
    

    But it is typically better to name a function that you use on a hook (it's easier to remove it, for one thing):

    (defun foo ()
      (set (make-local-variable 'mouse-1-click-follows-link) nil)))
    
    (add-hook 'dired-mode-hook 'foo)
    

    If you have a recent version of Emacs, where setq-local is defined, then you can use just (setq-local mouse-1-click-follows-link nil) in the hook function, in place of (set (make-local-variable 'mouse-1-click-follows-link) nil)