0

I need to search for every declared variable in a string with format %^{var}, prompt a value and replace in place.

(let ((primitive "(%^{size}, %^{center})"))
  (if (string-match "%^{\\([^}]*\\)}" primitive)
      (replace-regexp-in-string (format "%%^{%s}" (match-string 1 primitive))
                                (read-string (format "%s: " (match-string 1 primitive)))
                                primitive))
  (message "%s" primitive))

However this does not replace the variable in the string and the primitive is printed unchanged.

(Later when I fix this problem, I'm changing if to while so it does it for every variable in the string)

1

1 Answer 1

0

You're not doing anything with the return value of replace-regexp-in-string.

2
  • Fuck me. Rookie mistake. May 26 at 7:38
  • We've all been there :)
    – phils
    May 26 at 9:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.