emacs-devel
[Top][All Lists]
Advanced

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

Re: HIST to read-from-minibuffer


From: Leo
Subject: Re: HIST to read-from-minibuffer
Date: Mon, 31 May 2010 12:52:17 +0100

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



reply via email to

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