From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: HIST to read-from-minibuffer Date: Sun, 30 May 2010 21:45:38 +0300 Organization: JURTA Message-ID: <87bpbx6wyd.fsf@mail.jurta.org> References: <8739xgta9l.fsf@mail.jurta.org> <87ljb7q33m.fsf@mail.jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1275245830 15657 80.91.229.12 (30 May 2010 18:57:10 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 30 May 2010 18:57:10 +0000 (UTC) Cc: emacs-devel@gnu.org To: Leo Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun May 30 20:57:09 2010 connect(): No such file or directory Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OIngz-0004QA-KX for ged-emacs-devel@m.gmane.org; Sun, 30 May 2010 20:57:01 +0200 Original-Received: from localhost ([127.0.0.1]:33437 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OIngz-00041e-4H for ged-emacs-devel@m.gmane.org; Sun, 30 May 2010 14:57:01 -0400 Original-Received: from [140.186.70.92] (port=45674 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OIngs-0003yk-Jg for emacs-devel@gnu.org; Sun, 30 May 2010 14:56:55 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OIngr-0001T3-GF for emacs-devel@gnu.org; Sun, 30 May 2010 14:56:54 -0400 Original-Received: from smtp-out1.starman.ee ([85.253.0.3]:38328 helo=mx1.starman.ee) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OIngr-0001Ss-89 for emacs-devel@gnu.org; Sun, 30 May 2010 14:56:53 -0400 X-Virus-Scanned: by Amavisd-New at mx1.starman.ee Original-Received: from mail.starman.ee (82.131.30.129.cable.starman.ee [82.131.30.129]) by mx1.starman.ee (Postfix) with ESMTP id 0C7583F409A; Sun, 30 May 2010 21:56:48 +0300 (EEST) In-Reply-To: (Leo's message of "Tue, 25 May 2010 19:20:11 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:125368 Archived-At: >>>> (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/