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

[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.


reply via email to

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