Page 1 of 1
Inversion of eval-string function
Posted: Tue Mar 23, 2010 1:57 pm
by Fritz
I have a variable, which contains some text with special symbols:
Code: Select all
> {some symbols \/""}
"some symbols \\/\"\""
I want to save contents of this variable to the text file, with all that backslashes before quotes et cetera. Now I use function
Code: Select all
(define (gnirts-lave x)
(1 -1 (string (list x))))
But, may be, there exists more direct way to get "texted" value of a variable?
Re: Inversion of eval-string function
Posted: Tue Mar 23, 2010 3:06 pm
by HPW
How about:
Code: Select all
> (setq a "some symbols \/\"")
"some symbols /\""
> (source 'a)
"(set 'a \"some symbols /\\\"\")\r\n\r\n"
Re: Inversion of eval-string function
Posted: Tue Mar 23, 2010 3:19 pm
by Fritz
HPW wrote:How about... source
Thanx, "source" looks promising for me. Only problem: source + sym dislike lists for some reason:
Code: Select all
> (set 'test '(("a" '(1 2 3 4 5)) ("b" 52) ("c" "something")))
(("a" '(1 2 3 4 5)) ("b" 52) ("c" "something"))
> (source (sym (test 1 1)))
"(set (sym \"52\" MAIN:MAIN) nil)\n\n"
> (source (sym (test 0 1)))
ERR: number or string expected in function sym : (test 0 1)