summaryrefslogtreecommitdiff
path: root/.config
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2024-08-21 20:32:02 +0300
committerThanos Apollo <[email protected]>2024-08-21 20:32:02 +0300
commit3b0510539d70ec614043bf2374c26f6de7530ec2 (patch)
tree33c19750b5878128fb7e68f892d8a93ebe20a1cd /.config
parent799209ee8cab713547ea80d897341621401a59fc (diff)
emacs: (notmuch) Rewrite config.
Diffstat (limited to '.config')
-rw-r--r--.config/emacs/init.el117
1 files changed, 64 insertions, 53 deletions
diff --git a/.config/emacs/init.el b/.config/emacs/init.el
index fbd56de..f50038e 100644
--- a/.config/emacs/init.el
+++ b/.config/emacs/init.el
@@ -1034,59 +1034,70 @@ By default, returns all jabber related buffers format."
(use-package yaml-mode
:defer t)
-(when (or is-zeus is-hermes)
- (use-package notmuch
- :ensure t
- :commands notmuch-hello
- :bind (("C-x m" . notmuch-hello)
- :map notmuch-hello-mode-map
- ("U" . thanos/notmuch-update)
- ("u" . notmuch-hello-update)
- :map notmuch-search-mode-map
- ("u" . notmuch-refresh-all-buffers))
- :hook ((notmuch-hello-mode . (lambda () (display-line-numbers-mode 0)))
- (notmuch-search-mode . (lambda () (display-line-numbers-mode 0) (emojify-mode))))
- :config
- (defun thanos/notmuch-decrypt-script ()
- (let ((encrypted-script (expand-file-name "notmuch-hook.sh.gpg" "~/.scripts"))
- (script (expand-file-name "notmuch-hook.sh" "~/.scripts")))
- (unless (file-exists-p script)
- (epa-decrypt-file encrypted-script script)
- (set-file-modes script #o700))))
-
- (defun thanos/notmuch-update ()
- (interactive)
- (let ((default-directory "~/")
- (new-buffer (generate-new-buffer "*notmuch update*"))
- (height (max 5 (truncate (* (frame-height) 0.1))))
- (command "mbsync -a; ./.scripts/notmuch-hook.sh"))
- (split-window-vertically (- height))
- (other-window 1)
- (switch-to-buffer new-buffer)
- (thanos/notmuch-decrypt-script)
- (let ((proc (async-shell-command command new-buffer)))
- (set-process-sentinel
- (get-buffer-process new-buffer)
- (lambda (process event)
- (when (memq (process-status process) '(exit signal))
- (delete-window (get-buffer-window (process-buffer process)))
- (kill-buffer (process-buffer process))))))))
-
- (setf notmuch-archive-tags '("-inbox" "-unread" "+archived")
- notmuch-hello-sections '(notmuch-hello-insert-header notmuch-hello-insert-saved-searches notmuch-hello-insert-recent-searches notmuch-hello-insert-alltags notmuch-hello-insert-footer))
-
- (setq notmuch-search-oldest-first nil)
-
- (setf notmuch-identities '("[email protected]" "[email protected]"
-
- (setf notmuch-saved-searches
- `((:name "Inbox" :query "tag:inbox" :sort-order newest-first :key ,(kbd "i"))
- (:name "Today's message" :query "tag:inbox date:today" :sort-order newest-first
- :key ,(kbd "t"))
- (:name "sent" :query "tag:sent" :sort-order newest-first :key ,(kbd "s"))
- (:name "drafts" :query "tag:draft" :sort-order newest-first :key ,(kbd "d"))
- (:name "all mail" :query "*" :sort-order newest-first :key ,(kbd "a"))))))
+(defun thanos/notmuch-decrypt-script ()
+ (let ((encrypted-script (expand-file-name "notmuch-hook.sh.gpg" "~/.scripts"))
+ (script (expand-file-name "notmuch-hook.sh" "~/.scripts")))
+ (unless (file-exists-p script)
+ (epa-decrypt-file encrypted-script script)
+ (set-file-modes script #o700))))
+
+(defun thanos/notmuch-update--command (new-buffer)
+ (let ((default-directory "~/"))
+ (async-shell-command "mbsync -a; .scripts/notmuch-hook.sh" new-buffer)))
+
+(defun thanos/notmuch-update ()
+ (interactive)
+ (let ((new-buffer (generate-new-buffer "*notmuch update*"))
+ (height (max 5 (truncate (* (frame-height) 0.1)))))
+ (split-window-vertically (- height))
+ (other-window 1)
+ (switch-to-buffer new-buffer)
+ (thanos/notmuch-decrypt-script)
+ (let ((proc (thanos/notmuch-update--command new-buffer)))
+ (set-process-sentinel
+ (get-buffer-process new-buffer)
+ (lambda (process event)
+ (when (memq (process-status process) '(exit signal))
+ (sit-for 1)
+ (delete-window (get-buffer-window (process-buffer process)))
+ (kill-buffer (process-buffer process))))))))
+
+(use-package notmuch
+ :straight nil
+ :ensure t
+ :bind (("C-x m" . notmuch-hello)
+ :map notmuch-hello-mode-map
+ ("u" . notmuch-hello-update)
+ ("U" . thanos/notmuch-update)
+ :map notmuch-search-mode-map
+ ("u" . notmuch-refresh-all-buffers))
+ :hook ((notmuch-hello-mode . (lambda () (display-line-numbers-mode 0)))
+ (notmuch-search-mode . (lambda () (display-line-numbers-mode 0) (emojify-mode))))
+ :config
+ (setf notmuch-archive-tags '("-inbox" "-unread" "+archived")
+ notmuch-show-all-tags-list t
+ notmuch-hello-sections '(notmuch-hello-insert-header notmuch-hello-insert-saved-searches notmuch-hello-insert-alltags))
+
+ (setq notmuch-search-oldest-first nil)
+
+ (setf notmuch-tag-formats
+ '(("unread" (propertize tag 'face 'notmuch-tag-unread))
+ ("emacs-pm" (propertize tag 'face '((t :foreground "#ff9580"))))))
+
+ (setf notmuch-identities '("[email protected]" "[email protected]"
+
+ (setf notmuch-saved-searches
+ `((:name "Inbox" :query "tag:inbox" :sort-order newest-first :key ,(kbd "i"))
+ (:name "Unread" :query "tag:unread" :sort-order newest-first :key ,(kbd "u"))
+ (:name "Today's message" :query "tag:inbox date:today" :sort-order newest-first
+ :key ,(kbd "t"))
+ (:name "sent" :query "tag:sent" :sort-order newest-first :key ,(kbd "s"))
+ (:name "drafts" :query "tag:draft" :sort-order newest-first :key ,(kbd "d"))
+ (:name "all mail" :query "*" :sort-order newest-first :key ,(kbd "a")))))
+
+;; Update notmuch on startup
+;; (thanos/notmuch-update)
;; smtpmail settings
(setf smtpmail-smtp-user "[email protected]"