Emacs personal configuration
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

125 lines
5.5KB

  1. ;;; package --- mu4e
  2. ;;; Commentary:
  3. ;;; Code:
  4. (add-to-list 'load-path "/usr/share/emacs/site-lisp/elpa-src/mu4e-1.10.8")
  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. ;; https://www.djcbsoftware.nl/code/mu/mu4e/Bookmarks.html
  15. ;; Include a bookmark to open all of my inboxes
  16. (add-to-list 'mu4e-bookmarks
  17. '(:name "All Inboxes"
  18. :query "maildir:/INBOX"
  19. :key ?i))
  20. (add-to-list 'mu4e-bookmarks
  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. ( mu4e-sent-folder . "/Sent")
  47. ( user-mail-address . "aliced@home.example.com")
  48. ( smtpmail-smtp-user . "aliced@home.example.com")
  49. ( smtpmail-local-domain . "example.com")
  50. ( smtpmail-default-smtp-server . "smtp.example.com")
  51. ( smtpmail-smtp-server . "smtp.example.com")
  52. ( smtpmail-smtp-service . 587)
  53. ( smtpmail-stream-type . starttls)
  54. ( smtpmail-use-gnutls . t)))
  55. ,(make-mu4e-context
  56. :name "Work"
  57. :enter-func (lambda () (mu4e-message "Switch to the Work context"))
  58. ;; no leave-func
  59. ;; we match based on the maildir of the message
  60. ;; this matches maildir /Arkham and its sub-directories
  61. :match-func (lambda (msg)
  62. (when msg
  63. (string-match-p "^/Arkham" (mu4e-message-field msg :maildir))))
  64. :vars '( ( user-mail-address . "aderleth@miskatonic.example.com" )
  65. ( user-full-name . "ßingen" )
  66. ( mu4e-compose-signature . nil) (mu4e-sent-folder . "/Sent")
  67. ( user-mail-address . "aliced@home.example.com")
  68. ( smtpmail-smtp-user . "aliced@home.example.com")
  69. ( smtpmail-local-domain . "example.com")
  70. ( smtpmail-default-smtp-server . "smtp.example.com")
  71. ( smtpmail-smtp-server . "smtp.example.com")
  72. ( smtpmail-smtp-service . 587)
  73. ( smtpmail-stream-type . starttls)
  74. ( smtpmail-use-gnutls . t)))
  75. ,(make-mu4e-context
  76. :name "Cycling"
  77. :enter-func (lambda () (mu4e-message "Switch to the Cycling context"))
  78. ;; no leave-func
  79. ;; we match based on the maildir of the message; assume all
  80. ;; cycling-related messages go into the /cycling maildir
  81. :match-func (lambda (msg)
  82. (when msg
  83. (string= (mu4e-message-field msg :maildir) "/cycling")))
  84. :vars '( ( user-mail-address . "aderleth@example.com" )
  85. ( user-full-name . "ßingen" )
  86. ( mu4e-compose-signature . nil)
  87. ( mu4e-sent-folder . "/Sent")
  88. ( user-mail-address . "aliced@home.example.com")
  89. ( smtpmail-smtp-user . "aliced@home.example.com")
  90. ( smtpmail-local-domain . "example.com")
  91. ( smtpmail-default-smtp-server . "smtp.example.com")
  92. ( smtpmail-smtp-server . "smtp.example.com")
  93. ( smtpmail-smtp-service . 587)
  94. ( smtpmail-stream-type . starttls)
  95. ( smtpmail-use-gnutls . t)))))
  96. ;; set `mu4e-context-policy` and `mu4e-compose-policy` to tweak when mu4e should
  97. ;; guess or ask the correct context, e.g.
  98. ;; start with the first (default) context;
  99. ;; default is to ask-if-none (ask when there's no context yet, and none match)
  100. ;; (setq mu4e-context-policy 'pick-first)
  101. ;; compose with the current context is no context matches;
  102. ;; default is to ask
  103. ;; (setq mu4e-compose-context-policy nil)
  104. ;; http://pragmaticemacs.com/emacs/master-your-inbox-with-mu4e-and-org-mode/
  105. ;;store org-mode links to messages
  106. (require 'mu4e-org)
  107. ;;store link to message if in header view, not to header query
  108. (setq org-mu4e-link-query-in-headers-mode nil)
  109. (provide 'init-mu4e)
  110. ;;; init-mu4e.el ends here