Skip to content

Instantly share code, notes, and snippets.

@areina
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save areina/27df100c86ffacbf740e to your computer and use it in GitHub Desktop.
Save areina/27df100c86ffacbf740e to your computer and use it in GitHub Desktop.
Snippets for subscribe feeds with elfeed (emacs) from conkeror

In your emacs files:

(defun org-protocol-elfeed (data)
  (let ((url (org-protocol-sanitize-uri data)))
    (elfeed-add-feed url)
    (customize-save-variable 'elfeed-feeds elfeed-feeds)))

(add-to-list 'org-protocol-protocol-alist
             '("Subscribe to feed with elfeed."
               :protocol "elfeed"
               :function org-protocol-elfeed))

In your .conkerorrc:

// from http://conkeror.com/Tips
function subscribe_feed(I){
    var found = false;
    var document= I.buffer.document;
    var ls=document.getElementsByTagName("link");
    for(var i=0,l;l=ls[i];i++){
        var t=l.getAttribute('type');
        var r=l.getAttribute('rel');
        if(t&&(t=='application/rss+xml'||t=='application/atom+xml')&&r&&r=='alternate'){
            var h = l.getAttribute('href');
            if(h.indexOf('http')!=0){
                var p = (h.indexOf('/')!=0) ? '/' : document.location.pathname;
                h = 'http://'+document.location.hostname+p+h;
            }
	    subscribeLink = "org-protocol://elfeed://" + h;
            document.location = subscribeLink;
            found = true;
	    break;
        }}
    if(!found) I.minibuffer.message('Oops. Can\'t find a feed.');
};

interactive("subscribe-feed", null, subscribe_feed);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment