* RE: defvar and defcustom
2009-11-04 17:18 defvar and defcustom rustom
@ 2009-11-04 17:55 ` Drew Adams
0 siblings, 0 replies; 2+ messages in thread
From: Drew Adams @ 2009-11-04 17:55 UTC (permalink / raw)
To: 'rustom', help-gnu-emacs
> Whats the diff between defvar and defcustom?
> IOW if defvar defines a non-customise variable how is it different
> from setq?
Read the excellent manual: `C-h i', choose `Elisp', then `i defvar'.
1. setq vs defvar:
* defvar does not change the value of its variable, if it already has a value.
* defvar lets you attach a doc string.
* defvar applies only to the default value of a variable, not to a local value.
In this, it is like setq-default.
2. defcustom vs defvar:
* defcustom is intended for customizable user options, that is, for user
customization using Customize.
* defvar defines a non-Customizable user option if the doc string starts with
`*'. You can set the option value interactively, with `M-x set-variable', but
you cannot use Customize with it.
* defcustom lets you control the type of the variable's value (using keyword
:type).
* defcustom lets you group variables, for modularity (using keyword :group).
* defcustom lets you do lots more to control the variable's value - what happens
regarding its initialization, what happens each time it is set, and so on.
* defcustom variables are saved persistently (in your `custom-file' or in your
init file if you have no `custom-file').
That will get you started, but there is no substitute for exploring the manual
for this (and looking at examples in the Emacs code).
^ permalink raw reply [flat|nested] 2+ messages in thread