From: Juri Linkov <juri@jurta.org>
To: Leo <sdl.web@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: HIST to read-from-minibuffer
Date: Sun, 30 May 2010 21:45:38 +0300 [thread overview]
Message-ID: <87bpbx6wyd.fsf@mail.jurta.org> (raw)
In-Reply-To: <xbailjb7kfms.fsf@cam.ac.uk> (Leo's message of "Tue, 25 May 2010 19:20:11 +0100")
>>>> (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/
next prev parent reply other threads:[~2010-05-30 18:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2010-05-31 11:52 ` Leo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bpbx6wyd.fsf@mail.jurta.org \
--to=juri@jurta.org \
--cc=emacs-devel@gnu.org \
--cc=sdl.web@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.