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

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

RE: How to handle default value in read-string?


From: Drew Adams
Subject: RE: How to handle default value in read-string?
Date: Mon, 3 Aug 2015 16:51:43 -0700 (PDT)

> I'd like read-string to somehow indicate the default value.  A natural
> idea is to include it in the prompt, for example having a prompt like
> 
> (format "Foo (%s): " default)
> 
> However, Icicles' version of read-string already does exactly that, so
> for Icicles users this would be superfluous.
> 
> So here's the question: is there a better way than just have a prompt of
> 
> (if icicle-mode (don't-include-default) (do-include-default))?

That's OK.  Or wrap the `read-string' call in:

 (let ((icicle-default-value  nil)) ...)

A nil value of `icicle-default-value' tells Icicles not to put the
default value in the prompt.  Then you can add it to the prompt
explicitly, so it will be there with and without Icicle mode:

(defun foo (strg)
 (interactive
   (let ((icicle-default-value nil))
     (list (read-string "String (default my-default): "
                        nil nil "my-default")))))



reply via email to

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