From 279003ffd175b7cb672222f71ae58ce0068e7277 Mon Sep 17 00:00:00 2001 From: Matt Nish-Lapidus Date: Thu, 4 Jul 2024 14:42:42 -0400 Subject: [PATCH] moved mu4e config to its own files --- bindings.el | 26 +++++++ config.el | 185 +++------------------------------------------ mu4e-config.el | 166 ++++++++++++++++++++++++++++++++++++++++ obsidian-config.el | 19 +---- 4 files changed, 202 insertions(+), 194 deletions(-) create mode 100644 mu4e-config.el diff --git a/bindings.el b/bindings.el index 38117fb..044e565 100644 --- a/bindings.el +++ b/bindings.el @@ -464,6 +464,7 @@ "f" #'chezmoi-find "w" #'chezmoi-write) +;; mu4e bindings (map! :map '(mu4e-main-mode-map mu4e-compose-mode-map mu4e-headers-mode-map mu4e-view-mode-map) :localleader @@ -494,6 +495,7 @@ :localleader :desc "Send message and exit" "s" #'message-send-and-exit) +;; dired (map! :map dired-mode-map "h" #'dired-up-directory @@ -501,15 +503,39 @@ "" #'dired-up-directory "" #'dired-find-file) + +;; obsidian +(map! :leader + :desc "Obsidian Quick Capture" + "X" #'mnl/obsidian-capture) + +(map! :leader + :prefix "n" + :desc "Jump" "f" #'obsidian-jump + :desc "Search" "s" #'obsidian-search + :desc "Tag Search" "m" #'obsidian-tag-find + :desc "Daily Note" "n" #'mnl/obsidian-capture + :desc "Insert Wikilink" "w" #'obsidian-insert-wikilink + :desc "Backlink Jump" "j" #'obsidian-backlink-jump + :desc "Follow Link" "l" #'obsidian-follow-link-at-point + :desc "Update" "u" #'obsidian-update + "a" nil + "d" nil) + +;; left option is meta, right option is option (setq ns-alternate-modifier 'meta) (setq ns-right-alternate-modifier 'none) +;; leader key fix for meow from lemon-breezes pr (after! which-key (let ((prefix-re (regexp-opt (list doom-leader-key doom-leader-alt-key)))) (cl-pushnew `((,(format "\\`\\(?:C-w\\|%s w\\) m\\'" prefix-re)) nil . "maximize") which-key-replacement-alist))) +;; make esc close completion from corfu +(map! :map corfu-map [escape] 'corfu-quit) + ;; main meow normal mode keymap (map! :map meow-normal-state-keymap "<" #'meow-beginning-of-thing diff --git a/config.el b/config.el index 968eec3..63ef3ea 100644 --- a/config.el +++ b/config.el @@ -20,6 +20,9 @@ (setq scroll-preserve-screen-position t) (setq global-hl-line-modes nil) +(custom-set-faces! + '(line-number :foreground "#424242")) + (setq locale-coding-system 'utf-8) (set-terminal-coding-system 'utf-8) (set-keyboard-coding-system 'utf-8) @@ -29,6 +32,8 @@ (setq treesit-extra-load-path '("~/Source/_src/tree-sitter-module/dist/")) +(use-package! kbd-mode) + ;; Modeline ;; - add current workspace name ;; - add major mode icon @@ -95,9 +100,6 @@ ;; (setq-default indent-tabs-mode t) (setq-default tab-width 2) -;; import all my customized keybindings based on doom evil mode, but without evil. -(load! "bindings.el") - (after! treemacs (setq treemacs-follow-mode t) (setq treemacs-project-follow-mode t)) @@ -191,9 +193,6 @@ (setq sly-default-lisp 'sbcl) (setq sly-complete-symbol-function 'sly-flex-completions)) -;; make esc close completion from corfu -(map! :map corfu-map [escape] 'corfu-quit) - ;; cl-collider cl-patterns emacs helpers TODO: test this (after! lisp-mode (defun cl-patterns-helpers-load () @@ -241,177 +240,11 @@ (add-hook! 'gcode-mode-hook 'eldoc-mode)) (load! "obsidian-config.el") +(load! "mu4e-config.el") + +;; import all my customized keybindings based on doom evil mode, but with meow instead. +(load! "bindings.el") (add-hook 'window-setup-hook #'mnl/frame-center) -(custom-set-faces! - '(line-number :foreground "#424242")) - -;; mu4e -(set-email-account! "matt@emenel.ca" - '((mu4e-sent-folder . "/matt@emenel.ca/Sent") - (mu4e-drafts-folder . "/matt@emenel.ca/Drafts") - (mu4e-trash-folder . "/matt@emenel.ca/Trash") - (mu4e-refile-folder . "/matt@emenel.ca/Archive") - (mu4e-spam-folder . "/matt@emenel.ca/Spam") - (smtpmail-smtp-user . "matt@emenel.ca") - (user-mail-address . "matt@emenel.ca") ;; only needed for mu < 1.4 - (smtpmail-default-smtp-server . "smtp.fastmail.com") - (smtpmail-smtp-server . "smtp.fastmail.com") - (smtpmail-local-domain . "fastmail.com")) - t) - -(set-email-account! "admin@studyoftime.org" - '((mu4e-sent-folder . "/admin@studyoftime.org/Sent") - (mu4e-drafts-folder . "/admin@studyoftime.org/Drafts") - (mu4e-trash-folder . "/admin@studyoftime.org/Trash") - (mu4e-refile-folder . "/admin@studyoftime.org/Archive") - (mu4e-spam-folder . "/admin@studyoftime.org/Spam") - (smtpmail-smtp-user . "admin@studyoftime.org") - (user-mail-address . "admin@studyoftime.org") ;; only needed for mu < 1.4 - (smtpmail-default-smtp-server . "smtp.dreamhost.com") - (smtpmail-smtp-server . "smtp.dreamhost.com") - (smtpmail-local-domain . "dreamhost.com")) - t) - -(defun message-insert-signature-at-point () - "Insert signature at point." - (interactive) - (setq message-signature "Matt Nish-Lapidus\nhttps://emenel.ca") - (save-restriction - (narrow-to-region (point) (point)) - (message-insert-signature) - (newline)) - (setq message-signature nil)) - -(use-package! consult-mu - :defer-incrementally mu4e - :custom - (consult-mu-maxnum 200) - ;;show preview when pressing any keys - (consult-mu-preview-key 'any) - (consult-mu-mark-previewed-as-read nil) - ;;mark email as read when selected. - ;; (consult-mu-mark-viewed-as-read t) - (consult-mu-use-wide-reply t) - - (consult-mu-headers-template (lambda () (concat "%f" (number-to-string (floor (* (frame-width) 0.15))) "%s" (number-to-string (floor (* (frame-width) 0.5))) "%d13" "%g" "%x"))) - (consult-mu-action #'consult-mu--view-action) - - :config - (setq consult-mu-saved-searches-dynamics '("#flag:unread")) - (setq consult-mu-saved-searches-async '("#flag:unread")) - ;; require embark actions for marking, replying, forwarding, etc. directly from minibuffer - (require 'consult-mu-embark) - ;; require extra module for composing (e.g. for interactive attachment) as well as embark actions - (require 'consult-mu-compose) - (require 'consult-mu-compose-embark) - ;; require extra module for searching contacts and runing embark actions on contacts - (require 'consult-mu-contacts) - (require 'consult-mu-contacts-embark) - ;; change the prefiew key for compose so you don't open a preview of every file when selecting files to attach - (setq consult-mu-compose-preview-key "M-o") - ;; pick a key to bind to consult-mu-compose-attach in embark-file-map - (setq consult-mu-embark-attach-file-key "C-a") - (setq consult-mu-contacts-ignore-list '("^.*no.*reply.*")) - (setq consult-mu-contacts-ignore-case-fold-search t) - (consult-mu-compose-embark-bind-attach-file-key) - ;; choose if you want to use dired for attaching files (choice of 'always, 'in-dired, or nil) - (setq consult-mu-compose-use-dired-attachment 'in-dired)) - -(use-package! mu4e - :defer-incrementally t - :config - - ;; Run mu4e in the background to sync mail periodically - ;; (mu4e t) - - ;; tell meow to start mu4e in motion state - (pushnew! meow-mode-state-list '(mu4e-main-mode . motion)) - - (setq mu4e-update-interval 300 - mu4e-headers-auto-update t) - - (setq - mu4e-index-cleanup t - mu4e-index-lazy-check nil - mu4e-show-images t - message-kill-buffer-on-exit t - mu4e-enable-async-operations t) - - (setq message-citation-line-format "On %e %B %Y at %R %Z, %f wrote:\n") - (setq message-citation-line-function 'message-insert-formatted-citation-line) - - (add-hook 'mu4e-thread-mode-hook #'mu4e-thread-fold-all) - - (set-popup-rule! "*mu4e overview*" :side 'left :size '0.25) - - (setq mu4e-bookmarks nil) - - (setq sendmail-program "/opt/homebrew/bin/msmtp" - send-mail-function 'smtpmail-send-it - message-sendmail-f-is-evil t - message-sendmail-extra-arguments '("--read-envelope-from") - message-send-mail-function 'message-send-mail-with-sendmail) - - (setq mu4e-compose-format-flowed t) - - (setq message-signature nil) - - (add-hook! 'mu4e-compose-mode-hook - (use-hard-newlines -1) - ;; (message-add-header "CC:") - (message-goto-body) - (message-insert-signature-at-point) - (message-goto-body)) - - ;; (setq mu4e-bookmarks - ;; '((:name "Unread messages" :query "flag:unread AND NOT flag:trashed" :key ?i) - ;; (:name "Today's messages" :query "date:today..now" :key ?t) - ;; (:name "The Boss" :query "from:stallman" :key ?s) - ;; (:name "Last 7 days" :query "date:7d..now" :hide-unread t :key ?w) - ;; (:name "Messages with images" :query "mime:image/*" :key ?p))) - - (mu4e-bookmark-define - (concat "flag:unread" - " and not maildir:/matt@emenel.ca/Spam" - " and not maildir:/matt@emenel.ca/Trash" - " and not maildir:/admin@studyoftime.org/Spam" - " and not maildir:/admin@studyoftime.org/Trash") - "All Unread" - ?U) - - (mu4e-bookmark-define - (concat "flag:unread" - " and not maildir:/matt@emenel.ca/Spam" - " and not maildir:/matt@emenel.ca/Trash" - " and not maildir:/matt@emenel.ca/Archive" - " and not maildir:/admin@studyoftime.org/Spam" - " and not maildir:/admin@studyoftime.org/Trash" - " and not maildir:/admin@studyoftime.org/Archive") - "Inboxes Unread" - ?u) - - ;; inboxes - (mu4e-bookmark-define - (concat "maildir:/matt@emenel.ca/Inbox" - " or maildir:/admin@studyoftime.org/Inbox") - "All Inboxes" - ?i) - - (setq mu4e-maildir-shortcuts - '((:maildir "/matt@emenel.ca/Inbox" :key ?1 :name "Inbox/matt@emenel.ca") - (:maildir "/matt@emenel.ca/Sent" :key ?2 :name "Sent/matt@emenel.ca") - (:maildir "/matt@emenel.ca/Spam" :key ?3 :name "Spam/matt@emenel.ca") - (:maildir "/admin@studyoftime.org/Inbox" :key ?4 :name "Inbox/admin@studyoftime.org") - (:maildir "/admin@studyoftime.org/Sent" :key ?5 :name "Sent/admin@studyoftime.org") - (:maildir "/admin@studyoftime.org/Spam" :key ?6 :name "Spam/admin@studyoftime.org"))) - - (setq mu4e-alert-email-notification-types '(count)) - - (add-hook! mu4e-compose-mode - (ws-butler-mode -1))) - -(use-package! kbd-mode) - (server-start) diff --git a/mu4e-config.el b/mu4e-config.el new file mode 100644 index 0000000..ce33c77 --- /dev/null +++ b/mu4e-config.el @@ -0,0 +1,166 @@ +;; mu4e +(set-email-account! "matt@emenel.ca" + '((mu4e-sent-folder . "/matt@emenel.ca/Sent") + (mu4e-drafts-folder . "/matt@emenel.ca/Drafts") + (mu4e-trash-folder . "/matt@emenel.ca/Trash") + (mu4e-refile-folder . "/matt@emenel.ca/Archive") + (mu4e-spam-folder . "/matt@emenel.ca/Spam") + (smtpmail-smtp-user . "matt@emenel.ca") + (user-mail-address . "matt@emenel.ca") ;; only needed for mu < 1.4 + (smtpmail-default-smtp-server . "smtp.fastmail.com") + (smtpmail-smtp-server . "smtp.fastmail.com") + (smtpmail-local-domain . "fastmail.com")) + t) + +(set-email-account! "admin@studyoftime.org" + '((mu4e-sent-folder . "/admin@studyoftime.org/Sent") + (mu4e-drafts-folder . "/admin@studyoftime.org/Drafts") + (mu4e-trash-folder . "/admin@studyoftime.org/Trash") + (mu4e-refile-folder . "/admin@studyoftime.org/Archive") + (mu4e-spam-folder . "/admin@studyoftime.org/Spam") + (smtpmail-smtp-user . "admin@studyoftime.org") + (user-mail-address . "admin@studyoftime.org") ;; only needed for mu < 1.4 + (smtpmail-default-smtp-server . "smtp.dreamhost.com") + (smtpmail-smtp-server . "smtp.dreamhost.com") + (smtpmail-local-domain . "dreamhost.com")) + t) + +(defun message-insert-signature-at-point () + "Insert signature at point." + (interactive) + (setq message-signature "Matt Nish-Lapidus\nhttps://emenel.ca") + (save-restriction + (narrow-to-region (point) (point)) + (message-insert-signature) + (newline)) + (setq message-signature nil)) + +(use-package! consult-mu + :defer-incrementally mu4e + :custom + (consult-mu-maxnum 200) + ;;show preview when pressing any keys + (consult-mu-preview-key 'any) + (consult-mu-mark-previewed-as-read nil) + ;;mark email as read when selected. + ;; (consult-mu-mark-viewed-as-read t) + (consult-mu-use-wide-reply t) + + (consult-mu-headers-template (lambda () (concat "%f" (number-to-string (floor (* (frame-width) 0.15))) "%s" (number-to-string (floor (* (frame-width) 0.5))) "%d13" "%g" "%x"))) + (consult-mu-action #'consult-mu--view-action) + + :config + (setq consult-mu-saved-searches-dynamics '("#flag:unread")) + (setq consult-mu-saved-searches-async '("#flag:unread")) + ;; require embark actions for marking, replying, forwarding, etc. directly from minibuffer + (require 'consult-mu-embark) + ;; require extra module for composing (e.g. for interactive attachment) as well as embark actions + (require 'consult-mu-compose) + (require 'consult-mu-compose-embark) + ;; require extra module for searching contacts and runing embark actions on contacts + (require 'consult-mu-contacts) + (require 'consult-mu-contacts-embark) + ;; change the prefiew key for compose so you don't open a preview of every file when selecting files to attach + (setq consult-mu-compose-preview-key "M-o") + ;; pick a key to bind to consult-mu-compose-attach in embark-file-map + (setq consult-mu-embark-attach-file-key "C-a") + (setq consult-mu-contacts-ignore-list '("^.*no.*reply.*")) + (setq consult-mu-contacts-ignore-case-fold-search t) + (consult-mu-compose-embark-bind-attach-file-key) + ;; choose if you want to use dired for attaching files (choice of 'always, 'in-dired, or nil) + (setq consult-mu-compose-use-dired-attachment 'in-dired)) + +(use-package! mu4e + :defer-incrementally t + :config + + ;; Run mu4e in the background to sync mail periodically + ;; (mu4e t) + + (setq mm-discouraged-alternatives '("text/html" "text/richtext")) + + ;; tell meow to start mu4e in motion state + (pushnew! meow-mode-state-list '(mu4e-main-mode . motion)) + + (setq mu4e-update-interval 300 + mu4e-headers-auto-update t) + + (setq + mu4e-index-cleanup t + mu4e-index-lazy-check nil + mu4e-show-images t + message-kill-buffer-on-exit t + mu4e-enable-async-operations t) + + (setq message-citation-line-format "On %e %B %Y at %R %Z, %f wrote:\n") + (setq message-citation-line-function 'message-insert-formatted-citation-line) + + (add-hook 'mu4e-thread-mode-hook #'mu4e-thread-fold-all) + + (set-popup-rule! "*mu4e overview*" :side 'left :size '0.25) + + (setq mu4e-bookmarks nil) + + (setq sendmail-program "/opt/homebrew/bin/msmtp" + send-mail-function 'smtpmail-send-it + message-sendmail-f-is-evil t + message-sendmail-extra-arguments '("--read-envelope-from") + message-send-mail-function 'message-send-mail-with-sendmail) + + (setq mu4e-compose-format-flowed t) + + (setq message-signature nil) + + (add-hook! 'mu4e-compose-mode-hook + (use-hard-newlines -1) + ;; (message-add-header "CC:") + (message-goto-body) + (message-insert-signature-at-point) + (message-goto-body)) + + ;; (setq mu4e-bookmarks + ;; '((:name "Unread messages" :query "flag:unread AND NOT flag:trashed" :key ?i) + ;; (:name "Today's messages" :query "date:today..now" :key ?t) + ;; (:name "The Boss" :query "from:stallman" :key ?s) + ;; (:name "Last 7 days" :query "date:7d..now" :hide-unread t :key ?w) + ;; (:name "Messages with images" :query "mime:image/*" :key ?p))) + + (mu4e-bookmark-define + (concat "flag:unread" + " and not maildir:/matt@emenel.ca/Spam" + " and not maildir:/matt@emenel.ca/Trash" + " and not maildir:/admin@studyoftime.org/Spam" + " and not maildir:/admin@studyoftime.org/Trash") + "All Unread" + ?U) + + (mu4e-bookmark-define + (concat "flag:unread" + " and not maildir:/matt@emenel.ca/Spam" + " and not maildir:/matt@emenel.ca/Trash" + " and not maildir:/matt@emenel.ca/Archive" + " and not maildir:/admin@studyoftime.org/Spam" + " and not maildir:/admin@studyoftime.org/Trash" + " and not maildir:/admin@studyoftime.org/Archive") + "Inboxes Unread" + ?u) + + ;; inboxes + (mu4e-bookmark-define + (concat "maildir:/matt@emenel.ca/Inbox" + " or maildir:/admin@studyoftime.org/Inbox") + "All Inboxes" + ?i) + + (setq mu4e-maildir-shortcuts + '((:maildir "/matt@emenel.ca/Inbox" :key ?1 :name "Inbox/matt@emenel.ca") + (:maildir "/matt@emenel.ca/Sent" :key ?2 :name "Sent/matt@emenel.ca") + (:maildir "/matt@emenel.ca/Spam" :key ?3 :name "Spam/matt@emenel.ca") + (:maildir "/admin@studyoftime.org/Inbox" :key ?4 :name "Inbox/admin@studyoftime.org") + (:maildir "/admin@studyoftime.org/Sent" :key ?5 :name "Sent/admin@studyoftime.org") + (:maildir "/admin@studyoftime.org/Spam" :key ?6 :name "Spam/admin@studyoftime.org"))) + + (setq mu4e-alert-email-notification-types '(count)) + + (add-hook! mu4e-compose-mode + (ws-butler-mode -1))) diff --git a/obsidian-config.el b/obsidian-config.el index 0db4b2d..6452b0f 100644 --- a/obsidian-config.el +++ b/obsidian-config.el @@ -18,21 +18,4 @@ (let* ((title (read-from-minibuffer "Title: " (format-time-string "%Y-%m-%d"))) (filename (s-concat obsidian-directory "/_Journal/" title ".md")) (clean-filename (s-replace "//" "/" filename))) - (find-file (expand-file-name clean-filename) t))) - - (map! :leader - :desc "Obsidian Quick Capture" - "X" #'mnl/obsidian-capture) - - (map! :leader - :prefix "n" - :desc "Jump" "f" #'obsidian-jump - :desc "Search" "s" #'obsidian-search - :desc "Tag Search" "m" #'obsidian-tag-find - :desc "Daily Note" "n" #'mnl/obsidian-capture - :desc "Insert Wikilink" "w" #'obsidian-insert-wikilink - :desc "Backlink Jump" "j" #'obsidian-backlink-jump - :desc "Follow Link" "l" #'obsidian-follow-link-at-point - :desc "Update" "u" #'obsidian-update - "a" nil - "d" nil)) + (find-file (expand-file-name clean-filename) t))))