email: refactoring
This commit is contained in:
parent
b66a52630d
commit
e6ceb1899e
@ -635,4 +635,4 @@ the inbox. Refile to any org-gtd incubate target (see manual)."
|
|||||||
|
|
||||||
|
|
||||||
;; load personal modules
|
;; load personal modules
|
||||||
(load! "+mail")
|
(load! "email")
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
;;; +mail.el -*- lexical-binding: t; -*-
|
;;; email.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
(after! mu4e
|
(after! mu4e
|
||||||
;; Recommended msmtp config from doom module documentation
|
;; Recommended msmtp config from doom module documentation
|
||||||
@ -10,20 +10,21 @@
|
|||||||
|
|
||||||
;; `set-email-account!' doesn't accept a custom match-func
|
;; `set-email-account!' doesn't accept a custom match-func
|
||||||
(setq mu4e-contexts
|
(setq mu4e-contexts
|
||||||
(list (make-mu4e-context
|
(list
|
||||||
:name "upcycling"
|
;; (make-mu4e-context
|
||||||
:enter-func
|
;; :name "upcycling"
|
||||||
(lambda () (mu4e-message "Switched to upcycling"))
|
;; :enter-func
|
||||||
:leave-func
|
;; (lambda () (mu4e-message "Switched to upcycling"))
|
||||||
(lambda () (progn (setq +mu4e-personal-addresses nil)
|
;; :leave-func
|
||||||
(mu4e-clear-caches)))
|
;; (lambda () (progn (setq +mu4e-personal-addresses nil)
|
||||||
:match-func
|
;; (mu4e-clear-caches)))
|
||||||
(lambda (msg)
|
;; :match-func
|
||||||
(when msg
|
;; (lambda (msg)
|
||||||
(mu4e-message-contact-field-matches msg
|
;; (when msg
|
||||||
:to "upcycling@fsfe.org")))
|
;; (mu4e-message-contact-field-matches msg
|
||||||
:vars '((user-mail-address . "upcycling@fsfe.org")
|
;; :to "upcycling@fsfe.org")))
|
||||||
(user-full-name . "FSFE Team Upcycling Android")))
|
;; :vars '((user-mail-address . "upcycling@fsfe.org")
|
||||||
|
;; (user-full-name . "FSFE Team Upcycling Android")))
|
||||||
(make-mu4e-context
|
(make-mu4e-context
|
||||||
:name "mailbox"
|
:name "mailbox"
|
||||||
:enter-func
|
:enter-func
|
||||||
@ -78,16 +79,18 @@
|
|||||||
gnus-buttonized-mime-types '("multipart/encrypted" "multipart/signed")
|
gnus-buttonized-mime-types '("multipart/encrypted" "multipart/signed")
|
||||||
mml-secure-openpgp-encrypt-to-self t)
|
mml-secure-openpgp-encrypt-to-self t)
|
||||||
|
|
||||||
(add-to-list 'org-capture-templates `("m" "email" entry (file+headline ,(expand-file-name "newgtd/actionable.org" org-directory) "Actions")
|
;; Move message to the trash folder but do not set the trash flag
|
||||||
"* NEXT Reply to [[mu4e:msgid:%:message-id][%:fromname - %:subject]] :email:\n%U\n"))
|
;; https://github.com/djcb/mu/issues/1136#issuecomment-1066303788
|
||||||
|
(setf (alist-get 'trash mu4e-marks)
|
||||||
(defun max/mu4e-org-capture ()
|
(list :char '("d" . "▼")
|
||||||
"Invoke the email capture template for msg at point"
|
:prompt "dtrash"
|
||||||
(interactive)
|
:dyn-target (lambda (target msg)
|
||||||
(org-capture nil "m"))
|
(mu4e-get-trash-folder msg))
|
||||||
|
:action (lambda (docid msg target)
|
||||||
(map! :map mu4e-headers-mode-map
|
;; Here's the main difference to the regular trash mark,
|
||||||
:vne "l" #'max/mu4e-org-capture)
|
;; no +T before -N so the message is not marked as
|
||||||
|
;; IMAP-deleted:
|
||||||
|
(mu4e--server-move docid (mu4e--mark-check-target target) "+S-u-N"))))
|
||||||
|
|
||||||
(add-to-list 'mu4e-view-mime-part-actions
|
(add-to-list 'mu4e-view-mime-part-actions
|
||||||
'(:name "calendar"
|
'(:name "calendar"
|
||||||
@ -130,6 +133,13 @@
|
|||||||
|
|
||||||
(map! "<f2>" #'max/=mu4e)
|
(map! "<f2>" #'max/=mu4e)
|
||||||
|
|
||||||
|
(after! epa
|
||||||
|
(setq epa-keyserver "keys.openpgp.org")
|
||||||
|
(map! :map epa-ks-search-mode-map
|
||||||
|
:n "f" #'epa-ks-mark-key-to-fetch
|
||||||
|
:n "i" #'epa-ks-inspect-key-to-fetch
|
||||||
|
:n "u" #'epa-ks-unmark-key-to-fetch
|
||||||
|
:n "x" #'epa-ks-do-key-to-fetch))
|
||||||
|
|
||||||
(use-package! jl-encrypt
|
(use-package! jl-encrypt
|
||||||
:config
|
:config
|
||||||
@ -138,3 +148,41 @@
|
|||||||
(after! mu4e-alert
|
(after! mu4e-alert
|
||||||
(when IS-MAC
|
(when IS-MAC
|
||||||
(mu4e-alert-set-default-style 'notifier)))
|
(mu4e-alert-set-default-style 'notifier)))
|
||||||
|
|
||||||
|
;; Taken from http://pragmaticemacs.com/emacs/email-templates-in-mu4e-with-yasnippet/
|
||||||
|
(defun bjm/mu4e-get-names-for-yasnippet ()
|
||||||
|
"Return comma separated string of names for an email"
|
||||||
|
(interactive)
|
||||||
|
(let ((email-name "") str email-string email-list email-name2 tmpname)
|
||||||
|
(save-excursion
|
||||||
|
(goto-char (point-min))
|
||||||
|
;; first line in email could be some hidden line containing NO to field
|
||||||
|
(setq str (buffer-substring-no-properties (point-min) (point-max))))
|
||||||
|
;; take name from TO field - match series of names
|
||||||
|
(when (string-match "^To: \"?\\(.+\\)" str)
|
||||||
|
(setq email-string (match-string 1 str)))
|
||||||
|
;;split to list by comma
|
||||||
|
(setq email-list (split-string email-string " *, *"))
|
||||||
|
;;loop over emails
|
||||||
|
(dolist (tmpstr email-list)
|
||||||
|
;;get first word of email string
|
||||||
|
(setq tmpname (car (split-string tmpstr " ")))
|
||||||
|
;;remove whitespace or ""
|
||||||
|
(setq tmpname (replace-regexp-in-string "[ \"]" "" tmpname))
|
||||||
|
;;join to string
|
||||||
|
(setq email-name
|
||||||
|
(concat email-name ", " tmpname)))
|
||||||
|
;;remove initial comma
|
||||||
|
(setq email-name (replace-regexp-in-string "^, " "" email-name))
|
||||||
|
|
||||||
|
;;see if we want to use the name in the FROM field
|
||||||
|
;;get name in FROM field if available, but only if there is only
|
||||||
|
;;one name in TO field
|
||||||
|
(if (< (length email-list) 2)
|
||||||
|
(when (string-match "^\\([^ ,\n]+\\).+writes:$" str)
|
||||||
|
(progn (setq email-name2 (match-string 1 str))
|
||||||
|
;;prefer name in FROM field if TO field has "@"
|
||||||
|
(when (string-match "@" email-name)
|
||||||
|
(setq email-name email-name2))
|
||||||
|
)))
|
||||||
|
email-name))
|
Loading…
x
Reference in New Issue
Block a user