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: RE: syntax: anonymous vs. named functions Date: Sun, 16 Nov 2008 10:48:13 -0500 Organization: History Department, University of Toronto Message-ID: <1226850493.25203.335.camel@localhost> References: <3d16ac18-967c-4511-8c9c-9a80c40c3d8e@x16g2000prn.googlegroups.com> <1226695506.850373@arno.fh-trier.de><1226766956.4606.4915.camel@localhost> <1226806929.4606.6060.camel@localhost> <006401c947c1$7811c320$0200a8c0@us.oracle.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1226850548 11924 80.91.229.12 (16 Nov 2008 15:49:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 16 Nov 2008 15:49:08 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Drew Adams Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Nov 16 16:50:09 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 1L1jt3-0006dd-7R for geh-help-gnu-emacs@m.gmane.org; Sun, 16 Nov 2008 16:50:09 +0100 Original-Received: from localhost ([127.0.0.1]:54027 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L1jru-0001fz-Oj for geh-help-gnu-emacs@m.gmane.org; Sun, 16 Nov 2008 10:48:58 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L1jrZ-0001fJ-E3 for help-gnu-emacs@gnu.org; Sun, 16 Nov 2008 10:48:37 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L1jrX-0001f0-Sb for help-gnu-emacs@gnu.org; Sun, 16 Nov 2008 10:48:37 -0500 Original-Received: from [199.232.76.173] (port=32905 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L1jrX-0001et-LS for help-gnu-emacs@gnu.org; Sun, 16 Nov 2008 10:48:35 -0500 Original-Received: from bureau61.ns.utoronto.ca ([128.100.132.151]:36070) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1L1jrX-00067a-C3 for help-gnu-emacs@gnu.org; Sun, 16 Nov 2008 10:48:35 -0500 Original-Received: from anarres.mercey.org (CPE001d7e1d5798-CM0014f8cd1c4c.cpe.net.cable.rogers.com [173.32.83.31]) (authenticated bits=0) by bureau61.ns.utoronto.ca (8.13.8/8.13.8) with ESMTP id mAGFmHh5004933 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sun, 16 Nov 2008 10:48:32 -0500 Original-Received: by anarres.mercey.org (Postfix, from userid 1000) id 1A77D120353; Sun, 16 Nov 2008 10:48:14 -0500 (EST) In-Reply-To: <006401c947c1$7811c320$0200a8c0@us.oracle.com> 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:59833 Archived-At: On Sun, 2008-11-16 at 00:01 -0800, Drew Adams wrote: > > I have working code for my tab-completion problem (again thanks to > > everyone for answering my painfully stupid questions). i don't > > understand, though, why attempts to write my function as an unnamed > > lambda fails, but the same function succeeds when named. the "lambda" > > line commented out in tab-complete-from-function below > > returns an error > > "test-completion: Invalid function", while the uncommented call to a > > different, trivial function is successful. cna anyone advise me why? > > thanks much! > > > > (defun tab-complete-from-function (stub) > > "very simple tab completion function" > > (interactive (list (completing-read "Name: " > > ;; (lambda (string) > > (split-string (shell-command-to-string (concat > > "/home/matt/mutt-eds-query " string)) "\n" t)) > > (do-completion (string)) > > nil t))) > > (message stub)) > > > > > > (defun do-completion (stub) > > "minimal function" > > (split-string (shell-command-to-string (concat > > "/home/matt/mutt-eds-query " stub)) "\n" t)) > > (do-completion string) is not a function. It is a function application, and its > value is a list of strings. The lambda form is a function. > > To use a function as the `completing-read' COLLECTION argument, the function > must take the right (three) arguments and return the right values. See the doc > for a description of the kind of function that is needed. > thanks for the pointer -- i had looked at the docstrings but not really read the programmed completion node of the info manual. i see this: ---------- It would be consistent and clean for completion functions to allow lambda expressions (lists that are functions) as well as function symbols as COLLECTION, but this is impossible. ---------- not sure if that's exactly what you meant but it's enough to make me stop working in that direction... thanks, matt ps, does the collection function really need to accept all three arguments (string, predicate and t/nil/lambda)? i know you say that (do-completion (string)) is a function application, but what would a function look like in this case? just like this: do-completion (that is, a simple evaluated symbol)? > -- Matt Price matt.price@utoronto.ca