+(defun my-decrypt ()
+ ;; use for decrypting in mu4e
+ (interactive)
+ (beginning-of-buffer)
+ (when (search-forward "-----BEGIN PGP MESSAGE-----" nil t)
+ (read-only-mode 0)
+ (let ((start (match-beginning 0))
+ (end (search-forward "-----END PGP MESSAGE-----" nil t)))
+ (shell-command-on-region start end "gpg -dq" nil t shell-command-default-error-buffer t)
+ )))
+(add-hook 'mu4e-view-mode-hook 'my-decrypt)
+
+(defun mu-set-from-name (regexes)
+ "If we find an address matching regex, then set that address as the to,
+and whatever was used"
+ (when mu4e-compose-parent-message
+ (let ((found nil))
+ (while (and regexes (not found))
+ (setq re (car regexes)
+ regexes (cdr regexes)
+ found (mu4e-message-contact-field-matches
+ mu4e-compose-parent-message :to re)))
+ (when found (setq user-mail-address (cdr found)
+ user-full-name (car found)))
+ found)))
+(defun mu-set-from (regexes)
+ "If we find an address matching regex, then set that address as the to,
+and Ian Kelling as the name"
+ (when mu4e-compose-parent-message
+ (let ((found nil))
+ (while (and regexes (not found))
+ (setq re (car regexes)
+ regexes (cdr regexes)
+ found (cdr (mu4e-message-contact-field-matches
+ mu4e-compose-parent-message :to re))))
+ (when found (setq user-mail-address found
+ user-full-name "Ian Kelling"))
+ found)))
+
+
+(defun my-mu4e-to-fsf ()
+ "inspired by mu4e info manual, search for mu4e-compose-pre-hook."
+ (cond
+ ((mu-set-from '("iank@fsf.org"
+ "iank@gnu.org")))
+ ((setq user-mail-address "iank@fsf.org"
+ user-full-name "Ian Kelling"))))
+
+
+;; on first run mkdir -p /nocow/user/.mufsf; mu index --maildir=/nocow/user/fsfmd
+(defun mu-exit-wait ()
+ (interactive)
+ (let ((wait (= 0 (call-process "/bin/pidof" nil nil nil "mu"))))
+ (mu4e-quit)
+ ;; without sleep, we get database locked by another process error when hitting u
+ ;; if another mu was running.
+ (when wait (sleep-for 0 300))))
+(defun fsf-mu4e ()
+ (interactive)
+ (unless (equal mu4e-maildir "/nocow/user/fsfmd") (mu-exit-wait))
+ (setq
+ ;; fsf monitor is smaller
+ mu4e-headers-visible-lines 15
+ mu4e-maildir "/nocow/user/fsfmd"
+ mu4e-refile-folder "/Spam"
+ mu4e-get-mail-command "/a/bin/distro-setup/fsf-get-mail"
+ user-mail-address "iank@fsf.org"
+ mail-signature "
+
+--
+Ian Kelling | Senior Systems Administrator, Free Software Foundation
+GPG Key: B125 F60B 7B28 7FF6 A2B7 DF8F 170A F0E2 9542 95DF
+https://fsf.org | https://gnu.org
+"
+
+ mu4e-user-mail-address-list '("iank@fsf.org"
+ "iank@gnu.org")
+ mu4e-maildir-shortcuts
+ '( ("/INBOX" . ?i)
+ ("/sysadmin" . ?a)
+ ("/sec" . ?x)
+ ("/rtcc" . ?c)
+ ("/Drafts" . ?d)
+ ("/Sent" . ?s)
+ )
+ ) ;; end setq
+ (call-process "/a/exe/lnf" nil nil nil "-T" "/nocow/user/.mufsf" (concat (getenv "HOME") "/.mu"))
+ (add-hook 'mu4e-compose-pre-hook 'my-mu4e-to-fsf)
+ (remove-hook 'mu4e-compose-pre-hook 'my-mu4e-to)
+ (mu4e)) ;; end defun fsf-mu4e
+
+