Evaluating a variable whose name is stored in a string
elisp, emacs
Solution
`intern` is the function you're looking for:
(let ((my-str "rst-adjust"))
(intern my-str))
==> rst-adjust
Problem
Consider a problem of evaluating a variable who's name is a string: ``` (defun string-dereference () (interactive) (let ((myStr "rst-adjust")) ;; (describe-function 'myStr) => Symbol's function definition is void: myStr ;; (funcall (format "(describe-function '%s)" myStr) => Invalid function: "(describe-function 'rst-adjust)") ) ``` While the following works ``` (describe-function 'rst-adjust) ``` How do I do that given `rst-adjust` is stored in a string? Edit: The answer is: ``` (describe-function (intern myStr)) ```