From 8d9095c427f0a3b54c771365c9a353dd0f341ea7 Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Sun, 17 Apr 2022 17:46:22 -0700 Subject: elfeed: capture an entry in org-mode --- emacs/custom/my-elfeed.el | 34 ++++++++++++++++++++++++++++++++++ emacs/custom/my-org.el | 6 ++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/emacs/custom/my-elfeed.el b/emacs/custom/my-elfeed.el index 7bca54f..c774f20 100644 --- a/emacs/custom/my-elfeed.el +++ b/emacs/custom/my-elfeed.el @@ -18,6 +18,40 @@ (elfeed-org) (setq rmh-elfeed-org-files (list (expand-file-name "etc/elfeed.org" user-emacs-directory)))) +(defun copy-elfeed-link-title-to-org (entry) + "Copy the ENTRY title and URL as org link to the clipboard." + (interactive) + (let* ((link (elfeed-entry-link entry)) + (title (elfeed-entry-title entry)) + (titlelink (concat "[[" link "][" title "]]"))) + (when titlelink + (kill-new titlelink) + (x-set-selection 'PRIMARY titlelink) + (message "Yanked: %s" titlelink)))) + +(defun elfeed-show-quick-url-note () + "Fastest way to capture entry link to org agenda from elfeed show mode" + (interactive) + (copy-elfeed-link-title-to-org elfeed-show-entry) + (org-capture nil "n") + (yank) + (org-capture-finalize)) + +(defun elfeed-search-quick-url-note () + "In search mode, capture the title and link for the selected +entry or entries in org aganda." + (interactive) + (let ((entries (elfeed-search-selected))) + (cl-loop for entry in entries + do (elfeed-untag entry 'unread) + when (elfeed-entry-link entry) + do (copy-elfeed-link-title-to-org entry) + do (org-capture nil "f") + do (yank) + do (org-capture-finalize) + (mapc #'elfeed-search-update-entry entries)) + (unless (use-region-p) (forward-line)))) + (defalias 'elfeed-toggle-star (elfeed-expose #'elfeed-search-toggle-all 'star)) diff --git a/emacs/custom/my-org.el b/emacs/custom/my-org.el index 81f7a07..1197687 100644 --- a/emacs/custom/my-org.el +++ b/emacs/custom/my-org.el @@ -171,8 +171,7 @@ The page title is used as an entry heading." (pdf (string-suffix-p "pdf" url-string))) (unless pdf (let ((page-title (org-web-tools--html-title (org-web-tools--get-url url-string)))) - (concat "* " - page-title + (concat "* [[" url-string "][" page-title "]]" "\t%^g" "\n:PROPERTIES:\n:CREATED: %T\n:URL: " url-string @@ -185,6 +184,9 @@ The page title is used as an entry heading." ("n" "Note" entry (file "notes.org") "* %?\n:PROPERTIES:\n:CREATED: %T\n:END:\n") + ("f" "Feed" entry (file "inbox.org") + "* %?\n:PROPERTIES:\n:CREATED: %T\n:END:\n") + ("l" "Bookmark" entry (file "bookmarks.org") (function my/org-capture-link)) -- cgit 1.4.1