diff options
| -rw-r--r-- | bard-elisp/bard-email.el | 122 | ||||
| -rw-r--r-- | bard-elisp/bard-modeline.el | 12 | ||||
| -rw-r--r-- | bard-emacs-modules/bard-emacs-modeline.el | 11 |
3 files changed, 138 insertions, 7 deletions
diff --git a/bard-elisp/bard-email.el b/bard-elisp/bard-email.el new file mode 100644 index 0000000..34e5700 --- /dev/null +++ b/bard-elisp/bard-email.el @@ -0,0 +1,122 @@ +(require 'prot-common) +(eval-when-compile (require 'cl-lib)) + +(defgroup prot-notmuch () + "Extensions for notmuch.el." + :group 'notmuch) + +(defcustom prot-notmuch-delete-tag "del" + "Single tag that applies to mail marked for deletion. +This is used by `prot-notmuch-delete-mail'." + :type 'string + :group 'prot-notmuch) + +(defcustom prot-notmuch-mark-delete-tags + `(,(format "+%s" prot-notmuch-delete-tag) "-inbox" "-unread") + "List of tags to mark for deletion. +To actually delete email, refer to `prot-notmuch-delete-mail'." + :type '(repeat string) + :group 'prot-notmuch) + +(defcustom prot-notmuch-mark-flag-tags '("+flag" "-unread") + "List of tags to mark as important (flagged). +This gets the `notmuch-tag-flagged' face, if that is specified in +`notmuch-tag-formats'." + :type '(repeat string) + :group 'prot-notmuch) + +(defcustom prot-notmuch-mark-spam-tags '("+spam" "-inbox" "-unread") + "List of tags to mark as spam." + :type '(repeat string) + :group 'prot-notmuch) + +(autoload 'notmuch-interactive-region "notmuch") +(autoload 'notmuch-tag-change-list "notmuch") +(autoload 'notmuch-search-next-thread "notmuch") +(autoload 'notmuch-search-tag "notmuch") + +(defmacro prot-notmuch-search-tag-thread (name tags) + "Produce NAME function parsing TAGS." + (declare (indent defun)) + `(defun ,name (&optional untag beg end) + ,(format + "Mark with `%s' the currently selected thread. + +Operate on each message in the currently selected thread. With +optional BEG and END as points delimiting a region that +encompasses multiple threads, operate on all those messages +instead. + +With optional prefix argument (\\[universal-argument]) as UNTAG, +reverse the application of the tags. + +This function advances to the next thread when finished." + tags) + (interactive (cons current-prefix-arg (notmuch-interactive-region))) + (when ,tags + (notmuch-search-tag + (notmuch-tag-change-list ,tags untag) beg end)) + (when (eq beg end) + (notmuch-search-next-thread)))) + +(prot-notmuch-search-tag-thread + prot-notmuch-search-delete-thread + prot-notmuch-mark-delete-tags) + +(prot-notmuch-search-tag-thread + prot-notmuch-search-flag-thread + prot-notmuch-mark-flag-tags) + +(prot-notmuch-search-tag-thread + prot-notmuch-search-spam-thread + prot-notmuch-mark-spam-tags) + +(defmacro prot-notmuch-show-tag-message (name tags) + "Produce NAME function parsing TAGS." + (declare (indent defun)) + `(defun ,name (&optional untag) + ,(format + "Apply `%s' to message. + +With optional prefix argument (\\[universal-argument]) as UNTAG, +reverse the application of the tags." + tags) + (interactive "P") + (when ,tags + (apply 'notmuch-show-tag-message + (notmuch-tag-change-list ,tags untag))))) + +(prot-notmuch-show-tag-message + prot-notmuch-show-delete-message + prot-notmuch-mark-delete-tags) + +(prot-notmuch-show-tag-message + prot-notmuch-show-flag-message + prot-notmuch-mark-flag-tags) + +(prot-notmuch-show-tag-message + prot-notmuch-show-spam-message + prot-notmuch-mark-spam-tags) + +(defun prot-notmuch-delete-mail () + "Permanently delete mail marked as `prot-notmuch-delete-mail'. +Prompt for confirmation before carrying out the operation. + +Do not attempt to refresh the index. This will be done upon the +next invocation of 'notmuch new'." + (interactive) + (let* ((del-tag prot-notmuch-delete-tag) + (count + (string-to-number + (with-temp-buffer + (shell-command + (format "notmuch count tag:%s" prot-notmuch-delete-tag) t) + (buffer-substring-no-properties (point-min) (1- (point-max)))))) + (mail (if (> count 1) "mails" "mail"))) + (unless (> count 0) + (user-error "No mail marked as `%s'" del-tag)) + (when (yes-or-no-p + (format "Delete %d %s marked as `%s'?" count mail del-tag)) + (shell-command + (format "notmuch search --output=files --format=text0 tag:%s | xargs -r0 rm" del-tag) + t)))) diff --git a/bard-elisp/bard-modeline.el b/bard-elisp/bard-modeline.el index 6967f2c..e93b594 100644 --- a/bard-elisp/bard-modeline.el +++ b/bard-elisp/bard-modeline.el @@ -525,6 +525,14 @@ Specific to the current window's mode line.") "Mode line construct displaying Eglot information. Specific to the current window's mode line.") +(defvar-local prot-modeline-notmuch-indicator + '(notmuch-indicator-mode + (" " + (:eval (when (mode-line-window-selected-p) + notmuch-indicator--counters)))) + "The equivalent of `notmuch-indicator-mode-line-construct'. +Display the indicator only on the focused window's mode line.") + ;;;; Miscellaneous (defvar-local prot-modeline-misc-info @@ -549,8 +557,8 @@ Specific to the current window's mode line.") prot-modeline-vc-branch prot-modeline-flymake prot-modeline-eglot - prot-modeline-notmuch-indicator - prot-modeline-misc-info)) + prot-modeline-misc-info + prot-modeline-notmuch-indicator)) (put construct 'risky-local-variable t)) (provide 'bard-modeline) diff --git a/bard-emacs-modules/bard-emacs-modeline.el b/bard-emacs-modules/bard-emacs-modeline.el index 61a0ef0..b09b5e7 100644 --- a/bard-emacs-modules/bard-emacs-modeline.el +++ b/bard-emacs-modules/bard-emacs-modeline.el @@ -66,11 +66,11 @@ (setq mode-line-right-align-edge 'right-margin) (setq-default mode-line-format '("%e" - prot-modeline-kbd-macro + prot-modeline-kbd-macro prot-modeline-narrow - prot-modeline-input-method + prot-modeline-input-method prot-modeline-buffer-status - " " + " " prot-modeline-buffer-identification " " prot-modeline-major-mode @@ -79,9 +79,10 @@ prot-modeline-vc-branch " " prot-modeline-flymake - prot-modeline-eglot + prot-modeline-eglot " " - prot-modeline-misc-info)) + prot-modeline-misc-info + prot-modeline-notmuch-indicator)) (with-eval-after-load 'spacious-padding (defun prot/modeline-spacious-indicators () |
