评估名称存储在字符串中的变量

时间:2012-08-20 10:18:04

标签: emacs elisp

考虑一个评估名称是字符串的变量的问题:

(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)")
  )

以下工作

(describe-function 'rst-adjust)

如果rst-adjust存储在字符串中,我该怎么做?

修改

答案是:

(describe-function (intern myStr))

1 个答案:

答案 0 :(得分:7)

intern是您正在寻找的功能:

(let ((my-str "rst-adjust"))
  (intern my-str))
==> rst-adjust