]> code.delx.au - gnu-emacs/blobdiff - lisp/custom.el
; Revert "Use eldoc-documentation-functions"
[gnu-emacs] / lisp / custom.el
index 4ee1d45a1b0174c1bd7f42a81728d20a439baeb8..056ca3411978dcc5e2824754565ea0339a6fb144 100644 (file)
@@ -1,10 +1,10 @@
 ;;; custom.el --- tools for declaring and initializing options
 ;;
-;; Copyright (C) 1996-1997, 1999, 2001-2014 Free Software Foundation,
+;; Copyright (C) 1996-1997, 1999, 2001-2016 Free Software Foundation,
 ;; Inc.
 ;;
 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
 ;; Keywords: help, faces
 ;; Package: emacs
 
@@ -155,15 +155,14 @@ set to nil, as the value is no longer rogue."
     (unless (memq :group args)
       (custom-add-to-group (custom-current-group) symbol 'custom-variable))
     (while args
-      (let ((arg (car args)))
-       (setq args (cdr args))
-       (unless (symbolp arg)
+      (let ((keyword (pop args)))
+       (unless (symbolp keyword)
          (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))
+        (unless args
+          (error "Keyword %s is missing an argument" keyword))
+       (let ((value (pop args)))
+          ;; Can't use `pcase' because it is loaded after `custom.el'
+          ;; during bootstrap.  See `loadup.el'.
          (cond ((eq keyword :initialize)
                 (setq initialize value))
                ((eq keyword :set)
@@ -225,6 +224,7 @@ The remaining arguments to `defcustom' should have the form
 The following keywords are meaningful:
 
 :type  VALUE should be a widget type for editing the symbol's value.
+       Every `defcustom' should specify a value for this keyword.
 :options VALUE should be a list of valid members of the widget type.
 :initialize
        VALUE should be a function used to initialize the
@@ -232,9 +232,10 @@ The following keywords are meaningful:
        given in the `defcustom' call.  The default is
        `custom-initialize-reset'.
 :set   VALUE should be a function to set the value of the symbol
-        when using the Customize user interface.
-       It takes two arguments, the symbol to set and the value to
-       give it.  The default choice of function is `set-default'.
+       when using the Customize user interface.  It takes two arguments,
+       the symbol to set and the value to give it.  The function should
+       not modify its value argument destructively.  The default choice
+       of function is `set-default'.
 :get   VALUE should be a function to extract the value of symbol.
        The function takes one argument, a symbol, and should return
        the current value for that symbol.  The default choice of function
@@ -447,8 +448,7 @@ information."
   ;; Record the group on the `current' list.
   (let ((elt (assoc load-file-name custom-current-group-alist)))
     (if elt (setcdr elt symbol)
-      (push (cons (purecopy load-file-name) symbol)
-           custom-current-group-alist)))
+      (push (cons load-file-name symbol) custom-current-group-alist)))
   (run-hooks 'custom-define-hook)
   symbol)
 
@@ -464,7 +464,7 @@ are not usually written so.
 MEMBERS should be an alist of the form ((NAME WIDGET)...) where
 NAME is a symbol and WIDGET is a widget for editing that symbol.
 Useful widgets are `custom-variable' for editing variables,
-`custom-face' for edit faces, and `custom-group' for editing groups.
+`custom-face' for editing faces, and `custom-group' for editing groups.
 
 The remaining arguments should have the form
 
@@ -1119,7 +1119,7 @@ directory first---see `custom-theme-load-path'."
   :group 'customize
   :version "22.1")
 
-(defcustom custom-theme-load-path (list 'custom-theme-directory t)
+(defvar custom-theme-load-path (list 'custom-theme-directory t)
   "List of directories to search for custom theme files.
 When loading custom themes (e.g. in `customize-themes' and
 `load-theme'), Emacs searches for theme files in the specified
@@ -1131,13 +1131,11 @@ order.  Each element in the list should be one of the following:
 - a directory name (a string).
 
 Each theme file is named THEME-theme.el, where THEME is the theme
-name."
-  :type '(repeat (choice (const :tag "custom-theme-directory"
-                               custom-theme-directory)
-                        (const :tag "Built-in theme directory" t)
-                        directory))
-  :group 'customize
-  :version "24.1")
+name.
+
+This variable is designed for use in lisp code (including
+external packages).  For manual user customizations, use
+`custom-theme-directory' instead.")
 
 (defvar custom--inhibit-theme-enable nil
   "Whether the custom-theme-set-* functions act immediately.
@@ -1213,13 +1211,11 @@ Return t if THEME was successfully loaded, nil otherwise."
     (put theme 'theme-documentation nil))
   (let ((fn (locate-file (concat (symbol-name theme) "-theme.el")
                         (custom-theme--load-path)
-                        '("" "c")))
-       hash)
+                        '("" "c"))))
     (unless fn
       (error "Unable to find theme file for `%s'" theme))
     (with-temp-buffer
       (insert-file-contents fn)
-      (setq hash (secure-hash 'sha256 (current-buffer)))
       ;; Check file safety with `custom-safe-themes', prompting the
       ;; user if necessary.
       (when (or no-confirm
@@ -1227,8 +1223,9 @@ Return t if THEME was successfully loaded, nil otherwise."
                (and (memq 'default custom-safe-themes)
                     (equal (file-name-directory fn)
                            (expand-file-name "themes/" data-directory)))
-               (member hash custom-safe-themes)
-               (custom-theme-load-confirm hash))
+                (let ((hash (secure-hash 'sha256 (current-buffer))))
+                  (or (member hash custom-safe-themes)
+                      (custom-theme-load-confirm hash))))
        (let ((custom--inhibit-theme-enable t)
               (buffer-file-name fn))    ;For load-history.
          (eval-buffer))