<commit_before>;;; aly-mu4e-config.el --- mu4e (mu for Emacs) configurations
;; -*- mode: emacs-lisp -*-
;; vim: set ts=8 sw=2 tw=0 fenc=utf-8 ft=lisp:
;;
;; <NAME>
;; Created: 2016-02-21
;; Updated: 2016-05-15
;;

;;; Commentary:
;; mu4e (mu for Emacs) configurations for spacemacs.
;; mu (maildir indexer/searcher): https://github.com/djcb/mu
;;

;;; Code:

(with-eval-after-load 'mu4e
  ;; turn on debug: log debug information to the *mu4e-log* buffer
  (setq mu4e-debug t)
  (setq mu4e-maildir "~/mail")

  ;; multiple email accounts: contexts (require mu4e >= 0.9.16)
  (setq mu4e-contexts
    `( ,(make-mu4e-context
          :name "Outlook-aly"
          :enter-func (lambda ()
                        (mu4e-message "Switched to context: outlook-aly"))
          ;; `leave-func' not defined
          ;; `match-func' is invoked just before `mu4e-compose-pre-hook'
          :match-func (lambda (msg)
                        (when msg
                          (mu4e-message-contact-field-matches msg
                            :to "<EMAIL>")))
          :vars '((user-mail-address      . "<EMAIL>")
                  (user-full-name         . "<NAME>")
                  (mu4e-sent-folder       . "/outlook-aly/sent")
                  (mu4e-drafts-folder     . "/outlook-aly/drafts")
                  (mu4e-trash-folder      . "/outlook-aly/trash")
                  (mu4e-refile-folder     . "/outlook-aly/archive")
                  (mu4e-compose-signature . "Aly")
                  (mu4e-sent-messages-behavior . delete)))
        ,(make-mu4e-context
          :name "Gmail-aly"
          :enter-func (lambda ()
                        (mu4e-message "Switched to context: gmail-aly"))
          ;; `leave-func' not defined
          :match-func (lambda (msg)
                        (when msg
                          (mu4e-message-contact-field-matches msg
                            :to "<EMAIL>")))
          :vars '((user-mail-address      . "<EMAIL>")
                  (user-full-name         . "<NAME>")
                  ;; special folders
                  (mu4e-sent-folder       . "/sent")
                  (mu4e-drafts-folder     . "/gmail-aly/drafts")
                  (mu4e-trash-folder      . "/gmail-aly/trash")
                  (mu4e-refile-folder     . "/gmail-aly/archive")
                  (mu4e-compose-signature . "Aly")
                  ;; do NOT save message to 'sent-folder'
                  (mu4e-sent-messages-behavior . delete)))
        ,(make-mu4e-context
          :name "outlook-li"
          :enter-func (lambda ()
                        (mu4e-message "Switched to context: outlook-li"))
          ;; `leave-func' not defined
          :match-func (lambda (msg)
                        (when msg
                          (mu4e-message-contact-field-matches msg
                            :to '("<EMAIL>"
                                  "<EMAIL>"))))
          :vars '((user-mail-address      . "<EMAIL>")
                  (user-full-name         . "<NAME>")
                  (mu4e-sent-folder       . "/outlook-li/sent")
                  (mu4e-drafts-folder     . "/outlook-li/drafts")
                  (mu4e-trash-folder      . "/outlook-li/trash")
                  (mu4e-refile-folder     . "/outlook-li/archive")
                  (mu4e-compose-signature . "Weitian LI")
                  (mu4e-sent-messages-behavior . delete)))
        ,(make-mu4e-context
          :name "gmail-li"
          :enter-func (lambda ()
                        (mu4e-message "Switched to context: gmail-li"))
          ;; `leave-func' not defined
          :match-func (lambda (msg)
                        (when msg
                          (mu4e-message-contact-field-matches msg
                            :to "<EMAIL>")))
          :vars '((user-mail-address      . "<EMAIL>")
                  (user-full-name         . "<NAME>")
                  (mu4e-sent-folder       . "/sent")
                  (mu4e-drafts-folder     . "/gmail-li/drafts")
                  (mu4e-trash-folder      . "/gmail-li/trash")
                  (mu4e-refile-folder     . "/gmail-li/archive")
                  (mu4e-compose-signature . "Weitian LI")
                  (mu4e-sent-messages-behavior . delete)))
        ,(make-mu4e-context
          :name "sjtu"
          :enter-func (lambda ()
                        (mu4e-message "Switched to context: sjtu"))
          ;; `leave-func' not defined
          :match-func (lambda (msg)
                        (when msg
                          (mu4e-message-contact-field-matches msg
                            :to "<EMAIL>")))
          :vars '((user-mail-address      . "<EMAIL>")
                  (user-full-name         . "<NAME>")
                  (mu4e-sent-folder       . "/sjtu/sent")
                  (mu4e-drafts-folder     . "/sjtu/drafts")
                  (mu4e-trash-folder      . "/sjtu/trash")
                  (mu4e-refile-folder     . "/sjtu/archive")
                  (mu4e-compose-signature .
                    (concat "Weitian LI\n"
                            "Department of Physics and Astronomy\n"
                            "Shanghai Jiao Tong University"))
                  ;; copy message to sent folder
                  (mu4e-sent-messages-behavior . sent)))
        ,(make-mu4e-context
          :name "autistici"
          :enter-func (lambda ()
                        (mu4e-message "Switched to context: autistici"))
          ;; `leave-func' not defined
          :match-func (lambda (msg)
                        (when msg
                          (mu4e-message-contact-field-matches msg
                            :to "<EMAIL>")))
          :vars '((user-mail-address      . "<EMAIL>")
                  (user-full-name         . "<NAME>")
                  (mu4e-sent-folder       . "/autistici/sent")
                  (mu4e-drafts-folder     . "/autistici/drafts")
                  (mu4e-trash-folder      . "/autistici/trash")
                  (mu4e-refile-folder     . "/autistici/archive")
                  (mu4e-compose-signature . "Weitian LI")
                  ;; copy message to sent folder
                  (mu4e-sent-messages-behavior . sent)))
        ,(make-mu4e-context
          :name "foxmail"
          :enter-func (lambda ()
                        (mu4e-message "Switched to context: foxmail"))
          ;; `leave-func' not defined
          :match-func (lambda (msg)
                        (when msg
                          (mu4e-message-contact-field-matches msg
                            :to '("<EMAIL>"
                                  "<EMAIL>"))))
          :vars '((user-mail-address      . "<EMAIL>")
                  (user-full-name         . "<NAME>")
                  (mu4e-sent-folder       . "/foxmail/sent")
                  (mu4e-drafts-folder     . "/foxmail/drafts")
                  (mu4e-trash-folder      . "/foxmail/trash")
                  (mu4e-refile-folder     . "/foxmail/archive")
                  (mu4e-compose-signature . "Weitian LI")
                  (mu4e-sent-messages-behavior . delete)))))

  ;; start with the first (default) context
  ;; default: `ask-if-none' (ask when there's no context yet, and none match)
  (setq mu4e-context-policy 'pick-first)
  ;; compose with the current context if no context matches
  ;; default: `ask'
  ;(setq mu4e-compose-context-policy nil)

  ;; auto construct addresses list by extracting addresses from contexts
  (setq mu4e-user-mail-address-list
        (delq nil
              (mapcar (lambda (context)
                        (when (mu4e-context-vars context)
                          (cdr (assq 'user-mail-address
                                    (mu4e-context-vars context)))))
                      mu4e-contexts)))

  ;; send mail using `msmtp'
  (setq message-send-mail-function 'message-send-mail-with-sendmail
        message-sendmail-f-is-evil t
        ;; choose the account according to the `From' header
        message-sendmail-extra-arguments '("--read-envelope-from")
        sendmail-program "msmtp")

  ;; allow for fetch mail and update index using 'U' in the main view
  (setq mu4e-get-mail-command "offlineimap -o -1")
  ;; get mail and update index periodically in the background (unit: seconds)
  (setq mu4e-update-interval 900)

  ;; frequent mail folders, with shortcuts
  ;; NOTE: do not use shortcut `o' as it is used for `[o]ther'
  ;(setq mu4e-maildir-shortcuts
  ;      '(("/important"         . ?i)
  ;        ("/archive"           . ?a)
  ;        ("/gmail-aly/archive" . ?G)
  ;        ("/gmail-li/archive"  . ?g)
  ;        ("/outlook-aly/inbox" . ?l)
  ;        ("/outlook-li/inbox"  . ?L)
  ;        ("/sjtu/inbox"        . ?s)))

  ;; do not keep message buffers around
  (setq message-kill-buffer-on-exit t)

  ;; enable inline images
  (setq mu4e-view-show-images t)
  ;; use imagemagick if available
  (when (fboundp 'imagemagick-register-types)
    (imagemagick-register-types))

  ;; display rich-text messages
  (require 'mu4e-contrib)
  ;; use `shr' html renderer; reqiure emacs >= 24.4
  (setq mu4e-html2text-command 'mu4e-shr2text)
  (add-hook 'mu4e-view-mode-hook
            (lambda ()
              ;; try to emulate some of the `eww' key-bindings
              (local-set-key (kbd "<tab>")     'shr-next-link)
              (local-set-key (kbd "<backtab>") 'shr-previous-link)))
  ;; change the luminosity form dark theme
  (setq shr-color-visible-luminance-min 70)

  ;; customize bookmarks
  (setq mu4e-bookmarks
        '(("flag:unread AND NOT flag:trashed" "Unread messages"      ?u)
          ("date:today..now"                  "Today's messages"     ?T)
          ("date:7d..now"                     "Last 7 days"          ?w)
          ("flag:flagged"                     "Flagged messages"     ?f)
          ("tag:todo OR tag:task"             "TODO & Task"          ?t)
          ("tag:work"                         "Work"                 ?W)
          ("tag:astro"                        "Astro"                ?a)
          ("tag:arxiv OR from:arxiv.org"      "arXiv"                ?x)
          ("tag:SMS"                          "SMS"                  ?S)
          ("tag:CallLog"                      "Call Log"             ?C)
          ("flag:trashed OR tag:\\\\Trash"    "Deleted"              ?d)
          ("mime:image/*"                     "Messages with images" ?p)))

  ;; headers list appearance
  (setq mu4e-headers-date-format "%Y-%m-%d %H:%M"
        mu4e-headers-fields '((:date       . 18)  ;; also :human-date
                              (:flags      .  5)
                              (:from-or-to . 22)
                              (:subject    . nil)))  ;; also :thread-subject

  ;; use fancy non-ascii characters in various places
  ;(setq mu4e-use-fancy-chars t)

  ;; show full addresses instead of just names when view message
  (setq mu4e-view-show-addresses t)

  ;; also include messages related to the searched messages
  (setq mu4e-headers-include-related t)
  ;; exclude the duplicate messages with the same `Message-ID'
  ;(setq mu4e-headers-skip-duplicates t)

  ;; compose messages in a separate frame
  (setq mu4e-compose-in-new-frame t)
<commit_msg>mu4e: remove CallLog bookmark<commit_after>;;; aly-mu4e-config.el --- mu4e (mu for Emacs) configurations
;; -*- mode: emacs-lisp -*-
;; vim: set ts=8 sw=2 tw=0 fenc=utf-8 ft=lisp:
;;
;; <NAME>
;; Created: 2016-02-21
;; Updated: 2016-08-19
;;

;;; Commentary:
;; mu4e (mu for Emacs) configurations for spacemacs.
;; mu (maildir indexer/searcher): https://github.com/djcb/mu
;;

;;; Code:

(with-eval-after-load 'mu4e
  ;; turn on debug: log debug information to the *mu4e-log* buffer
  (setq mu4e-debug t)
  (setq mu4e-maildir "~/mail")

  ;; multiple email accounts: contexts (require mu4e >= 0.9.16)
  (setq mu4e-contexts
    `( ,(make-mu4e-context
          :name "Outlook-aly"
          :enter-func (lambda ()
                        (mu4e-message "Switched to context: outlook-aly"))
          ;; `leave-func' not defined
          ;; `match-func' is invoked just before `mu4e-compose-pre-hook'
          :match-func (lambda (msg)
                        (when msg
                          (mu4e-message-contact-field-matches msg
                            :to "<EMAIL>")))
          :vars '((user-mail-address      . "<EMAIL>")
                  (user-full-name         . "<NAME>")
                  (mu4e-sent-folder       . "/outlook-aly/sent")
                  (mu4e-drafts-folder     . "/outlook-aly/drafts")
                  (mu4e-trash-folder      . "/outlook-aly/trash")
                  (mu4e-refile-folder     . "/outlook-aly/archive")
                  (mu4e-compose-signature . "Aly")
                  (mu4e-sent-messages-behavior . delete)))
        ,(make-mu4e-context
          :name "Gmail-aly"
          :enter-func (lambda ()
                        (mu4e-message "Switched to context: gmail-aly"))
          ;; `leave-func' not defined
          :match-func (lambda (msg)
                        (when msg
                          (mu4e-message-contact-field-matches msg
                            :to "<EMAIL>")))
          :vars '((user-mail-address      . "<EMAIL>")
                  (user-full-name         . "<NAME>")
                  ;; special folders
                  (mu4e-sent-folder       . "/sent")
                  (mu4e-drafts-folder     . "/gmail-aly/drafts")
                  (mu4e-trash-folder      . "/gmail-aly/trash")
                  (mu4e-refile-folder     . "/gmail-aly/archive")
                  (mu4e-compose-signature . "Aly")
                  ;; do NOT save message to 'sent-folder'
                  (mu4e-sent-messages-behavior . delete)))
        ,(make-mu4e-context
          :name "outlook-li"
          :enter-func (lambda ()
                        (mu4e-message "Switched to context: outlook-li"))
          ;; `leave-func' not defined
          :match-func (lambda (msg)
                        (when msg
                          (mu4e-message-contact-field-matches msg
                            :to '("<EMAIL>"
                                  "<EMAIL>"))))
          :vars '((user-mail-address      . "<EMAIL>")
                  (user-full-name         . "<NAME>")
                  (mu4e-sent-folder       . "/outlook-li/sent")
                  (mu4e-drafts-folder     . "/outlook-li/drafts")
                  (mu4e-trash-folder      . "/outlook-li/trash")
                  (mu4e-refile-folder     . "/outlook-li/archive")
                  (mu4e-compose-signature . "Weitian LI")
                  (mu4e-sent-messages-behavior . delete)))
        ,(make-mu4e-context
          :name "gmail-li"
          :enter-func (lambda ()
                        (mu4e-message "Switched to context: gmail-li"))
          ;; `leave-func' not defined
          :match-func (lambda (msg)
                        (when msg
                          (mu4e-message-contact-field-matches msg
                            :to "<EMAIL>")))
          :vars '((user-mail-address      . "<EMAIL>")
                  (user-full-name         . "<NAME>")
                  (mu4e-sent-folder       . "/sent")
                  (mu4e-drafts-folder     . "/gmail-li/drafts")
                  (mu4e-trash-folder      . "/gmail-li/trash")
                  (mu4e-refile-folder     . "/gmail-li/archive")
                  (mu4e-compose-signature . "Weitian LI")
                  (mu4e-sent-messages-behavior . delete)))
        ,(make-mu4e-context
          :name "sjtu"
          :enter-func (lambda ()
                        (mu4e-message "Switched to context: sjtu"))
          ;; `leave-func' not defined
          :match-func (lambda (msg)
                        (when msg
                          (mu4e-message-contact-field-matches msg
                            :to "<EMAIL>")))
          :vars '((user-mail-address      . "<EMAIL>")
                  (user-full-name         . "<NAME>")
                  (mu4e-sent-folder       . "/sjtu/sent")
                  (mu4e-drafts-folder     . "/sjtu/drafts")
                  (mu4e-trash-folder      . "/sjtu/trash")
                  (mu4e-refile-folder     . "/sjtu/archive")
                  (mu4e-compose-signature .
                    (concat "Weitian LI\n"
                            "Department of Physics and Astronomy\n"
                            "Shanghai Jiao Tong University"))
                  ;; copy message to sent folder
                  (mu4e-sent-messages-behavior . sent)))
        ,(make-mu4e-context
          :name "autistici"
          :enter-func (lambda ()
                        (mu4e-message "Switched to context: autistici"))
          ;; `leave-func' not defined
          :match-func (lambda (msg)
                        (when msg
                          (mu4e-message-contact-field-matches msg
                            :to "<EMAIL>")))
          :vars '((user-mail-address      . "<EMAIL>")
                  (user-full-name         . "<NAME>")
                  (mu4e-sent-folder       . "/autistici/sent")
                  (mu4e-drafts-folder     . "/autistici/drafts")
                  (mu4e-trash-folder      . "/autistici/trash")
                  (mu4e-refile-folder     . "/autistici/archive")
                  (mu4e-compose-signature . "Weitian LI")
                  ;; copy message to sent folder
                  (mu4e-sent-messages-behavior . sent)))
        ,(make-mu4e-context
          :name "foxmail"
          :enter-func (lambda ()
                        (mu4e-message "Switched to context: foxmail"))
          ;; `leave-func' not defined
          :match-func (lambda (msg)
                        (when msg
                          (mu4e-message-contact-field-matches msg
                            :to '("<EMAIL>"
                                  "<EMAIL>"))))
          :vars '((user-mail-address      . "<EMAIL>")
                  (user-full-name         . "<NAME>")
                  (mu4e-sent-folder       . "/foxmail/sent")
                  (mu4e-drafts-folder     . "/foxmail/drafts")
                  (mu4e-trash-folder      . "/foxmail/trash")
                  (mu4e-refile-folder     . "/foxmail/archive")
                  (mu4e-compose-signature . "Weitian LI")
                  (mu4e-sent-messages-behavior . delete)))))

  ;; start with the first (default) context
  ;; default: `ask-if-none' (ask when there's no context yet, and none match)
  (setq mu4e-context-policy 'pick-first)
  ;; compose with the current context if no context matches
  ;; default: `ask'
  ;(setq mu4e-compose-context-policy nil)

  ;; auto construct addresses list by extracting addresses from contexts
  (setq mu4e-user-mail-address-list
        (delq nil
              (mapcar (lambda (context)
                        (when (mu4e-context-vars context)
                          (cdr (assq 'user-mail-address
                                    (mu4e-context-vars context)))))
                      mu4e-contexts)))

  ;; send mail using `msmtp'
  (setq message-send-mail-function 'message-send-mail-with-sendmail
        message-sendmail-f-is-evil t
        ;; choose the account according to the `From' header
        message-sendmail-extra-arguments '("--read-envelope-from")
        sendmail-program "msmtp")

  ;; allow for fetch mail and update index using 'U' in the main view
  (setq mu4e-get-mail-command "offlineimap -o -1")
  ;; get mail and update index periodically in the background (unit: seconds)
  (setq mu4e-update-interval 900)

  ;; frequent mail folders, with shortcuts
  ;; NOTE: do not use shortcut `o' as it is used for `[o]ther'
  ;(setq mu4e-maildir-shortcuts
  ;      '(("/important"         . ?i)
  ;        ("/archive"           . ?a)
  ;        ("/gmail-aly/archive" . ?G)
  ;        ("/gmail-li/archive"  . ?g)
  ;        ("/outlook-aly/inbox" . ?l)
  ;        ("/outlook-li/inbox"  . ?L)
  ;        ("/sjtu/inbox"        . ?s)))

  ;; do not keep message buffers around
  (setq message-kill-buffer-on-exit t)

  ;; enable inline images
  (setq mu4e-view-show-images t)
  ;; use imagemagick if available
  (when (fboundp 'imagemagick-register-types)
    (imagemagick-register-types))

  ;; display rich-text messages
  (require 'mu4e-contrib)
  ;; use `shr' html renderer; reqiure emacs >= 24.4
  (setq mu4e-html2text-command 'mu4e-shr2text)
  (add-hook 'mu4e-view-mode-hook
            (lambda ()
              ;; try to emulate some of the `eww' key-bindings
              (local-set-key (kbd "<tab>")     'shr-next-link)
              (local-set-key (kbd "<backtab>") 'shr-previous-link)))
  ;; change the luminosity form dark theme
  (setq shr-color-visible-luminance-min 70)

  ;; customize bookmarks
  (setq mu4e-bookmarks
        '(("flag:unread AND NOT flag:trashed" "Unread messages"      ?u)
          ("date:today..now"                  "Today's messages"     ?T)
          ("date:7d..now"                     "Last 7 days"          ?w)
          ("flag:flagged"                     "Flagged messages"     ?f)
          ("tag:todo OR tag:task"             "TODO & Task"          ?t)
          ("tag:work"                         "Work"                 ?W)
          ("tag:astro"                        "Astro"                ?a)
          ("tag:arxiv OR from:arxiv.org"      "arXiv"                ?x)
          ("tag:SMS"                          "SMS"                  ?S)
          ("flag:trashed OR tag:\\\\Trash"    "Deleted"              ?d)
          ("mime:image/*"                     "Messages with images" ?p)))

  ;; headers list appearance
  (setq mu4e-headers-date-format "%Y-%m-%d %H:%M"
        mu4e-headers-fields '((:date       . 18)  ;; also :human-date
                              (:flags      .  5)
                              (:from-or-to . 22)
                              (:subject    . nil)))  ;; also :thread-subject

  ;; use fancy non-ascii characters in various places
  ;(setq mu4e-use-fancy-chars t)

  ;; show full addresses instead of just names when view message
  (setq mu4e-view-show-addresses t)

  ;; also include messages related to the searched messages
  (setq mu4e-headers-include-related t)
  ;; exclude the duplicate messages with the same `Message-ID'
  ;(setq mu4e-headers-skip-duplicates t)

  ;; compose messages in a separate frame
  (setq mu4e-compose-in-new-frame t)

{'fraction_non_alphanumeric': 0.1342602941833952, 'fraction_numerical': 0.012294898734743149, 'mean_word_length': 1.346868114573497, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 59, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5985914', 'n_tokens_mistral': 7051, 'n_tokens_neox': 6611, 'n_words': 1435}