尝试评估属性列表中的函数时,Elispvoid-variable \]

问题描述

在Spacemacs配置中,我将组织层配置为按比例缩放它生成的任何乳胶

(org :variables
      org-format-latex-options '(:foreground "#90ee90" :background default :scale 2.0
                                                :html-foreground default
                                                :html-background "Transparent" :html-scale 1 :matchers
                                                ("begin" "$1" "$" "$$" "\\(" "\\["))

我在多台计算机上使用此配置,并且我喜欢不同的缩放比例以适应不同的显示器,所以我写了一个小功能

(defun switch-scale ()
  (cond
   ((equal (system-name) "WMachine") 5.0)
   (t 2.0) ;; default
   )
  )

并重写上面的代码调用:scale属性中的函数,就像这样

org-format-latex-options '(:foreground "#90ee90" :background default :scale (switch-scale)
                           ...

当我在暂存缓冲区中测试开关刻度时,它可以正常工作(返回5.0),但是当我将其添加到配置中时,尝试在组织模式下生成乳胶时会触发以下错误

Debugger entered--Lisp error: (void-variable \])
  eval(\] nil)
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)

我对正在发生的事情感到困惑,似乎(开关比例)没有得到评估?

解决方法

答案是我不了解elisps评估系统...因此,因为它在带引号的列表中,该列表中的所有内容均为文字,因此我实际上需要使用反引号将列表引号,然后使用逗号进行评估(缩放比例)功能,如此处https://www.gnu.org/software/emacs/manual/html_node/elisp/Backquote.html

所述