* Read another with M-RET
@ 2010-07-21 11:25 Nordlöw
2010-07-21 12:37 ` Andreas Politz
2010-07-21 14:45 ` TheFlyingDutchman
0 siblings, 2 replies; 4+ messages in thread
From: Nordlöw @ 2010-07-21 11:25 UTC (permalink / raw)
To: help-gnu-emacs
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))
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Read another with M-RET
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
1 sibling, 0 replies; 4+ messages in thread
From: Andreas Politz @ 2010-07-21 12:37 UTC (permalink / raw)
To: help-gnu-emacs
Nordlöw <per.nordlow@gmail.com> writes:
> 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
>
Define the key in minibuffer-local-map as `exit-minibuffer' around your
code.
-ap
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Read another with M-RET
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
1 sibling, 1 reply; 4+ messages in thread
From: TheFlyingDutchman @ 2010-07-21 14:45 UTC (permalink / raw)
To: help-gnu-emacs
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))
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Read another with M-RET
2010-07-21 14:45 ` TheFlyingDutchman
@ 2010-07-21 20:48 ` Nordlöw
0 siblings, 0 replies; 4+ messages in thread
From: Nordlöw @ 2010-07-21 20:48 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-07-21 20:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).