A Short Elfeed Story: From How Do I Get a Link to Copy as Markdown
Last night I left some unread articles in Elfeed. Reading RSS in Emacs gives me a great fuzzy, geeky feeling. So even if I’m a long time Reeder user, most recently I’ve been using Elfeed more and more. Even more since I have found how to patch a bug that was making it unsable; but I’m getting in the wrong direction.
While in Elfeed, I asked myself: how do I get the link of the current item I’m
reading? Bringing up the mode help, I landed my eyes on
elfeed-kill-link-url-at-point
bound to c
. It took me a bit to realize that
this was not what I was looking for; still a very useful functionl. What I was
looking for is elfeed-show-yank
bound to y
. I am happy already. Again the
thought that “Emacs gives you everything. And more. You just need to keep
looking” popped in my mind. And I was ready to move on.
But then the second question came: how do I get the title of the current item? This smelled like an opportunity to look into some ELisp code—yes, I’m fascinated by Lisp and ELisp is the closest I got to it. Recently I learned that after opening the help of a function, I can actually go and see the source of the function. Time again for “Emacs gives you everything…”
From here things evolved much faster: if I can get the title, how about being able to copy as Markdown? The code I wrote to get this functionality is minimal. Why? You already know the answer! It’s thanks to the fact that “Emacs gives you everything.” I have found all the functions I needed in El
From here things evolved much faster: if I can get the title, how about being able to copy as Markdown? The code I wrote to get this functionality is minimal. Why? You already know the answer! It’s thanks to the fact that “Emacs gives you everything.” Indeed this time is Elfeed to be thanked.
I have found all the functions I needed in Elfeed right away.
(defun alpo/elfeed-show-yank-markdown ()
"Copy the title and link to current entry as markdown."
(interactive)
(let ((link (elfeed-entry-link elfeed-show-entry))
(title (elfeed-entry-title elfeed-show-entry)))
(kill-new (format "[%s](%s)" title link))
(message "Yanked [%s](%s)" title link)))