added executable check for mu4e during loading
This commit is contained in:
parent
b82bdedb81
commit
0c71282f98
247
conf.org
247
conf.org
|
@ -111,12 +111,19 @@ event of an error or nonlocal exit."
|
||||||
(defmacro nd/when-os (os &rest body)
|
(defmacro nd/when-os (os &rest body)
|
||||||
"Execute BODY if the operating system is OS.
|
"Execute BODY if the operating system is OS.
|
||||||
OS is one of those in `system-type'."
|
OS is one of those in `system-type'."
|
||||||
`(when (eq system-type os) ,@body))
|
`(if (eq system-type ,os) (progn ,@body)
|
||||||
|
(print "Skipping OS-restricted code")))
|
||||||
|
|
||||||
(defmacro nd/when-not-os (os &rest body)
|
(defmacro nd/when-not-os (os &rest body)
|
||||||
"Execute BODY if the operating system is not OS.
|
"Execute BODY if the operating system is not OS.
|
||||||
OS is one of those in `system-type'."
|
OS is one of those in `system-type'."
|
||||||
`(when (not (eq system-type os)) ,@body))
|
`(when (not (eq system-type ,os)) (progn ,@body)
|
||||||
|
(print "Skipping OS-restricted code")))
|
||||||
|
|
||||||
|
(defmacro nd/when-bin (bin &rest body)
|
||||||
|
"Execute BODY if the program BIN exists."
|
||||||
|
`(if (executable-find ,bin) (progn ,@body)
|
||||||
|
(print (format "Executable %s not found. Skipping." ,bin))))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** functions
|
** functions
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
@ -469,6 +476,10 @@ Some prompts require literal "yes" or "no" to decide action. Life is short and I
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
* low-level config
|
* low-level config
|
||||||
General configuation for behind-the-scenes behavior
|
General configuation for behind-the-scenes behavior
|
||||||
|
** user information
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(setq user-full-name "Dwarshuis, Nathan J")
|
||||||
|
#+END_SRC
|
||||||
** autosave
|
** autosave
|
||||||
Saving files continuously is actually really annoying and clutters my disk. Turn it off.
|
Saving files continuously is actually really annoying and clutters my disk. Turn it off.
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
@ -3376,11 +3387,13 @@ make sizes human readable
|
||||||
*** mu4e attachments
|
*** mu4e attachments
|
||||||
By default the included gnus-dired package does not understan mu4e, so override the existing =gnus-dired-mail-buffers= function to fix. This allows going to a dired buffer, marking files, and attaching them interactively to mu4e draft buffers.
|
By default the included gnus-dired package does not understan mu4e, so override the existing =gnus-dired-mail-buffers= function to fix. This allows going to a dired buffer, marking files, and attaching them interactively to mu4e draft buffers.
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
;; from here:
|
(nd/when-bin
|
||||||
;; https://www.djcbsoftware.nl/code/mu/mu4e/Dired.html#Dired
|
"mu"
|
||||||
(require 'gnus-dired)
|
;; from here:
|
||||||
|
;; https://www.djcbsoftware.nl/code/mu/mu4e/Dired.html#Dired
|
||||||
|
(require 'gnus-dired)
|
||||||
|
|
||||||
(eval-after-load 'gnus-dired
|
(eval-after-load 'gnus-dired
|
||||||
'(defun gnus-dired-mail-buffers ()
|
'(defun gnus-dired-mail-buffers ()
|
||||||
"Return a list of active mu4e message buffers."
|
"Return a list of active mu4e message buffers."
|
||||||
(let (buffers)
|
(let (buffers)
|
||||||
|
@ -3392,8 +3405,8 @@ By default the included gnus-dired package does not understan mu4e, so override
|
||||||
(push (buffer-name buffer) buffers))))
|
(push (buffer-name buffer) buffers))))
|
||||||
(nreverse buffers))))
|
(nreverse buffers))))
|
||||||
|
|
||||||
(setq gnus-dired-mail-mode 'mu4e-user-agent)
|
(setq gnus-dired-mail-mode 'mu4e-user-agent)
|
||||||
(add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode)
|
(add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
*** directory sized
|
*** directory sized
|
||||||
By default dired uses =ls -whatever= to get its output. This does not have recursive directory contents by default. This nitfy package solves this. This is not on default because navigation is much slower and the du output adds very little in many situations (toggle when needed).
|
By default dired uses =ls -whatever= to get its output. This does not have recursive directory contents by default. This nitfy package solves this. This is not on default because navigation is much slower and the du output adds very little in many situations (toggle when needed).
|
||||||
|
@ -3441,108 +3454,62 @@ Filtering is useful for obvious reasons
|
||||||
:ensure t)
|
:ensure t)
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** mu4e
|
** mu4e
|
||||||
*** basic
|
Since mu4e is an external program, need to check that it is installed before loading anything.
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(require 'mu4e)
|
(nd/when-bin
|
||||||
|
"mu"
|
||||||
(setq mail-user-agent 'mu4e-user-agent
|
(require 'mu4e)
|
||||||
mu4e-maildir "/mnt/data/Mail"
|
(setq mail-user-agent 'mu4e-user-agent
|
||||||
|
|
||||||
mu4e-attachment-dir "~/Downloads"
|
|
||||||
|
|
||||||
mu4e-view-show-images t
|
|
||||||
mu4e-headers-show-target nil
|
|
||||||
|
|
||||||
mu4e-view-show-addresses t
|
|
||||||
|
|
||||||
message-kill-buffer-on-exit t
|
message-kill-buffer-on-exit t
|
||||||
|
|
||||||
|
;; misc
|
||||||
mu4e-change-filenames-when-moving t
|
mu4e-change-filenames-when-moving t
|
||||||
|
|
||||||
mu4e-confirm-quit nil
|
mu4e-confirm-quit nil
|
||||||
|
|
||||||
mu4e-view-prefer-html t
|
|
||||||
|
|
||||||
mu4e-compose-dont-reply-to-self t
|
mu4e-compose-dont-reply-to-self t
|
||||||
|
|
||||||
mu4e-get-mail-command "systemctl --user start mbsync"
|
mu4e-get-mail-command "systemctl --user start mbsync"
|
||||||
|
mu4e-use-fancy-chars nil
|
||||||
|
|
||||||
user-full-name "Dwarshuis, Nathan J")
|
;; directories
|
||||||
#+END_SRC
|
mu4e-maildir "/mnt/data/Mail"
|
||||||
*** headers view
|
mu4e-attachment-dir "~/Downloads"
|
||||||
#+BEGIN_SRC emacs-lisp
|
|
||||||
(setq mu4e-headers-fields '((:human-date . 11)
|
;; headers
|
||||||
|
mu4e-headers-show-target nil
|
||||||
|
mu4e-headers-fields '((:human-date . 11)
|
||||||
(:flags . 5)
|
(:flags . 5)
|
||||||
(:from . 22)
|
(:from . 22)
|
||||||
(:thread-subject))
|
(:thread-subject))
|
||||||
mu4e-headers-date-format "%F"
|
mu4e-headers-date-format "%F"
|
||||||
mu4e-headers-time-format "%R"
|
mu4e-headers-time-format "%R"
|
||||||
mu4e-use-fancy-chars nil)
|
|
||||||
#+END_SRC
|
|
||||||
*** citing
|
|
||||||
The citation line should enable history folding in outlook. This is enabled by using 32 underscores followed by the addressing info of the previous message(s).
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
|
||||||
;; necessary for the header macros below
|
|
||||||
(require 'nnheader)
|
|
||||||
|
|
||||||
(defun nd/message-insert-citation-header ()
|
;; view
|
||||||
"Insert the header of the reply message."
|
mu4e-view-show-images t
|
||||||
(let* ((h message-reply-headers)
|
mu4e-view-show-addresses t
|
||||||
(sep "________________________________")
|
mu4e-view-prefer-html t
|
||||||
(from (concat "From: " (mail-header-from h)))
|
|
||||||
(date (concat "Sent: " (mail-header-date h)))
|
|
||||||
(to (concat "To: " user-full-name))
|
|
||||||
(subj (concat "Subject: " (message-strip-subject-re (mail-header-subject h)))))
|
|
||||||
(insert (string-join `("" ,sep ,from ,date ,to ,subj "") "\n"))))
|
|
||||||
|
|
||||||
(setq message-citation-line-function 'nd/message-insert-citation-header)
|
;; compose
|
||||||
#+END_SRC
|
mu4e-compose-signature-auto-include nil ;; sigs are annoying by default
|
||||||
|
mu4e-compose-signature
|
||||||
|
(string-join
|
||||||
|
'("Nathan Dwarshuis"
|
||||||
|
""
|
||||||
|
"PhD Student - Biomedical Engineering - Krish Roy Lab"
|
||||||
|
"Georgia Institute of Technology and Emory University"
|
||||||
|
"ndwarshuis3@gatech.edu")
|
||||||
|
"\n")
|
||||||
|
|
||||||
The default "> " things are annoying when citing old messages.
|
;; yanking (aka citing)
|
||||||
#+BEGIN_SRC emacs-lisp
|
message-yank-prefix "" ;; the ">" characters are annoying
|
||||||
(setq message-yank-prefix "")
|
message-yank-cited-prefix ""
|
||||||
(setq message-yank-cited-prefix "")
|
message-yank-empty-prefix ""
|
||||||
(setq message-yank-empty-prefix "")
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
By default the citation is destroyed (as in totally textified) if it is HTML. I want the links to be preserved, so use html2text and set arguments accordingly. Note that =--body-width=0= is necessary to prevent line breaks from being inserted in the middle of links.
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
;; contexts (multiple inboxes)
|
||||||
(setq
|
mu4e-context-policy 'pick-first
|
||||||
mu4e-compose-pre-hook
|
|
||||||
(lambda ()
|
|
||||||
(let* ((msg mu4e-compose-parent-message)
|
|
||||||
(html (and msg (plist-get msg :body-html)))
|
|
||||||
;; oops, mu4e screwed up
|
|
||||||
(mu4e-html2text-command
|
|
||||||
(if (file-exists-p "/usr/bin/html2text")
|
|
||||||
"html2text --ignore-emphasis --images-to-alt --body-width=0"
|
|
||||||
'mu4e-shr2text)))
|
|
||||||
(when (and html mu4e-view-prefer-html (member compose-type '(reply forward)))
|
|
||||||
;; hackity hack, since the normal mu4e-message-body-text function
|
|
||||||
;; does not render the desired html, do it here and force the
|
|
||||||
;; aforementioned function to only look at text by removing
|
|
||||||
;; the html
|
|
||||||
(plist-put msg :body-txt (mu4e~html2text-shell msg mu4e-html2text-command))
|
|
||||||
(plist-put msg :body-html nil)))))
|
|
||||||
#+END_SRC
|
|
||||||
*** smtp
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
|
||||||
(require 'smtpmail)
|
|
||||||
;; (require 'smtpmail-async)
|
|
||||||
;; (require 'secrets)
|
|
||||||
;; (setq secrets-enabled t)
|
|
||||||
(setq send-mail-function 'smtpmail-send-it
|
|
||||||
message-send-mail-function 'smtpmail-send-it)
|
|
||||||
(add-to-list 'auth-sources (expand-file-name "~/.emacs.d/.authinfo_mu4e.gpg"))
|
|
||||||
;; (add-to-list 'auth-sources "secrets:default")
|
|
||||||
#+END_SRC
|
|
||||||
*** contexts
|
|
||||||
I have current have three contexts, personal and two work accounts. The first is a gmail account and the second/third are office365 accounts.
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
|
||||||
(setq mu4e-context-policy 'pick-first
|
|
||||||
mu4e-compose-context-policy 'ask-if-none
|
mu4e-compose-context-policy 'ask-if-none
|
||||||
mu4e-user-mail-address-list '("natedwarshuis@gmail.com" "ndwarshuis3@gatech.edu" "ndwarsh@emory.edu")
|
mu4e-user-mail-address-list '("natedwarshuis@gmail.com"
|
||||||
|
"ndwarshuis3@gatech.edu"
|
||||||
|
"ndwarsh@emory.edu")
|
||||||
mu4e-contexts
|
mu4e-contexts
|
||||||
`( ,(make-mu4e-context
|
`( ,(make-mu4e-context
|
||||||
:name "personal"
|
:name "personal"
|
||||||
|
@ -3613,44 +3580,67 @@ I have current have three contexts, personal and two work accounts. The first is
|
||||||
("/emory/trash" . ?t)
|
("/emory/trash" . ?t)
|
||||||
("/emory/drafts" . ?d)
|
("/emory/drafts" . ?d)
|
||||||
("/emory/archive" . ?a)))))))
|
("/emory/archive" . ?a)))))))
|
||||||
#+END_SRC
|
|
||||||
*** org-mu4e
|
;; enable visual line mode and spell checking
|
||||||
#+BEGIN_SRC emacs-lisp
|
(add-hook 'mu4e-compose-mode-hook 'turn-off-auto-fill)
|
||||||
(use-package org-mu4e
|
(add-hook 'mu4e-compose-mode-hook 'visual-line-mode)
|
||||||
|
(add-hook 'mu4e-view-mode-hook 'turn-off-auto-fill)
|
||||||
|
(add-hook 'mu4e-view-mode-hook 'visual-line-mode)
|
||||||
|
(add-hook 'mu4e-compose-mode-hook (lambda () (flyspell-mode 1)))
|
||||||
|
|
||||||
|
;; Outlook doesn't know how to fold mu4e messages by default.
|
||||||
|
;; This is enabled by using 32 underscores followed by the addressing
|
||||||
|
;; info of the previou message(s).
|
||||||
|
(require 'nnheader) ; necessary for the header macros below
|
||||||
|
|
||||||
|
(defun nd/message-insert-citation-header ()
|
||||||
|
"Insert the header of the reply message."
|
||||||
|
(let* ((h message-reply-headers)
|
||||||
|
(sep "________________________________")
|
||||||
|
(from (concat "From: " (mail-header-from h)))
|
||||||
|
(date (concat "Sent: " (mail-header-date h)))
|
||||||
|
(to (concat "To: " user-full-name))
|
||||||
|
(subj (concat "Subject: " (message-strip-subject-re (mail-header-subject h)))))
|
||||||
|
(insert (string-join `("" ,sep ,from ,date ,to ,subj "") "\n"))))
|
||||||
|
|
||||||
|
(setq message-citation-line-function 'nd/message-insert-citation-header)
|
||||||
|
|
||||||
|
;; prevent html to text conversion from destroying links
|
||||||
|
(setq
|
||||||
|
mu4e-compose-pre-hook
|
||||||
|
(lambda ()
|
||||||
|
(let* ((msg mu4e-compose-parent-message)
|
||||||
|
(html (and msg (plist-get msg :body-html)))
|
||||||
|
;; oops, mu4e screwed up
|
||||||
|
(mu4e-html2text-command
|
||||||
|
(if (executable-find "html2text")
|
||||||
|
"html2text --ignore-emphasis --images-to-alt --body-width=0"
|
||||||
|
'mu4e-shr2text)))
|
||||||
|
(when (and html mu4e-view-prefer-html (member compose-type '(reply forward)))
|
||||||
|
;; hackity hack, since the normal mu4e-message-body-text function
|
||||||
|
;; does not render the desired html, do it here and force the
|
||||||
|
;; aforementioned function to only look at text by removing
|
||||||
|
;; the html
|
||||||
|
(plist-put msg :body-txt (mu4e~html2text-shell msg mu4e-html2text-command))
|
||||||
|
(plist-put msg :body-html nil)))))
|
||||||
|
|
||||||
|
(require 'smtpmail)
|
||||||
|
;; (require 'smtpmail-async)
|
||||||
|
;; (require 'secrets)
|
||||||
|
;; (setq secrets-enabled t)
|
||||||
|
;; (add-to-list 'auth-sources "secrets:default")
|
||||||
|
(setq send-mail-function 'smtpmail-send-it
|
||||||
|
message-send-mail-function 'smtpmail-send-it)
|
||||||
|
(add-to-list 'auth-sources (expand-file-name "~/.emacs.d/.authinfo_mu4e.gpg"))
|
||||||
|
|
||||||
|
(use-package org-mu4e
|
||||||
:after (org mu4e)
|
:after (org mu4e)
|
||||||
:config
|
:config
|
||||||
(setq
|
(setq
|
||||||
;; for using mu4e in org-capture templates
|
;; for using mu4e in org-capture templates
|
||||||
org-mu4e-link-query-in-headers-mode nil
|
org-mu4e-link-query-in-headers-mode nil
|
||||||
;; for composing rich-text emails using org mode
|
;; for composing rich-text emails using org mode
|
||||||
org-mu4e-convert-to-html t))
|
org-mu4e-convert-to-html t)))
|
||||||
#+END_SRC
|
|
||||||
*** signature
|
|
||||||
Signatures take lots of space and make short messages look needlessly clunky, so keep off by default.
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
|
||||||
(setq mu4e-compose-signature-auto-include nil
|
|
||||||
|
|
||||||
mu4e-compose-signature
|
|
||||||
(string-join
|
|
||||||
'("Nathan Dwarshuis"
|
|
||||||
""
|
|
||||||
"PhD Student - Biomedical Engineering - Krish Roy Lab"
|
|
||||||
"Georgia Institute of Technology and Emory University"
|
|
||||||
"ndwarshuis3@gatech.edu")
|
|
||||||
"\n"))
|
|
||||||
#+END_SRC
|
|
||||||
*** visual-line-mode
|
|
||||||
By default mu4e adds breaks after 80-ish chars using auto-fill-mode which makes messages look weird when opened. =Visual-line-mode= avoids this problem.
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
|
||||||
(add-hook 'mu4e-compose-mode-hook 'turn-off-auto-fill)
|
|
||||||
(add-hook 'mu4e-compose-mode-hook 'visual-line-mode)
|
|
||||||
(add-hook 'mu4e-view-mode-hook 'turn-off-auto-fill)
|
|
||||||
(add-hook 'mu4e-view-mode-hook 'visual-line-mode)
|
|
||||||
#+END_SRC
|
|
||||||
*** flyspell
|
|
||||||
Spell checking is generally a good idea when writing to pointy-haired bosses.
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
|
||||||
(add-hook 'mu4e-compose-mode-hook (lambda () (flyspell-mode 1)))
|
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** shell
|
** shell
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
|
@ -4027,8 +4017,10 @@ These are for mode-specific bindings that can/should be outside of the evil maps
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
*** mu4e
|
*** mu4e
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(define-key mu4e-headers-mode-map (kbd "C-c C-l") 'org-store-link)
|
(nd/when-bin
|
||||||
(define-key mu4e-view-mode-map (kbd "C-c C-l") 'org-store-link)
|
"mu"
|
||||||
|
(define-key mu4e-headers-mode-map (kbd "C-c C-l") 'org-store-link)
|
||||||
|
(define-key mu4e-view-mode-map (kbd "C-c C-l") 'org-store-link))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
*** dired
|
*** dired
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
@ -4068,10 +4060,11 @@ The function keys are nice because they are almost (not always) free in every mo
|
||||||
(global-set-key (kbd "C-<f3>") 'nd/org-cluster-show-conflicts)
|
(global-set-key (kbd "C-<f3>") 'nd/org-cluster-show-conflicts)
|
||||||
(global-set-key (kbd "C-S-<f3>") 'nd/org-cluster-show-overloads)
|
(global-set-key (kbd "C-S-<f3>") 'nd/org-cluster-show-overloads)
|
||||||
(global-set-key (kbd "<f4>") 'org-clock-goto)
|
(global-set-key (kbd "<f4>") 'org-clock-goto)
|
||||||
|
(global-set-key (kbd "C-<f4>") 'nd/org-tomato-user-get-summary)
|
||||||
(global-set-key (kbd "<f5>") 'ansi-term)
|
(global-set-key (kbd "<f5>") 'ansi-term)
|
||||||
(global-set-key (kbd "<f8>") 'helm-command-prefix)
|
(global-set-key (kbd "<f8>") 'helm-command-prefix)
|
||||||
(global-set-key (kbd "C-<f5>") 'nd/open-urxvt)
|
(global-set-key (kbd "C-<f5>") 'nd/open-urxvt)
|
||||||
(global-set-key (kbd "<f12>") 'mu4e)
|
(nd/when-bin "mu" (global-set-key (kbd "<f12>") 'mu4e))
|
||||||
(global-set-key (kbd "C-<f12>") 'global-hl-line-mode)
|
(global-set-key (kbd "C-<f12>") 'global-hl-line-mode)
|
||||||
(global-set-key (kbd "S-<f12>") 'display-line-numbers-mode)
|
(global-set-key (kbd "S-<f12>") 'display-line-numbers-mode)
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
Loading…
Reference in New Issue