Open Firefox URL in eww

index

A small step for man,
even smaller for mankind.
                        [unknown]

[2021-01-26 Tue] {eww firefox microoptimization}

This article shows a convenient way to open the current url of firefox in the Emacs Web Wouser aka eww.

Functionality

By Foot

You don't need this shortcut. You can do the steps by foot.

  • copy the URL in firefox C-l C-c
  • switch to Emacs
  • M-x eww C-y RET

And eww trys to open the URL.

Take a Shortcut

With the preparation below you get the following.

  • In firefox type C-l e.

And eww trys to open the URL.

This flow saves some work. The e above activates a suitable bookmarklet. Find the bookmarklet below.

Requirement

The functionality is based on org-protocol.

  • Make sure org-protocol is active. See the documentation about org-protocol for more.

Preparation   code

Preparation on the Emacs Side

Activate the following code. E.g. place the code in an Emacs config file.

(add-to-list 'org-protocol-protocol-alist
             '("eww"
               :protocol "eww"
               :function mw-start-eww-for-url))

The above code defines subprotocol eww.

The function for interpreting the data is

(defun mw-start-eww-for-url (plist)
  "Raise Emacs and call eww with the url in PLIST."
  (raise-frame)
  (eww (plist-get plist :url))
  nil)

Preparation on the Firefox Side

Create a bookmarklet which refers the subprotocol eww defined above in the code section.

  • Example bookmarklet used by the author.
    • Name : eww
    • Location : javascript:location.href='org-protocol://eww?url='+encodeURIComponent(location.href)
    • Tags : eww
    • Keyword : e

Meta

Please use the features of gitlab for comments etc. See e.g. https://gitlab.com/marcowahl/emacs-blog-mw/-/issues/ .

Share under CC BY-SA 4.0.

RSS

Author: Marco Wahl (marcowahlsoft@gmail.com)

Date:

Emacs 28.0.50 (Org mode 9.4.4)

Validate