I am using emacs with PuTTY. I have xterm-mouse-mode turned on, and it works nicely, except that nothing happens when I click on "clickable texts" for example on the start page, or in neotree.
Is there a way to use mouse clicks for these?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.Sign up to join this community
This was a bug in the
xterm-mouse-mode handling. Should be fixed in Emacs-25.
If you're interested about the details, the problem is the need to perform several rewritings:
- first from xterm's escape sequence to a
- then from
mouse-2 (because it's a left click on a link).
These two steps only work if they're performed in the right order, but in the old code, the two steps were not performed in the right order, so when the link-handling code was trying to modify
mouse-2, all it saw was some escape sequence which it had no idea was actually "equivalent" to a
As Gilles said, emacs interprets the clicks of the middle mouse button, not the left. This means that you should first move the cursor to the desired position with the left mouse button, and then click with the middle. I do not find this behavior ergonomic, so I redefined the left-click to the "usual" way:
(defun on-mouse1-click (*click) (interactive "e") (let ((p1 (posn-point (event-start *click)))) (goto-char p1) (push-button) (neotree-enter))) (global-set-key (kbd "<mouse-1>") 'on-mouse1-click)
On linked text, such as what you find on the start page, left-clicking only moves the cursor and sets the active window like it normally does. To follow the link, you need to press the middle mouse button (that's the wheel if you have a two-buttons-and-a-wheel mouse). Left-clicking does push proper buttons.
A a long press of the left mouse button (450ms by default) also follows links, but I think that doesn't work in terminals.
If you want left clicks to always follow links regardless of duration, in the Customize interface, go to Editing → Mouse and change the setting of “Mouse 1 Click Follows Link” to enable it. Or put this in your init file:
(setq mouse-1-click-follows-link t)
If you want only double-clicks of the left button to follow links, set the variable to
double instead of
I don't know if that setting affects Neotree.
GUI Emacs tends to be more comfortable to work in than terminal Emacs. Instead of running Emacs on the remote machine, consider running Emacs locally and editing remote files.