help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: pymacs & interactivel isp functions


From: Kevin Rodgers
Subject: Re: pymacs & interactivel isp functions
Date: Sat, 22 Nov 2008 08:27:11 -0700
User-agent: Thunderbird 2.0.0.18 (Macintosh/20081105)

Matt Price wrote:
On Wed, 2008-11-19 at 09:37 -0800, Drew Adams wrote:
(setq collection (edsquery-return-addresslist "matt"))

which assigns this value to collection:
("Matt Price <matt.price@utoronto.ca>" ...)

my problem comes with a test function that triesto use the results of a query as a collection for tab-completion:

(defun matt/external-addressbook-completion (stub)
"get a list of addresses for tab-completion in a new email"
  (interactive (list (completing-read "Name: "
(edsquery-return-addresslist (string))
;;                                    collection
        


You used (string), which calls string with an empty list of args, so it
concatenates all zero of those together into the empty string, "".

to me it seems that the completion function isn't being sent the input
string.
What input string? You're passing (string), which is "", not any input string.

thanks drew.  i don't know why i thought that similar syntax had worked
in an earlier case -- clearly it must not have.  this was very helpful
and now i am very close.
i now have the following completion code:

(defun matt/external-addressbook-completion (stub)
  (interactive (list (completing-read "Name: "
#'edsquery-return-addresslist nil t))))
when called interactively, it _does_ suggest the first option in the
list that python returns, but it also gives me the following error:

ad-Orig-minibuffer-complete: Wrong type argument: number-or-marker-p,
("Matt Price <moptop99@gmail.com>" "Matthew Garrett
<mjg59@srcf.ucam.org>" "Matt Zimmerman <mdz@canonical.com>" "Matt
Fontaine <Matty_fontaine@hotmail.com>" "Matt Wilks
<matt@madhaus.cns.utoronto.ca>" "Matthew Yates <myatesmyates@yahoo.com>"
"Matthew Flaschen <matthew.flaschen@gatech.edu>" "Matthew Vermeulen
<MattVermeulen@gmail.com>" "Matthew East <matt@mdke.org>" "matthewreedy
<matthewreedy@yahoo.com>" ...)

i'm not sure, but it looks like it isn't breaking the cdr cell down into
its components before evaluating it? suggesting to me that, again,
there's something wrong with my syntax.

When you pass a function to completing-read, it is not used to generate
the list of canidate completions.  As documented:

        collection can be a list of strings, an alist, an obarray or a hash 
table.
        collection can also be a function to do the completion itself.
        predicate limits completion to a subset of collection.
        See `try-completion' and `all-completions' for more details
...
        collection can also be a function to do the completion itself.
        It receives three arguments: the values string, predicate and nil.

I think what you want is:

(defun matt/external-addressbook-completion (stub)
  (interactive (list (completing-read "Name: "
                                      (edsquery-return-addresslist "")
                                      nil t))))

--
Kevin Rodgers
Denver, Colorado, USA





reply via email to

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