0

first, defined this interactive function:

(defun system-is-windows ()
  (interactive)
  (string-equal system-type "windows-nt"))

then call this function in one setting.el file

; don't show the scroll bar
(if system-is-windows (scroll-bar-mode 0))

and it throws back the following error:

Debugger entered--Lisp error: (void-variable system-is-windows)
  (if system-is-windows (scroll-bar-mode 0))
  eval-buffer(#<buffer  *load*-51294> nil "c:/Users/user/.emacs.d/settings/general-settings.el" nil t)  ; Reading at buffer position 1439
  load-with-code-conversion("c:/Users/user/.emacs.d/settings/general-settings.el" "c:/Users/user/.emacs.d/settings/general-settings.el" nil t)
  require(general-settings)
  eval-buffer(#<buffer  *load*> nil "c:/Users/user/.emacs.d/init.el" nil t)  ; Reading at buffer position 849
  load-with-code-conversion("c:/Users/user/.emacs.d/init.el" "c:/Users/user/.emacs.d/init.el" t t)
  load("c:/Users/user/.emacs.d/init" t t)
  #f(compiled-function () #<bytecode 0x1000be22d>)()
  command-line()
  normal-top-level()
2
  • Reviewers, answerers: As there are lot of Q's and A's on this site now, it's more and more important/helpful to check for duplicate Q's. There are many Q's with "void-variable", and the reasons for the error are multiple, so multiple such Q's are appropriate. But this one - using a function without parens or funcall or mapcar etc. is a duplicate (and even perhaps more than one dup?).
    – Drew
    Feb 13, 2020 at 17:55
  • We really could use some help creating Community Q & A that removes some of the extraneous stuff from existing Q's to get to the hearts of the issues.
    – Drew
    Feb 13, 2020 at 17:56

1 Answer 1

2

The following code:

(if system-is-windows (scroll-bar-mode 0))

Does not evaluate system-is-windows as a function, but tries to evaluate it as a variable. That's why you're getting the (void-variable system-is-windows) error message.

Instead, you need to write:

(if (system-is-windows)
    (scroll-bar-mode 0))

The parentheses tell Emacs that you are evaluating it as a function.

1
  • Thank you @Dan. adding () around function name fixes the issue.
    – YiC
    Feb 13, 2020 at 17:06

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