bbdb-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Add integration to gnus-search library, if present


From: Eric Abrahamsen
Subject: Re: Add integration to gnus-search library, if present
Date: Wed, 11 Nov 2020 18:14:59 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

"Roland Winkler" <winkler@gnu.org> writes:

> On Tue Nov 10 2020 Eric Abrahamsen wrote:
>> +(defun bbdb-completion-at-point ()
> [snip]
>> +
>> +(defvar bbdb-completion-at-point-table
>> +  (completion-table-dynamic #'bbdb-completion-at-point)
>
> Did you test this? Shouldn't the arg FUNCTION of
> completion-table-dynamic be a function taking an argument?

Yes, I was being too hasty.

"Roland Winkler" <winkler@gnu.org> writes:

> On Wed Nov 11 2020 Eric Abrahamsen wrote:
>> (Just realized the function that collects strings should be
>> catching 'bbdb-hash-ok, not just testing the return value, but
>> that's a simple change.)
>
> Here I have lost track of what you are trying to achieve.
> How about you send a more complete and tested patch.

Okay, here's a complete and tested patch. You can try it out by applying
the patch and then evaluating the below, which is a simple emulation of
how an external package might make use of this completion table.

Evaluate the defun and defvar, and then eval the final sexp. You'll see
that you can type whatever you like at the prompt, but only when you've
typed "from:" and then either hit TAB directly, or given it a short
string and then hit TAB, will it complete on BBDB values.

This is an example of how completion-at-point can provide very targeted
minibuffer completion within a larger context. (This could happily
coexist with, for example, completion on file names on a different
search query key.)

(defun example-capf-function ()
  (save-excursion
    (let ((start (point)))
      (when (re-search-backward "from:" (minibuffer-prompt-end) t)
        (list (match-end 0) start
              bbdb-completion-at-point-table)))))

(defvar example-completion-map
  (let ((km (make-sparse-keymap)))
    (set-keymap-parent km minibuffer-local-map)
    (define-key km (kbd "TAB") #'completion-at-point)
    km))

(minibuffer-with-setup-hook
    (lambda ()
      (add-hook 'completion-at-point-functions
                #'example-capf-function
                nil t))
  (read-from-minibuffer
   "Query: " nil example-completion-map))


Attachment: bbdb-capf.diff
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]