unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* completing-read
@ 2014-05-28 17:44 drain
  2014-05-28 18:16 ` completing-read Drew Adams
  2014-05-29  1:54 ` completing-read lee
  0 siblings, 2 replies; 5+ messages in thread
From: drain @ 2014-05-28 17:44 UTC (permalink / raw)
  To: Help-gnu-emacs

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.



--
View this message in context: http://emacs.1067599.n5.nabble.com/completing-read-tp323117.html
Sent from the Emacs - Help mailing list archive at Nabble.com.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: completing-read
  2014-05-28 17:44 completing-read drain
@ 2014-05-28 18:16 ` Drew Adams
  2014-05-29  1:54 ` completing-read lee
  1 sibling, 0 replies; 5+ messages in thread
From: Drew Adams @ 2014-05-28 18:16 UTC (permalink / raw)
  To: drain, Help-gnu-emacs

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



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: completing-read
  2014-05-28 17:44 completing-read drain
  2014-05-28 18:16 ` completing-read Drew Adams
@ 2014-05-29  1:54 ` lee
  2014-05-29  2:17   ` completing-read Drew Adams
  1 sibling, 1 reply; 5+ messages in thread
From: lee @ 2014-05-29  1:54 UTC (permalink / raw)
  To: help-gnu-emacs

drain <aeuster@gmail.com> writes:

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

Shouldn`t that, nowadays, be more like '(("foobar1" . 1) ...'?

So you cannot create a list like this (anymore)?

But it works here:


,----
| *** Welcome to IELM ***  Type (describe-mode) for help.
| ELISP>  (completing-read
|   "Complete a foo: "
|   '(("foobar1" 1) ("barfoo" 2) ("foobaz" 3) ("foobar2" 4))
|   nil t "fo")
| "foobar1"
| ELISP> 
`----


-- 
Knowledge is volatile and fluid.  Software is power.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: completing-read
  2014-05-29  1:54 ` completing-read lee
@ 2014-05-29  2:17   ` Drew Adams
  2014-05-30  5:12     ` completing-read drain
  0 siblings, 1 reply; 5+ messages in thread
From: Drew Adams @ 2014-05-29  2:17 UTC (permalink / raw)
  To: lee, help-gnu-emacs

> > (completing-read
> >  "Complete a foo: "
> >  '(("foobar1" 1) ("barfoo" 2) ("foobaz" 3) ("foobar2" 4))
> >  nil t "fo")
>
> Shouldn`t that, nowadays, be more like '(("foobar1" . 1) ...'?

("foobar" 2) is the same as ("foobar" . (2)), that is, a cons
whose cdr is the list (2).  Nothing non-nowadays about such a
beast.

> So you cannot create a list like this (anymore)?

'("foobar" 2)
`("foobar" ,(length "ab"))
(list (symbol-name 'foobar) (1+ 1))
...



^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: completing-read
  2014-05-29  2:17   ` completing-read Drew Adams
@ 2014-05-30  5:12     ` drain
  0 siblings, 0 replies; 5+ messages in thread
From: drain @ 2014-05-30  5:12 UTC (permalink / raw)
  To: Help-gnu-emacs

Thanks for the help.

. . .

What are some cases in which using dotted pair notation would be better
than using list notation? Or even more interesting: cases in which dotted
pair notation would be /necessary/, and list notation would be impossible.

Right now this is just a theoretical distinction to me.




--
View this message in context: http://emacs.1067599.n5.nabble.com/completing-read-tp323117p323304.html
Sent from the Emacs - Help mailing list archive at Nabble.com.



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-05-30  5:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-28 17:44 completing-read drain
2014-05-28 18:16 ` completing-read Drew Adams
2014-05-29  1:54 ` completing-read lee
2014-05-29  2:17   ` completing-read Drew Adams
2014-05-30  5:12     ` completing-read drain

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