help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Read another with M-RET


From: Nordlöw
Subject: Read another with M-RET
Date: Wed, 08 Dec 2010 15:19:44 -0000
User-agent: G2/1.0

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))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]