Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create org-mode links to elfeed entries #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions elfeed-org.el
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
(require 'org)
(require 'dash)
(require 's)
(require 'rx)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This library also needs to be added to `;; Package-Requires : ((elfeed "1.1.1") (org "8.2.7") (dash "2.10.0") (s "1.9.0"))`` for it to be installed correctly.



(defgroup elfeed-org nil
Expand Down Expand Up @@ -195,6 +196,41 @@ 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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you perform these setup function in the `elfeed-org`` autoload function?

(add-hook 'org-store-link-functions 'org-elfeed-store-link)

(defun org-elfeed-open (path)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you be so kind to rename these function to make them consistent with the naming of the other functions?

org-elfeed-open -> rmh-elfeed-org-open
org-elfeed-store-link -> rmh-elfeed-org-store-link

"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)))
(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."
(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