diff --git a/modules/email/notmuch/autoload.el b/modules/email/notmuch/autoload.el index 8dfb33f6b..f9a7fb43e 100644 --- a/modules/email/notmuch/autoload.el +++ b/modules/email/notmuch/autoload.el @@ -24,23 +24,33 @@ ;;;###autoload (defun +notmuch/quit () + "TODO" (interactive) ;; (+popup/close (get-buffer-window "*notmuch-hello*")) (doom-kill-matching-buffers "^\\*notmuch") (+workspace/delete "*MAIL*")) -(defun notmuch-get-sync-command () - (let ((afew-cmd "afew -a -t") - (sync-cmd (pcase +notmuch-sync-backend - (`gmi - (concat "cd " +notmuch-mail-folder " && gmi sync && notmuch new")) - (`mbsync - "mbsync -a && notmuch new") - (`mbsync-xdg - "mbsync -c \"$XDG_CONFIG_HOME\"/isync/mbsyncrc -a && notmuch new") - (`offlineimap - "offlineimap && notmuch new") - (`custom +notmuch-sync-command)))) +(defun +notmuch-get-sync-command () + "Return a shell command string to synchronize your notmuch mmail with." + (let* ((afew-cmd "afew -a -t") + (sync-cmd + (pcase +notmuch-sync-backend + (`gmi + (concat "cd " +notmuch-mail-folder " && gmi sync && notmuch new")) + ((or `mbsync + `mbsync-xdg) ; DEPRECATED `mbsync-xdg' is now just `mbsync' + (format "mbsync %s -a && notmuch new" + (if-let (config-file + (doom-glob (or (getenv "XDG_CONFIG_HOME") + "~/.config") + "isync/mbsyncrc")) + (format "-c %S" config-file) + ""))) + (`offlineimap + "offlineimap && notmuch new") + ((and (pred stringp) it) it) + (_ (user-error "Invalid notmuch backend specified: %S" + +notmuch-sync-backend))))) (if (featurep! +afew) (format "%s && %s" sync-cmd afew-cmd) sync-cmd))) @@ -49,7 +59,7 @@ (defun +notmuch/update () "Sync notmuch emails with server." (interactive) - (with-current-buffer (compile (notmuch-get-sync-command)) + (with-current-buffer (compile (+notmuch-get-sync-command)) (let ((w (get-buffer-window (current-buffer)))) (select-window w) (add-hook diff --git a/modules/email/notmuch/config.el b/modules/email/notmuch/config.el index 663b09f68..ce5132392 100644 --- a/modules/email/notmuch/config.el +++ b/modules/email/notmuch/config.el @@ -6,10 +6,21 @@ "Function for customizing the landing page for doom-emacs =notmuch.") (defvar +notmuch-sync-backend 'gmi - "Which backend to use. Can be either gmi, mbsync, offlineimap or nil (manual).") + "Which backend to use to synchrone email. +Accepts a symbol or a shell command string. -(defvar +notmuch-sync-command nil - "Command for custom notmuch sync") +More specifically, this accepts one of the following symbols (see +`+notmuch-get-sync-command' definition for details): + + `gmi' Use gmailieer (https://github.com/gauteh/lieer) + `mbsync' Use isync (https://isync.sourceforge.io) + `offlineimap' Use offlineimap (https://www.offlineimap.org) + +OR a shell command string such as + + \"path/to/some/shell-script.sh\" + \"offlineimap && notmuch new && afew -a -t\" + \"mbsync %s -a && notmuch new && afew -a -t\"") (defvar +notmuch-mail-folder "~/.mail/account.gmail" "Where your email folder is located (for use with gmailieer).")