From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Matt Price Newsgroups: gmane.emacs.help Subject: interactive function: generate tab-completion list with another function Date: Sat, 15 Nov 2008 11:35:56 -0500 Organization: History Department, University of Toronto Message-ID: <1226766956.4606.4915.camel@localhost> References: <3d16ac18-967c-4511-8c9c-9a80c40c3d8e@x16g2000prn.googlegroups.com> <1226695506.850373@arno.fh-trier.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1226767005 11018 80.91.229.12 (15 Nov 2008 16:36:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 15 Nov 2008 16:36:45 +0000 (UTC) Cc: help-gnu-emacs@gnu.org, Xah To: Andreas Politz Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Nov 15 17:37:47 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1L1O9b-0001gh-3r for geh-help-gnu-emacs@m.gmane.org; Sat, 15 Nov 2008 17:37:47 +0100 Original-Received: from localhost ([127.0.0.1]:47048 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L1O8S-0000Ep-Qz for geh-help-gnu-emacs@m.gmane.org; Sat, 15 Nov 2008 11:36:36 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L1O81-0000At-Dy for help-gnu-emacs@gnu.org; Sat, 15 Nov 2008 11:36:09 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L1O80-0000AL-Qx for help-gnu-emacs@gnu.org; Sat, 15 Nov 2008 11:36:08 -0500 Original-Received: from [199.232.76.173] (port=58450 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L1O80-0000A9-I8 for help-gnu-emacs@gnu.org; Sat, 15 Nov 2008 11:36:08 -0500 Original-Received: from bureau60.ns.utoronto.ca ([128.100.132.147]:58621) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1L1O80-0004RY-Bc for help-gnu-emacs@gnu.org; Sat, 15 Nov 2008 11:36:08 -0500 Original-Received: from anarres.mercey.org (CPE001d7e1d5798-CM0014f8cd1c4c.cpe.net.cable.rogers.com [173.32.83.31]) (authenticated bits=0) by bureau60.ns.utoronto.ca (8.13.8/8.13.8) with ESMTP id mAFGa03i011244 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sat, 15 Nov 2008 11:36:02 -0500 Original-Received: by anarres.mercey.org (Postfix, from userid 1000) id 86D66120352; Sat, 15 Nov 2008 11:35:59 -0500 (EST) In-Reply-To: <1226695506.850373@arno.fh-trier.de> X-Mailer: Evolution 2.24.1 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:59821 Archived-At: 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