Numbered links in emacs-w3m

I’ve been trying conkeror as my secondary browser for a while, and i really like it. It has a much smaller memory footprint than Firefox, and it doesn’t take ages to start up. It’s also nicely hackable and extensible (using javascript), and it comes with some interesting functionality, available out of the box. For instance, external editor support or link numbering: pressing ‘f’ numbers all links in the page and you enter a link number to follow it.

As it happens, recent (as in CVS 1.4.4) versions of emacs-w3m offer a similar functionality in the w3m-lnum package. M-x w3m-link-numbering-mode toggles a minor mode showing link numbers on an overlay, and M-n M-x w3m-move-numbered-anchor, where n is the link number, moves the pointer to the desired link. Providing conkeror's
more handy functionality is then a matter of a few elisp lines:

  
  (require 'w3m-lnum)
  (defun jao-w3m-go-to-linknum ()
    "Turn on link numbers and ask for one to go to."
    (interactive)
    (let ((active w3m-link-numbering-mode))
      (when (not active) (w3m-link-numbering-mode))
      (unwind-protect
          (w3m-move-numbered-anchor (read-number "Anchor number: "))
        (when (not active) (w3m-link-numbering-mode)))))

  (define-key w3m-mode-map "f" 'jao-w3m-go-to-linknum)

Happy browsing!

About these ads

3 Responses to “Numbered links in emacs-w3m”

  1. PILCH Hartmut Says:

    This works very nicely, it has become part of my .emacs, thanks.

    Btw I’m posting this from conkeror, but unfortunately the invocation of the external editor isn’t working, so I’m not using emacsclient.

  2. Tuss Says:

    Thanks a lot, I was looking for something like this. You’re an angel.

  3. James Says:

    Thanks for the tip!

    My emacs doesn’t have read-number, so I changed it to:

    (require ‘w3m-lnum)
    (defun jao-w3m-go-to-linknum ()
    “Turn on link numbers and ask for one to go to.”
    (interactive)
    (let ((active w3m-link-numbering-mode))
    (when (not active) (w3m-link-numbering-mode))
    (unwind-protect
    (w3m-move-numbered-anchor (string-to-number (read-string “Anchor number: “)))

    (when (not active) (w3m-link-numbering-mode)))))

    (define-key w3m-mode-map “f” ‘jao-w3m-go-to-linknum)


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: