* completing-read
@ 2007-02-19 16:53 John J Foerch
2007-02-19 17:46 ` completing-read Drew Adams
0 siblings, 1 reply; 7+ messages in thread
From: John J Foerch @ 2007-02-19 16:53 UTC (permalink / raw)
To: bug-gnu-emacs
Hello,
The following code exhibits a behavior of completing-read that I would call a
bug. Or am I missing something?
(let ((table '((foo . "you selected foo")
(foobar . "you selected foobar"))))
(completing-read "Symbol: " table nil 'require-match))
The unexpected behavior is that it is impossible to select `foo'.
Thanks,
John Foerch
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: completing-read
2007-02-19 16:53 completing-read John J Foerch
@ 2007-02-19 17:46 ` Drew Adams
0 siblings, 0 replies; 7+ messages in thread
From: Drew Adams @ 2007-02-19 17:46 UTC (permalink / raw)
To: John J Foerch, bug-gnu-emacs
> The following code exhibits a behavior of completing-read that I
> would call a bug. Or am I missing something?
>
> (let ((table '((foo . "you selected foo")
> (foobar . "you selected foobar"))))
> (completing-read "Symbol: " table nil 'require-match))
>
> The unexpected behavior is that it is impossible to select `foo'.
You need to use strings, not symbols, if you use an ALIST second argument to
`completing-read':
(let ((table '(("foo" . "you selected foo")
("foobar" . "you selected foobar"))))
(completing-read "Symbol: " table nil 'require-match))
^ permalink raw reply [flat|nested] 7+ messages in thread
* 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; 7+ 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] 7+ 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; 7+ 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] 7+ 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; 7+ 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] 7+ 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; 7+ 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] 7+ 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; 7+ 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] 7+ messages in thread
end of thread, other threads:[~2014-05-30 5:12 UTC | newest]
Thread overview: 7+ 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
-- strict thread matches above, loose matches on Subject: below --
2007-02-19 16:53 completing-read John J Foerch
2007-02-19 17:46 ` completing-read Drew Adams
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.