]> code.delx.au - gnu-emacs/blobdiff - lisp/custom.el
Merge from origin/emacs-25
[gnu-emacs] / lisp / custom.el
index cc284ef51ce5d3191687e6e7163dad8899f85317..056ca3411978dcc5e2824754565ea0339a6fb144 100644 (file)
@@ -1,6 +1,6 @@
 ;;; custom.el --- tools for declaring and initializing options
 ;;
-;; Copyright (C) 1996-1997, 1999, 2001-2015 Free Software Foundation,
+;; Copyright (C) 1996-1997, 1999, 2001-2016 Free Software Foundation,
 ;; Inc.
 ;;
 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
@@ -157,27 +157,37 @@ set to nil, as the value is no longer rogue."
     (while args
       (let ((keyword (pop args)))
        (unless (symbolp keyword)
-         (error "Junk in args %S" (cons keyword args)))
+         (error "Junk in args %S" args))
         (unless args
           (error "Keyword %s is missing an argument" keyword))
        (let ((value (pop args)))
-         (pcase keyword
-            (`:initialize (setq initialize value))
-            (`:set (put symbol 'custom-set value))
-            (`:get (put symbol 'custom-get value))
-            (`:require (push value requests))
-            (`:risky (put symbol 'risky-local-variable value))
-            (`:safe (put symbol 'safe-local-variable value))
-            (`:type (put symbol 'custom-type (purecopy value)))
-            (`:options (if (get symbol 'custom-options)
-                           ;; Slow safe code to avoid duplicates.
-                           (mapc (lambda (option)
-                                   (custom-add-option symbol option))
-                                 value)
-                         ;; Fast code for the common case.
-                         (put symbol 'custom-options (copy-sequence value))))
-            (_ (custom-handle-keyword symbol keyword value
-                                'custom-variable))))))
+          ;; 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)
+                (put symbol 'custom-set value))
+               ((eq keyword :get)
+                (put symbol 'custom-get value))
+               ((eq keyword :require)
+                (push value requests))
+               ((eq keyword :risky)
+                (put symbol 'risky-local-variable value))
+               ((eq keyword :safe)
+                (put symbol 'safe-local-variable value))
+               ((eq keyword :type)
+                (put symbol 'custom-type (purecopy value)))
+               ((eq keyword :options)
+                (if (get symbol 'custom-options)
+                    ;; Slow safe code to avoid duplicates.
+                    (mapc (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.
     (unless custom-dont-initialize
@@ -214,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
@@ -400,8 +411,7 @@ In the ATTS property list, possible attributes are `:family',
 
 See Info node `(elisp) Faces' in the Emacs Lisp manual for more
 information."
-  (declare (doc-string 3)
-           (indent 1))
+  (declare (doc-string 3))
   ;; It is better not to use backquote in this file,
   ;; because that makes a bootstrapping problem
   ;; if you need to recompile all the Lisp files using interpreted code.
@@ -454,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