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

code to create orgmode links #34

Closed
brabalan opened this issue Jun 30, 2014 · 7 comments
Closed

code to create orgmode links #34

brabalan opened this issue Jun 30, 2014 · 7 comments

Comments

@brabalan
Copy link

I have the following in my configuration files.

(defun elfeed-entry-as-html-link ()
  "Store an http link to an elfeed entry"
  (when (equal major-mode 'elfeed-show-mode)
    (let ((description (elfeed-entry-title elfeed-show-entry))
      (link (elfeed-entry-link elfeed-show-entry)))
     (org-store-link-props
      :type "http"
      :link link
      :description description))))

(add-hook 'org-store-link-functions 'elfeed-entry-as-html-link)

This way, when I org-capture in elfeed-show-mode using a template that includes a link, I get a nicely formatted link to the online linked entry. I use this to capture stuff I want to read later. Don't hesitate to use this if you want to integrate this small function to elfeed.

@skeeto
Copy link
Owner

skeeto commented Jul 1, 2014

Thanks! I need to learn a lot more about org-mode, though, before I can
understand the value of this.

@brabalan
Copy link
Author

brabalan commented Jul 1, 2014

Of course. And thanks a lot for elfeed!

@groks
Copy link
Contributor

groks commented Nov 23, 2015

Here's another version:

(defun my-elfeed-store-link ()
  "Store a link to an elfeed search or entry buffer."
  (cond ((derived-mode-p 'elfeed-search-mode)
         (org-store-link-props
          :type "elfeed"
          :link (format "elfeed:%s" elfeed-search-filter)
          :description elfeed-search-filter))
        ((derived-mode-p 'elfeed-show-mode)
         (org-store-link-props
          :type "elfeed"
          :link (format "elfeed:%s#%s"
                        (car (elfeed-entry-id elfeed-show-entry))
                        (cdr (elfeed-entry-id elfeed-show-entry)))
          :description (elfeed-entry-title elfeed-show-entry)))))

(defun my-elfeed-open (filter-or-id)
  "Jump to an elfeed entry or search, depending on what FILTER-OR-ID looks like."
  (message "filter-or-id: %s" filter-or-id)
  (if (string-match "\\([^#]+\\)#\\(.+\\)" filter-or-id)
      (elfeed-show-entry (elfeed-db-get-entry (cons (match-string 1 filter-or-id)
                                                    (match-string 2 filter-or-id))))
    (switch-to-buffer (elfeed-search-buffer))
    (unless (eq major-mode 'elfeed-search-mode)
      (elfeed-search-mode))
    (elfeed-search-set-filter filter-or-id)))

(org-add-link-type "elfeed" #'my-elfeed-open)
(add-hook 'org-store-link-functions #'my-elfeed-store-link)

Rather than crate an http: link this creates a elfeed: link, which can link to either:

  • an entry
  • a search

For example, here's a search link:

[[elfeed:@1-week-ago%20+unread][New and Unread]]

The data gathered by org-store-link can also be substituted into a capture template, as in @brabalan's use case, and there it would be useful to store all the item-meta-data when storing a link in a show-item buffer. I might try adding that later.

An example use-case for org links might be: schedule yourself in org to triage various bug feeds, with a link to the appropriate elfeed search. While scanning the entries, org-capture TODO's back into org. When they come due on your org agenda, follow the link back to the entry in elfeed. Pretty cool.

groks added a commit to groks/elfeed that referenced this issue Dec 8, 2015
Also gathers meta-data for org-capture and exports links to HTML.

Fixes skeeto#34
groks added a commit to groks/elfeed that referenced this issue Dec 18, 2015
Also gathers meta-data for org-capture and exports links to HTML.

Fixes skeeto#34
groks added a commit to groks/elfeed that referenced this issue Dec 27, 2015
Also gathers meta-data for org-capture and exports links to HTML.

Fixes skeeto#34
@CJKinni
Copy link

CJKinni commented Nov 12, 2016

Is there any update on whether this will be incorporated? I'd love to use this feature, but having a very hard time adding it myself using spacemacs.

@csantosb
Copy link

csantosb commented Dec 7, 2016

Fully agree, this feature is really useful. Any plans to incorporate to elfeed master ?

@semente
Copy link

semente commented Mar 12, 2017

@groks rather than:

(org-add-link-type "elfeed" #'my-elfeed-open)
(add-hook 'org-store-link-functions #'my-elfeed-store-link)

I had to use the following code on org-mode 9.0:

(org-link-set-parameters
     "elfeed"
     :follow 'my-elfeed-open
     :store 'my-elfeed-store-link)

Thanks for sharing this solution!

@skeeto
Copy link
Owner

skeeto commented Apr 12, 2017

Merged via #206.

@skeeto skeeto closed this as completed Apr 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants