From 2ebbd31bf32ef330e7735c543b285e17852fd5a5 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Tue, 9 Aug 2022 22:07:39 -0700 Subject: don't include whole threads in interactive searches, remap 'A W' --- .emacs.d/init.el | 39 ++++++++++++++++++++++++++++----------- 1 file 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) -- cgit v1.2.3