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

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

RE: completing-read


From: Drew Adams
Subject: RE: completing-read
Date: Wed, 28 May 2014 11:16:17 -0700 (PDT)

> I'm curious what the numbers passed to the completing-read function are
> used for. Here is the example I found online:
> 
> (completing-read
>  "Complete a foo: "
>  '(("foobar1" 1) ("barfoo" 2) ("foobaz" 3) ("foobar2" 4))
>  nil t "fo")
> 
> This function appears to work fine without the 1, 2, 3, 4.

You would probably need to look at the context of the example
you cite, to see why they used an alist or that particular alist.

As to whether it is *necessary* to use an alist: no.

1. If by "without the 1,2,3,4" you mean (("foobar1") ("barfoo)...)
then yes.  That has always worked just as well.

2. If you instead mean ("foobar1" "barfoo"...) then yes, that
works just as well also.  However, in older versions of Emacs
the second arg, if a list, had to be a proper alist.  You could
not pass just a list of strings.

3. The real point behind having an alist argument is that the
arg *can* be an alist.  There are lots of ready-to-hand alists
in Emacs.  You can pass an alist as arg directly, without first
mapping over it to get its cars.



reply via email to

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