summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2022-08-09 22:07:39 -0700
committerSean Whitton <spwhitton@spwhitton.name>2022-08-10 22:41:28 -0700
commit2ebbd31bf32ef330e7735c543b285e17852fd5a5 (patch)
treec6592af8aef1ecc5f75af675bcd97bca6c769328
parentdac55207a73043b4606d2490554d90cecee6056f (diff)
downloaddotfiles-2ebbd31bf32ef330e7735c543b285e17852fd5a5.tar.gz
don't include whole threads in interactive searches, remap 'A W'
-rw-r--r--.emacs.d/init.el39
1 files changed, 28 insertions, 11 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el
index 386de7ae..84edfe16 100644
--- a/.emacs.d/init.el
+++ b/.emacs.d/init.el
@@ -2776,10 +2776,14 @@ mutt's review view, after exiting EDITOR."
(gnus-summary-rescan-group))))
(global-set-key "\C-cgn" #'spw/gnus)
-(defun spw/gnus-notmuch-ephemeral-search (query &optional limit)
- (interactive (list (read-string "Query: ")
- (and current-prefix-arg
- (prefix-numeric-value current-prefix-arg))))
+(defun spw/gnus-notmuch-ephemeral-search (query &optional limit thread)
+ (interactive
+ (list (read-string "Query: ")
+ (and current-prefix-arg (prefix-numeric-value current-prefix-arg))
+ ;; With (thread . t) messages not matching the search can easily
+ ;; swamp the message(s) we're looking for.
+ ;; Instead, can type 'A W' to view whole threads.
+ nil))
(require 'gnus)
(unless (gnus-alive-p) (gnus))
(gnus-group-read-ephemeral-group
@@ -2791,12 +2795,8 @@ mutt's review view, after exiting EDITOR."
(nnselect-args
. ((search-group-spec ("nnmaildir:fmail"))
(search-query-spec
- ,@(cond
- ((null limit) '((limit . 200) (thread . t)))
- ((cl-plusp limit) `((limit . ,limit) (thread . t)))
- ((cl-minusp limit) `((limit . ,(abs limit)) (thread . nil)))
- (t '((thread . t)))) ; C-u 0
- (query . ,query) (raw . t))))))
+ (thread . ,thread) (query . ,query) (raw . t)
+ (limit . ,(cl-case limit (0 nil) ((nil) 200) (t limit))))))))
(nnselect-artlist . nil))))
(global-set-key "\C-cgm" #'spw/gnus-notmuch-ephemeral-search)
@@ -3240,10 +3240,27 @@ mutt's review view, after exiting EDITOR."
(define-key gnus-summary-mode-map
"vm" #'spw/gnus-summary-save-all-attachments))
+(defun spw/gnus-warp-to-article ()
+ (interactive)
+ (let* ((specs
+ (gnus-group-get-parameter gnus-newsgroup-name 'nnselect-specs t)))
+ (if (gnus-search-notmuch-p
+ (gnus-search-server-to-engine
+ (caadr (assq 'search-group-spec
+ (cdr (assq 'nnselect-args specs))))))
+ (let* ((mid (gnus-summary-header "message-id"))
+ (search (concat "id:" (string-trim mid "<" ">"))))
+ (spw/gnus-notmuch-ephemeral-search search 0 t)
+ (gnus-summary-goto-article mid))
+ (gnus-warp-to-article))))
+(with-eval-after-load 'gnus-sum
+ (define-key gnus-summary-mode-map
+ [remap gnus-warp-to-article] #'spw/gnus-warp-to-article))
+
(defun spw/org-gnus-follow-link (orig-fun &optional group article)
(if (not article)
(apply orig-fun group nil)
- (spw/gnus-notmuch-ephemeral-search (concat "id:" article) 0)
+ (spw/gnus-notmuch-ephemeral-search (concat "id:" article) 0 t)
(gnus-summary-goto-article article)))
(advice-add 'org-gnus-follow-link :around #'spw/org-gnus-follow-link)