elfeed-webkit
elfeed-webkit copied to clipboard
Emacs: Render elfeed entries in embedded webkit widgets
- elfeed-webkit.el
Render [[https://github.com/skeeto/elfeed][elfeed]] entries in embedded webkit widgets.
Many feeds render well as text, some don't. Or maybe you're interested in a feed entry's dynamic content that doesn't get rendered into the feed at all (think comments). Elfeed provides =b= for this case, which opens an entry's link in the browser. If you'd rather stay in Emacs and not lose the context of elfeed and its key bindings, this package allows you to render an entry's link in an embedded webkit widget.
Webkit rendering can be toggled on/off manually, or automatically based on an entry's tags.
- Installation
If you use MELPA, an easy way to install this package is via =package-install=. Alternatively, download =elfeed-webkit.el=, put it in your =load-path= and =require= it.
If you use both MELPA and =use-package=, you can use this, too:
#+begin_src emacs-lisp (use-package elfeed-webkit :ensure :after elfeed) #+end_src
- Requirements
Your Emacs needs to have been compiled with support for xwidgets. Try =(featurep 'xwidget-internal)= if you're unsure.
- Usage and customization Options ** Toggle manually
Use =M-x elfeed-webkit-toggle= to toggle webkit on/off in an elfeed entry buffer. It is recommended to bind that command to a convenient key in =elfeed-show-mode-map=:
#+begin_src emacs-lisp (use-package elfeed-webkit :ensure :bind (:map elfeed-show-mode-map ("%" . elfeed-webkit-toggle))) #+end_src
Note that when webkit is toggled on in an elfeed entry buffer, the related keybindings from =xwidget-webkit-mode-map= are superimposed on =elfeed-show-mode-map=. Best pick a key that's not bound in either of these maps.
Alternatively, use the =elfeed-webkit-enable= and =elfeed-webkit-disable= commands to turn webkit on or off directly.
** Enable/Disable based on an entry's tags
Elfeed entries can also be rendered with or without webkit automatically, based on an entry's tags. This can be useful if you know that a specific feed /never/ renders well in text, or misbehaves when rendered with webkit. See elfeed's [[https://github.com/skeeto/elfeed/tree/master#autotagging][autotagging feature]] for how to apply tags to all entries of a given feed.
To set up automatic rendering with webkit based on an entry's tags, run =elfeed-webkit-auto-toggle-by-tag=.
By default, entries with either a =wk= or =webkit= tag will be rendered with webkit, even if rendering with webkit is toggled off otherwise. The list of tags that triggers webkit is customizable via =elfeed-webkit-auto-enable-tags=.
Likewise, entries with either a =no-wk= or =no-webkit= tag will be rendered as text, even if rendering with webkit is toggled on otherwise. Again, the list of tags is customizable via =elfeed-webkit-auto-disable-tags=.
Here's an example setup:
#+begin_src emacs-lisp (use-package elfeed-webkit :ensure :demand ;; ! :init (setq elfeed-webkit-auto-enable-tags '(webkit comics)) :config (elfeed-webkit-auto-toggle-by-tag) :bind (:map elfeed-show-mode-map ("%" . elfeed-webkit-toggle))) #+end_src
- Keys
In a gist, =elfeed-webkit= uses the default keys available in elfeed entry buffers, then layers the xwidget webkit keys on top with a select few customizations.
Here are some of the more commonly used keys:
| Key | Function | |-----+------------------------------------------------------| | =n= | show next item in elfeed search buffer | | =p= | show previous item in elfeed search buffer | | =u= | mark current entry unread | | =+= | add tag(s) to displayed entry | | =-= | remove tag(s) from displayed entry | | =g= | refresh displayed entry | | =b= | go back in webkit's browsing history | | =f= | go forward | | =v= | visit current webkit URL in a browser | | =y= | yank current webkit URL | | =a= | adjust size of widget to fill entire available space |
As always, use =C-h b= to display all defined keys in a buffer.
- Screenshot
[[screenshots/screenshot.gif]]
- I start out on the =elfeed-search= buffer with a few [[https://irreal.org/blog/][Irreal blog posts]], and with webkit rendering disabled.
- I press =RET= to open the selected entry "/Completing Org Links/"; it renders as text.
- I press =%= to toggle on webkit rendering, then =%= one more time to toggle it off again.
- I press =n= to go to the next entry, "/Moving to Elfeed/"; it renders as text.
- I press =n= to go to the next entry, "/Captee/": this entry has the =webkit= tag mentioned before, and automatically renders with webkit as a result.
- I press =q= to quit out to =elfeed-search=.
- Related work
- Boris Glavic's [[https://github.com/lordpretzel/xwidgets-reuse][xwidgets-reuse]] package enables reuse of xwidgets sessions and comes with an [[https://github.com/lordpretzel/xwidgets-reuse/#example][example setup for elfeed entry browsing]].