* HIST to read-from-minibuffer
@ 2010-05-22 20:25 Leo
2010-05-25 16:09 ` Juri Linkov
0 siblings, 1 reply; 8+ messages in thread
From: Leo @ 2010-05-22 20:25 UTC (permalink / raw)
To: emacs-devel
Hello,
I am trying to read a string with a hist variable. I want the default to
be the first element of the hist variable and the history to start from
the SECOND element.
I can seem to get the behaviour I want with '(hist . 1) but not '(hist .
2). However the doc string says:
"positions are counted starting from 1 at the beginning of the list"
This looks contradictory to the behaviour I observed. Is this a mistake
on my understand or the doc string? Thanks.
Leo
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: HIST to read-from-minibuffer
2010-05-22 20:25 HIST to read-from-minibuffer Leo
@ 2010-05-25 16:09 ` Juri Linkov
2010-05-25 16:37 ` Leo
0 siblings, 1 reply; 8+ messages in thread
From: Juri Linkov @ 2010-05-25 16:09 UTC (permalink / raw)
To: Leo; +Cc: emacs-devel
> I am trying to read a string with a hist variable. I want the default to
> be the first element of the hist variable and the history to start from
> the SECOND element.
>
> I can seem to get the behaviour I want with '(hist . 1) but not '(hist .
> 2). However the doc string says:
>
> "positions are counted starting from 1 at the beginning of the list"
>
> This looks contradictory to the behaviour I observed. Is this a mistake
> on my understand or the doc string? Thanks.
Sorry, I don't understand what is contradictory?
(let ((hist '("a" "b" "c")))
(read-from-minibuffer "Prompt: " nil nil nil '(hist . 2)))
M-p => "c"
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: HIST to read-from-minibuffer
2010-05-25 16:09 ` Juri Linkov
@ 2010-05-25 16:37 ` Leo
2010-05-25 17:54 ` Juri Linkov
0 siblings, 1 reply; 8+ messages in thread
From: Leo @ 2010-05-25 16:37 UTC (permalink / raw)
To: emacs-devel
On 2010-05-25 17:09 +0100, Juri Linkov wrote:
> Sorry, I don't understand what is contradictory?
>
> (let ((hist '("a" "b" "c")))
> (read-from-minibuffer "Prompt: " nil nil nil '(hist . 2)))
>
> M-p => "c"
I think I don't understand this sentence:
"Positions are counted starting from 1 at the beginning of the list."
I thought HIST is a 1-based list, but it is still 0-based. Could you
make the doc-string a bit clearer? Thanks.
For example, 0 works just fine:
(let ((hist '("a" "b" "c")))
(read-from-minibuffer "Prompt: " nil nil nil '(hist . 0)))
M-p => "a"
Leo
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: HIST to read-from-minibuffer
2010-05-25 16:37 ` Leo
@ 2010-05-25 17:54 ` Juri Linkov
2010-05-25 18:20 ` Leo
0 siblings, 1 reply; 8+ messages in thread
From: Juri Linkov @ 2010-05-25 17:54 UTC (permalink / raw)
To: Leo; +Cc: emacs-devel
>> (let ((hist '("a" "b" "c")))
>> (read-from-minibuffer "Prompt: " nil nil nil '(hist . 2)))
>>
>> M-p => "c"
>
> I think I don't understand this sentence:
>
> "Positions are counted starting from 1 at the beginning of the list."
>
> I thought HIST is a 1-based list, but it is still 0-based. Could you
> make the doc-string a bit clearer? Thanks.
It is 1-based.
> For example, 0 works just fine:
>
> (let ((hist '("a" "b" "c")))
> (read-from-minibuffer "Prompt: " nil nil nil '(hist . 0)))
>
> M-p => "a"
"a" is the 1st element of HIST. M-p moves to the 1st history element here.
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: HIST to read-from-minibuffer
2010-05-25 17:54 ` Juri Linkov
@ 2010-05-25 18:20 ` Leo
2010-05-26 3:52 ` Leo
2010-05-30 18:45 ` Juri Linkov
0 siblings, 2 replies; 8+ messages in thread
From: Leo @ 2010-05-25 18:20 UTC (permalink / raw)
To: emacs-devel
On 2010-05-25 18:54 +0100, Juri Linkov wrote:
>>> (let ((hist '("a" "b" "c")))
>>> (read-from-minibuffer "Prompt: " nil nil nil '(hist . 2)))
>>>
>
>>> M-p => "c"
>>
>> I think I don't understand this sentence:
>>
>> "Positions are counted starting from 1 at the beginning of the list."
>>
>> I thought HIST is a 1-based list, but it is still 0-based. Could you
>> make the doc-string a bit clearer? Thanks.
>
> It is 1-based.
>
>> For example, 0 works just fine:
>>
>> (let ((hist '("a" "b" "c")))
>> (read-from-minibuffer "Prompt: " nil nil nil '(hist . 0)))
>>
>> M-p => "a"
>
> "a" is the 1st element of HIST. M-p moves to the 1st history element here.
This bit is what confuses me:
(hist . 0)
^
+----- why '0' here to mean first element?
Leo
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: HIST to read-from-minibuffer
2010-05-25 18:20 ` Leo
@ 2010-05-26 3:52 ` Leo
2010-05-30 18:45 ` Juri Linkov
1 sibling, 0 replies; 8+ messages in thread
From: Leo @ 2010-05-26 3:52 UTC (permalink / raw)
To: emacs-devel
On 2010-05-25 19:20 +0100, Leo wrote:
> This bit is what confuses me:
>
> (hist . 0)
> ^
> +----- why '0' here to mean first element?
The doc-string says: positions are counting from '1' while '0' means the
first element. That '1' and '0' is rather confusing.
Leo
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: HIST to read-from-minibuffer
2010-05-25 18:20 ` Leo
2010-05-26 3:52 ` Leo
@ 2010-05-30 18:45 ` Juri Linkov
2010-05-31 11:52 ` Leo
1 sibling, 1 reply; 8+ messages in thread
From: Juri Linkov @ 2010-05-30 18:45 UTC (permalink / raw)
To: Leo; +Cc: emacs-devel
>>>> (let ((hist '("a" "b" "c")))
>>>> (read-from-minibuffer "Prompt: " nil nil nil '(hist . 2)))
>>>>
>>
>>>> M-p => "c"
>>>
>>> I think I don't understand this sentence:
>>>
>>> "Positions are counted starting from 1 at the beginning of the list."
>>>
>>> I thought HIST is a 1-based list, but it is still 0-based. Could you
>>> make the doc-string a bit clearer? Thanks.
>>
>> It is 1-based.
>>
>>> For example, 0 works just fine:
>>>
>>> (let ((hist '("a" "b" "c")))
>>> (read-from-minibuffer "Prompt: " nil nil nil '(hist . 0)))
>>>
>>> M-p => "a"
>>
>> "a" is the 1st element of HIST. M-p moves to the 1st history element here.
>
> This bit is what confuses me:
>
> (hist . 0)
> ^
> +----- why '0' here to mean first element?
'(hist . 0) is the same as 'hist and means no history is used by default.
'(hist . 1) means the history is moved to the first history element.
Please pay attention to this text in the docstring of `read-from-minibuffer':
For consistency, you should also specify that
element of the history as the value of INITIAL-CONTENTS.
This means you have to insert the selected history element
as initial contents:
(let ((hist '("a" "b" "c")))
(read-from-minibuffer "Prompt: " (nth 1 hist) nil nil '(hist . 2)))
Here you can see the difference - the same history element is
first in INITIAL-CONTENTS, but second in HIST.
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: HIST to read-from-minibuffer
2010-05-30 18:45 ` Juri Linkov
@ 2010-05-31 11:52 ` Leo
0 siblings, 0 replies; 8+ messages in thread
From: Leo @ 2010-05-31 11:52 UTC (permalink / raw)
To: Juri Linkov; +Cc: emacs-devel
>> This bit is what confuses me:
>>
>> (hist . 0)
>> ^
>> +----- why '0' here to mean first element?
>
> '(hist . 0) is the same as 'hist and means no history is used by default.
> '(hist . 1) means the history is moved to the first history element.
>
> Please pay attention to this text in the docstring of `read-from-minibuffer':
>
> For consistency, you should also specify that
> element of the history as the value of INITIAL-CONTENTS.
>
> This means you have to insert the selected history element
> as initial contents:
>
> (let ((hist '("a" "b" "c")))
> (read-from-minibuffer "Prompt: " (nth 1 hist) nil nil '(hist . 2)))
>
> Here you can see the difference - the same history element is
> first in INITIAL-CONTENTS, but second in HIST.
The elisp info is very clear on explaining the HIST argument. The doc
string intends to say if you specify a cons cell you'd better have a
HISTPOS >= 1; but then it uses "Positions are counted starting from 1
at the beginning of the list". When I first looked at it, I thought
the HIST has a special index scheme than normal lists which it
doesn't. This is where I am confused. But if others understand it
fine, just ignore this.
Best,
Leo
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-05-31 11:52 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-22 20:25 HIST to read-from-minibuffer Leo
2010-05-25 16:09 ` Juri Linkov
2010-05-25 16:37 ` Leo
2010-05-25 17:54 ` Juri Linkov
2010-05-25 18:20 ` Leo
2010-05-26 3:52 ` Leo
2010-05-30 18:45 ` Juri Linkov
2010-05-31 11:52 ` Leo
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.