branch: master commit 6f430895afdcb19c06e2bfa98c7992953b8eb3d5 Author: Eric Abrahamsen <e...@ericabrahamsen.net> Commit: Eric Abrahamsen <e...@ericabrahamsen.net>
New function gnorb-gnus-search-registry * packages/gnorb/gnorb-gnus.el (gnorb-gnus-search-registry): For searching the registry and displaying messages. (gnorb-registry-search-history): History var. * packages/gnorb/gnorb.org: Document. --- packages/gnorb/gnorb-gnus.el | 61 ++++++++++++++++++++++++++++++ packages/gnorb/gnorb.info | 88 ++++++++++++++++++++++++++++---------------- packages/gnorb/gnorb.org | 20 ++++++++++ packages/gnorb/gnorb.texi | 32 +++++++++++++++- 4 files changed, 168 insertions(+), 33 deletions(-) diff --git a/packages/gnorb/gnorb-gnus.el b/packages/gnorb/gnorb-gnus.el index 9029163..2c465d2 100644 --- a/packages/gnorb/gnorb-gnus.el +++ b/packages/gnorb/gnorb-gnus.el @@ -687,6 +687,67 @@ reply." (add-to-list 'gnus-registry-extra-entries-precious 'org-tags) (add-to-list 'gnus-registry-track-extra 'org-tags)) +(defvar gnorb-registry-search-history nil) + +;;;###autoload +(defun gnorb-gnus-search-registry (search-string) + "Search for and display messages using the registry. +Prompt for a registry-specific SEARCH-STRING, then create an +ephemeral group containing the resulting messages. All tracked +registry data keys are acceptable, see (slot-value +gnus-registry-db 'tracked). Unknown keys will be ignored. Keys +and search strings should be given as \"key:value\", with extra +quotes around multi-word search values. Eg: + +sender:google.com subject:\"your search results\"" + (interactive + (list (read-string "Registry search terms: " nil + gnorb-registry-search-history))) + (let (parsed found this-pass term) + (with-temp-buffer + (insert search-string) + (goto-char (point-min)) + (while (re-search-forward + "\\([[:alpha:]]+\\):\\(\\(?:\\w+\\|\"[[:alpha:] ]+\"\\)\\)" + (point-at-eol) t) + (push (cons (intern (match-string 1)) + (string-trim (match-string 2) "\"" "\"")) + parsed)) + (dolist (sym (slot-value gnus-registry-db 'tracked)) + (when (setq term (cdr-safe (assoc sym parsed))) + (maphash + (lambda (k v) + (when (string-match-p term k) + (setq this-pass (append v this-pass)))) + (gethash sym (slot-value gnus-registry-db 'tracker))) + (setq found (if found + (seq-intersection found this-pass) + this-pass) + this-pass nil))) + (if found + (let* ((server (gnorb-gnus-find-gnorb-server)) + (artlist + (mapcar + (lambda (msg) + (pcase-let ((`(,group . ,artno) (gnorb-msg-id-request-head + msg))) + (when (and artno (integerp artno) (> artno 0)) + (vector group artno 100)))) + (delq nil (delete-dups found)))) + (name (make-temp-name "registry messages")) + (spec (list + (cons 'nnir-specs (list (cons 'nnir-query-spec + `((query . "dummy") + (articles . ,artlist))) + (cons 'nnir-group-spec + `((,server ,(list name)))))) + (cons 'nnir-artlist nil)))) + (switch-to-buffer gnus-group-buffer) + (gnus-group-read-ephemeral-group + name `(nnir ,server) nil `(switch-to-buffer ,gnus-group-buffer) + nil nil spec)) + (message "No results found")))))) + ;;;###autoload (defun gnorb-gnus-tag-message (arg &optional tags) "Tag message or messages with TAGS. diff --git a/packages/gnorb/gnorb.info b/packages/gnorb/gnorb.info index 414242e..0bb27fa 100644 --- a/packages/gnorb/gnorb.info +++ b/packages/gnorb/gnorb.info @@ -52,6 +52,7 @@ Misc Org Misc Gnus +* Searching With the Registry:: * User Options: User Options 2. @@ -673,12 +674,37 @@ File: gnorb.info, Node: Misc Gnus, Next: Default Keybindings, Prev: Misc Org, * Menu: +* Searching With the Registry:: * User Options: User Options 2. -File: gnorb.info, Node: User Options 2, Up: Misc Gnus +File: gnorb.info, Node: Searching With the Registry, Next: User Options 2, Up: Misc Gnus -11.1 User Options +11.1 Searching With the Registry +================================ + +Gnorb can use the Gnus registry as a sort of limited search index: the +registry tracks information about sender, recipient, subject, and a few +other things, and while this isn’t as powerful as a full-text search +index, it’s often sufficient. It’s also very fast, as it doesn’t rely +on external program, and doesn’t require the user to mark a particular +set of groups beforehand. + +‘gnorb-gnus-search-registry’ + Prompt the user for a search string, and match it against messages + tracked in the registry. Search strings are given as a series of + “key:value” terms, with double quotes around multi-word values. + See docstring for available keys. + + This function is not bound by default; you might consider: + + (with-eval-after-load "gnus-group" + (define-key gnus-group-group-map (kbd "/") #'gnorb-gnus-search-registry)) + + +File: gnorb.info, Node: User Options 2, Prev: Searching With the Registry, Up: Misc Gnus + +11.2 User Options ================= ‘gnorb-gnus-mail-search-backend’ @@ -740,6 +766,8 @@ File: gnorb.info, Node: Default Keybindings, Prev: Misc Gnus, Up: Top 12 Default Keybindings ********************** +Using the bundled function ‘gnorb-install-defaults’ runs the code below. +If you don’t like these defaults, you can always do your own setup. (global-set-key (kbd "C-c A") 'gnorb-restore-layout) (eval-after-load "gnorb-bbdb" '(progn @@ -778,40 +806,38 @@ File: gnorb.info, Node: Default Keybindings, Prev: Misc Gnus, Up: Top (eval-after-load "message" '(progn (define-key message-mode-map (kbd "C-c t") #'gnorb-gnus-outgoing-do-todo))) - Using the bundled function ‘gnorb-install-defaults’ runs the code -below. If you don’t like these defaults, you can always do your own -setup. Tag Table: Node: Top194 -Node: Introduction1002 -Node: Installation2327 -Node: Setup2705 -Node: Email Tracking3158 -Node: Likely Workflow4362 -Node: Tracking Setup7132 -Node: Beginning and Continuing the Tracking Process8412 -Node: Trigger Actions12604 -Node: Viewing Things13678 -Node: Hinting in Gnus15794 -Node: Message Attachments16859 -Node: Registry Usage18098 -Node: Restoring Window Layout18525 -Node: Recent Mails From BBDB Contacts18922 -Node: Tagging Messages and Contacts19928 -Node: BBDB posting styles21579 -Node: Misc BBDB22486 -Node: Searching for messages from BBDB contacts22702 -Node: Citing BBDB contacts23148 -Node: User Options23469 -Node: Misc Org24992 -Node: Inserting BBDB links25167 -Node: User Options 125423 -Node: Misc Gnus28321 -Node: User Options 228483 -Node: Default Keybindings31625 +Node: Introduction1034 +Node: Installation2359 +Node: Setup2737 +Node: Email Tracking3190 +Node: Likely Workflow4394 +Node: Tracking Setup7164 +Node: Beginning and Continuing the Tracking Process8444 +Node: Trigger Actions12636 +Node: Viewing Things13710 +Node: Hinting in Gnus15826 +Node: Message Attachments16891 +Node: Registry Usage18130 +Node: Restoring Window Layout18557 +Node: Recent Mails From BBDB Contacts18954 +Node: Tagging Messages and Contacts19960 +Node: BBDB posting styles21611 +Node: Misc BBDB22518 +Node: Searching for messages from BBDB contacts22734 +Node: Citing BBDB contacts23180 +Node: User Options23501 +Node: Misc Org25024 +Node: Inserting BBDB links25199 +Node: User Options 125455 +Node: Misc Gnus28353 +Node: Searching With the Registry28547 +Node: User Options 229574 +Node: Default Keybindings32752 End Tag Table diff --git a/packages/gnorb/gnorb.org b/packages/gnorb/gnorb.org index c298c1b..dfc2d92 100644 --- a/packages/gnorb/gnorb.org +++ b/packages/gnorb/gnorb.org @@ -482,6 +482,26 @@ insert an Org link to that record at point. Agenda-related BBDB popup, takes the same values as bbdb-pop-up-layout. * Misc Gnus +** Searching With the Registry +Gnorb can use the Gnus registry as a sort of limited search index: the +registry tracks information about sender, recipient, subject, and a +few other things, and while this isn't as powerful as a full-text +search index, it's often sufficient. It's also very fast, as it +doesn't rely on external program, and doesn't require the user to mark +a particular set of groups beforehand. + +- `gnorb-gnus-search-registry' :: Prompt the user for a search string, + and match it against messages tracked in the registry. Search + strings are given as a series of "key:value" terms, with double + quotes around multi-word values. See docstring for available + keys. + +This function is not bound by default; you might consider: + +#+BEGIN_SRC elisp + (with-eval-after-load "gnus-group" + (define-key gnus-group-group-map (kbd "/") #'gnorb-gnus-search-registry)) +#+END_SRC ** User Options - `gnorb-gnus-mail-search-backend' :: Specifies the search backend that you use for searching mails. Currently supports notmuch, diff --git a/packages/gnorb/gnorb.texi b/packages/gnorb/gnorb.texi index eeab2b7..6c3a2fc 100644 --- a/packages/gnorb/gnorb.texi +++ b/packages/gnorb/gnorb.texi @@ -64,6 +64,7 @@ Misc Org Misc Gnus +* Searching With the Registry:: * User Options: User Options 2. @end detailmenu @@ -663,9 +664,36 @@ bbdb-pop-up-layout. @chapter Misc Gnus @menu +* Searching With the Registry:: * User Options: User Options 2. @end menu +@node Searching With the Registry +@section Searching With the Registry + +Gnorb can use the Gnus registry as a sort of limited search index: the +registry tracks information about sender, recipient, subject, and a +few other things, and while this isn't as powerful as a full-text +search index, it's often sufficient. It's also very fast, as it +doesn't rely on external program, and doesn't require the user to mark +a particular set of groups beforehand. + +@table @asis +@item `gnorb-gnus-search-registry' +Prompt the user for a search string, +and match it against messages tracked in the registry. Search +strings are given as a series of ``key:value'' terms, with double +quotes around multi-word values. See docstring for available +keys. +@end table + +This function is not bound by default; you might consider: + +@lisp +(with-eval-after-load "gnus-group" + (define-key gnus-group-group-map (kbd "/") #'gnorb-gnus-search-registry)) +@end lisp + @node User Options 2 @section User Options @@ -733,6 +761,8 @@ line. Defaults to ``&''. @node Default Keybindings @chapter Default Keybindings +Using the bundled function `gnorb-install-defaults' runs the code +below. If you don't like these defaults, you can always do your own setup. @lisp (global-set-key (kbd "C-c A") 'gnorb-restore-layout) (eval-after-load "gnorb-bbdb" @@ -773,7 +803,5 @@ line. Defaults to ``&''. '(progn (define-key message-mode-map (kbd "C-c t") #'gnorb-gnus-outgoing-do-todo))) @end lisp -Using the bundled function `gnorb-install-defaults' runs the code -below. If you don't like these defaults, you can always do your own setup. @bye \ No newline at end of file