doom-conf/config.org

848 lines
26 KiB
Org Mode
Raw Permalink Normal View History

2022-05-05 15:48:43 +02:00
#+title: Doom Emacs literal configuration
2020-05-31 21:14:41 +02:00
#+STARTUP: content
2022-05-05 16:38:39 +02:00
* Table of Contents :TOC_3:noexport:
2020-04-10 17:40:46 +02:00
- [[#misc][Misc]]
- [[#lexical-bindings][Lexical bindings]]
- [[#dir-local-variables][Dir local variables]]
2020-12-25 22:56:15 +01:00
- [[#taking-svg-screenshots][Taking SVG screenshots]]
2020-05-23 12:55:05 +02:00
- [[#theme][Theme]]
- [[#main-theme][Main theme]]
2020-05-23 15:33:17 +02:00
- [[#dark-theme-toggle][Dark theme toggle]]
2020-04-10 17:40:46 +02:00
- [[#font][Font]]
- [[#line-numbers][Line numbers]]
2020-04-15 09:52:00 +02:00
- [[#battery-indicator][Battery indicator]]
2020-04-10 17:40:46 +02:00
- [[#programming][Programming]]
- [[#tridactyl-mode][Tridactyl mode]]
2020-08-03 16:24:17 +02:00
- [[#smart-parens][Smart parens]]
2020-04-10 17:40:46 +02:00
- [[#rust][Rust]]
2020-08-03 17:08:08 +02:00
- [[#column-width][Column width]]
2020-12-31 02:03:49 +01:00
- [[#run-clippy-in-rust-analyzer][Run clippy in rust-analyzer]]
- [[#enable-proc-macro-support][Enable proc macro support]]
2020-04-10 17:40:46 +02:00
- [[#cc][C/C++]]
- [[#default-style][Default style]]
2022-04-10 11:58:04 +02:00
- [[#nix][Nix]]
- [[#formatting][Formatting]]
2022-10-27 20:27:05 +02:00
- [[#lilypond][LilyPond]]
- [[#org-mode][Org mode]]
2020-04-27 23:41:49 +02:00
- [[#directory][Directory]]
2020-05-23 12:55:31 +02:00
- [[#appearance][Appearance]]
- [[#fancier-ellipsis-indicator][Fancier ellipsis indicator]]
2022-04-09 18:18:44 +02:00
- [[#logging][Logging]]
2022-04-09 19:04:47 +02:00
- [[#archiving][Archiving]]
2020-04-11 16:59:02 +02:00
- [[#agenda-setup][Agenda setup]]
- [[#default-task-keywords][Default task keywords]]
- [[#org-capture-setup][Org capture setup]]
- [[#main-agenda-view][Main agenda view]]
- [[#habits][Habits]]
- [[#save-all-org-buffers-shortcut][Save all org buffers shortcut]]
2022-04-11 21:59:34 +02:00
- [[#script-to-open-agenda-window-automatically][Script to open agenda window automatically]]
2020-04-12 22:50:39 +02:00
- [[#roam][Roam]]
- [[#roam-directory][Roam Directory]]
2022-04-11 16:31:33 +02:00
- [[#org-roam-ui][org-roam-ui]]
2020-05-14 00:52:30 +02:00
- [[#export-backends][Export backends]]
2020-04-11 16:59:02 +02:00
- [[#doom-specific][Doom specific]]
2022-05-15 07:06:56 +02:00
- [[#enable-some-link-modules-that-doom-disables-by-default][Enable some link modules that doom disables by default]]
2022-04-11 20:22:23 +02:00
- [[#bugfix][Bugfix]]
2020-10-07 11:09:17 +02:00
- [[#magit][Magit]]
2021-01-03 01:25:10 +01:00
- [[#gitlab-ci-skip-flag][Gitlab CI skip flag]]
2021-03-18 01:14:28 +01:00
- [[#email][Email]]
- [[#account-configuration][Account configuration]]
2022-04-10 00:52:40 +02:00
- [[#sending-mail][Sending mail]]
2022-04-10 00:54:53 +02:00
- [[#reading-plain-text][Reading plain text]]
2022-05-15 07:29:03 +02:00
- [[#org-msg-setup][=org-msg= setup]]
2021-03-18 19:21:57 +01:00
- [[#message-quoting-style][Message quoting style]]
2021-03-30 00:02:54 +02:00
- [[#disable-formatflowed][Disable format=flowed]]
2022-04-10 00:54:53 +02:00
- [[#dont-permanently-delete-when-trashing-mails][Don't permanently delete when trashing mails]]
2021-03-30 00:02:54 +02:00
- [[#add-git-apply-path-to-mu4e-actions][Add git-apply-path to mu4e actions]]
2022-04-11 16:31:48 +02:00
- [[#enable-auto-updates][Enable auto updates]]
- [[#ask-which-address-to-send-with-when-composing-a-new-mail][Ask which address to send with when composing a new mail]]
- [[#only-fetch-main-directories-by-default][Only fetch main directories by default]]
2022-05-05 14:46:06 +02:00
- [[#headers-view-format][Headers view format]]
- [[#message-view-fields][Message view fields]]
- [[#mailing-list-pretty-names][Mailing list pretty names]]
- [[#fix-attachment-icon-with-light-theme][Fix attachment icon with light theme]]
2022-05-05 15:48:35 +02:00
- [[#bookmarks][Bookmarks]]
2022-05-11 12:15:15 +02:00
- [[#apply-marks-on-quit][Apply marks on quit]]
2020-04-10 17:40:46 +02:00
* Misc
** Lexical bindings
Enable lexical binding, of course...
#+BEGIN_SRC emacs-lisp
;;; -*- lexical-binding: t; -*-
#+END_SRC
** Dir local variables
Disable these because I don't use them and don't want to get prompted by them in
some projects.
#+BEGIN_SRC emacs-lisp
(setq enable-dir-local-variables nil)
#+END_SRC
2020-12-25 22:56:15 +01:00
** Taking SVG screenshots
Since Emacs 27, we can take SVG screenshots! Emacs needs to be built with
=cairo= to support this.
#+begin_src emacs-lisp
2022-05-05 14:46:15 +02:00
(defun my/screenshot-svg ()
2020-12-25 22:56:15 +01:00
"Save a screenshot of the current frame as an SVG image.
Saves to a temp file and puts the filename in the kill ring."
(interactive)
2022-05-05 14:46:15 +02:00
(let ((filename (make-temp-file "Emacs" nil ".svg"))
2020-12-25 22:56:15 +01:00
(data (x-export-frames nil 'svg)))
(with-temp-file filename
(insert data))
(kill-new filename)
(message filename)))
#+end_src
2020-05-23 12:55:05 +02:00
* Theme
** Main theme
2020-05-23 12:55:05 +02:00
A list of all doom themes can be found here:
https://github.com/hlissner/emacs-doom-themes
#+BEGIN_SRC emacs-lisp
2022-05-17 20:15:12 +02:00
(setq doom-theme 'doom-one-light)
2020-05-23 12:55:05 +02:00
#+END_SRC
2020-04-10 16:57:07 +02:00
2020-05-23 15:33:17 +02:00
** Dark theme toggle
I've come to prefer using a light theme during the day, and a dark theme at
night. Using a dark theme with daylight leads to cranking up the screen
brightness, which hurts my eyes more than using the light theme.
Set my light and dark themes:
#+BEGIN_SRC emacs-lisp
(setq my/light-theme doom-theme
my/dark-theme 'doom-one)
#+END_SRC
Function to toggle between the two easily:
#+BEGIN_SRC emacs-lisp
(defun my/toggle-dark-theme ()
(interactive)
(if (eq my/dark-theme doom-theme)
(load-theme my/light-theme t)
(load-theme my/dark-theme t)))
#+END_SRC
Bind this to =SPC t d=:
#+BEGIN_SRC emacs-lisp
(map! :leader
(:prefix-map ("t" . "toggle")
:desc "Dark theme" "d" #'my/toggle-dark-theme))
#+END_SRC
2020-04-10 16:57:07 +02:00
** Font
Doom exposes five (optional) variables for controlling fonts in Doom. Here are
the three important ones:
- =doom-font=
- =doom-variable-pitch-font=
- =doom-big-font= -- used for =doom-big-font-mode=; use this for presentations
or streaming.
They all accept either a font-spec, font string (=Input Mono-12=), or xlfd font
string. You generally only need these two:
#+BEGIN_SRC emacs-lisp
2020-04-21 22:03:44 +02:00
(setq doom-font
2021-04-22 17:14:08 +02:00
(font-spec :family "Iosevka Fixed" :size 10.0 :weight 'medium))
2020-04-10 16:57:07 +02:00
#+END_SRC
** Line numbers
Possible values of =display-line-numbers-type= are =nil=, =t=, and ='relative=.
#+BEGIN_SRC emacs-lisp
(setq display-line-numbers-type 'relative)
2020-04-10 16:57:07 +02:00
#+END_SRC
2020-04-15 09:52:00 +02:00
** Battery indicator
I'm on a laptop, so let's display my battery in the modeline:
#+BEGIN_SRC emacs-lisp
(display-battery-mode 1)
#+END_SRC
2020-04-10 16:57:07 +02:00
* Programming
** Tridactyl mode
#+begin_src emacs-lisp
(defvar tridactylrc-font-lock-keywords
`( ;; Line comment
("^[\t ]*\\(\"\\)\\(.*\\)$"
(1 font-lock-comment-delimiter-face)
(2 font-lock-comment-face))
;; Trailing comment
("[\t ]+\\(\"\\)\\([^\"\r\n]*\\)$"
(1 font-lock-comment-delimiter-face)
(2 font-lock-comment-face))
;; String start:
("\\(\"[^\n\r\"]*\"\\)\\|\\('[^\n\r]*'\\)"
(0 font-lock-string-face)) ;; String end;
))
(defvar tridactylrc-mode-syntax-table
(let ((table (make-syntax-table)))
(modify-syntax-entry ?' "\"" table)
(modify-syntax-entry ?\" "<" table)
(modify-syntax-entry ?\n ">" table)
table))
(define-derived-mode tridactylrc-mode prog-mode "tridactylrc"
"Major mode for editing tridactylrc configuration files."
:group 'tridactylrc-mode
:syntax-table tridactylrc-mode-syntax-table
(font-lock-add-keywords nil tridactylrc-font-lock-keywords)
(setq-local comment-start "\"")
(setq-local comment-end ""))
#+end_src
2020-08-03 16:24:17 +02:00
** Smart parens
Disable smart parens because half of the time it doesn't do what I want:
#+BEGIN_SRC emacs-lisp
(remove-hook 'doom-first-buffer-hook #'smartparens-global-mode)
#+END_SRC
2020-04-10 16:57:07 +02:00
** Rust
2020-08-03 17:08:08 +02:00
*** Column width
2020-06-19 23:17:34 +02:00
=rustfmt= limits lines to 100 characters, let's display it correctly.
#+BEGIN_SRC emacs-lisp
2020-12-25 22:56:49 +01:00
(add-hook! rustic-mode
2020-06-19 23:17:34 +02:00
(set-fill-column 100))
#+END_SRC
2020-12-31 02:03:49 +01:00
*** Run clippy in rust-analyzer
The default is ~"check"~, but I want clippy lints as well.
#+begin_src emacs-lisp
(setq lsp-rust-analyzer-cargo-watch-command "clippy")
#+end_src
*** Enable proc macro support
By default lsp-mode disable these, I want them.
#+begin_src emacs-lisp
(setq lsp-rust-analyzer-experimental-proc-attr-macros t)
(setq lsp-rust-analyzer-proc-macro-enable t)
#+end_src
2020-04-10 16:57:07 +02:00
** C/C++
*** Default style
2020-04-10 16:57:07 +02:00
Setup the default format for C/C++ editing.
#+BEGIN_SRC emacs-lisp
(add-hook! (c-mode c++-mode)
(setq c-default-style "gnu")
(setq c-basic-offset 2))
2020-04-10 16:57:07 +02:00
#+END_SRC
2022-04-10 11:58:04 +02:00
** Nix
*** Formatting
Use [[https://github.com/kamadorueda/alejandra][alejandra]] to format Nix code.
#+begin_src emacs-lisp
2024-02-06 11:09:47 +01:00
(set-formatter! 'alejandra '("alejandra" "--quiet") :modes '(nix-mode))
2022-04-10 11:58:04 +02:00
#+end_src
2022-10-27 20:27:05 +02:00
** LilyPond
Just load the lilypond mode
#+begin_src emacs-lisp
(require 'lilypond-init)
#+end_src
2022-04-10 11:58:04 +02:00
* Org mode
2020-04-27 23:41:49 +02:00
** Directory
Set a default directory for all my org-mode files.
#+BEGIN_SRC emacs-lisp
(setq org-directory "~/org/")
#+END_SRC
2020-05-23 12:55:31 +02:00
** Appearance
*** Fancier ellipsis indicator
2020-05-23 12:55:58 +02:00
#+BEGIN_SRC emacs-lisp
(setq org-ellipsis " ▼ ")
#+END_SRC
2022-04-09 18:18:44 +02:00
** Logging
Log state changes in a src_org{:LOGBOOK:} drawer so that it doesn't pollute the main content.
#+begin_src emacs-lisp
(after! org
(setq org-log-into-drawer t))
#+end_src
2022-04-09 19:04:47 +02:00
** Archiving
I don't want to see archival files appearing when listing files in the current
directory, so hide them by default.
#+begin_src emacs-lisp
(after! org
(setq org-archive-location ".%s_archive::"))
#+end_src
2020-04-11 16:59:02 +02:00
** Agenda setup
*** Default task keywords
2020-04-11 23:03:07 +02:00
Here are the [[https://orgmode.org/manual/TODO-Extensions.html#TODO-Extensions][keywords]] I'm using to track task progress. I'm also making use of
some automatic [[https://orgmode.org/manual/Tracking-TODO-state-changes.html#Tracking-TODO-state-changes][state changes]].
2020-05-23 13:02:17 +02:00
| keyword | meaning |
|-------------+----------------------------------------------------------|
| =TODO= | Self explanatory |
| =DONE= | This task is finished, no longer displayed in the agenda |
| =CANCELLED= | This task isn't finished but is no longer relevant |
2020-04-11 23:03:07 +02:00
#+BEGIN_SRC emacs-lisp
(after! org
(setq org-todo-keywords
'((sequence
"TODO(t)"
"|"
"DONE(d!)"
"CANCELLED(c@/!)")
(sequence
"[ ](T)"
"|"
"[X](D)"))))
#+END_SRC
*** Org capture setup
2020-04-11 23:03:07 +02:00
Of course I also need to setup [[https://orgmode.org/manual/Capture-templates.html][capture templates]]:
The first one just prompts me for a new task to add to my inbox, I can then
[[https://orgmode.org/guide/Refile-and-Copy.html][refile]] them where I want later.
The second one exists because I like to keep a separate list of articles /
papers / books to read.
#+BEGIN_SRC emacs-lisp
2020-04-11 16:59:02 +02:00
(after! org
2020-04-11 23:03:07 +02:00
(setq org-capture-templates
2020-05-31 21:24:57 +02:00
'(("t" "New entry" entry (file "inbox.org")
"* TODO %?")
2020-08-27 14:35:36 +02:00
("T" "Task" entry (file+headline "tasks.org" "Misc")
2020-04-11 23:03:07 +02:00
"* TODO %?")
("r" "Reading" entry (file "reading.org")
2020-06-19 10:52:26 +02:00
"* TODO %x"
:immediate-finish t)
("w" "Watching" entry (file "watching.org")
"* TODO %x"
:immediate-finish t))))
2020-04-11 23:03:07 +02:00
#+END_SRC
2020-05-31 21:40:10 +02:00
I also change [[https://github.com/hlissner/doom-emacs/blob/134554dd69d9b1cea3d2190422de580fddf40ecd/modules/config/default/%2Bevil-bindings.el#L265][the default Doom binding]] for ~#'org-capture~ to be =SPC x= instead
of =SPC X=. Also need to rebind what was [[https://github.com/hlissner/doom-emacs/blob/134554dd69d9b1cea3d2190422de580fddf40ecd/modules/config/default/%2Bevil-bindings.el#L264][previously bound]] to =SPC x=, to =SPC
X=.
#+BEGIN_SRC emacs-lisp
(map! :leader
:desc "Org Capture" "x" #'org-capture
:desc "Pop up scratch buffer" "X" #'doom/open-scratch-buffer)
#+END_SRC
*** Main agenda view
2020-04-11 23:03:07 +02:00
All these tasks, once captured, are then centralized in my [[https://orgmode.org/guide/Agenda-Views.html][agenda view]].
I'm using multiple categories to organize tasks, depending on their triage /
status (inspired by [[https://blog.jethro.dev/posts/org_mode_workflow_preview/]]).
#+BEGIN_SRC emacs-lisp
(after! org-agenda
(setq org-agenda-custom-commands
'((" " "Agenda"
((agenda ""
((org-agenda-span 'day)
(org-agenda-start-day nil)
(org-deadline-warning-days 365)))
(todo "TODO"
((org-agenda-overriding-header "Triage")
(org-agenda-files '("~/org/inbox.org"))))
2021-04-06 15:41:02 +02:00
(todo "TODO"
((org-agenda-overriding-header "Job")
(org-agenda-files '("~/org/job.org"))
(org-agenda-skip-function '(org-agenda-skip-entry-if 'deadline
'scheduled))))
2021-08-06 23:09:57 +02:00
(todo "TODO"
((org-agenda-overriding-header "Tasks")
(org-agenda-files '("~/org/tasks.org"))
(org-agenda-skip-function '(org-agenda-skip-entry-if 'deadline
'scheduled))))
2020-04-11 23:03:07 +02:00
)))))
#+END_SRC
I want the default agenda view to be a weekly view, with a log of what I've done
during the day.
#+BEGIN_SRC emacs-lisp
(after! org-agenda
(setq org-agenda-span 'week)
(setq org-agenda-start-on-weekday 1)
(setq org-agenda-start-with-log-mode '(clock)))
#+END_SRC
I also remove the block separators in the agenda view:
#+BEGIN_SRC emacs-lisp
(after! org-agenda
(setq org-agenda-block-separator ""))
#+END_SRC
2020-04-10 18:52:52 +02:00
*** Habits
Let's enable the =org-habit= module:
#+BEGIN_SRC emacs-lisp
(add-to-list 'org-modules 'org-habit)
2022-10-03 16:34:03 +02:00
(after! org-agenda
(setq org-habit-show-all-today t))
#+END_SRC
*** Save all org buffers shortcut
By default bound to =C-x C-s=, rebind it to =SPC m s= in =org-agenda-mode= :
#+BEGIN_SRC emacs-lisp
(map! :after org-agenda
:map org-agenda-mode-map
:localleader
"s" #'org-save-all-org-buffers)
#+END_SRC
2022-04-11 21:59:34 +02:00
*** Script to open agenda window automatically
I use this script to automatically open the agenda when pressing a specific key binding in my window manager.
#+begin_src emacs-lisp :tangle "launch-agenda.el"
(find-file org-directory)
(with-selected-window (split-window-horizontally)
;; need to wait for the window to appear
(sleep-for 0.1)
(org-agenda nil " "))
#+end_src
2020-04-12 22:50:39 +02:00
** Roam
Setup for [[https://github.com/jethrokuan/org-roam][org-roam]].
*** Roam Directory
2020-04-12 22:50:39 +02:00
First, set a directory where =org-roam= will index things.
#+BEGIN_SRC emacs-lisp
(setq org-roam-directory (expand-file-name "notes/" org-directory))
#+END_SRC
2022-04-11 16:31:33 +02:00
*** org-roam-ui
Setup [[https://github.com/org-roam/org-roam-ui][org-roam-ui]]
#+begin_src emacs-lisp
(use-package! websocket
:after org-roam)
(use-package! org-roam-ui
:after org-roam
:config (setq org-roam-ui-sync-theme t
org-roam-ui-follow t
org-roam-ui-update-on-save t
org-roam-ui-open-on-start t))
#+end_src
2020-05-14 00:52:30 +02:00
** Export backends
Sometimes I need to export an Org subtree to a file, which is quite easy with
the =org= export backend. It doesn't seem to be enabled by default, so let's add
it to the list:
#+BEGIN_SRC emacs-lisp
(after! org
(add-to-list 'org-export-backends 'org))
#+END_SRC
2020-04-11 16:59:02 +02:00
** Doom specific
2022-04-07 19:56:33 +02:00
Doom makes some changes to org-id behaviour which I don't like / think are necessary.
#+begin_src emacs-lisp
(after! org
(setq org-id-locations-file (expand-file-name "~/.config/emacs/.org-id-locations"))
(setq org-id-locations-file-relative nil))
#+end_src
2020-04-11 16:59:02 +02:00
Doom replaces the default tab behavior on headings, this restores the default
one. Taken from [[https://github.com/hlissner/doom-emacs/tree/develop/modules/lang/org#hacks][here]].
2020-04-10 18:52:52 +02:00
#+BEGIN_SRC emacs-lisp
2020-04-11 16:59:02 +02:00
(after! evil-org
(remove-hook 'org-tab-first-hook #'+org-cycle-only-current-subtree-h))
2020-04-10 18:52:52 +02:00
#+END_SRC
2020-10-07 11:09:17 +02:00
2022-05-15 07:06:56 +02:00
*** Enable some link modules that doom disables by default
#+begin_src emacs-lisp
(add-to-list 'org-modules 'ol-info)
(add-to-list 'org-modules 'ol-doi)
#+end_src
2022-04-11 20:22:23 +02:00
*** Bugfix
Fix a bug with capture mode not working correctly when agenda is opened, stolen
from https://github.com/hlissner/doom-emacs/issues/5714#issuecomment-1018788028
#+begin_src emacs-lisp
(after! org
(defadvice! dan/+org--restart-mode-h-careful-restart (fn &rest args)
:around #'+org--restart-mode-h
(let ((old-org-capture-current-plist (and (bound-and-true-p org-capture-mode)
(bound-and-true-p org-capture-current-plist))))
(apply fn args)
(when old-org-capture-current-plist
(setq-local org-capture-current-plist old-org-capture-current-plist)
(org-capture-mode +1)))))
#+end_src
2020-10-07 11:09:17 +02:00
* Magit
2021-01-03 01:25:10 +01:00
** Gitlab CI skip flag
This option tells GitLab to skip the CI run for this push, in case I know it's
not ready yet.
2020-10-07 11:09:17 +02:00
#+BEGIN_SRC emacs-lisp
(after! magit
(transient-append-suffix 'magit-push "-n"
'(4 "-s" "Skip GitLab CI" "--push-option=ci.skip")))
#+END_SRC
2021-01-03 01:25:10 +01:00
GitLab push options are documented [[https://docs.gitlab.com/ee/user/project/push_options.html][here]].
2021-03-18 01:14:28 +01:00
* Email
2022-04-26 15:48:14 +02:00
#+begin_src emacs-lisp :noweb no-export
(after! mu4e
<<after-mu4e>>)
#+end_src
2021-03-18 01:14:28 +01:00
** Account configuration
Setup my main email account.
#+begin_src emacs-lisp
2022-04-10 00:52:40 +02:00
(set-email-account! "alarsyo"
'((mu4e-sent-folder . "/alarsyo/Sent")
(mu4e-drafts-folder . "/alarsyo/Drafts")
(mu4e-refile-folder . "/alarsyo/Archive")
(mu4e-trash-folder . "/alarsyo/Trash")
2021-03-18 01:14:28 +01:00
(user-mail-address . "antoine@alarsyo.net")
(user-full-name . "Antoine Martin")
(mu4e-compose-signature . "Antoine Martin"))
t)
2021-03-20 00:32:53 +01:00
(set-email-account! "lrde"
'((mu4e-sent-folder . "/lrde/Sent")
(mu4e-drafts-folder . "/lrde/Drafts")
(mu4e-trash-folder . "/lrde/Trash")
(user-mail-address . "amartin@lrde.epita.fr")
(user-full-name . "Antoine Martin")
(mu4e-compose-signature . "Antoine Martin"))
nil)
2022-05-09 01:37:39 +02:00
(set-email-account! "prologin"
'((mu4e-sent-folder . "/prologin/Sent")
(mu4e-drafts-folder . "/prologin/Drafts")
(mu4e-trash-folder . "/prologin/Trash")
(user-mail-address . "antoine.martin@prologin.org")
(user-full-name . "Antoine Martin")
(mu4e-compose-signature . "Antoine Martin"))
nil)
2021-03-18 01:14:28 +01:00
#+end_src
2022-04-10 00:52:40 +02:00
** Sending mail
I use =msmtp= as a SMTP forwarder
2022-04-26 15:48:14 +02:00
#+begin_src emacs-lisp :noweb-ref after-mu4e :tangle no
(setq sendmail-program (executable-find "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)
2022-04-10 00:52:40 +02:00
#+end_src
I don't want something like ~ws-butler~ to mess with my formatting, especially
the trailing space after a signature delimiter:
#+BEGIN_SRC emacs-lisp
(add-hook! mu4e-compose-mode
(ws-butler-mode -1))
#+END_SRC
2022-04-10 00:54:53 +02:00
** Reading plain text
Ask the =gnus-view= (default viewer used by =mu4e=) to avoid HTML whenever
possible.
2022-04-26 15:48:14 +02:00
#+begin_src emacs-lisp :noweb-ref after-mu4e :tangle no
(add-to-list 'mm-discouraged-alternatives "text/html")
(add-to-list 'mm-discouraged-alternatives "text/richtext")
2022-04-10 00:54:53 +02:00
#+end_src
2022-05-15 07:29:03 +02:00
** =org-msg= setup
2021-03-18 01:14:28 +01:00
Add =-:nil= to the export options list, otherwise the =--= in the signature gets
converted to a single hyphen when exporting to utf-8. See [[info:org#Export settings]]
2021-03-18 01:14:28 +01:00
2022-05-15 07:29:03 +02:00
#+begin_src emacs-lisp :noweb-ref after-mu4e :tangle no
(setq org-msg-options (concat org-msg-options " -:nil"))
2022-05-15 07:29:03 +02:00
#+end_src
Setup signature as well. The double backslashes are there to make sure that the
linebreak is preserved even in the html export, which otherwise wraps the
signature lines as a single paragraph.
2022-05-15 07:29:03 +02:00
#+begin_src emacs-lisp :noweb-ref after-mu4e :tangle no
(setq org-msg-signature "\n#+begin_signature\n-- \\\\\nAntoine Martin\n#+end_signature")
#+end_src
I don't want to send HTML emails at all unless I choose to explicitely.
#+begin_src emacs-lisp :noweb-ref after-mu4e :tangle no
(setq org-msg-default-alternatives '((new utf-8)
(reply-to-text utf-8)
(reply-to-html utf-8)))
2021-03-18 01:14:28 +01:00
#+end_src
2021-03-18 19:21:57 +01:00
** Message quoting style
Has to be duplicated because =mu4e= doesn't use ~message-cite-style~'s values.
#+begin_src emacs-lisp
(defconst message-cite-style-custom
'((message-cite-function 'message-cite-original-without-signature)
(message-citation-line-function 'message-insert-formatted-citation-line)
(message-cite-reply-position 'traditional)
(message-yank-prefix "> ")
(message-yank-cited-prefix "> ")
(message-yank-empty-prefix ">")
(message-citation-line-format "%f writes:"))
"Message citation style used for email. Use with `message-cite-style'.")
(after! message
(setq message-cite-style message-cite-style-custom
message-cite-function 'message-cite-original-without-signature
message-citation-line-function 'message-insert-formatted-citation-line
message-cite-reply-position 'traditional
message-yank-prefix "> "
message-yank-cited-prefix "> "
message-yank-empty-prefix ">"
message-citation-line-format "%f writes:"))
#+end_src
2021-03-30 00:02:54 +02:00
2022-04-10 00:54:53 +02:00
** Disable format=flowed
2021-03-30 00:02:54 +02:00
2022-04-26 15:48:14 +02:00
#+begin_src emacs-lisp :noweb-ref after-mu4e :tangle no
(setq mu4e-compose-format-flowed nil)
2021-03-30 00:02:54 +02:00
#+end_src
2022-04-10 00:54:53 +02:00
** Don't permanently delete when trashing mails
By default =mu4e= sets the =trashed= flag on emails trashed using the =d=
keybinding. This just replaces the action to just move the message to the trash
instead.
See https://github.com/djcb/mu/issues/1136#issuecomment-1066303788, the code
will have to be adapted soon.
2021-03-30 00:02:54 +02:00
2022-04-26 15:48:14 +02:00
#+begin_src emacs-lisp :noweb-ref after-mu4e :tangle no
(setf (alist-get 'trash mu4e-marks)
(list :char '("d" . "▼")
:prompt "dtrash"
:dyn-target (lambda (target msg)
(mu4e-get-trash-folder msg))
:action (lambda (docid msg target)
2022-07-23 18:12:31 +02:00
(mu4e--server-move
docid (mu4e--mark-check-target target) "-N"))))
2021-03-30 00:02:54 +02:00
#+end_src
** Add git-apply-path to mu4e actions
2022-04-26 15:48:14 +02:00
#+begin_src emacs-lisp :noweb-ref after-mu4e :tangle no
;; TODO: upstream this, Doom emacs adds a view in browser action but it seems
;; to be present by default now.
(setq mu4e-view-actions
(remove '("View in browser" . mu4e-action-view-in-browser) mu4e-view-actions))
(add-to-list 'mu4e-view-actions
'("GitApply" . mu4e-action-git-apply-patch) t)
(add-to-list 'mu4e-view-actions
'("MboxGitApply" . mu4e-action-git-apply-mbox) t)
2021-03-30 00:02:54 +02:00
#+end_src
2022-04-11 16:31:48 +02:00
** Enable auto updates
2022-05-05 14:46:06 +02:00
=mu4e= refreshes my email in the background.
2022-04-26 15:48:14 +02:00
#+begin_src emacs-lisp :noweb-ref after-mu4e :tangle no
(setq mu4e-update-interval 900)
2022-04-11 16:31:48 +02:00
#+end_src
2022-05-05 14:46:06 +02:00
If it fetches new mail while I'm browsing some messages, it will refresh the
headers view, potentially loosing context (like some messages that got marked as
read because I skimmed over them, but that I don't want to see disappear yet).
So let's disable this automatic update of headers:
2022-04-11 16:31:48 +02:00
2022-04-26 15:48:14 +02:00
#+begin_src emacs-lisp :noweb-ref after-mu4e :tangle no
2022-05-05 14:46:06 +02:00
(setq mu4e-headers-auto-update nil)
2022-04-11 16:31:48 +02:00
#+end_src
Additionally, don't show all new mail in the modeline, only relevant ones:
#+begin_src emacs-lisp :noweb-ref after-mu4e :tangle no
(setq mu4e-alert-interesting-mail-query "flag:unread AND NOT flag:list")
#+end_src
2022-05-05 14:46:06 +02:00
** Ask which address to send with when composing a new mail
#+begin_src emacs-lisp :noweb-ref after-mu4e :tangle no
2022-05-05 14:46:06 +02:00
(setq mu4e-compose-context-policy 'ask)
#+end_src
** Only fetch main directories by default
I have a lot (100+) directories on my main email account, I only want to fetch
the "important" ones (i.e. those coming from real individuals, addressed to me
directly) when I ask for a refresh explicitely (updating everything in the
background is fine the rest of the time).
Let's define a new function that does just that:
#+begin_src emacs-lisp :noweb-ref after-mu4e :tangle no
(defun my/mu4e-update-main-mail-and-index (run-in-background)
"Get mail for all folders, not just the main ones"
(interactive "P")
2022-05-09 01:37:39 +02:00
(let ((mu4e-get-mail-command "mbsync alarsyo-main lrde prologin-main"))
(mu4e-update-mail-and-index run-in-background)))
#+end_src
Let's also bind it to =u= in the main view, overriding the default binding
(which I'll remap to =U=).
#+begin_src emacs-lisp :noweb-ref after-mu4e :tangle no
(map! :map mu4e-main-mode-map
:ne "u" #'my/mu4e-update-main-mail-and-index
:ne "U" #'mu4e-update-mail-and-index)
#+end_src
2022-05-05 14:46:06 +02:00
** Headers view format
Use "french" date format in header view:
#+begin_src emacs-lisp :noweb-ref after-mu4e :tangle no
(setq mu4e-headers-date-format "%d/%m/%y")
#+end_src
Set the time display to 24h:
#+begin_src emacs-lisp :noweb-ref after-mu4e :tangle no
(setq mu4e-headers-time-format "%T")
#+end_src
Setup the headers view columns how I like them
#+begin_src emacs-lisp :noweb-ref after-mu4e :tangle no
(setq mu4e-headers-fields '((:account-stripe . 1)
;; just enough room for dd/mm/yy or hh:mm:ss
(:human-date . 8)
(:flags . 6)
(:mailing-list . 30)
2024-02-06 11:09:18 +01:00
(:maildir . 30)
2022-05-05 14:46:06 +02:00
(:from-or-to . 30)
(:subject)))
#+end_src
** Message view fields
#+begin_src emacs-lisp :noweb-ref after-mu4e :tangle no
(setq mu4e-view-fields '(:from :to :cc :subject :flags :date :mailing-list :maildir :path :size :tags :attachments :user-agent :signature :decryption))
#+end_src
** Mailing list pretty names
#+begin_src emacs-lisp :noweb-ref after-mu4e :tangle no
(setq mu4e-mailing-list-patterns '("[0-9]+\\.\\(.+\\)\\.gitlab\\.lrde\\.epita\\.fr"
"[0-9]+\\.\\(.+\\)\\.gitlab\\.com"
2022-05-09 01:37:39 +02:00
"\\(.+\\)\\.github\\.com")
mu4e-user-mailing-lists '(("info.prologin.org" . "Infos Prologin")
("membres.ml.prologin.org" . "Membres Prologin")))
2022-05-05 14:46:06 +02:00
#+end_src
** Fix attachment icon with light theme
#+begin_src emacs-lisp :noweb-ref after-mu4e :tangle no
(setq mu4e-headers-attach-mark (cons "a" (+mu4e-normalised-icon "file-text-o" :color "cyan")))
#+end_src
2022-05-05 15:48:35 +02:00
** Bookmarks
Let's not display messages from mailing lists in main views, leave them to specific bookmarks.
#+begin_src emacs-lisp :noweb-ref after-mu4e :tangle no
(setq mu4e-bookmarks '((:name "Unread messages" :query "flag:unread AND NOT flag:list" :key ?u)
(:name "Today's messages" :query "date:today..now AND NOT flag:list" :key ?t)
(:name "Last 7 days" :query "date:7d..now AND NOT flag:list" :hide-unread t :key ?w)
(:name "Messages with images" :query "mime:image/* AND NOT flag:list" :key ?p)
(:name "All unread messages" :query "flag:unread AND NOT maildir:/prologin/*" :key ?U)
(:name "All Prologin messages" :query "flag:unread AND maildir:/prologin/*" :key ?P)
2022-05-05 15:48:35 +02:00
(:name "Today's messages (lists included)" :query "date:today..now" :key ?T)
(:name "Last 7 days (lists included)" :query "date:7d..now" :hide-unread t :key ?W)
(:name "Orgmode mailing list new posts" :query "list:emacs-orgmode.gnu.org AND flag:unread" :key ?o)
(:name "All messages with images" :query "mime:image/*" :key ?P)))
#+end_src
2022-05-11 12:15:15 +02:00
** Apply marks on quit
I don't want confirm to apply marks everytime I quit the headers view.
#+begin_src emacs-lisp :noweb-ref after-mu4e :tangle no
(setq mu4e-headers-leave-behavior 'apply)
#+end_src