Re: Comparison of defcustom and defvar arguments

[email protected]
Newsgroups gmane.emacs.help
Message-ID <[email protected]>
Heime <[email protected]> writes:

> Looked at the decumentation of defcustom and defvar
>
> (defcustom SYMBOL STANDARD DOC &rest ARGS)
>
> defcustom accepts STANDARD to be an expression, and includes 
> keyword declarations such as :initualize
>
> (defvar SYMBOL &optional INITVALUE DOCSTRING)
>
> On the other hand, defvar does not seem to allow INITVALUE to be
> an expression, and keyword declarations are not allowed.
>
> It seems to me that defvar is very restrictive.
>

The definition of ‘defvar’ is complex because it can be used
in several contexts, but it is possible to use an expression
(which *will* be evaluated) in a ‘defvar’ expression.

Simple example:

  (defvar my-var (list (quote a)
                       (char-to-string ?b)
                       (cons 'c 'd)
                       emacs-version))

M-: my-var

=> (a "b" (c . d) "30.2")

-- 
The lyf so short, the craft so long to lerne.
- Geoffrey Chaucer, The Parliament of Birds.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.