[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to convert a string to a symbol?
From: |
Pascal J. Bourguignon |
Subject: |
Re: how to convert a string to a symbol? |
Date: |
Sun, 14 Sep 2008 15:47:47 +0200 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/22.2 (gnu/linux) |
sunway <sunwayforever@gmail.com> writes:
> What you say is close to what I want, I do want to turn a string into
> a sexp,but the string could from the minibuffer or somewhere else.
> for example, I want to write a function , it takes a string as
> argument, the function could turn the string to a sexp, eval it, and
> return the result.
>From the minibuffer, you can read the s-expression directly.
Read the documentation of read-from-minibuffer!
(eval (read-from-minibuffer "Expression: " nil nil t))
Since you mention somewhere else, I'll mention also read:
(with-temp-buffer
(insert "(+ 1 2)\n(* 3 4)\n")
(goto-char (point-min))
(list (eval (read (current-buffer)))
(eval (read (current-buffer)))))
Read the documentation of read!
If you don't know it already:
C-h f read RET
C-h f read-from-minibuffer RET
--
__Pascal Bourguignon__ http://www.informatimago.com/
CONSUMER NOTICE: Because of the "uncertainty principle," it is
impossible for the consumer to simultaneously know both the precise
location and velocity of this product.
- how to convert a string to a symbol?, sunway, 2008/09/14
- RE: how to convert a string to a symbol?, Drew Adams, 2008/09/14
- RE: how to convert a string to a symbol?, Drew Adams, 2008/09/14
- Message not available
- Re: how to convert a string to a symbol?, sunway, 2008/09/14
- Re: how to convert a string to a symbol?, Pascal J. Bourguignon, 2008/09/14
- Re: how to convert a string to a symbol?, Tim X, 2008/09/14
- Re: how to convert a string to a symbol?, sunway, 2008/09/14
- Re: how to convert a string to a symbol?, Joost Diepenmaat, 2008/09/14
- Re: how to convert a string to a symbol?,
Pascal J. Bourguignon <=
- Message not available
- Message not available