unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: "'Matt Price'" <matt.price@utoronto.ca>
Cc: help-gnu-emacs@gnu.org
Subject: RE: syntax:  anonymous vs. named functions
Date: Sun, 16 Nov 2008 17:06:45 -0800	[thread overview]
Message-ID: <000f01c94850$c2b6e740$0200a8c0@us.oracle.com> (raw)
In-Reply-To: <1226850493.25203.335.camel@localhost>

> 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)





  reply	other threads:[~2008-11-17  1:06 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.201.1226528857.26697.help-gnu-emacs@gnu.org>
2008-11-12 23:08 ` starting an external command from emacs Dan Espen
2008-11-13  3:48   ` Matt Price
     [not found]   ` <mailman.217.1226563070.26697.help-gnu-emacs@gnu.org>
2008-11-13 13:54     ` Dan Espen
2008-11-13 15:50 ` Xah
2008-11-14 13:24   ` break a chunk of text into a list of lines Matt Price
2008-11-14 15:33   ` starting an external command from emacs Matt Price
     [not found]   ` <mailman.359.1226672766.26697.help-gnu-emacs@gnu.org>
2008-11-14 19:33     ` break a chunk of text into a list of lines Xah
2008-11-14 20:43     ` Andreas Politz
2008-11-15 16:35       ` interactive function: generate tab-completion list with another function Matt Price
2008-11-16  3:42         ` syntax: anonymous vs. named functions Matt Price
2008-11-16  8:01           ` Drew Adams
2008-11-16 15:48             ` Matt Price
2008-11-17  1:06               ` Drew Adams [this message]
     [not found]               ` <mailman.552.1226883997.26697.help-gnu-emacs@gnu.org>
2008-11-17  8:08                 ` Andreas Politz
     [not found]   ` <mailman.365.1226676836.26697.help-gnu-emacs@gnu.org>
2008-11-14 19:43     ` starting an external command from emacs Xah
2008-11-14 20:31     ` Andreas Politz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='000f01c94850$c2b6e740$0200a8c0@us.oracle.com' \
    --to=drew.adams@oracle.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=matt.price@utoronto.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).