unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Nordlöw <per.nordlow@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Read another with M-RET
Date: Wed, 21 Jul 2010 13:48:55 -0700 (PDT)	[thread overview]
Message-ID: <9e7b619d-021a-4f30-be1f-a9bf59516dc9@j8g2000yqd.googlegroups.com> (raw)
In-Reply-To: 3da57f3a-0fdc-4e04-8d4b-3c070bc1ea6d@x20g2000pro.googlegroups.com

On Jul 21, 4:45 pm, TheFlyingDutchman <zzbba...@aol.com> wrote:
> On Jul 21, 4:25 am, Nordlöw <per.nord...@gmail.com> 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öw
>
> > Here's the code:
>
> > (defun read-string-list (&optional prompt uniquify)
> >   "Construct a list of strings interactively from minibuffer.
> > An empty string (RET) terminates the read loop."
> >   (interactive)
> >   (let ((sl nil))
> >     (let (str)
> >       (while (not (equal
> >                    (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))))
> >         ))
> >     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.
>   <ALT-RETURN> to terminate all items except the last, which is
>   ended with <RETURN>."
>   (interactive)
>   (define-key minibuffer-local-map (kbd "<M-return>") 'exit-
> minibuffer)
>   (define-key minibuffer-local-map (kbd "<return>") '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 "<return>") 'exit-
> minibuffer)
>          )
>     (message "%s" sl)
>     sl))

Thanks a lot.

/Per


      reply	other threads:[~2010-07-21 20:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-21 11:25 Read another with M-RET Nordlöw
2010-07-21 12:37 ` Andreas Politz
2010-07-21 14:45 ` TheFlyingDutchman
2010-07-21 20:48   ` Nordlöw [this message]

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9e7b619d-021a-4f30-be1f-a9bf59516dc9@j8g2000yqd.googlegroups.com \
    --to=per.nordlow@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).