+elfeed/dispatch-entry -> +elfeed/dispatch

Don't pop the option up to the user on entry, just provide a good
binding to access when needed.
This commit is contained in:
2025-02-17 22:50:01 +00:00
parent 038d51b405
commit 51ce40aee0

View File

@@ -3722,6 +3722,9 @@ to elfeed for loading the system.
"gr" #'elfeed-update "gr" #'elfeed-update
"s" #'elfeed-search-live-filter "s" #'elfeed-search-live-filter
"<return>" #'elfeed-search-show-entry) "<return>" #'elfeed-search-show-entry)
(nmmap
:keymaps 'elfeed-show-mode-map
"M-RET" #'+elfeed/dispatch)
:init :init
(setq elfeed-db-directory (no-littering-expand-var-file-name "elfeed/")) (setq elfeed-db-directory (no-littering-expand-var-file-name "elfeed/"))
:config :config
@@ -3732,7 +3735,7 @@ to elfeed for loading the system.
'(("Yank URL" . '(("Yank URL" .
(lambda (url) (lambda (url)
(kill-new url) (kill-new url)
(message "elfeed: Yanked %s" url))) (message "elfeed-dispatch: Yanked %s" url)))
("Open via EWW" . eww) ("Open via EWW" . eww)
("Play via EMPV" . ("Play via EMPV" .
(lambda (url) (lambda (url)
@@ -3740,17 +3743,18 @@ to elfeed for loading the system.
;; FIXME: Using internal macro ;; FIXME: Using internal macro
(empv--with-video-enabled (empv--with-video-enabled
(empv-play-or-enqueue url)) (empv-play-or-enqueue url))
(message "elfeed: EMPV is not available"))))) (message "elfeed-dispatch: EMPV is not available")))))
"Options available on entering an elfeed post.") "Options available on entering an elfeed post.")
(defun +elfeed/dispatch-entry (entry) (defun +elfeed/dispatch ()
"Provide some extra options once you've clicked on an article." "Provide some extra options once you've clicked on an article."
(interactive)
(if (null elfeed-show-entry)
(user-error "elfeed-dispatch: Not in an elfeed post."))
(let ((choice (completing-read "Choose action: " (mapcar #'car +elfeed/dispatch-options))) (let ((choice (completing-read "Choose action: " (mapcar #'car +elfeed/dispatch-options)))
(url (elfeed-entry-link entry))) (url (elfeed-entry-link elfeed-show-entry)))
(if-let ((option (cdr (assoc choice +elfeed/dispatch-options #'string=)))) (if-let ((option (cdr (assoc choice +elfeed/dispatch-options #'string=))))
(funcall option url)))) (funcall option url)))))
(advice-add 'elfeed-search-show-entry :after #'+elfeed/dispatch-entry))
#+end_src #+end_src
*** Elfeed-org *** Elfeed-org
#+begin_src emacs-lisp #+begin_src emacs-lisp