summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2022-03-03 22:15:21 +0000
committerjao <jao@gnu.org>2022-03-03 22:17:26 +0000
commita2a9bb379e97085249287b29560f789c7ccc63a5 (patch)
tree28221c4d61bf38091552c8bb5484e61faa3c5789
parent31c1da1f0722ab0b85d022062f8e5eb46564f920 (diff)
downloadelibs-a2a9bb379e97085249287b29560f789c7ccc63a5.tar.gz
elibs-a2a9bb379e97085249287b29560f789c7ccc63a5.tar.bz2
more gnus and notmuch tagging integration
-rw-r--r--gnus.org6
-rw-r--r--lib/net/jao-notmuch-gnus.el30
-rw-r--r--notmuch.org2
3 files changed, 22 insertions, 16 deletions
diff --git a/gnus.org b/gnus.org
index 558b98e..c6320c8 100644
--- a/gnus.org
+++ b/gnus.org
@@ -530,10 +530,16 @@
(gnus-summary-goto-article (cdr jao-gnus--last-move) nil t)))
(add-hook 'gnus-summary-article-move-hook 'jao-gnus-move-hook)
+ (defun jao-gnus--tag-archiving ()
+ (when (string-match ".+:\\(.+\\)" jao-gnus--archiving-group)
+ (let ((tags (match-string 1 jao-gnus--archiving-group)))
+ (jao-notmuch-gnus-toggle-tags (split-string tags "\\.")))))
+
(defun jao-gnus-archive (follow)
(interactive "P")
(if jao-gnus--archiving-group
(progn
+ (jao-gnus--tag-archiving)
(if (or jao-gnus--archive-as-copy-p
(not (gnus-check-backend-function
'request-move-article gnus-newsgroup-name)))
diff --git a/lib/net/jao-notmuch-gnus.el b/lib/net/jao-notmuch-gnus.el
index 3f18f12..1951ae0 100644
--- a/lib/net/jao-notmuch-gnus.el
+++ b/lib/net/jao-notmuch-gnus.el
@@ -31,28 +31,30 @@
;;; Tagging in notmuch from Gnus buffers
(defun jao-notmuch-gnus-message-id ()
- "Find the id currently selected message in Gnus."
+ "Find the id of currently selected message in Gnus or notmuch."
(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)))))
+ (cond (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))))
+ ((derived-mode-p 'notmuch-show-mode 'notmuch-tree-mode)
+ (notmuch-show-get-message-id))))
(defun jao-notmuch-gnus-message-tags (id)
"Ask notmuch for the tags of a message with the given ID."
(let ((cmd (format "notmuch search --output=tags 'id:%s'" id)))
(split-string (shell-command-to-string cmd))))
-(defun jao-notmuch-gnus-tag-message ()
+(defun jao-notmuch-gnus-tag-message (&optional id tags)
"Interactively add or remove tags to the current message."
(interactive)
- (let* ((id (jao-notmuch-gnus-message-id))
+ (let* ((id (or id (jao-notmuch-gnus-message-id)))
(current (jao-notmuch-gnus-message-tags id))
(prompt (format "Change tags %s" (string-join current "/")))
- (tags (notmuch-read-tag-changes current prompt)))
+ (tags (or tags (notmuch-read-tag-changes current prompt))))
(notmuch-tag (concat "id:" id) tags)
(message "%s -> %s" current (jao-notmuch-gnus-message-tags id))))
@@ -72,17 +74,16 @@
(notmuch-tag (concat "id:" id) tags)
(message "New tags: %s" (jao-notmuch-gnus-message-tags id))))
-
;;;; Displaying search results in Gnus
(defvar jao-notmuch-gnus-server "nnml"
"Name of the target Gnus server, e.g. nnml+mail.")
-(defvar jao-notmuch-gnus-mail-directory message-directory
+(defvar jao-notmuch-gnus-mail-directory (expand-file-name "~/.emacs.d/gnus/Mail")
"Directory where Gnus stores its mail.")
-(defvar jao-notmuch-gnus-leafnode-directory "~/var/news"
+(defvar jao-notmuch-gnus-leafnode-directory (expand-file-name "~/var/news")
"Directory where leafnode stores its messages as seen by notmuch.")
(defun jao-notmuch-gnus-file-to-group (file &optional maildir newsdir)
@@ -122,8 +123,7 @@ Example:
(defun jao-notmuch-gnus-goto-message ()
"Open a summary buffer containing the current notmuch article."
(interactive)
- (let ((group (jao-notmuch-gnus-file-to-group (notmuch-show-get-filename)
- jao-notmuch-gnus-mail-directory))
+ (let ((group (jao-notmuch-gnus-file-to-group (notmuch-show-get-filename)))
(message-id (replace-regexp-in-string "^id:"
""
(notmuch-show-get-message-id))))
diff --git a/notmuch.org b/notmuch.org
index 236c9a3..4a0a98d 100644
--- a/notmuch.org
+++ b/notmuch.org
@@ -492,7 +492,7 @@
("M-u" . jao-notmuch-tree-reset-tags))))
#+end_src
* org mode
- Stolen and adapted from [[https://gist.github.com/fedxa/fac592424473f1b70ea489cc64e08911][Fedor Bezrukov]].
+ Stolen and adapted from [[https://gist.github.com/fedxa/fac592424473f1b70ea489cc64e08911][Fedor Bezrukov]].
#+begin_src emacs-lisp
(defvar jao-org-notmuch-last-subject nil)
(defun jao-org-notmuch-last-subject () jao-org-notmuch-last-subject)