mu4e-config.el 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. (require 'mu4e)
  2. (require 'org-mu4e)
  3. (require 'mu4e-contrib)
  4. (require 'smtpmail)
  5. (add-hook 'mu4e-compose-mode-hook #'(lambda () (auto-save-mode -1)))
  6. (auth-source-pass-enable)
  7. (setq auth-source-debug t)
  8. (setq auth-source-do-cache nil)
  9. (setq auth-sources '(password-store))
  10. (setq message-kill-buffer-on-exit t)
  11. (setq message-send-mail-function 'smtpmail-send-it)
  12. (setq mu4e-attachment-dir "~/Downloads")
  13. (setq mu4e-change-filenames-when-moving t)
  14. (setq mu4e-completing-read-function 'completing-read)
  15. (setq mu4e-compose-complete-addresses t)
  16. (setq mu4e-compose-context-policy nil)
  17. (setq mu4e-compose-dont-reply-to-self t)
  18. (setq mu4e-compose-keep-self-cc nil)
  19. (setq mu4e-context-policy 'pick-first)
  20. (setq mu4e-get-mail-command "mbsync -a")
  21. (setq mu4e-headers-date-format "%d-%m-%Y %H:%M")
  22. (setq mu4e-headers-fields '((:human-date . 20)
  23. (:flags . 6)
  24. (:mailing-list . 10)
  25. (:from . 22)
  26. (:subject)))
  27. (setq mu4e-headers-include-related t)
  28. (setq mu4e-sent-messages-behavior 'delete)
  29. (setq mu4e-view-show-addresses t)
  30. (setq mu4e-view-show-images t)
  31. (setq smtpmail-debug-info t)
  32. (setq smtpmail-stream-type 'starttls)
  33. (setq mm-sign-option 'guided)
  34. (when (fboundp 'imagemagick-register-types)
  35. (imagemagick-register-types))
  36. (defun sign-or-encrypt-message ()
  37. (let ((answer (read-from-minibuffer "Sign or encrypt?\nEmpty to do nothing.\n[s/e]: ")))
  38. (cond
  39. ((string-equal answer "s") (progn
  40. (message "Signing message.")
  41. (mml-secure-message-sign-pgpmime)))
  42. ((string-equal answer "e") (progn
  43. (message "Encrypt and signing message.")
  44. (mml-secure-message-encrypt-pgpmime)))
  45. (t (progn
  46. (message "Dont signing or encrypting message.")
  47. nil)))))
  48. (add-hook 'message-send-hook 'sign-or-encrypt-message)
  49. (setq mu4e-contexts
  50. `( ,(make-mu4e-context
  51. :name "gmail"
  52. :enter-func (lambda ()
  53. (mu4e-message "Entering gmail context")
  54. (when (string-match-p (buffer-name (current-buffer)) "mu4e-main")
  55. (revert-buffer)))
  56. :leave-func (lambda ()
  57. (mu4e-message "Leaving gmail context")
  58. (when (string-match-p (buffer-name (current-buffer)) "mu4e-main")
  59. (revert-buffer)))
  60. :match-func (lambda (msg)
  61. (when msg
  62. (or (mu4e-message-contact-field-matches msg :to "zadca12@gmail.com")
  63. (mu4e-message-contact-field-matches msg :from "zadca12@gmail.com")
  64. (mu4e-message-contact-field-matches msg :cc "zadca12@gmail.com")
  65. (mu4e-message-contact-field-matches msg :bcc "zadca12@gmail.com")
  66. (string-match-p "^/gmail/Inbox" (mu4e-message-field msg :maildir)))))
  67. :vars '( ( user-mail-address . "zadca12@gmail.com" )
  68. ( smtpmail-smtp-user . "zadca12@gmail.com" )
  69. ( mu4e-compose-signature . "Adam Salwowski" )
  70. ( smtpmail-smtp-server . "smtp.gmail.com" )
  71. ( smtpmail-smtp-service . 587 )
  72. ( mu4e-maildir-shortcuts . ((:maildir "/gmail/Inbox" :key ?i)))
  73. ( mu4e-bookmarks
  74. .
  75. (( :name "Unread messages"
  76. :query "maildir:/gmail/Inbox AND flag:unread AND NOT flag:trashed AND NOT outdoorexperten"
  77. :key ?u)
  78. ( :name "Today's messages"
  79. :query "maildir:/gmail/Inbox AND date:today..now"
  80. :key ?t)
  81. ( :name "Last 7 days"
  82. :query "maildir:/gmail/Inbox AND date:7d..now"
  83. :hide-unread t
  84. :key ?w)
  85. ( :name "Deleted"
  86. :query "flag:trashed"
  87. :key ?d)
  88. ( :name "Possibly garbage"
  89. :query "bokio OR outdoorexperten"
  90. :key ?g)))))
  91. ,(make-mu4e-context
  92. :name "school"
  93. :enter-func (lambda ()
  94. (mu4e-message "Entering school context")
  95. (when (string-match-p (buffer-name (current-buffer)) "mu4e-main")
  96. (revert-buffer)))
  97. :leave-func (lambda ()
  98. (mu4e-message "Leaving school context")
  99. (when (string-match-p (buffer-name (current-buffer)) "mu4e-main")
  100. (revert-buffer)))
  101. :match-func (lambda (msg)
  102. (when msg
  103. (or (mu4e-message-contact-field-matches msg :to "150998@student.uwm.edu.pl")
  104. (mu4e-message-contact-field-matches msg :from "150998@student.uwm.edu.pl")
  105. (mu4e-message-contact-field-matches msg :cc "150998@student.uwm.edu.pl")
  106. (mu4e-message-contact-field-matches msg :bcc "150998@student.uwm.edu.pl"))))
  107. :vars '( ( user-mail-address . "150998@student.uwm.edu.pl" )
  108. ( smtpmail-smtp-user . "150998@student.uwm.edu.pl" )
  109. ( smtpmail-smtp-server . "smtp.office365.com" )
  110. ( smtpmail-smtp-service . 587 )
  111. ( mu4e-compose-signature . "Adam Salwowski, ISI, indeks: 150998" )
  112. ( mu4e-maildir-shortcuts . ((:maildir "/outlook/Inbox" :key ?i)))
  113. ( mu4e-bookmarks
  114. .
  115. (( :name "All school mails"
  116. :query "maildir:/outlook/Inbox"
  117. :key ?a)
  118. ( :name "Unread school messages"
  119. :query "maildir:/outlook/Inbox AND flag:unread AND NOT flag:trashed"
  120. :key ?u)))))))