Add better recipient handling in mu4e

master
Jacopo De Simoi 1 year ago
parent 785b8a8bf8
commit 8337f3f0b7
  1. 46
      global.org

@ -11,8 +11,9 @@
candidates
- [ ] Implement action for ignoring contacts
** TODO take care of the "dear To" when completing the name in an email
** TODO make an alist for names to nicknames when completing the name…
** TODO remove duplicates in contacts list with double spaces and such
** DONE take care of the "dear To" when completing the name in an email
** DONE make an alist for names to nicknames when completing the name…
** TODO how to "open with" attachments with mu4e?
** TODO investigate what is wrong with inline-pdf image width
I need to cycle the mode on/off to make it work as intended
@ -890,22 +891,45 @@
with abbrev mode shortcuts
#+begin_src emacs-lisp
(setq nicknames-alist
'(("Konstantin Khanin" . "Kostya")
("Nicholas Fleming". "Nick")
("Pramathanath Sastry". "Pramath")
("Buddhima Kasun Fernando Akurugodage (Staff)" . "Kasun")
))
;; the above should be moved to a private file
(defun wilder/mu4e-process-recipient-name (name)
(interactive)
(let ((clean-name (replace-regexp-in-string "\"" "" name)))
(cond
((assoc clean-name nicknames-alist) (cdr (assoc clean-name nicknames-alist)))
((string-match-p (regexp-quote ",") clean-name) (string-trim (replace-regexp-in-string ".*," "" clean-name)))
(t (replace-regexp-in-string " .*" "" clean-name)))))
(defun recipients-ng ()
(interactive)
(message (save-excursion
(goto-char (point-min))
(search-forward-regexp "To: \\(\\(.\\|\n\\)*\\)\\(Subject\\|CC\\|BCC\\)")
(mapcar (lambda (s) (substring-no-properties (string-trim (car (split-string s "<"))))) (mapcar #'string-trim (split-string (match-string 1) ">,"))))))
(save-excursion
(goto-char (point-min))
(search-forward-regexp "To: \\(\\(.\\|\n\\)*\\)\\(Subject\\|CC\\|BCC\\)")
(mapconcat #'wilder/mu4e-process-recipient-name
(mapcar (lambda (s) (substring-no-properties
(string-trim (car (split-string s "<")))))
(mapcar #'string-trim (split-string (match-string 1) ">,")))
", ")))
#+end_src
This seems to be a very crude attempt, that is indeed what I am
using right now.
#+begin_src emacs-lisp
(defun mu4e-insert-recipients-name ()
"Inserts the name of the recipients at point"
;; needs several improvements: at the moment it only handles very
;; basic situations (one recipient, single-word first name)
(insert (concat (save-excursion
(goto-char (point-min))
(search-forward "To: ")
(current-word)))
"," ))
(insert (concat (recipients-ng) ", ")))
#+end_src
Customize ~mu4e~ bookmarks

Loading…
Cancel
Save