From 8b8b40fe1ed9485b5bba72c584ab9b5507b9b65c Mon Sep 17 00:00:00 2001 From: jao Date: Wed, 2 Mar 2022 01:47:37 +0000 Subject: gnus: tagging commands for notmuch interop --- gnus.org | 101 +++++++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 75 insertions(+), 26 deletions(-) (limited to 'gnus.org') diff --git a/gnus.org b/gnus.org index 1cf1690..afd7110 100644 --- a/gnus.org +++ b/gnus.org @@ -377,7 +377,55 @@ (eval-after-load "message" '(setq message-draft-headers (remove 'Date message-draft-headers))) #+END_SRC -* Add-ons +* Notmuch integration +*** notmuch tags + #+begin_src emacs-lisp + (defun jao-gnus-message-id () + (when (derived-mode-p 'gnus-summary-mode) + (save-window-excursion (gnus-summary-show-article))) + (when gnus-original-article-buffer + (with-current-buffer gnus-original-article-buffer + (when-let (id (message-field-value "message-id")) + (if (string-match "<\\(.+\\)>" id) + (match-string 1 id) + id))))) + + (defun jao-gnus-message-tags (id) + (let ((cmd (format "notmuch search --output=tags 'id:%s'" id))) + (split-string (shell-command-to-string cmd)))) + + (defun jao-gnus-tag-message () + (interactive) + (let* ((id (jao-gnus-message-id)) + (current (jao-gnus-message-tags id)) + (prompt (format "Change tags %s" (string-join current "/"))) + (tags (notmuch-read-tag-changes current prompt))) + (notmuch-tag (concat "id:" id) tags) + (message "%s -> %s" current (jao-gnus-message-tags id)))) + + (defun jao-gnus-show-tags () + (interactive) + (when-let (id (jao-gnus-message-id)) + (message "%s" (string-join (jao-gnus-message-tags id) " ")))) + + (defun jao-gnus-toggle-tags (tags) + (let* ((id (jao-gnus-message-id)) + (current (jao-gnus-message-tags id)) + (tags (mapcar (lambda (x) + (concat (if (member x current) "-" "+") x)) + tags))) + (notmuch-tag (concat "id:" id) tags) + (message "New tags: %s" (jao-gnus-message-tags id)))) + + (defun jao-gnus-toggle-todo () + (interactive) + (jao-gnus-toggle-tags '("todo"))) + + (define-key gnus-summary-mode-map (kbd "C-c T") #'jao-gnus-tag-message) + (define-key gnus-summary-mode-map (kbd "C-c t") #'jao-gnus-show-tags) + (define-key gnus-summary-mode-map (kbd "C-c C-t") #'jao-gnus-toggle-todo) + + #+end_src *** notmuch -> gnus / consult-notmuch #+begin_src emacs-lisp (defun jao-notmuch-goto-message-in-gnus () @@ -408,31 +456,6 @@ (define-key notmuch-show-mode-map (kbd "C-c C-c") #'jao-notmuch-goto-message-in-gnus)) #+end_src -*** icalendar/org - #+begin_src emacs-lisp - (require 'ol-gnus) - (use-package gnus-icalendar - :demand t - :init (setq gnus-icalendar-org-capture-file - (expand-file-name "inbox.org" org-directory) - gnus-icalendar-org-capture-headline '("Appointments")) - :config (gnus-icalendar-org-setup)) - #+end_src -*** bbdb - #+begin_src emacs-lisp - (with-eval-after-load "bbdb" - (bbdb-initialize 'gnus 'message 'pgp 'mail) - (bbdb-mua-auto-update-init 'gnus) - (with-eval-after-load "gnus-sum" - (define-key gnus-summary-mode-map ":" 'bbdb-mua-annotate-sender) - (define-key gnus-summary-mode-map ";" 'bbdb-mua-annotate-recipients))) - #+end_src -*** randomsig - #+begin_src emacs-lisp - (with-eval-after-load "randomsig" - (with-eval-after-load "gnus-sum" - (define-key gnus-summary-save-map "-" 'gnus/randomsig-summary-read-sig))) - #+end_src * Groups buffer #+begin_src emacs-lisp ;; (setq gnus-group-line-format " %m%S%p%P:%~(pad-right 35)c %3y %B\n") @@ -747,6 +770,32 @@ (when-let ((url (thing-at-point-url-at-point))) (jao-browse-add-url-to-mpc url)))))) #+end_src +* Add-ons +*** icalendar/org + #+begin_src emacs-lisp + (require 'ol-gnus) + (use-package gnus-icalendar + :demand t + :init (setq gnus-icalendar-org-capture-file + (expand-file-name "inbox.org" org-directory) + gnus-icalendar-org-capture-headline '("Appointments")) + :config (gnus-icalendar-org-setup)) + #+end_src +*** bbdb + #+begin_src emacs-lisp + (with-eval-after-load "bbdb" + (bbdb-initialize 'gnus 'message 'pgp 'mail) + (bbdb-mua-auto-update-init 'gnus) + (with-eval-after-load "gnus-sum" + (define-key gnus-summary-mode-map ":" 'bbdb-mua-annotate-sender) + (define-key gnus-summary-mode-map ";" 'bbdb-mua-annotate-recipients))) + #+end_src +*** randomsig + #+begin_src emacs-lisp + (with-eval-after-load "randomsig" + (with-eval-after-load "gnus-sum" + (define-key gnus-summary-save-map "-" 'gnus/randomsig-summary-read-sig))) + #+end_src * Keyboard shortcuts #+begin_src emacs-lisp (define-key gnus-article-mode-map "i" 'jao-gnus-show-images) -- cgit v1.2.3