all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* defvar and defcustom
@ 2009-11-04 17:18 rustom
  2009-11-04 17:55 ` Drew Adams
  0 siblings, 1 reply; 2+ messages in thread
From: rustom @ 2009-11-04 17:18 UTC (permalink / raw
  To: help-gnu-emacs

Whats the diff between defvar and defcustom?
IOW if defvar defines a non-customise variable how is it different
from setq?


^ permalink raw reply	[flat|nested] 2+ messages in thread

* 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

end of thread, other threads:[~2009-11-04 17:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-04 17:18 defvar and defcustom rustom
2009-11-04 17:55 ` Drew Adams

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.