[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: middle click to open url in new session
On 2007-01-17, Katsumi Yamaoka said:
>>>>>> In [emacs-w3m : No.09080] Leo wrote:
>> Looking forward to it ;) And thanks for the help.
> 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)
> (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
This seems to work real well. Thank you very much.
Leo <sdl.web AT gmail.com> (GPG Key: 9283AA3F)