help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [External] : Does defvar-local has same effect as make-variable-buff


From: Drew Adams
Subject: RE: [External] : Does defvar-local has same effect as make-variable-buffer-local?
Date: Sat, 15 May 2021 20:49:55 +0000

> (defvar rcd-current-hash nil)
> (make-variable-buffer-local 'rcd-current-hash)
> 
> Is the above totally equivalent to this below?
> 
> (defvar-local rcd-current-hash nil)

Ask Emacs.

`C-h f defvar-local', then click link `subr.el':

(defmacro defvar-local (var val &optional docstring)
  "..."
  ;; 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))))

So yes.  Without the fiddling for presence in `subr.el'
that would be just:

(defmacro defvar-local (var val &optional docstring)
  `(progn (defvar ,var ,val docstring)
          (make-variable-buffer-local ',val)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]