From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: TheFlyingDutchman Newsgroups: gmane.emacs.help Subject: Re: Read another with M-RET Date: Wed, 21 Jul 2010 07:45:47 -0700 (PDT) Organization: http://groups.google.com Message-ID: <3da57f3a-0fdc-4e04-8d4b-3c070bc1ea6d@x20g2000pro.googlegroups.com> References: <34e5f154-9ba5-4a06-8eb9-c7a891a193b7@i31g2000yqm.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1291848028 28395 80.91.229.12 (8 Dec 2010 22:40:28 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 8 Dec 2010 22:40:28 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Dec 08 23:40:25 2010 Return-path: Envelope-to: geh-help-gnu-emacs@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 1PQSgR-0005WY-Q6 for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Dec 2010 23:40:23 +0100 Original-Received: from localhost ([127.0.0.1]:33724 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQSgR-0003Ei-2M for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Dec 2010 17:40:23 -0500 Original-Path: usenet.stanford.edu!postnews.google.com!x20g2000pro.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 68 Original-NNTP-Posting-Host: 75.36.158.158 Original-X-Trace: posting.google.com 1279723547 21680 127.0.0.1 (21 Jul 2010 14:45:47 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Wed, 21 Jul 2010 14:45:47 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: x20g2000pro.googlegroups.com; posting-host=75.36.158.158; posting-account=9bWHAAoAAAAxSFC_2O_ssTETNW9NhMbW User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; GTB6.5; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; AskTbBT5/5.8.0.12304),gzip(gfe) Original-Xref: usenet.stanford.edu gnu.emacs.help:179888 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:76145 Archived-At: On Jul 21, 4:25=A0am, Nordl=F6w wrote: > How do I modify read-string-list so that RET ends loop a single read > and M-RET finishes current input and ask for another instead of the > logic given in the code below where RET finishes current and ask for > another and a final empty string (just RET) instead ends the loop? > > Thanks in advance, > Nordl=F6w > > Here's the code: > > (defun read-string-list (&optional prompt uniquify) > =A0 "Construct a list of strings interactively from minibuffer. > An empty string (RET) terminates the read loop." > =A0 (interactive) > =A0 (let ((sl nil)) > =A0 =A0 (let (str) > =A0 =A0 =A0 (while (not (equal > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(setq str (read-string > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (concat (or p= rompt > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 "String") > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 " (or RET to end list): "))) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"")) > =A0 =A0 =A0 =A0 (if uniquify > =A0 =A0 =A0 =A0 =A0 =A0 (add-to-list 'sl str t) > =A0 =A0 =A0 =A0 =A0 (setq sl (append sl `(,str)))) > =A0 =A0 =A0 =A0 )) > =A0 =A0 sl)) I think this does what you are asking for: (defun Return () "exit minibuffer and stop loop in read-string-list2" (interactive) (setq keepLooping nil) (exit-minibuffer) ) (defun read-string-list2 (&optional prompt uniquify) "Construct a list of strings interactively from minibuffer. to terminate all items except the last, which is ended with ." (interactive) (define-key minibuffer-local-map (kbd "") 'exit- minibuffer) (define-key minibuffer-local-map (kbd "") 'Return) (let ((sl nil)) (let (str) (setq keepLooping t) (while keepLooping (setq str (read-string (concat (or prompt "String") " (or RET to end list): "))) (if uniquify (add-to-list 'sl str t) (setq sl (append sl `(,str)))) ) (define-key minibuffer-local-map (kbd "") 'exit- minibuffer) ) (message "%s" sl) sl))