Elisp (void-variable\]) when trying to evaluate a function in property list

241 Views Asked by At

In my Spacemacs configuration, I configure my org layer to scale any latex it generates like so

(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" "$" "$$" "\\(" "\\["))

I use this configuration on multiple machines, and I like different scaling's for different displays, so I wrote a little function

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

And rewrote the above code to call the function in the :scale property, like so

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

When I test switch-scale in a scratch buffer, it works fine (returns 5.0), but when I add it to my configuration it triggers the following error when trying to generate latex in org mode

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)

I'm stuck as to what's happening, it seems like (switch-scale) just isn't being evaluated???

1

There are 1 best solutions below

0
On

Answer was I don't understand elisps evaluation system ... so because it was in a quoted list everything inside that list was literal, so I actually needed to use a backquote to quote the list and then use a comma to evaluate the (switch-scale) function, as explained here https://www.gnu.org/software/emacs/manual/html_node/elisp/Backquote.html