Add "ask AI" mu4e action

This commit is contained in:
Jeremy Dormitzer 2024-07-08 11:06:39 -04:00
parent 8ac32f0955
commit 6a33416fad

View File

@ -5,6 +5,15 @@
:if (locate-library "mu4e") :if (locate-library "mu4e")
:commands (mu4e mu4e-update-mail-and-index) :commands (mu4e mu4e-update-mail-and-index)
:config :config
(defun mu4e-action-ai (msg)
(let* ((subject (mu4e-message-field msg :subject))
(body (mu4e-view-message-text msg))
(prompt (read-string "AI prompt: " "Summarize the key points from this email in bullet points"))
(buffer (generate-new-buffer-name (format "*%s*" subject))))
(gptel buffer nil (format "%s\n\n%s" body prompt))
(with-current-buffer buffer
(gptel-send))
(display-buffer buffer)))
(setq (setq
;; General ;; General
mu4e-maildir (expand-file-name "~/.mail") mu4e-maildir (expand-file-name "~/.mail")
@ -21,7 +30,12 @@
mu4e-view-actions '(("capture message" . mu4e-action-capture-message) mu4e-view-actions '(("capture message" . mu4e-action-capture-message)
("view as pdf" . mu4e-action-view-as-pdf) ("view as pdf" . mu4e-action-view-as-pdf)
("show this thread" . mu4e-action-show-thread) ("show this thread" . mu4e-action-show-thread)
("View in browser" . mu4e-action-view-in-browser)) ("View in browser" . mu4e-action-view-in-browser)
("ask AI" . mu4e-action-ai))
mu4e-headers-actions '(("capture message" . mu4e-action-capture-message)
("browse online archive" . mu4e-action-browse-list-archive)
("show this thread" . mu4e-action-show-thread)
("ask AI" . mu4e-action-ai))
;; Bookmarked searches ;; Bookmarked searches
mu4e-bookmarks '((:name "Inbox" mu4e-bookmarks '((:name "Inbox"
:query "maildir:/jeremy-dormitzer-gmail-com/Inbox OR maildir:/jeremydormitzer-hummingbird-co/Inbox" :query "maildir:/jeremy-dormitzer-gmail-com/Inbox OR maildir:/jeremydormitzer-hummingbird-co/Inbox"