Function: persist-defvar

persist-defvar is a macro defined in persist.el.

Signature

(persist-defvar SYMBOL INITVALUE DOCSTRING &optional LOCATION)

Documentation

Define SYMBOL as a persistent variable and return SYMBOL.

This form is nearly equivalent to defvar, except that the variable persists between Emacs sessions. When this form is evaluated, the variable's default value is always set to INITVALUE.

It does not support the optional parameters. Both INITVALUE and DOCSTRING need to be given.

Source Code

;; Defined in ~/.emacs.d/elpa/persist-0.8/persist.el
(defmacro persist-defvar (symbol initvalue docstring &optional location)
  "Define SYMBOL as a persistent variable and return SYMBOL.

This form is nearly equivalent to `defvar', except that the
variable persists between Emacs sessions.  When this form is
evaluated, the variable's default value is always set to
INITVALUE.

It does not support the optional parameters.  Both INITVALUE and
DOCSTRING need to be given."
  ;; We cannot distinguish between calls with initvalue of nil and a
  ;; single parameter call. Unfortunately, these two calls have
  ;; different semantics -- the single arity shuts up the byte
  ;; compiler, but does not define the symbol. So, don't support a
  ;; single arity persist-defvar.

  ;; Don't support 2-arity calls either because we are lazy and
  ;; because if you want to persist it, you want to doc it.
  (declare (debug (symbolp form stringp &optional form))
           (doc-string 3)
           (indent defun))
  ;; Define inside progn so the byte compiler sees defvar
  `(progn
     (defvar ,symbol ,initvalue ,docstring)
     ;; `defvar' must stay at top level within `progn'.  Pass init
     ;; value to `persist--defvar-1' since the `defvar' form may not
     ;; set the symbol's value and we don't want to set the
     ;; persist-default property to the current value of the symbol.
     ;; See bug#75779 for details.
     (persist--defvar-1 ',symbol ,location ,initvalue)
     ',symbol))