On Tuesday, 3 April 2012 10:01:18 UTC+8, Xah Lee wrote:
> woops! no go! because if the 4th arg is t, it means the input as a
> string will be fed to lisp reader, then interpreted as a lisp object.
> Hot damn. This means, if you want a string, you have to feed it
> 「"\"mystring\""」. (the outter string makes it a lisp string to be fed
> to lisp reader, then, the inner string gets you a lisp string object)
>
> So, now i have to do this:
>
> (read-from-minibuffer
> (format "Directory (default %s):" default-directory) nil nil t nil
> (format "\"%s\"" default-directory) )
>
> But no! Because, now if user actually enter a value, e.g. type 「mary」,
> lisp reader freaks out. Again, it doesn't undertand what the letter
> sequence 「mary」 is. It wants a string 「"\"mary\""」. So, user will have
> to actually type 「"mary"」 for this to work.
>
> WTF?
That's because if you want to simply read a string, you can easily check for the blank string yourself and return the default value:
(let ((value (read-from-string ...)))
(if (string= "" value) default-value value))