Heikki @ home

Loose leaves from my tree

Note taking 3: Notes from elfeed entries

This is the third article in the series on quick note taking using emacs. It shows an quick way of creating a note for the current entry in elfeed news reader with one key press.

  1. Org agenda with date tree file
  2. Notes from browser window
  3. Notes from elfeed entries


Elfeed is a web feed reader that is written in emacs lisp that makes it easy to modify and extend for different work flows. I use it with elfeed-org package to follow dozens of web sites. Every now and then I do not want to open an entry in the browser but to make a quick note of it into my org notes directly from elfeed.

I am now using a previously unbound key v to paste a link to the appropriate place in my date tree using org-capture. For situations where I want to paste the link to some other text, I use letter l to copy the org link to clipboard.

Elfeed has two main modes, elfeed-search and elfeed-show, that need separate functions tailored for them. The elfeed-search buffer shows titles of currently filtered entries, and the elfeed-show buffer renders (part of) the entry itself.

Copy the link string

I first define a generic function elfeed-link-title that takes an elfeed entry object as an argument. It creates the org link from the URL and the title of the entry and places the string in the clipboard.

(defun elfeed-link-title (entry)
  "Copy the entry title and URL as org link to the clipboard."
  (let* ((link (elfeed-entry-link entry))
         (title (elfeed-entry-title entry))
         (titlelink (org-make-link-string link title))))
    (when titlelink
      (kill-new titlelink)
      (x-set-selection 'PRIMARY titlelink)
      (message "Yanked: %s" titlelink))))

Elfeed-show mode

The elfeed-show mode link command simply calls that function with the current entry. The note command does the same and uses the note org capture function defined in the first article in this series to store the link.

I use bind-keys from use-package to bind keys in the correct key map to these functions.

(defun elfeed-show-link-title ()
  "Copy the current entry title and URL as org link to the clipboard."
  (elfeed-link-title elfeed-show-entry))

(defun elfeed-show-quick-url-note ()
  "Fastest way to capture entry link to org agenda from elfeed show mode"
  (elfeed-link-title elfeed-show-entry)
  (org-capture nil "n")

(bind-keys :map elfeed-show-mode-map
           ("l" . elfeed-show-link-title)
           ("v" . elfeed-show-quick-url-note)))

Elfeed-search mode

The elfeed-search mode can have several entries selected, so the functions need to loop over them although selecting multiple entries is not very useful in this context. Creating a link to an entry has the same side effects than opening it in a browser: The entry is mark as read and the focus in moved to the next line.

  (defun elfeed-search-link-title ()
    "Copy the current entry title and URL as org link to the clipboard."
    (let ((entries (elfeed-search-selected)))
      (cl-loop for entry in entries
               when (elfeed-entry-link entry)
               do (elfeed-link-title entry))))

  (defun elfeed-search-quick-url-note ()
    "In search mode, capture the title and link for the selected
entry or entries in org aganda."
    (let ((entries (elfeed-search-selected)))
      (cl-loop for entry in entries
               do (elfeed-untag entry 'unread)
               when (elfeed-entry-link entry)
               do (elfeed-link-title entry)
               do (org-capture nil "n")
               do (yank)
               do (org-capture-finalize)
               (mapc #'elfeed-search-update-entry entries))
      (unless (use-region-p) (forward-line))))

  (bind-keys :map elfeed-search-mode-map
             ("l" . elfeed-search-link-title)
             ("v" . elfeed-search-quick-url-note))


For the above code snippets to be fully functional they need to be within use-package macro as in this gist. Otherwise the key bindings will fail.