Emacs personal configuration
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

99 行
3.9KB

  1. ;;; package --- mu4e
  2. ;;; Commentary:
  3. ;;; Code:
  4. (add-to-list 'load-path "/usr/share/emacs/site-lisp/mu4e")
  5. (require 'mu4e)
  6. (autoload 'mu4e "mu4e" "Mail client based on mu (maildir-utils)." t)
  7. (setq
  8. mu4e-maildir (expand-file-name "~/.Maildir")
  9. mu4e-drafts-folder "/Drafts"
  10. mu4e-sent-folder "/Sent"
  11. mu4e-trash-folder "/Trash")
  12. ;;(setq mu4e-get-mail-command "offlineimap")
  13. ;; http://cachestocaches.com/2017/3/complete-guide-email-emacs-using-mu-and-/
  14. ;; Include a bookmark to open all of my inboxes
  15. (add-to-list 'mu4e-bookmarks
  16. (make-mu4e-bookmark
  17. :name "All Inboxes"
  18. :query "maildir:/INBOX"
  19. :key ?i)
  20. (make-mu4e-bookmark
  21. :name "Gmail unread"
  22. :query "maildir:/Gmail AND flag:unread AND NOT flag:trashed"
  23. :key ?g))
  24. ;; This allows me to use 'helm' to select mailboxes
  25. (setq mu4e-completing-read-function 'completing-read)
  26. ;; Why would I want to leave my message open after I've sent it?
  27. (setq message-kill-buffer-on-exit t)
  28. ;; Don't ask for a 'context' upon opening mu4e
  29. (setq mu4e-context-policy 'pick-first)
  30. ;; Don't ask to quit... why is this the default?
  31. (setq mu4e-confirm-quit nil)
  32. (setq mu4e-contexts
  33. `( ,(make-mu4e-context
  34. :name "Private"
  35. :enter-func (lambda () (mu4e-message "Entering Private context"))
  36. :leave-func (lambda () (mu4e-message "Leaving Private context"))
  37. ;; we match based on the contact-fields of the message
  38. :match-func (lambda (msg)
  39. (when msg
  40. (mu4e-message-contact-field-matches msg
  41. '(:to :from :cc :bcc)
  42. ".*@home.example.com")))
  43. :vars '( ( user-mail-address . "aliced@home.example.com" )
  44. ( user-full-name . "ßingen" )
  45. ( mu4e-compose-signature . nil)))
  46. ,(make-mu4e-context
  47. :name "Work"
  48. :enter-func (lambda () (mu4e-message "Switch to the Work context"))
  49. ;; no leave-func
  50. ;; we match based on the maildir of the message
  51. ;; this matches maildir /Arkham and its sub-directories
  52. :match-func (lambda (msg)
  53. (when msg
  54. (string-match-p "^/Arkham" (mu4e-message-field msg :maildir))))
  55. :vars '( ( user-mail-address . "aderleth@miskatonic.example.com" )
  56. ( user-full-name . "ßingen" )
  57. ( mu4e-compose-signature . nil)))
  58. ,(make-mu4e-context
  59. :name "Cycling"
  60. :enter-func (lambda () (mu4e-message "Switch to the Cycling context"))
  61. ;; no leave-func
  62. ;; we match based on the maildir of the message; assume all
  63. ;; cycling-related messages go into the /cycling maildir
  64. :match-func (lambda (msg)
  65. (when msg
  66. (string= (mu4e-message-field msg :maildir) "/cycling")))
  67. :vars '( ( user-mail-address . "aderleth@example.com" )
  68. ( user-full-name . "ßingen" )
  69. ( mu4e-compose-signature . nil)))))
  70. ;; set `mu4e-context-policy` and `mu4e-compose-policy` to tweak when mu4e should
  71. ;; guess or ask the correct context, e.g.
  72. ;; start with the first (default) context;
  73. ;; default is to ask-if-none (ask when there's no context yet, and none match)
  74. ;; (setq mu4e-context-policy 'pick-first)
  75. ;; compose with the current context is no context matches;
  76. ;; default is to ask
  77. ;; (setq mu4e-compose-context-policy nil)
  78. ;; http://pragmaticemacs.com/emacs/master-your-inbox-with-mu4e-and-org-mode/
  79. ;;store org-mode links to messages
  80. (require 'org-mu4e)
  81. ;;store link to message if in header view, not to header query
  82. (setq org-mu4e-link-query-in-headers-mode nil)
  83. (provide 'init-mu4e)
  84. ;;; init-mu4e.el ends here