Skip to content

Instantly share code, notes, and snippets.

/nuh-elfeed-custom
Created Dec 1, 2013

Embed
What would you like to do?
;----
; Ad killer
(defun my-elfeed-no-ads (entry)
(let ((entry-feed-id (elfeed-entry-feed-id entry)))
(cond
; heise & golem
((or (string= entry-feed-id "http://www.heise.de/newsticker/heise.rdf" )
(string= entry-feed-id "http://www.golem.de/rss.php?feed=RSS1.0" ))
(let* ((original (elfeed-deref (elfeed-entry-content entry)))
(replace (replace-regexp-in-string "<img.*" "" original)))
(message (elfeed-entry-link entry))
(setf (elfeed-entry-content entry) (elfeed-ref replace))))
)))
(add-hook 'elfeed-new-entry-hook #'my-elfeed-no-ads)
;----
; Read all key
(define-key elfeed-search-mode-map "R"
'(lambda () (interactive) (save-excursion
(mark-whole-buffer)
(elfeed-search-untag-all-unread)
)))
;----
; comment links in hacker news
(defun my-elfeed-browse-hn-comment ()
"in an hn entry, open comments link"
(interactive)
(search-forward "Comments")
(backward-char)
(execute-kbd-macro [ return ?q ]))
(define-key elfeed-search-mode-map "v"
'(lambda () (interactive)
(beginning-of-line)
(let ((hn? (re-search-forward "[(,]hn\\b" (line-end-position) t))) ; is it an hn entry?
(call-interactively 'elfeed-search-show-entry)
(if hn? ; yes, open comments link
(my-elfeed-browse-hn-comment)
))
(define-key elfeed-show-mode-map "c" 'my-elfeed-browse-hn-comment)
;----
; handle pods via emms
(defun my-elfeed-play-pod ()
"play selected feed item (should be pod) via emms"
(interactive)
(elfeed-show-yank)
(let ((mp3-url (x-get-selection 'PRIMARY)))
(if (string-match "[mM][pP]3$" mp3-url)
(emms-play-url mp3-url)
; not an mp3 link, search for it
(re-search-forward "Enclosure:[^h]+http")
(setq mp3-url (get-text-property (point) 'shr-url))
(if (numberp (string-match "[mM][pP]3$" mp3-url))
(emms-play-url mp3-url)
(message "no mp3 link found!")
))))
(define-key elfeed-search-mode-map "m"
'(lambda () (interactive)
(call-interactively 'elfeed-search-show-entry)
(my-elfeed-play-pod)))
(define-key elfeed-show-mode-map "m" 'my-elfeed-play-pod)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.