[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

Re: middle click to open url in new session

----- Katsumi Yamaoka (2007-01-17) wrote:-----

> If I understood correctly how mouse.el works, it simply replaces a
> mouse-1 event with that of mouse-2 when clicking mouse-1.  This means
> that the command we can invoke by mouse-1 is always the command that
> is bound to mouse-2.  Therefore, there is no well- mannered way to
> bind different commands to mouse-1 and mouse-2.  However, I'm not
> necessarily a well-mannered person.  Although it cannot be implemented
> in emacs-w3m, here is a workaround.  You can use the following snippet
> in your ~/.emacs-w3m.el file:
> (define-key w3m-mode-map [mouse-2] 'w3m-mouse-view-this-url-new-session)
> (defadvice mouse-drag-track (after replace-mouse-2-event activate)
>   "Replace mounse-2 event with the key for `w3m-view-this-url' command.
> This will be done only when mouse-1 is clicked in an emacs-w3m buffer
> and `mouse-1-click-follows-link' is non-nil."
>   (let ((keys (this-command-keys)))
>     (if (and (vectorp keys)
> 	     (= (length keys) 2)
> 	     (eq (car (aref keys 0)) 'down-mouse-1)
> 	     (eq (car (aref keys 1)) 'mouse-2)
> 	     (with-current-buffer
> 		 (window-buffer
> 		  (posn-window (event-start (car unread-command-events))))
> 	       (eq major-mode 'w3m-mode)))
> 	(setcar unread-command-events
> 		(aref (car (where-is-internal 'w3m-view-this-url
> 					      w3m-mode-map))
> 		      0)))))
> Regards,

I have been using this trick for quite sometime now. But recently I
start using Emacs in xterm and this trick will always open a link in a
new tab. Can this be fixed?

To use mouse in xterm, you need to have xterm-mouse-mode enabled.

Leo <sdl.web AT gmail.com>                         (GPG Key: 9283AA3F)