summaryrefslogtreecommitdiffhomepage
path: root/lib/net
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 /lib/net
parent31c1da1f0722ab0b85d022062f8e5eb46564f920 (diff)
downloadelibs-a2a9bb379e97085249287b29560f789c7ccc63a5.tar.gz
elibs-a2a9bb379e97085249287b29560f789c7ccc63a5.tar.bz2
more gnus and notmuch tagging integration
Diffstat (limited to 'lib/net')
-rw-r--r--lib/net/jao-notmuch-gnus.el30
1 files changed, 15 insertions, 15 deletions
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))))