VM

emacs-w3m key bindings

Bug #912531 reported by Uday Reddy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
VM
Triaged
Low
khinsen
8.2.x
Triaged
Low
Unassigned

Bug Description

emacs-w3m uses its own key bindings, which conflict with those of VM. On second look, this problem is not as bad as it appeared. It should be easy enough to fix.

The variable `vm-w3m-use-w3m-minor-mode-map' is set to t. One can set this to nil to disable W3M keys. But then how does one navigate inside the html text, and invoke URL's?

The variable `w3m-minor-mode-command-alist' shows all the emacs-w3m commands that are bound to keys in the minor mode. If we can rebind them to the corresponding VM key bindings, we would do well.

Tags: 8.1 w3m

Related branches

Revision history for this message
Uday Reddy (reddyuday) wrote :

Clicking on hyperlinks doesn't work if if the minor-mode-map is disabled.

Revision history for this message
khinsen (konrad-hinsen) wrote :

I am compiling a set of key bindings for vm-mode-map that includes all of the useful w3m functionality, such that vm-w3m-use-w3m-minor-mode-map can safely be set to nil and forgotten. Watch this space for the details :-)

An important but badly documented function missing from w3m-minor-mode-command-alist is w3m-view-url-with-external-browser. It opens a link in an external program that is chosen by MIME-type. I use this much more often than w3m-view-this-url because so many Web pages use AJAX stuff nowadays and don't work in w3m at all.

Revision history for this message
khinsen (konrad-hinsen) wrote :

The following bindings work pretty well for me:

; Bindings for navigating HTML mails rendered through emacs-w3m
(define-key vm-mode-map (kbd "C-c C-o") 'w3m-view-url-with-external-browser)
(define-key vm-mode-map (kbd "C-c C-v") 'w3m-view-this-url)
(define-key vm-mode-map (kbd "<down-mouse-1>") 'w3m-mouse-view-this-url)
(define-key vm-mode-map (kbd "C-c C-p") 'w3m-previous-anchor)
(define-key vm-mode-map (kbd "C-c C-n") 'w3m-next-anchor)
(define-key vm-mode-map (kbd "C-c C-w") 'w3m-print-this-url)
(define-key vm-mode-map (kbd "C-c C-[") 'w3m-previous-image)
(define-key vm-mode-map (kbd "C-c C-]") 'w3m-next-image)
(define-key vm-mode-map (kbd "C-c C-i") 'w3m-toggle-inline-image)
(define-key vm-mode-map (kbd "C-c i") 'w3m-toggle-inline-images)

Revision history for this message
Uday Reddy (reddyuday) wrote :

Well, we can define our own `vm-w3m-minor-mode-map' and dump the standard one. That is what should have been done originally. (But, Katsumi Yamaoka was probably not much of a VM user, and he just produced a sample interface that we could build on.)

In this minor-mode, we can rebind "[" and "]" to w3m-previous-anchor and w3m-next-anchor. We could also bind "C-x [" and "C-x ]" to the image navigation functions. (I don't think anybody would need "page" navigation functions in an email message.)

We would also need define a context-menu (mouse-3 menu) that can be used on URL's which should look the same as in normal VM mode.

Revision history for this message
khinsen (konrad-hinsen) wrote :

A separate keymap is an excellent idea, as this allows to override the standard vm-mode-map. The attached patch implements this.

I have created a new keymap called vm-w3m-minor-mode-map. It is used unconditionally, because it doesn't do any harm. vm-w3m-use-w3m-minor-mode-map is gone. I have left vm-w3m-mode-map untouched as I don't understand what exactly is required for Emacs 20.

Adding a context menu for mouse-3 sounds like a good idea as well, but I don't know much about how menus are handled in Emacs and/or VM. I am a keyboard person :-)

Uday Reddy (reddyuday)
Changed in vm:
milestone: 8.2.90a → 8.2.1
Revision history for this message
Uday Reddy (reddyuday) wrote :

Thanks Konrad. That is a good start!

Couple of problems that I notice.

1. We can't simply get rid of the vm-w3m-use-w3m-minor-mode-map because some emacs-w3m users might actually be using it. I am going to add a new variable so that people can customize which minor mode they want to use for emacs-w3m.

2. `[' and `]' are supposed be vm-next-button/vm-previous-button. Binding them to w3m functions now means that they stop doing the old functions. It looks like I would need to modify vm-next-button/vm-previous-button to take care of the minor mode.

3. There is also a more subtle problem that emacs-w3m only knows about the URL's that are declared as URL's in html. When a URL occurs just as text, VM is later scanning the text and highlighting them. These text URL's are not being handled by the w3m functions. I don't know what to do about them yet.

Revision history for this message
Uday Reddy (reddyuday) wrote :

Revision 1336 has
   * New variables `vm-use-presentation-minor-modes' and
     `vm-presentation-minor-modes' control the minor modes to be used with
     presentation text prepared by other tools such as emacs-w3m. The
     old variable `vm-w3m-use-w3m-minor-mode-map' is obsolete.

We can customize `vm-presentation-minor-modes' to use the new `vm-w3m-minor-mode'.

Only the minor-mode-map is defined so far. The minor mode itself doesn't exist.

The key bindings of `[' and `]' override those of vm-mode, using w3m functions. So, they can't get to attachment buttons. Probably, the best solution is for VM to energize the hyperlinks that appear in Emacs-w3m output.

Lots of work yet to be done!

Revision history for this message
khinsen (konrad-hinsen) wrote :

The latest version works fine for me.

I didn't notice the URL problem because I have (and use a lot) a global binding for browse-url, which works just fine with URLs in e-mail. But I agree that it would be nicer to have URLs in the text handled just like marked-up URLs.

As for the button problem, would it be possible to make the notion of a "button" extendable by presentation minor modes?

Another solution would be to have a modified w3m-next-anchor that hands control back to vm-next-button when it is called on the last anchor in the HTML part.

Uday Reddy (reddyuday)
Changed in vm:
milestone: 8.2.1 → 8.2.90a
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.