[Top][All Lists]

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

defcustom documentation error

From: Richard Y. Kim
Subject: defcustom documentation error
Date: Sat, 14 Apr 2001 15:51:01 -0700

(describe-function 'defcustom) says:

        VALUE should be a function used to initialize the
        variable.  It takes two arguments, the symbol and value
        given in the `defcustom' call.  The default is

I believe `custom-initialize-default' above should be
`custom-initialize-reset' instead if the code in custom.el is

In emacs-20.7/lisp/custom.el file, custom-declare-variable function
uses `custom-initialize-reset' as the default value of the
`initialize' local variable.

I include the text of `custom-declare-variable' below for your

(defun custom-declare-variable (symbol default doc &rest args)
  "Like `defcustom', but SYMBOL and DEFAULT are evaluated as normal arguments.
DEFAULT should be an expression to evaluate to compute the default value,
not the default value itself."
  ;; Remember the standard setting.
  (put symbol 'standard-value (list default))
  ;; Maybe this option was rogue in an earlier version.  It no longer is.
  (when (get symbol 'force-value)
    ;; It no longer is.    
    (put symbol 'force-value nil))
  (when doc
    (put symbol 'variable-documentation doc))
  (let ((initialize 'custom-initialize-reset)
        (requests nil))
    (while args 
      (let ((arg (car args)))
        (setq args (cdr args))
        (unless (symbolp arg)
          (error "Junk in args %S" args))
        (let ((keyword arg)
              (value (car args)))
          (unless args
            (error "Keyword %s is missing an argument" keyword))
          (setq args (cdr args))
          (cond ((eq keyword :initialize)
                 (setq initialize value))
                ((eq keyword :set)
                 (put symbol 'custom-set value))
                ((eq keyword :get)
                 (put symbol 'custom-get value))
                ((eq keyword :require)
                 (setq requests (cons value requests)))
                ((eq keyword :type)
                 (put symbol 'custom-type value))
                ((eq keyword :options)
                 (if (get symbol 'custom-options)
                     ;; Slow safe code to avoid duplicates.
                     (mapcar (lambda (option)
                               (custom-add-option symbol option))
                   ;; Fast code for the common case.
                   (put symbol 'custom-options (copy-sequence value))))
                 (custom-handle-keyword symbol keyword value
    (put symbol 'custom-requests requests)
    ;; Do the actual initialization.
    (funcall initialize symbol default))
  (setq current-load-list (cons symbol current-load-list))
  (run-hooks 'custom-define-hook)

reply via email to

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