From 36ec3d389711141577133b2117fe7ab3e0ecbb4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Jadi?= Date: Fri, 2 Oct 2015 15:24:29 +0200 Subject: [PATCH 1/2] feat(org-link): Store and open org-mode's links in elfeed --- elfeed-org.el | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/elfeed-org.el b/elfeed-org.el index 69a8642..121053f 100644 --- a/elfeed-org.el +++ b/elfeed-org.el @@ -36,6 +36,7 @@ (require 'org) (require 'dash) (require 's) +(require 'rx) (defgroup elfeed-org nil @@ -195,6 +196,39 @@ all. Which in my opinion makes the process more traceable." "Load all feed settings before elfeed is started." (rmh-elfeed-org-process rmh-elfeed-org-files rmh-elfeed-org-tree-id))) +(org-add-link-type "elfeed" 'org-elfeed-open) +(add-hook 'org-store-link-functions 'org-elfeed-store-link) + +(defun org-elfeed-open (path) + "Visit the elfeed on PATH." + (string-match (rx bos + "entry-feed:" + (group (1+ any)) + ":entry-url:" + (group (1+ any)) + eos) + path) + (let* ((entry-feed (match-string 1 path)) + (entry-url (match-string 2 path)) + (entry (gethash (cons entry-feed entry-url) elfeed-db-entries))) + (elfeed-show-entry entry))) + +(defun org-elfeed-store-link () + "Store a link to an elfeed entry." + (let ((entry (cond ((eq major-mode 'elfeed-search-mode) + (elfeed-search-selected :ignore-region)) + ((eq major-mode 'elfeed-show-mode) + elfeed-show-entry)))) + (when entry + (let* ((id (elfeed-entry-id entry)) + (feed (first id)) + (url (rest id)) + (title (elfeed-entry-title entry))) + (org-store-link-props + :type "elfeed" + :link (format "elfeed:entry-feed:%s:entry-url:%s" + feed url) + :description title))))) (provide 'elfeed-org) ;;; elfeed-org.el ends here From bca370f30d5a51070aabe2da6b4eb7ecbb061f0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Jadi?= Date: Mon, 26 Oct 2015 09:52:16 +0100 Subject: [PATCH 2/2] fix(org-elfeed-open): Display a message when we try to open a non-existing entry --- elfeed-org.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/elfeed-org.el b/elfeed-org.el index 121053f..04423a2 100644 --- a/elfeed-org.el +++ b/elfeed-org.el @@ -211,7 +211,9 @@ all. Which in my opinion makes the process more traceable." (let* ((entry-feed (match-string 1 path)) (entry-url (match-string 2 path)) (entry (gethash (cons entry-feed entry-url) elfeed-db-entries))) - (elfeed-show-entry entry))) + (if entry + (elfeed-show-entry entry) + (error "This entry isn't in the database")))) (defun org-elfeed-store-link () "Store a link to an elfeed entry."