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

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

using lisp in replacement string


From: Guido Van Hoecke
Subject: using lisp in replacement string
Date: Wed, 24 Dec 2014 15:25:20 +0100

Hi,

I am trying to apply what I found in the Emacs manual
-> Search (15 Searching and replacement)
-> Replace (15.10 Replacement Commands)
-> Regexp Replace (15.10.2 Regexp Replacement)
"You can use Lisp expressions to calculate parts of the replacement
string.  To do this, write `\,' followed by the expression in the
replacement string.  Each replacement calculates the value of the
expression and converts it to text without quoting (if it's a string,
this means using the string's contents), and uses it in the replacement
string in place of the expression itself."

So I have a temp buffer with following content
|2+6*21|
|3*15|
|7-3|
and I want to replace the formulas between the '|' characters by the
result of passing them to calc-eval:

(replace-regexp "|\\([^|]*\\)|" \\,(calc-eval \\1) nil (point-min)(point-max))
but this causes Debugger entered--Lisp error: (void-variable \\)

So I try it with single slash:
(replace-regexp "|\\([^|]*\\)|" \,(calc-eval \\1) nil (point-min)(point-max))
and then I get : Symbol's value as variable is void: \,

I got the distinct feeling I'm missing something very basic here...

Please advise

TIA,

Guido



reply via email to

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