1

When starting Emacs 23.3.1 under Ubuntu 12.0.4.5 LTS, I get the following message:

Warning (initialization): An error occurred while loading `/home/john/.emacs': 
Symbol's function definition is void: defvar-local

When I restart with emacs --debug-init, I get the following response:

Debugger entered--Lisp error: (void-function defvar-local)
  (defvar-local ess-dump-object-function nil "When defined this function is called by `ess-dump-object'.")
(progn (defvar-local ess-dump-object-function nil "When defined this function is called by `ess-dump-object'.") (defun ess-dump-object (object filename) "Dump the ESS object OBJECT into file FILENAME.\n\nUse `ess-defmethod' to define dialect specific overrides." (let ... ... ...)))
  (eval-and-compile (defvar-local ess-dump-object-function nil "When defined this function is called by `ess-dump-object'.") (defun ess-dump-object (object filename) "Dump the ESS object OBJECT into file FILENAME.\n\nUse `ess-defmethod' to define dialect specific overrides." (let ... ... ...)))
  (ess-defgeneric ess-dump-object (object filename) "Dump the ESS object OBJECT into file FILENAME." (let (...) (if ... nil ...) (:override ... ... ... ... ... ... ... ... ...)))
  eval-buffer(#<buffer  *load*<4>> nil "/usr/share/emacs/site-lisp/ess/ess-mode.el" nil t)  ; Reading at buffer position 44237
  load-with-code-conversion("/usr/share/emacs/site-lisp/ess/ess-mode.el" "/usr/share/emacs/site-lisp/ess/ess-mode.el" nil t)
require(ess-mode)
eval-buffer(#<buffer  *load*<3>> nil "/usr/share/emacs/site-lisp/ess/ess.el" nil t)  ; Reading at buffer position 4533
 load-with-code-conversion("/usr/share/emacs/site-lisp/ess/ess.el" "/usr/share/emacs/site-lisp/ess/ess.el" nil t)
  require(ess)
 eval-buffer(#<buffer  *load*<2>> nil "/usr/share/emacs/site-lisp/ess/ess-site.el" nil t)  ; Reading at buffer position 7790
  load-with-code-conversion("/usr/share/emacs/site-lisp/ess/ess-site.el" "/usr/share/emacs/site-lisp/ess/ess-site.el" nil nil)
load("/usr/share/emacs/site-eval-buffer(#<buffer  *load*> nil "/home/john/.emacs" nil t)  ; Reading at buffer position 4844
  load-with-code-conversion("/home/john/.emacs" "/home/john/.emacs" t t)
 load("~/.emacs" t t)
  #[nil "\205\264�  \306=\203�\307\310Q\2027�   \311=\2033�\312\307\313\314#\203#�\315\2027�\312\307\313\316#\203/�\317\2027�\315\2027�\307\320Q\321\322\n\321\211#\210\321=\203_�\323\324\325\307\326Q!\"\322\f\321\211#\210\321=\203^�\n)\203\244�\327!\330\232\203\244�\331!\211\332P\"\333\"!\203\200�\"\202\213�\333
!\203\212�
\202\213�\313\211\203\243�\334
\"\203\241�\335\336
#\210\337\340!\210
*#?\205\263�\313$\322\341\321\211#))\207" [init-file-user system-type user-init-file-1 user-init-file otherfile source ms-dos "~" "/_emacs" windows-nt directory-files nil "^\\.emacs\\(\\.elc?\\)?$" "~/.emacs" "^_emacs\\(\\.elc?\\)?$" "~/_emacs" "/.emacs" t load expand-file-name "init" file-name-as-directory "/.emacs.d" file-name-extension "elc" file-name-sans-extension ".el" file-exists-p file-newer-than-file-p message "Warning: %s is newer than %s" sit-for 1 "default" alt inhibit-default-init inhibit-startup-screen] 7]() 
  command-line()  
  normal-top-level()

Emacs basic functions work o.k. But the features I had specified in the .emacs file are ignored. I have not located the troublesome "defvar-local" definition. If someone could tell me how to correct the error, I would be most grateful.

Scott Weldon
  • 2,695
  • 1
  • 17
  • 31

2 Answers2

2

You are getting this error because macro defvar-local does not exist in your Emacs version (23). It was introduced in Emacs 24.3. (You might consider upgrading to a more recent version.)

You can define the macro if you want, or you can replace its use by substituting its definition.

(defmacro defvar-local (var val &optional docstring)
  "Define VAR as a buffer-local variable with default value VAL.
Like `defvar' but additionally marks the variable as being automatically
buffer-local wherever it is set."
  (declare (debug defvar) (doc-string 3))
  ;; Can't use backquote here, it's too early in the bootstrap.
  (list 'progn (list 'defvar var val docstring)
        (list 'make-variable-buffer-local (list 'quote var))))

If you define it, be sure to do so before loading the file where the error is being raised. Or define the macro and then byte-compile that file again, to incorporate the macro calls.

If substituting, this is all you really need:

(defvar THE-VARIABLE THE-VALUE THE-DOC)
(make-variable-buffer-local THE-VARIABLE)

However, be prepared for other gotchas (if you don't upgrade), since apparently that library needs Emacs 24.3 or later. It is possible that there are other things from such a recent version that it needs, besides defvar-local.

Drew
  • 75,699
  • 9
  • 109
  • 225
1

Answering the I have not located the troublesome "defvar-local" definition part of the question...

The message tells you where the error is coming from - /usr/share/emacs/site-lisp/ess/ess-mode.el (and that this was required from ess.el in the same directory and that came from ess-site). The fact that this is from site-lisp hints that you might have a later version of emacs installed.

You might decide that you don't want to (require 'ess-site) or at least move it to the end of /home/john/.emacs

(There is also a --no-site-lisp startup option in case you have a conflict, but I doubt that this is the problem)

icarus
  • 1,904
  • 1
  • 10
  • 15