diff options
Diffstat (limited to 'lisp/custom.el')
| -rw-r--r-- | lisp/custom.el | 117 |
1 files changed, 62 insertions, 55 deletions
diff --git a/lisp/custom.el b/lisp/custom.el index 3db34e4d1fb..afff8674f34 100644 --- a/lisp/custom.el +++ b/lisp/custom.el @@ -1,10 +1,10 @@ ;;; custom.el --- tools for declaring and initializing options ;; -;; Copyright (C) 1996-1997, 1999, 2001-2013 Free Software Foundation, +;; Copyright (C) 1996-1997, 1999, 2001-2015 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) @@ -232,9 +231,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 @@ -354,7 +354,7 @@ FACE does not need to be quoted. Third argument DOC is the face documentation. -If FACE has been set with `custom-set-faces', set the face +If FACE has been set with `custom-theme-set-faces', set the face attributes as specified by that function, otherwise set the face attributes according to SPEC. @@ -362,7 +362,7 @@ The remaining arguments should have the form [KEYWORD VALUE]... For a list of valid keywords, see the common keywords listed in `defcustom'. -SPEC should be an alist of the form +SPEC should be a \"face spec\", i.e., an alist of the form ((DISPLAY . ATTS)...) @@ -410,7 +410,8 @@ 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)) + (declare (doc-string 3) + (indent 1)) ;; 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. @@ -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) @@ -870,20 +870,21 @@ See `custom-known-themes' for a list of known themes." (setcar (cdr setting) value))) ;; Add a new setting: (t - (unless old - ;; If the user changed a variable outside of Customize, save - ;; the value to a fake theme, `changed'. If the theme is - ;; later disabled, we use this to bring back the old value. - ;; - ;; For faces, we just use `face-new-frame-defaults' to - ;; recompute when the theme is disabled. - (when (and (eq prop 'theme-value) - (boundp symbol)) - (let ((sv (get symbol 'standard-value)) - (val (symbol-value symbol))) - (unless (and sv (equal (eval (car sv)) val)) - (setq old `((changed ,(custom-quote val)))))))) - (put symbol prop (cons (list theme value) old)) + (unless custom--inhibit-theme-enable + (unless old + ;; If the user changed a variable outside of Customize, save + ;; the value to a fake theme, `changed'. If the theme is + ;; later disabled, we use this to bring back the old value. + ;; + ;; For faces, we just use `face-new-frame-defaults' to + ;; recompute when the theme is disabled. + (when (and (eq prop 'theme-value) + (boundp symbol)) + (let ((sv (get symbol 'standard-value)) + (val (symbol-value symbol))) + (unless (and sv (equal (eval (car sv)) val)) + (setq old `((changed ,(custom-quote val)))))))) + (put symbol prop (cons (list theme value) old))) (put theme 'theme-settings (cons (list prop symbol theme value) theme-settings)))))) @@ -1118,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 @@ -1130,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. @@ -1212,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 @@ -1226,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)) @@ -1277,7 +1275,14 @@ NAME should be a symbol." (eq name 'changed))))) (defun custom-available-themes () - "Return a list of available Custom themes (symbols)." + "Return a list of Custom themes available for loading. +Search the directories specified by `custom-theme-load-path' for +files named FOO-theme.el, and return a list of FOO symbols. + +The returned symbols may not correspond to themes that have been +loaded, and no effort is made to check that the files contain +valid Custom themes. For a list of loaded themes, check the +variable `custom-known-themes'." (let (sym themes) (dolist (dir (custom-theme--load-path)) (when (file-directory-p dir) @@ -1416,6 +1421,10 @@ See `custom-enabled-themes' for a list of enabled themes." (setq custom-enabled-themes (delq theme custom-enabled-themes))))) +;; Only used if window-system not null. +(declare-function x-get-resource "frame.c" + (attribute class &optional component subclass)) + (defun custom--frame-color-default (frame attribute resource-attr resource-class tty-default x-default) (let ((col (face-attribute 'default attribute t))) @@ -1448,12 +1457,15 @@ This function returns nil if no custom theme specifies a value for VARIABLE." (eval (car valspec)))))) (defun custom-theme-recalc-face (face) - "Set FACE according to currently enabled custom themes." + "Set FACE according to currently enabled custom themes. +If FACE is not initialized as a face, do nothing; otherwise call +`face-spec-recalc' to recalculate the face on all frames." (if (get face 'face-alias) (setq face (get face 'face-alias))) - ;; Reset the faces for each frame. - (dolist (frame (frame-list)) - (face-spec-recalc face frame))) + (if (facep face) + ;; Reset the faces for each frame. + (dolist (frame (frame-list)) + (face-spec-recalc face frame)))) ;;; XEmacs compatibility functions @@ -1486,11 +1498,6 @@ This means reset VARIABLE. (The argument IGNORED is ignored)." ;;; The End. -;; Process the defcustoms for variables loaded before this file. -(while custom-declare-variable-list - (apply 'custom-declare-variable (car custom-declare-variable-list)) - (setq custom-declare-variable-list (cdr custom-declare-variable-list))) - (provide 'custom) ;;; custom.el ends here |
