From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.help Subject: RE: syntax: anonymous vs. named functions Date: Sun, 16 Nov 2008 17:06:45 -0800 Message-ID: <000f01c94850$c2b6e740$0200a8c0@us.oracle.com> 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> <1226850493.25203.335.camel@localhost> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1226884027 14032 80.91.229.12 (17 Nov 2008 01:07:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 17 Nov 2008 01:07:07 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: "'Matt Price'" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Nov 17 02:08:07 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 1L1saz-0006du-D5 for geh-help-gnu-emacs@m.gmane.org; Mon, 17 Nov 2008 02:08:05 +0100 Original-Received: from localhost ([127.0.0.1]:39914 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L1sZq-0006ex-Tj for geh-help-gnu-emacs@m.gmane.org; Sun, 16 Nov 2008 20:06:54 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L1sZX-0006es-S5 for help-gnu-emacs@gnu.org; Sun, 16 Nov 2008 20:06:35 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L1sZW-0006ef-BG for help-gnu-emacs@gnu.org; Sun, 16 Nov 2008 20:06:35 -0500 Original-Received: from [199.232.76.173] (port=51114 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L1sZW-0006ec-89 for help-gnu-emacs@gnu.org; Sun, 16 Nov 2008 20:06:34 -0500 Original-Received: from acsinet11.oracle.com ([141.146.126.233]:27107) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1L1sZV-0001uz-Sx for help-gnu-emacs@gnu.org; Sun, 16 Nov 2008 20:06:34 -0500 Original-Received: from acsinet13.oracle.com (acsinet13.oracle.com [141.146.126.235]) by acsinet11.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id mAH174Vq011167 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 17 Nov 2008 01:07:05 GMT Original-Received: from acsmt707.oracle.com (acsmt707.oracle.com [141.146.40.85]) by acsinet13.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id mAH16fji031203; Mon, 17 Nov 2008 01:06:42 GMT Original-Received: from dradamslap1 (/24.23.165.218) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Nov 2008 01:06:27 +0000 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: <1226850493.25203.335.camel@localhost> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3350 Thread-Index: AclIAvvlB1QAsfhfQHGhTpX4APX9FQASzbIw X-Source-IP: acsmt707.oracle.com [141.146.40.85] X-Auth-Type: Internal IP X-CT-RefId: str=0001.0A090204.4920C394.00A5:SCFSTAT928724,ss=1,fgs=0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 1) 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:59851 Archived-At: > 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 No, actually I had forgotten that a lambda form was not accepted as a function here. ;-) My point was that a lambda form is a function, whereas (do-completion (string)) is a list of strings - that is, it returns such a list. `completing-read' lets you provide, as the COLLECTION argument, either (1) an explicit set of completion candidates, as a list of strings, an alist, an obarray, or a hash table or (2) an implicit set of candidates: a function of three arguments that does everything. (do-completion (string)) is case #1. A lambda form is case #2 (though, as you pointed out, a lambda form is not accepted as the functional arg). The reason that a lambda form is not allowed as a functional COLLECTION argument is that although a lambda form can generally be used as a function, it _evaluates_ to a list (whose car is `lambda' etc. - that is, to itself). And since COLLECTION can also be an explicit list of candidates, it would be problematic to distinguish the intention of passing an argument whose value is a list that has the form (lambda (...) ...). This is a feature of Lisp's program=data quality. > ps, does the collection function really need to accept all three > arguments (string, predicate and t/nil/lambda)? Yes. It need not _use_ all three, or even any of them, to do its job, but it must accept three arguments. The primitive Emacs completion functions depend on it having such a signature. > 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)? Correct. You would pass the function `do-completion' this way: (completing-read "Name: " #'do-completion nil t)