Skip to content

Instantly share code, notes, and snippets.

@mdom

mdom/init.el

Last active May 16, 2018
Embed
What would you like to do?
elfeed enclosure filename
(defun my-slugify (str)
(downcase
(replace-regexp-in-string
"[[:space:]-]+" "-"
(my-trim-string
(replace-regexp-in-string
"[^[:word:][:space:]]+" "" str)))))
(defun my-trim-string (string)
(replace-regexp-in-string
"\\`[ \t\n]*" ""
(replace-regexp-in-string "[ \t\n]*\\'" "" string)))
(setq elfeed-show-enclosure-filename-function
(lambda (entry url-enclosure)
(let*
((fname (file-name-nondirectory
(url-unhex-string
(car (url-path-and-query (url-generic-parse-url
url-enclosure))))))
(feed-title (elfeed-feed-title (elfeed-entry-feed entry))))
(mapconcat 'directory-file-name (list (my-slugify feed-title) fname) "/"))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment