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

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

interactive function: generate tab-completion list with another function


From: Matt Price
Subject: interactive function: generate tab-completion list with another function
Date: Sat, 15 Nov 2008 11:35:56 -0500

On Fri, 2008-11-14 at 21:43 +0100, Andreas Politz wrote:

> 
> As Xah pointed out `split-string' is the way to go. Btw `cmd-name' and 
> `sh-output'
> will become global variables with your code. I doubt that's what you want. 
> Better use
> let-forms.
> 
> (defun query-python-addressbook (name)
>      (interactive "s To:")
>      (let ((cmd-name "python /home/matt/evo-query.py"))
>           (split-string (shell-command-to-string (concat cmd-name " " name)) 
> "\n" t)))
> 
> 
> In this case the variable is probably superficial anyway.
xah and andreas,

thank you both.  andreas, this does seem to be more or less exactly what
i was really trying to do.  though the answers you and Xah give to the
other part of my query suggest i have some work to do still.  

What i now want to do:  pass the user input to a function in order to
generate the tab-completion list.  the documentation for try-completion
suggests this is possible:
---------------
(try-completion string collection &optional predicate)

Return common substring of all completions of string in collection.
Test each possible completion specified by collection
to see if it begins with string.  The possible completions may be
strings or symbols.  Symbols are converted to strings before testing,
see `symbol-name'.
...
collection can also be a function to do the completion itself.
It receives three arguments: the values string, predicate and nil.
Whatever it returns becomes the value of `try-completion'.
-------------

i guess i just don't understand the syntax to use whn making
"collection" into a function.  i have the following code which doesn't
work but i think gives a sense of what i'm going for.  i now feelthat
this is possible but i'm at a loss as to how to do it:

(defun query-python-addressbook (stub)
   "interactive tab-completing query of addressbook"
   (interactive (list "s Name: " (try-completion string 
(do-python-query(string))
))))


(defun do-python-query (stub)
      (let ((cmd-name "python /home/matt/evo-query.py"))
          (split-string (shell-command-to-string (concat cmd-name " " stub)) 
"\n" t)))

the current error i'm getting is:
list: Wrong type argument: stringp, [followed by the long list of
alternatives i'm generating]

anyway i know these are stupid syntax problems that i ought to pick up
by picking the manual, but i seem to be particularly dense on this kind
of issue.  can you guys help me out?  thanks a lot!

matt




> 
> -ap
-- 
Matt Price
matt.price@utoronto.ca




reply via email to

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