Add integration to gnus-search library, if present

Eric Abrahamsen <[email protected]> Wed, 04 Nov 2020 15:06:57 -0800
Newsgroups gmane.emacs.bbdb.user
Message-ID <[email protected]>
Hi,

There's a new search query syntax in Gnus, in Emacs master, in a library
called gnus-search.el. This library allows contact management packages
to add auto-completion for contact names/mail addresses during search
query entry: for instance the user could type "from:eri<TAB>", and that
would complete to "from:[email protected]".

The attached patch checks to see if the library is present, and adds
bbdb-hashtable to the contact tables if so. It might be desirable to
create a specific completion table just for this, but I expect just
using bbdb-hashtable directly will be fine.

Thanks,
Eric
0001-Add-Gnus-search-query-auto-completion-for-BBDB-conta.patch (text/x-patch, 1.2 KB)
From f3b857e5d021036b1bb7f1d7dcf77e0ab99cb64d Mon Sep 17 00:00:00 2001
From: Eric Abrahamsen <[email protected]>
Date: Wed, 4 Nov 2020 15:00:22 -0800
Subject: [PATCH] Add Gnus search query auto-completion for BBDB contacts

* lisp/bbdb-gnus.el (bbdb-insinuate-gnus): Add bbdb-hashtable to
`gnus-search-contact-tables', if that option is defined.
---
 lisp/bbdb-gnus.el | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lisp/bbdb-gnus.el b/lisp/bbdb-gnus.el
index c2ac987..043fe8b 100644
--- a/lisp/bbdb-gnus.el
+++ b/lisp/bbdb-gnus.el
@@ -43,6 +43,10 @@ Do not call this in your init file.  Use `bbdb-initialize'."
   ;;`gnus-article-read-summary-keys' restores the window configuration.
   (define-key gnus-summary-mode-map ";" 'bbdb-mua-edit-field-sender)
   (define-key gnus-article-mode-map ";" 'bbdb-mua-edit-field-sender)
+  (when (boundp 'gnus-search-contact-tables)
+    (add-hook 'bbdb-after-read-db-hook
+	      (lambda ()
+		(push bbdb-hashtable gnus-search-contact-tables))))
   ;; Do we need keybindings for more commands?  Suggestions welcome.
   ;; (define-key gnus-summary-mode-map ":" 'bbdb-mua-display-records)
   ;; (define-key gnus-summary-mode-map "'" 'bbdb-mua-display-recipients)
-- 
2.29.2