diff options
| author | tslil clingman <> | 2020-05-18 10:39:54 -0700 |
|---|---|---|
| committer | tslil clingman <> | 2020-05-18 10:39:54 -0700 |
| commit | f229132fe819bd596020451b4f25a5d46a952cdd (patch) | |
| tree | 6af250deccefcbc045db3baf6740d3ed9f61ba2c | |
| parent | 3e2cfdd1063dbfa78244f26b72b36849156777cb (diff) | |
QoL notmuch things
| -rw-r--r-- | emacs/notmuch-config.el | 125 |
1 files changed, 40 insertions, 85 deletions
diff --git a/emacs/notmuch-config.el b/emacs/notmuch-config.el index 1960cd9..184c5f6 100644 --- a/emacs/notmuch-config.el +++ b/emacs/notmuch-config.el @@ -22,12 +22,11 @@ (let ((server (or (cdr (assoc (save-restriction (message-narrow-to-headers) (message-fetch-field "from")) - smtp-from-server-alist)) - "posteo.de"))) + smtp-from-server-alist)) "server"))) (setq smtpmail-smtp-server server smtpmail-stream-type 'ssl smtpmail-smtp-service 465) - (when (string-equal server "smtp.office365.com") + (when (string-equal server "other server") (setq smtpmail-stream-type 'starttls smtpmail-smtp-service 587)) (message "SMTP server changed to %s" server))) @@ -39,13 +38,16 @@ mm-decrypt-option 'always mml-secure-method "pgpmime" mml-default-sign-method "pgpmime" + mml-secure-openpgp-sign-with-sender nil + mml-secure-openpgp-signers '("me@server.tld") notmuch-crypto-process-mime t) (defmacro secure-or-send (&rest body) - `(quote (lambda () - (interactive) + `(quote (lambda (arg) + (interactive "P") (set-smtp-server) - ,@(mapcar #'list body) + (unless arg + ,@(mapcar #'list body)) (notmuch-mua-send-and-exit)))) (define-key notmuch-message-mode-map (kbd "C-c C-S-c") 'message-send-and-exit) @@ -53,26 +55,13 @@ (define-key notmuch-message-mode-map (kbd "C-c M-c") (secure-or-send mml-secure-encrypt)) ;; =================================================================== -;; bbdb stuff -;; (require 'bbdb) -;; (bbdb-initialize) - -;; (setq bbdb-file "~/.bbdb" -;; bbdb-completion-list t -;; bbdb-complete-mail t -;; bbdb-mail-user-agent 'message-user-agent -;; bbdb-complete-mail-allow-cycling t -;; bbdb-mua-pop-up nil -;; bbdb-mua-auto-update-p t) - -;; (add-hook 'notmuch-message-mode-hook (lambda () -;; (add-to-list 'company-backends 'company-bbdb))) - -;; =================================================================== ;; notmuch-hello bindings -(setq notmuch-saved-searches '(list-of-things)) +(setq notmuch-saved-searches '((:name "flagged" :query "tag:flagged") + (:name "sent" :query "tag:sent") + (:name "drafts" :query "tag:draft"))) (defvar notmuch-hello-tree-searches '(("u" . "tag:unread") + ("d" . "tag:drafts") ("s" . "tag:sent") ("f" . "tag:flagged") ("i" . "tag:inbox") @@ -92,8 +81,13 @@ pairs in `binds' of the form ( ... (argfunc arg) body)." (lambda () (interactive) (,argfunc ,(cdr pair)) ,@body))) (eval binds)))) -;;(define-key notmuch-show-mode-map (kbd "R") 'notmuch-show-reply) -;;(define-key notmuch-show-mode-map (kbd "r") 'notmuch-show-reply-sender) +(define-key notmuch-hello-mode-map (kbd "q") + (lambda () + (interactive) + (when (timerp offlineimap--timer) + (cancel-timer offlineimap--timer)) + (notmuch-bury-or-kill-this-buffer))) + (define-key notmuch-search-mode-map (kbd "R") 'notmuch-search-reply-to-thread) (define-key notmuch-search-mode-map (kbd "r") 'notmuch-search-reply-to-thread-sender) (define-key notmuch-tree-mode-map (kbd "R") (lambda () @@ -105,14 +99,6 @@ pairs in `binds' of the form ( ... (argfunc arg) body)." (notmuch-tree-close-message-window) (notmuch-show-reply-sender))) - -(define-key notmuch-hello-mode-map (kbd "q") - (lambda () - (interactive) - (when (timerp offlineimap--timer) - (cancel-timer offlineimap--timer)) - (notmuch-bury-or-kill-this-buffer))) - (make-binds notmuch-hello-mode-map notmuch-hello-tree-searches notmuch-tree) @@ -128,6 +114,22 @@ pairs in `binds' of the form ( ... (argfunc arg) body)." (notmuch-tree-next-message)) ;; =================================================================== +;; I want signatures before quoted text +(defun notmuch-signature-before-body (query-string &optional prompt-for-sender reply-all) + (save-excursion + (message-goto-body) + (newline) + (message-goto-signature) + (when (re-search-backward message-signature-separator nil t) + (if message-signature-insert-empty-line + (forward-line -1)) + (delete-region (point) (point-max)) + (message-goto-body) + (mail-signature t)))) + +(advice-add 'notmuch-mua-new-reply :after #'notmuch-signature-before-body) + +;; =================================================================== ;; notmuch-hello widgets and offlineimap integration (defun notmuch-hello-header-new () (setq fill-column (window-width)) @@ -150,57 +152,8 @@ pairs in `binds' of the form ( ... (argfunc arg) body)." (if (= 1 unread) "is" "are"))) (center-line) (widget-insert "\n"))) -(defun check-and-notify-new-mail () - (notmuch-hello-update t) - (let ((num (string-to-number (car (process-lines - notmuch-command "count" "tag:unread"))))) - (when (< 0 num) - (message (format "New mail! (%s)" num))))) - -(defun offlineimap-output-filter (process string) - "Handle output from offlineimap process." - (let ((buff (process-buffer process))) - (when (buffer-live-p buff) - (with-current-buffer buff - (save-excursion - (goto-char (point-max)) - (insert string))) - (let ((lines (split-string string "\n+" t))) - (cl-loop for line in lines do - (when (string-match-p "added to the database" line) - (check-and-notify-new-mail))))))) - -(defun offlineimap-sentinal (process string) - "Handle the termination of the offlineimap process." - (when (string-equal "finished\n" string) - (let ((buff (process-buffer process))) - (when (buffer-live-p buff) - (with-current-buffer buff - (save-excursion - (goto-char (point-max)) - (insert (format-time-string "--- %d.%m.%y/%H:%M:%S ---\n\n\n")))))) - (check-and-notify-new-mail))) - -(defun offlineimap-run () - "Run offlineimap and report on results." - (let ((proc (start-process "offlineimap-process" - "*offlineimap*" - "offlineimap"))) - (set-process-filter proc 'offlineimap-output-filter) - (set-process-sentinel proc 'offlineimap-sentinal))) - -(defun notmuch-hello-offlineimap () - "Widget to run offlineimap async." - (setq fill-column (window-width)) - (widget-create 'push-button :help-echo "Run offlineimap" - :notify (lambda (&rest nope) - (offlineimap-run)) - "Fetch mail") - (center-line) - (widget-insert "\n")) - (setq notmuch-hello-sections '(notmuch-hello-header-new - notmuch-hello-offlineimap + ;; notmuch-hello-offlineimap notmuch-hello-insert-saved-searches notmuch-hello-insert-search notmuch-hello-insert-alltags)) @@ -228,8 +181,10 @@ running offlineimap (t) or manual (nil).") (add-to-list 'mm-discouraged-alternatives "text/html") (add-to-list 'mm-discouraged-alternatives "text/richtext") -;; I don't actually want w3m anymore -(setq mm-text-html-renderer 'shr) +(use-package w3m :ensure t :defer t) + +(setq mm-text-html-renderer 'w3m) + (add-hook 'message-mode-hook (lambda () (turn-on-auto-fill) |
