bug-gnu-emacs
[Top][All Lists]
Advanced

[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:

    :initialize
        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
        `custom-initialize-default' 

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

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
convenience. 

(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))
                             value)
                   ;; Fast code for the common case.
                   (put symbol 'custom-options (copy-sequence value))))
                (t
                 (custom-handle-keyword symbol keyword value
                                        'custom-variable))))))
    (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)
  symbol)




reply via email to

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