In emacs, we can define customizable user option variable.
defcustom - Programming in Emacs Lisp http://www.gnu.org/software/emacs/manual/html_node/eintr/defcustom.html
And we can make variable to have buffer-local binding.
Creating Buffer-Local - GNU Emacs Lisp Reference Manual http://www.gnu.org/software/emacs/manual/html_node/elisp/Creating-Buffer_002dLocal.html#Creating-Buffer_002dLocal
If I want to make non-customizable variable, I can use make-local-variable
or setq-local
.
But I can't find any ways how to make customizable variable to have buffer-local binding.
Even if I call make-local-variable
for variable defined by defcustom
, custom-set-variables
set to global-value.
If I call setq-local
, value is set to local-variable. It is better. But I don't think this is best practice.
Is there any valid ways how to set buffer-local value for a variable defined by defcustom?
setq-local
(ormake-local-variable
prior to Emacs 24.3). That is best-practice. Is your question actually "How can I specify within adefcustom
declaration that a variable should always be buffer-local?" ? Or perhaps "How can I use the Customize user-interface to set a buffer-local value for a variable?" ? - philssetq-local
andcustom-set-variables
?". But @Drew posted comprehensive answer. Thank you. - kumar8600