[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: HIST to read-from-minibuffer
From: |
Juri Linkov |
Subject: |
Re: HIST to read-from-minibuffer |
Date: |
Sun, 30 May 2010 21:45:38 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu) |
>>>> (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/