Mercurial > emacs
annotate lisp/custom.el @ 67421:a405a1787bef
From: Kyotaro HORIGUCHI (tiny change)
(Fvertical_motion): Force move if starting on stretch glyph.
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Fri, 09 Dec 2005 09:35:21 +0000 |
parents | 6e41569f62c8 |
children | 118df638c3ff |
rev | line source |
---|---|
38412
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents:
36902
diff
changeset
|
1 ;;; custom.el --- tools for declaring and initializing options |
17334 | 2 ;; |
64762
41bb365f41c4
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64441
diff
changeset
|
3 ;; Copyright (C) 1996, 1997, 1999, 2001, 2002, 2003, 2004, |
41bb365f41c4
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64441
diff
changeset
|
4 ;; 2005 Free Software Foundation, Inc. |
17334 | 5 ;; |
6 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk> | |
26582
fbd1f4d3000d
(custom-declare-group): Purecopy DOC.
Dave Love <fx@gnu.org>
parents:
25888
diff
changeset
|
7 ;; Maintainer: FSF |
17334 | 8 ;; Keywords: help, faces |
9 | |
17520 | 10 ;; This file is part of GNU Emacs. |
11 | |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
13 ;; it under the terms of the GNU General Public License as published by | |
14 ;; the Free Software Foundation; either version 2, or (at your option) | |
15 ;; any later version. | |
16 | |
17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
64091 | 24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
25 ;; Boston, MA 02110-1301, USA. | |
17520 | 26 |
17334 | 27 ;;; Commentary: |
28 ;; | |
48238
b6f8e90bc592
Fix typos in Commentary section.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
47822
diff
changeset
|
29 ;; This file only contains the code needed to declare and initialize |
17334 | 30 ;; user options. The code to customize options is autoloaded from |
25683 | 31 ;; `cus-edit.el' and is documented in the Emacs Lisp Reference manual. |
17334 | 32 |
48238
b6f8e90bc592
Fix typos in Commentary section.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
47822
diff
changeset
|
33 ;; The code implementing face declarations is in `cus-face.el'. |
17334 | 34 |
35 ;;; Code: | |
36 | |
37 (require 'widget) | |
38 | |
17415 | 39 (defvar custom-define-hook nil |
40 ;; Customize information for this option is in `cus-edit.el'. | |
41 "Hook called after defining each customize option.") | |
42 | |
47570
b65cc673fb00
(custom-dont-initialize): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
45366
diff
changeset
|
43 (defvar custom-dont-initialize nil |
b65cc673fb00
(custom-dont-initialize): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
45366
diff
changeset
|
44 "Non-nil means `defcustom' should not initialize the variable. |
b65cc673fb00
(custom-dont-initialize): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
45366
diff
changeset
|
45 That is used for the sake of `custom-make-dependencies'. |
b65cc673fb00
(custom-dont-initialize): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
45366
diff
changeset
|
46 Users should not set it.") |
b65cc673fb00
(custom-dont-initialize): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
45366
diff
changeset
|
47 |
41224
fc0e6d3f905d
(custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39981
diff
changeset
|
48 (defvar custom-current-group-alist nil |
fc0e6d3f905d
(custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39981
diff
changeset
|
49 "Alist of (FILE . GROUP) indicating the current group to use for FILE.") |
fc0e6d3f905d
(custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39981
diff
changeset
|
50 |
17334 | 51 ;;; The `defcustom' Macro. |
52 | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
53 (defun custom-initialize-default (symbol value) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
54 "Initialize SYMBOL with VALUE. |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
55 This will do nothing if symbol already has a default binding. |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
56 Otherwise, if symbol has a `saved-value' property, it will evaluate |
55518
10cd0e6bfb73
(custom-initialize-default, defcustom): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
54161
diff
changeset
|
57 the car of that and use it as the default binding for symbol. |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
58 Otherwise, VALUE will be evaluated and used as the default binding for |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
59 symbol." |
17415 | 60 (unless (default-boundp symbol) |
18033
bccd356a3b7c
Synched with version 1.9900.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17949
diff
changeset
|
61 ;; Use the saved value if it exists, otherwise the standard setting. |
17334 | 62 (set-default symbol (if (get symbol 'saved-value) |
63 (eval (car (get symbol 'saved-value))) | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
64 (eval value))))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
65 |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
66 (defun custom-initialize-set (symbol value) |
19535
e9d8fcec9843
(custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents:
19516
diff
changeset
|
67 "Initialize SYMBOL based on VALUE. |
e9d8fcec9843
(custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents:
19516
diff
changeset
|
68 If the symbol doesn't have a default binding already, |
e9d8fcec9843
(custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents:
19516
diff
changeset
|
69 then set it using its `:set' function (or `set-default' if it has none). |
e9d8fcec9843
(custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents:
19516
diff
changeset
|
70 The value is either the value in the symbol's `saved-value' property, |
e9d8fcec9843
(custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents:
19516
diff
changeset
|
71 if any, or VALUE." |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
72 (unless (default-boundp symbol) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
73 (funcall (or (get symbol 'custom-set) 'set-default) |
25683 | 74 symbol |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
75 (if (get symbol 'saved-value) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
76 (eval (car (get symbol 'saved-value))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
77 (eval value))))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
78 |
64200
25277c60733f
(custom-initialize-safe-set, custom-initialize-safe-default): New functions.
Luc Teirlinck <teirllm@auburn.edu>
parents:
64149
diff
changeset
|
79 (defun custom-initialize-safe-set (symbol value) |
25277c60733f
(custom-initialize-safe-set, custom-initialize-safe-default): New functions.
Luc Teirlinck <teirllm@auburn.edu>
parents:
64149
diff
changeset
|
80 "Like `custom-initialize-set', but catches errors. |
25277c60733f
(custom-initialize-safe-set, custom-initialize-safe-default): New functions.
Luc Teirlinck <teirllm@auburn.edu>
parents:
64149
diff
changeset
|
81 If an error occurs during initialization, SYMBOL is set to nil |
25277c60733f
(custom-initialize-safe-set, custom-initialize-safe-default): New functions.
Luc Teirlinck <teirllm@auburn.edu>
parents:
64149
diff
changeset
|
82 and no error is thrown. This is meant for use in pre-loaded files |
64302
8bf3ae544cd2
(custom-initialize-safe-set, custom-initialize-safe-default): Further doc fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
64299
diff
changeset
|
83 where some variables or functions used to compute VALUE may not yet |
64303 | 84 be defined. You can then re-evaluate VALUE in startup.el, for instance |
64299
840e01598f66
(custom-initialize-safe-set, custom-initialize-safe-default): Doc fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
64239
diff
changeset
|
85 using `custom-reevaluate-setting'." |
64200
25277c60733f
(custom-initialize-safe-set, custom-initialize-safe-default): New functions.
Luc Teirlinck <teirllm@auburn.edu>
parents:
64149
diff
changeset
|
86 (condition-case nil |
25277c60733f
(custom-initialize-safe-set, custom-initialize-safe-default): New functions.
Luc Teirlinck <teirllm@auburn.edu>
parents:
64149
diff
changeset
|
87 (custom-initialize-set symbol value) |
25277c60733f
(custom-initialize-safe-set, custom-initialize-safe-default): New functions.
Luc Teirlinck <teirllm@auburn.edu>
parents:
64149
diff
changeset
|
88 (error (set-default symbol nil)))) |
25277c60733f
(custom-initialize-safe-set, custom-initialize-safe-default): New functions.
Luc Teirlinck <teirllm@auburn.edu>
parents:
64149
diff
changeset
|
89 |
25277c60733f
(custom-initialize-safe-set, custom-initialize-safe-default): New functions.
Luc Teirlinck <teirllm@auburn.edu>
parents:
64149
diff
changeset
|
90 (defun custom-initialize-safe-default (symbol value) |
25277c60733f
(custom-initialize-safe-set, custom-initialize-safe-default): New functions.
Luc Teirlinck <teirllm@auburn.edu>
parents:
64149
diff
changeset
|
91 "Like `custom-initialize-default', but catches errors. |
25277c60733f
(custom-initialize-safe-set, custom-initialize-safe-default): New functions.
Luc Teirlinck <teirllm@auburn.edu>
parents:
64149
diff
changeset
|
92 If an error occurs during initialization, SYMBOL is set to nil |
25277c60733f
(custom-initialize-safe-set, custom-initialize-safe-default): New functions.
Luc Teirlinck <teirllm@auburn.edu>
parents:
64149
diff
changeset
|
93 and no error is thrown. This is meant for use in pre-loaded files |
64302
8bf3ae544cd2
(custom-initialize-safe-set, custom-initialize-safe-default): Further doc fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
64299
diff
changeset
|
94 where some variables or functions used to compute VALUE may not yet |
64303 | 95 be defined. You can then re-evaluate VALUE in startup.el, for instance |
64299
840e01598f66
(custom-initialize-safe-set, custom-initialize-safe-default): Doc fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
64239
diff
changeset
|
96 using `custom-reevaluate-setting'." |
64200
25277c60733f
(custom-initialize-safe-set, custom-initialize-safe-default): New functions.
Luc Teirlinck <teirllm@auburn.edu>
parents:
64149
diff
changeset
|
97 (condition-case nil |
25277c60733f
(custom-initialize-safe-set, custom-initialize-safe-default): New functions.
Luc Teirlinck <teirllm@auburn.edu>
parents:
64149
diff
changeset
|
98 (custom-initialize-default symbol value) |
25277c60733f
(custom-initialize-safe-set, custom-initialize-safe-default): New functions.
Luc Teirlinck <teirllm@auburn.edu>
parents:
64149
diff
changeset
|
99 (error (set-default symbol nil)))) |
25277c60733f
(custom-initialize-safe-set, custom-initialize-safe-default): New functions.
Luc Teirlinck <teirllm@auburn.edu>
parents:
64149
diff
changeset
|
100 |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
101 (defun custom-initialize-reset (symbol value) |
19535
e9d8fcec9843
(custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents:
19516
diff
changeset
|
102 "Initialize SYMBOL based on VALUE. |
e9d8fcec9843
(custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents:
19516
diff
changeset
|
103 Set the symbol, using its `:set' function (or `set-default' if it has none). |
e9d8fcec9843
(custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents:
19516
diff
changeset
|
104 The value is either the symbol's current value |
e9d8fcec9843
(custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents:
19516
diff
changeset
|
105 \(as obtained using the `:get' function), if any, |
e9d8fcec9843
(custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents:
19516
diff
changeset
|
106 or the value in the symbol's `saved-value' property if any, |
e9d8fcec9843
(custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents:
19516
diff
changeset
|
107 or (last of all) VALUE." |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
108 (funcall (or (get symbol 'custom-set) 'set-default) |
25683 | 109 symbol |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
110 (cond ((default-boundp symbol) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
111 (funcall (or (get symbol 'custom-get) 'default-value) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
112 symbol)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
113 ((get symbol 'saved-value) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
114 (eval (car (get symbol 'saved-value)))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
115 (t |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
116 (eval value))))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
117 |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
118 (defun custom-initialize-changed (symbol value) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
119 "Initialize SYMBOL with VALUE. |
36269
9a470a7db563
(custom-initialize-changed, defcustom): Doc fix.
Dave Love <fx@gnu.org>
parents:
33027
diff
changeset
|
120 Like `custom-initialize-reset', but only use the `:set' function if |
19535
e9d8fcec9843
(custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents:
19516
diff
changeset
|
121 not using the standard setting. |
36269
9a470a7db563
(custom-initialize-changed, defcustom): Doc fix.
Dave Love <fx@gnu.org>
parents:
33027
diff
changeset
|
122 For the standard setting, use `set-default'." |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
123 (cond ((default-boundp symbol) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
124 (funcall (or (get symbol 'custom-set) 'set-default) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
125 symbol |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
126 (funcall (or (get symbol 'custom-get) 'default-value) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
127 symbol))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
128 ((get symbol 'saved-value) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
129 (funcall (or (get symbol 'custom-set) 'set-default) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
130 symbol |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
131 (eval (car (get symbol 'saved-value))))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
132 (t |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
133 (set-default symbol (eval value))))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
134 |
19516
6591f294b265
(custom-declare-variable): Rename 2nd arg to DEFAULT.
Richard M. Stallman <rms@gnu.org>
parents:
18882
diff
changeset
|
135 (defun custom-declare-variable (symbol default doc &rest args) |
6591f294b265
(custom-declare-variable): Rename 2nd arg to DEFAULT.
Richard M. Stallman <rms@gnu.org>
parents:
18882
diff
changeset
|
136 "Like `defcustom', but SYMBOL and DEFAULT are evaluated as normal arguments. |
6591f294b265
(custom-declare-variable): Rename 2nd arg to DEFAULT.
Richard M. Stallman <rms@gnu.org>
parents:
18882
diff
changeset
|
137 DEFAULT should be an expression to evaluate to compute the default value, |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
138 not the default value itself. |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
139 |
64226
278c7e4c078a
(custom-declare-variable): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
64221
diff
changeset
|
140 DEFAULT is stored as SYMBOL's standard value, in SYMBOL's property |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
141 `standard-value'. At the same time, SYMBOL's property `force-value' is |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
142 set to nil, as the value is no longer rogue." |
19516
6591f294b265
(custom-declare-variable): Rename 2nd arg to DEFAULT.
Richard M. Stallman <rms@gnu.org>
parents:
18882
diff
changeset
|
143 (put symbol 'standard-value (list default)) |
17415 | 144 ;; Maybe this option was rogue in an earlier version. It no longer is. |
145 (when (get symbol 'force-value) | |
146 (put symbol 'force-value nil)) | |
17334 | 147 (when doc |
148 (put symbol 'variable-documentation doc)) | |
19535
e9d8fcec9843
(custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents:
19516
diff
changeset
|
149 (let ((initialize 'custom-initialize-reset) |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
150 (requests nil)) |
41224
fc0e6d3f905d
(custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39981
diff
changeset
|
151 (unless (memq :group args) |
fc0e6d3f905d
(custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39981
diff
changeset
|
152 (custom-add-to-group (custom-current-group) symbol 'custom-variable)) |
25683 | 153 (while args |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
154 (let ((arg (car args))) |
17334 | 155 (setq args (cdr args)) |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
156 (unless (symbolp arg) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
157 (error "Junk in args %S" args)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
158 (let ((keyword arg) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
159 (value (car args))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
160 (unless args |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
161 (error "Keyword %s is missing an argument" keyword)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
162 (setq args (cdr args)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
163 (cond ((eq keyword :initialize) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
164 (setq initialize value)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
165 ((eq keyword :set) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
166 (put symbol 'custom-set value)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
167 ((eq keyword :get) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
168 (put symbol 'custom-get value)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
169 ((eq keyword :require) |
48476
29e63846608d
(custom-declare-variable): Use push.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48334
diff
changeset
|
170 (push value requests)) |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
171 ((eq keyword :type) |
26928
755f54893c1f
(custom-declare-variable): Purecopy value.
Dave Love <fx@gnu.org>
parents:
26831
diff
changeset
|
172 (put symbol 'custom-type (purecopy value))) |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
173 ((eq keyword :options) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
174 (if (get symbol 'custom-options) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
175 ;; Slow safe code to avoid duplicates. |
32225
15a7324321bb
(custom-declare-variable, custom-set-variables): Use mapc.
Dave Love <fx@gnu.org>
parents:
31362
diff
changeset
|
176 (mapc (lambda (option) |
15a7324321bb
(custom-declare-variable, custom-set-variables): Use mapc.
Dave Love <fx@gnu.org>
parents:
31362
diff
changeset
|
177 (custom-add-option symbol option)) |
48476
29e63846608d
(custom-declare-variable): Use push.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48334
diff
changeset
|
178 value) |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
179 ;; Fast code for the common case. |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
180 (put symbol 'custom-options (copy-sequence value)))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
181 (t |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
182 (custom-handle-keyword symbol keyword value |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
183 'custom-variable)))))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
184 (put symbol 'custom-requests requests) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
185 ;; Do the actual initialization. |
47570
b65cc673fb00
(custom-dont-initialize): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
45366
diff
changeset
|
186 (unless custom-dont-initialize |
b65cc673fb00
(custom-dont-initialize): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
45366
diff
changeset
|
187 (funcall initialize symbol default))) |
59507
359397c57b70
(custom-declare-variable): Just put symbol instead of (defvar . symbol)
John Paul Wallington <jpw@pobox.com>
parents:
59385
diff
changeset
|
188 (push symbol current-load-list) |
17334 | 189 (run-hooks 'custom-define-hook) |
190 symbol) | |
191 | |
192 (defmacro defcustom (symbol value doc &rest args) | |
193 "Declare SYMBOL as a customizable variable that defaults to VALUE. | |
194 DOC is the variable documentation. | |
195 | |
55518
10cd0e6bfb73
(custom-initialize-default, defcustom): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
54161
diff
changeset
|
196 Neither SYMBOL nor VALUE need to be quoted. |
17334 | 197 If SYMBOL is not already bound, initialize it to VALUE. |
198 The remaining arguments should have the form | |
199 | |
25683 | 200 [KEYWORD VALUE]... |
17334 | 201 |
22141 | 202 The following keywords are meaningful: |
17334 | 203 |
47677 | 204 :type VALUE should be a widget type for editing the symbol's value. |
17334 | 205 :options VALUE should be a list of valid members of the widget type. |
25683 | 206 :group VALUE should be a customization group. |
17334 | 207 Add SYMBOL to that group. |
42508
37d771fc6685
(defcustom): Fix syntax of previous change.
Richard M. Stallman <rms@gnu.org>
parents:
42503
diff
changeset
|
208 :link LINK-DATA |
42503
e95910976840
(defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents:
41821
diff
changeset
|
209 Include an external link after the documentation string for this |
e95910976840
(defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents:
41821
diff
changeset
|
210 item. This is a sentence containing an active field which |
e95910976840
(defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents:
41821
diff
changeset
|
211 references some other documentation. |
49588
37645a051842
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49522
diff
changeset
|
212 |
67064
e541df85ad86
(defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents:
67058
diff
changeset
|
213 There are several alternatives you can use for LINK-DATA: |
49588
37645a051842
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49522
diff
changeset
|
214 |
42508
37d771fc6685
(defcustom): Fix syntax of previous change.
Richard M. Stallman <rms@gnu.org>
parents:
42503
diff
changeset
|
215 (custom-manual INFO-NODE) |
42503
e95910976840
(defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents:
41821
diff
changeset
|
216 Link to an Info node; INFO-NODE is a string which specifies |
67064
e541df85ad86
(defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents:
67058
diff
changeset
|
217 the node name, as in \"(emacs)Top\". |
49588
37645a051842
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49522
diff
changeset
|
218 |
42508
37d771fc6685
(defcustom): Fix syntax of previous change.
Richard M. Stallman <rms@gnu.org>
parents:
42503
diff
changeset
|
219 (info-link INFO-NODE) |
42503
e95910976840
(defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents:
41821
diff
changeset
|
220 Like `custom-manual' except that the link appears in the |
e95910976840
(defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents:
41821
diff
changeset
|
221 customization buffer with the Info node name. |
49588
37645a051842
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49522
diff
changeset
|
222 |
42508
37d771fc6685
(defcustom): Fix syntax of previous change.
Richard M. Stallman <rms@gnu.org>
parents:
42503
diff
changeset
|
223 (url-link URL) |
42503
e95910976840
(defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents:
41821
diff
changeset
|
224 Link to a web page; URL is a string which specifies the URL. |
67064
e541df85ad86
(defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents:
67058
diff
changeset
|
225 |
e541df85ad86
(defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents:
67058
diff
changeset
|
226 (emacs-commentary-link LIBRARY) |
e541df85ad86
(defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents:
67058
diff
changeset
|
227 Link to the commentary section of LIBRARY. |
e541df85ad86
(defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents:
67058
diff
changeset
|
228 |
e541df85ad86
(defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents:
67058
diff
changeset
|
229 (emacs-library-link LIBRARY) |
e541df85ad86
(defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents:
67058
diff
changeset
|
230 Link to an Emacs Lisp LIBRARY file. |
e541df85ad86
(defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents:
67058
diff
changeset
|
231 |
e541df85ad86
(defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents:
67058
diff
changeset
|
232 (file-link FILE) |
e541df85ad86
(defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents:
67058
diff
changeset
|
233 Link to FILE. |
e541df85ad86
(defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents:
67058
diff
changeset
|
234 |
e541df85ad86
(defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents:
67058
diff
changeset
|
235 (function-link FUNCTION) |
e541df85ad86
(defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents:
67058
diff
changeset
|
236 Link to the documentation of FUNCTION. |
e541df85ad86
(defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents:
67058
diff
changeset
|
237 |
e541df85ad86
(defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents:
67058
diff
changeset
|
238 (variable-link VARIABLE) |
e541df85ad86
(defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents:
67058
diff
changeset
|
239 Link to the documentation of VARIABLE. |
e541df85ad86
(defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents:
67058
diff
changeset
|
240 |
e541df85ad86
(defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents:
67058
diff
changeset
|
241 (custom-group-link GROUP) |
e541df85ad86
(defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents:
67058
diff
changeset
|
242 Link to another customization GROUP. |
49588
37645a051842
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49522
diff
changeset
|
243 |
42503
e95910976840
(defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents:
41821
diff
changeset
|
244 You can specify the text to use in the customization buffer by |
e95910976840
(defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents:
41821
diff
changeset
|
245 adding `:tag NAME' after the first element of the LINK-DATA; for |
42508
37d771fc6685
(defcustom): Fix syntax of previous change.
Richard M. Stallman <rms@gnu.org>
parents:
42503
diff
changeset
|
246 example, (info-link :tag \"foo\" \"(emacs)Top\") makes a link to the |
42503
e95910976840
(defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents:
41821
diff
changeset
|
247 Emacs manual which appears in the buffer as `foo'. |
49588
37645a051842
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49522
diff
changeset
|
248 |
42503
e95910976840
(defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents:
41821
diff
changeset
|
249 An item can have more than one external link; however, most items |
e95910976840
(defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents:
41821
diff
changeset
|
250 have none at all. |
22141 | 251 :initialize |
252 VALUE should be a function used to initialize the | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
253 variable. It takes two arguments, the symbol and value |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
254 given in the `defcustom' call. The default is |
41821 | 255 `custom-initialize-reset'. |
25683 | 256 :set VALUE should be a function to set the value of the symbol. |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
257 It takes two arguments, the symbol to set and the value to |
22606
36171df7d571
(custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22499
diff
changeset
|
258 give it. The default choice of function is `custom-set-default'. |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
259 :get VALUE should be a function to extract the value of symbol. |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
260 The function takes one argument, a symbol, and should return |
22141 | 261 the current value for that symbol. The default choice of function |
25683 | 262 is `custom-default-value'. |
22141 | 263 :require |
264 VALUE should be a feature symbol. If you save a value | |
265 for this option, then when your `.emacs' file loads the value, | |
266 it does (require VALUE) first. | |
29761 | 267 :version |
268 VALUE should be a string specifying that the variable was | |
269 first introduced, or its default value was changed, in Emacs | |
270 version VERSION. | |
42503
e95910976840
(defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents:
41821
diff
changeset
|
271 :tag LABEL |
e95910976840
(defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents:
41821
diff
changeset
|
272 Use LABEL, a string, instead of the item's name, to label the item |
42556 | 273 in customization menus and buffers. |
42503
e95910976840
(defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents:
41821
diff
changeset
|
274 :load FILE |
e95910976840
(defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents:
41821
diff
changeset
|
275 Load file FILE (a string) before displaying this customization |
47822
46f8bf0fc7b4
(custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47677
diff
changeset
|
276 item. Loading is done with `load', and only if the file is |
42503
e95910976840
(defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents:
41821
diff
changeset
|
277 not already loaded. |
48821
d886606b4f3a
(defcustom, custom-set-variables): Doc fix.
Dave Love <fx@gnu.org>
parents:
48476
diff
changeset
|
278 :set-after VARIABLES |
d886606b4f3a
(defcustom, custom-set-variables): Doc fix.
Dave Love <fx@gnu.org>
parents:
48476
diff
changeset
|
279 Specifies that SYMBOL should be set after the list of variables |
d886606b4f3a
(defcustom, custom-set-variables): Doc fix.
Dave Love <fx@gnu.org>
parents:
48476
diff
changeset
|
280 VARIABLES when both have been customized. |
17334 | 281 |
56558 | 282 If SYMBOL has a local binding, then this form affects the local |
283 binding. This is normally not what you want. Thus, if you need | |
284 to load a file defining variables with this form, or with | |
285 `defvar' or `defconst', you should always load that file | |
286 _outside_ any bindings for these variables. \(`defvar' and | |
287 `defconst' behave similarly in this respect.) | |
288 | |
17442 | 289 Read the section about customization in the Emacs Lisp manual for more |
17334 | 290 information." |
66399
65d160cfd8f2
(defface, defcustom): Add `doc-string' declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65480
diff
changeset
|
291 (declare (doc-string 3)) |
21703
aea35bf72489
(defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents:
20599
diff
changeset
|
292 ;; It is better not to use backquote in this file, |
aea35bf72489
(defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents:
20599
diff
changeset
|
293 ;; because that makes a bootstrapping problem |
aea35bf72489
(defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents:
20599
diff
changeset
|
294 ;; if you need to recompile all the Lisp files using interpreted code. |
aea35bf72489
(defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents:
20599
diff
changeset
|
295 (nconc (list 'custom-declare-variable |
aea35bf72489
(defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents:
20599
diff
changeset
|
296 (list 'quote symbol) |
aea35bf72489
(defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents:
20599
diff
changeset
|
297 (list 'quote value) |
aea35bf72489
(defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents:
20599
diff
changeset
|
298 doc) |
aea35bf72489
(defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents:
20599
diff
changeset
|
299 args)) |
17334 | 300 |
301 ;;; The `defface' Macro. | |
302 | |
303 (defmacro defface (face spec doc &rest args) | |
304 "Declare FACE as a customizable face that defaults to SPEC. | |
305 FACE does not need to be quoted. | |
306 | |
307 Third argument DOC is the face documentation. | |
308 | |
53040 | 309 If FACE has been set with `custom-set-faces', set the face attributes |
17334 | 310 as specified by that function, otherwise set the face attributes |
311 according to SPEC. | |
312 | |
313 The remaining arguments should have the form | |
314 | |
315 [KEYWORD VALUE]... | |
316 | |
17949 | 317 The following KEYWORDs are defined: |
17334 | 318 |
319 :group VALUE should be a customization group. | |
320 Add FACE to that group. | |
321 | |
322 SPEC should be an alist of the form ((DISPLAY ATTS)...). | |
323 | |
61530 | 324 In the first element, DISPLAY can be :default. The ATTS in that |
325 element then act as defaults for all the following elements. | |
326 | |
327 Aside from that, DISPLAY specifies conditions to match some or | |
328 all frames. For each frame, the first element of SPEC where the | |
329 DISPLAY conditions are satisfied is the one that applies to that | |
330 frame. The ATTRs in this element take effect, and the following | |
331 elements are ignored, on that frame. | |
332 | |
333 In the last element, DISPLAY can be t. That element applies to a | |
334 frame if none of the previous elements (except the :default if | |
335 any) did. | |
17334 | 336 |
17949 | 337 ATTS is a list of face attributes followed by their values: |
338 (ATTR VALUE ATTR VALUE...) | |
24986
cf6d86af7374
(defface): Extend documentation to include new
Gerd Moellmann <gerd@gnu.org>
parents:
24872
diff
changeset
|
339 |
cf6d86af7374
(defface): Extend documentation to include new
Gerd Moellmann <gerd@gnu.org>
parents:
24872
diff
changeset
|
340 The possible attributes are `:family', `:width', `:height', `:weight', |
cf6d86af7374
(defface): Extend documentation to include new
Gerd Moellmann <gerd@gnu.org>
parents:
24872
diff
changeset
|
341 `:slant', `:underline', `:overline', `:strike-through', `:box', |
39981
c576f3427825
(defface): Mention `:inherit' in doc-string.
Miles Bader <miles@gnu.org>
parents:
38857
diff
changeset
|
342 `:foreground', `:background', `:stipple', `:inverse-video', and `:inherit'. |
17334 | 343 |
61530 | 344 DISPLAY can be `:default' (only in the first element), the symbol |
345 t (only in the last element) to match all frames, or an alist of | |
346 conditions of the form \(REQ ITEM...). For such an alist to | |
347 match a frame, each of the conditions must be satisfied, meaning | |
348 that the REQ property of the frame must match one of the | |
349 corresponding ITEMs. These are the defined REQ values: | |
17334 | 350 |
351 `type' (the value of `window-system') | |
25888
7144668076c7
(defface): Extend documentation for new values of `type'.
Gerd Moellmann <gerd@gnu.org>
parents:
25683
diff
changeset
|
352 Under X, in addition to the values `window-system' can take, |
55545
70c4138d3b8d
* custom.el (defface): Document that type can have value gtk.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55518
diff
changeset
|
353 `motif', `lucid', `gtk' and `x-toolkit' are allowed, and match when |
70c4138d3b8d
* custom.el (defface): Document that type can have value gtk.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55518
diff
changeset
|
354 the Motif toolkit, Lucid toolkit, GTK toolkit or any X toolkit is in use. |
17334 | 355 |
356 `class' (the frame's color support) | |
357 Should be one of `color', `grayscale', or `mono'. | |
358 | |
359 `background' (what color is used for the background text) | |
360 Should be one of `light' or `dark'. | |
361 | |
54152
42286a8d371c
(defface): Add documentation for `min-colors'.
Eli Zaretskii <eliz@gnu.org>
parents:
53371
diff
changeset
|
362 `min-colors' (the minimum number of colors the frame should support) |
42286a8d371c
(defface): Add documentation for `min-colors'.
Eli Zaretskii <eliz@gnu.org>
parents:
53371
diff
changeset
|
363 Should be an integer, it is compared with the result of |
42286a8d371c
(defface): Add documentation for `min-colors'.
Eli Zaretskii <eliz@gnu.org>
parents:
53371
diff
changeset
|
364 `display-color-cells'. |
42286a8d371c
(defface): Add documentation for `min-colors'.
Eli Zaretskii <eliz@gnu.org>
parents:
53371
diff
changeset
|
365 |
55945
4ecb534c2d20
(defface): Add `supports' to docstring.
Juri Linkov <juri@jurta.org>
parents:
55545
diff
changeset
|
366 `supports' (only match frames that support the specified face attributes) |
4ecb534c2d20
(defface): Add `supports' to docstring.
Juri Linkov <juri@jurta.org>
parents:
55545
diff
changeset
|
367 Should be a list of face attributes. See the documentation for |
4ecb534c2d20
(defface): Add `supports' to docstring.
Juri Linkov <juri@jurta.org>
parents:
55545
diff
changeset
|
368 the function `display-supports-face-attributes-p' for more |
4ecb534c2d20
(defface): Add `supports' to docstring.
Juri Linkov <juri@jurta.org>
parents:
55545
diff
changeset
|
369 information on exactly how testing is done. |
4ecb534c2d20
(defface): Add `supports' to docstring.
Juri Linkov <juri@jurta.org>
parents:
55545
diff
changeset
|
370 |
17442 | 371 Read the section about customization in the Emacs Lisp manual for more |
17334 | 372 information." |
66399
65d160cfd8f2
(defface, defcustom): Add `doc-string' declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65480
diff
changeset
|
373 (declare (doc-string 3)) |
21703
aea35bf72489
(defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents:
20599
diff
changeset
|
374 ;; It is better not to use backquote in this file, |
aea35bf72489
(defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents:
20599
diff
changeset
|
375 ;; because that makes a bootstrapping problem |
aea35bf72489
(defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents:
20599
diff
changeset
|
376 ;; if you need to recompile all the Lisp files using interpreted code. |
aea35bf72489
(defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents:
20599
diff
changeset
|
377 (nconc (list 'custom-declare-face (list 'quote face) spec doc) args)) |
17334 | 378 |
379 ;;; The `defgroup' Macro. | |
380 | |
41224
fc0e6d3f905d
(custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39981
diff
changeset
|
381 (defun custom-current-group () |
fc0e6d3f905d
(custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39981
diff
changeset
|
382 (cdr (assoc load-file-name custom-current-group-alist))) |
fc0e6d3f905d
(custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39981
diff
changeset
|
383 |
17334 | 384 (defun custom-declare-group (symbol members doc &rest args) |
385 "Like `defgroup', but SYMBOL is evaluated as a normal argument." | |
25683 | 386 (while members |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
387 (apply 'custom-add-to-group symbol (car members)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
388 (setq members (cdr members))) |
17334 | 389 (when doc |
26582
fbd1f4d3000d
(custom-declare-group): Purecopy DOC.
Dave Love <fx@gnu.org>
parents:
25888
diff
changeset
|
390 ;; This text doesn't get into DOC. |
fbd1f4d3000d
(custom-declare-group): Purecopy DOC.
Dave Love <fx@gnu.org>
parents:
25888
diff
changeset
|
391 (put symbol 'group-documentation (purecopy doc))) |
25683 | 392 (while args |
17334 | 393 (let ((arg (car args))) |
394 (setq args (cdr args)) | |
395 (unless (symbolp arg) | |
396 (error "Junk in args %S" args)) | |
397 (let ((keyword arg) | |
398 (value (car args))) | |
399 (unless args | |
400 (error "Keyword %s is missing an argument" keyword)) | |
401 (setq args (cdr args)) | |
402 (cond ((eq keyword :prefix) | |
403 (put symbol 'custom-prefix value)) | |
404 (t | |
405 (custom-handle-keyword symbol keyword value | |
406 'custom-group)))))) | |
41224
fc0e6d3f905d
(custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39981
diff
changeset
|
407 ;; Record the group on the `current' list. |
fc0e6d3f905d
(custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39981
diff
changeset
|
408 (let ((elt (assoc load-file-name custom-current-group-alist))) |
fc0e6d3f905d
(custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39981
diff
changeset
|
409 (if elt (setcdr elt symbol) |
fc0e6d3f905d
(custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39981
diff
changeset
|
410 (push (cons load-file-name symbol) custom-current-group-alist))) |
17334 | 411 (run-hooks 'custom-define-hook) |
412 symbol) | |
413 | |
414 (defmacro defgroup (symbol members doc &rest args) | |
415 "Declare SYMBOL as a customization group containing MEMBERS. | |
416 SYMBOL does not need to be quoted. | |
417 | |
418 Third arg DOC is the group documentation. | |
419 | |
420 MEMBERS should be an alist of the form ((NAME WIDGET)...) where | |
20599 | 421 NAME is a symbol and WIDGET is a widget for editing that symbol. |
422 Useful widgets are `custom-variable' for editing variables, | |
17334 | 423 `custom-face' for edit faces, and `custom-group' for editing groups. |
424 | |
425 The remaining arguments should have the form | |
426 | |
25683 | 427 [KEYWORD VALUE]... |
17334 | 428 |
29761 | 429 The following KEYWORDs are defined: |
17334 | 430 |
29761 | 431 :group VALUE should be a customization group. |
432 Add SYMBOL to that group. | |
433 | |
434 :version VALUE should be a string specifying that the group was introduced | |
435 in Emacs version VERSION. | |
17334 | 436 |
17442 | 437 Read the section about customization in the Emacs Lisp manual for more |
17334 | 438 information." |
67058
65266d675973
(defgroup): Add doc-string-elt info.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
66399
diff
changeset
|
439 (declare (doc-string 3)) |
21703
aea35bf72489
(defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents:
20599
diff
changeset
|
440 ;; It is better not to use backquote in this file, |
aea35bf72489
(defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents:
20599
diff
changeset
|
441 ;; because that makes a bootstrapping problem |
aea35bf72489
(defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents:
20599
diff
changeset
|
442 ;; if you need to recompile all the Lisp files using interpreted code. |
aea35bf72489
(defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents:
20599
diff
changeset
|
443 (nconc (list 'custom-declare-group (list 'quote symbol) members doc) args)) |
17334 | 444 |
445 (defun custom-add-to-group (group option widget) | |
446 "To existing GROUP add a new OPTION of type WIDGET. | |
33025
9559a9aeff3c
(custom-add-to-group): Allow multiple entries for a given value OPTION,
Miles Bader <miles@gnu.org>
parents:
32225
diff
changeset
|
447 If there already is an entry for OPTION and WIDGET, nothing is done." |
9559a9aeff3c
(custom-add-to-group): Allow multiple entries for a given value OPTION,
Miles Bader <miles@gnu.org>
parents:
32225
diff
changeset
|
448 (let ((members (get group 'custom-group)) |
9559a9aeff3c
(custom-add-to-group): Allow multiple entries for a given value OPTION,
Miles Bader <miles@gnu.org>
parents:
32225
diff
changeset
|
449 (entry (list option widget))) |
9559a9aeff3c
(custom-add-to-group): Allow multiple entries for a given value OPTION,
Miles Bader <miles@gnu.org>
parents:
32225
diff
changeset
|
450 (unless (member entry members) |
9559a9aeff3c
(custom-add-to-group): Allow multiple entries for a given value OPTION,
Miles Bader <miles@gnu.org>
parents:
32225
diff
changeset
|
451 (put group 'custom-group (nconc members (list entry)))))) |
17334 | 452 |
47822
46f8bf0fc7b4
(custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47677
diff
changeset
|
453 (defun custom-group-of-mode (mode) |
46f8bf0fc7b4
(custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47677
diff
changeset
|
454 "Return the custom group corresponding to the major or minor MODE. |
46f8bf0fc7b4
(custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47677
diff
changeset
|
455 If no such group is found, return nil." |
46f8bf0fc7b4
(custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47677
diff
changeset
|
456 (or (get mode 'custom-mode-group) |
46f8bf0fc7b4
(custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47677
diff
changeset
|
457 (if (or (get mode 'custom-group) |
46f8bf0fc7b4
(custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47677
diff
changeset
|
458 (and (string-match "-mode\\'" (symbol-name mode)) |
46f8bf0fc7b4
(custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47677
diff
changeset
|
459 (get (setq mode (intern (substring (symbol-name mode) |
46f8bf0fc7b4
(custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47677
diff
changeset
|
460 0 (match-beginning 0)))) |
46f8bf0fc7b4
(custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47677
diff
changeset
|
461 'custom-group))) |
46f8bf0fc7b4
(custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47677
diff
changeset
|
462 mode))) |
46f8bf0fc7b4
(custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47677
diff
changeset
|
463 |
17334 | 464 ;;; Properties. |
465 | |
466 (defun custom-handle-all-keywords (symbol args type) | |
467 "For customization option SYMBOL, handle keyword arguments ARGS. | |
468 Third argument TYPE is the custom option type." | |
41224
fc0e6d3f905d
(custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39981
diff
changeset
|
469 (unless (memq :group args) |
48272
8555178ad8a0
(custom-handle-all-keywords): Fix arg passed to custom-add-to-group.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
48238
diff
changeset
|
470 (custom-add-to-group (custom-current-group) symbol type)) |
25683 | 471 (while args |
17334 | 472 (let ((arg (car args))) |
473 (setq args (cdr args)) | |
474 (unless (symbolp arg) | |
475 (error "Junk in args %S" args)) | |
476 (let ((keyword arg) | |
477 (value (car args))) | |
478 (unless args | |
479 (error "Keyword %s is missing an argument" keyword)) | |
480 (setq args (cdr args)) | |
25683 | 481 (custom-handle-keyword symbol keyword value type))))) |
17334 | 482 |
483 (defun custom-handle-keyword (symbol keyword value type) | |
484 "For customization option SYMBOL, handle KEYWORD with VALUE. | |
485 Fourth argument TYPE is the custom option type." | |
26582
fbd1f4d3000d
(custom-declare-group): Purecopy DOC.
Dave Love <fx@gnu.org>
parents:
25888
diff
changeset
|
486 (if purify-flag |
fbd1f4d3000d
(custom-declare-group): Purecopy DOC.
Dave Love <fx@gnu.org>
parents:
25888
diff
changeset
|
487 (setq value (purecopy value))) |
17334 | 488 (cond ((eq keyword :group) |
489 (custom-add-to-group value symbol type)) | |
20445
20ff88ac8cc2
(custom-add-version): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19535
diff
changeset
|
490 ((eq keyword :version) |
20ff88ac8cc2
(custom-add-version): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19535
diff
changeset
|
491 (custom-add-version symbol value)) |
17334 | 492 ((eq keyword :link) |
493 (custom-add-link symbol value)) | |
494 ((eq keyword :load) | |
495 (custom-add-load symbol value)) | |
496 ((eq keyword :tag) | |
497 (put symbol 'custom-tag value)) | |
26831
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
498 ((eq keyword :set-after) |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
499 (custom-add-dependencies symbol value)) |
17334 | 500 (t |
24872
9db8a7ed814e
(custom-handle-keyword): Fix error message.
Karl Heuer <kwzh@gnu.org>
parents:
24438
diff
changeset
|
501 (error "Unknown keyword %s" keyword)))) |
17334 | 502 |
26831
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
503 (defun custom-add-dependencies (symbol value) |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
504 "To the custom option SYMBOL, add dependencies specified by VALUE. |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
505 VALUE should be a list of symbols. For each symbol in that list, |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
506 this specifies that SYMBOL should be set after the specified symbol, if |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
507 both appear in constructs like `custom-set-variables'." |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
508 (unless (listp value) |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
509 (error "Invalid custom dependency `%s'" value)) |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
510 (let* ((deps (get symbol 'custom-dependencies)) |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
511 (new-deps deps)) |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
512 (while value |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
513 (let ((dep (car value))) |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
514 (unless (symbolp dep) |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
515 (error "Invalid custom dependency `%s'" dep)) |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
516 (unless (memq dep new-deps) |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
517 (setq new-deps (cons dep new-deps))) |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
518 (setq value (cdr value)))) |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
519 (unless (eq deps new-deps) |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
520 (put symbol 'custom-dependencies new-deps)))) |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
521 |
17334 | 522 (defun custom-add-option (symbol option) |
523 "To the variable SYMBOL add OPTION. | |
524 | |
63932
bbf23e50d797
(custom-add-option): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
63927
diff
changeset
|
525 If SYMBOL's custom type is a hook, OPTION should be a hook member. |
bbf23e50d797
(custom-add-option): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
63927
diff
changeset
|
526 If SYMBOL's custom type is an alist, OPTION specifies a symbol |
bbf23e50d797
(custom-add-option): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
63927
diff
changeset
|
527 to offer to the user as a possible key in the alist. |
bbf23e50d797
(custom-add-option): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
63927
diff
changeset
|
528 For other custom types, this has no effect." |
17334 | 529 (let ((options (get symbol 'custom-options))) |
530 (unless (member option options) | |
531 (put symbol 'custom-options (cons option options))))) | |
532 | |
533 (defun custom-add-link (symbol widget) | |
534 "To the custom option SYMBOL add the link WIDGET." | |
535 (let ((links (get symbol 'custom-links))) | |
536 (unless (member widget links) | |
26582
fbd1f4d3000d
(custom-declare-group): Purecopy DOC.
Dave Love <fx@gnu.org>
parents:
25888
diff
changeset
|
537 (put symbol 'custom-links (cons (purecopy widget) links))))) |
17334 | 538 |
20445
20ff88ac8cc2
(custom-add-version): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19535
diff
changeset
|
539 (defun custom-add-version (symbol version) |
20ff88ac8cc2
(custom-add-version): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19535
diff
changeset
|
540 "To the custom option SYMBOL add the version VERSION." |
26582
fbd1f4d3000d
(custom-declare-group): Purecopy DOC.
Dave Love <fx@gnu.org>
parents:
25888
diff
changeset
|
541 (put symbol 'custom-version (purecopy version))) |
20445
20ff88ac8cc2
(custom-add-version): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19535
diff
changeset
|
542 |
17334 | 543 (defun custom-add-load (symbol load) |
544 "To the custom option SYMBOL add the dependency LOAD. | |
545 LOAD should be either a library file name, or a feature name." | |
546 (let ((loads (get symbol 'custom-loads))) | |
547 (unless (member load loads) | |
26582
fbd1f4d3000d
(custom-declare-group): Purecopy DOC.
Dave Love <fx@gnu.org>
parents:
25888
diff
changeset
|
548 (put symbol 'custom-loads (cons (purecopy load) loads))))) |
17334 | 549 |
49099
04672e32e3b0
(custom-autoload, custom-variable-p): New functions.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
48951
diff
changeset
|
550 (defun custom-autoload (symbol load) |
04672e32e3b0
(custom-autoload, custom-variable-p): New functions.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
48951
diff
changeset
|
551 "Mark SYMBOL as autoloaded custom variable and add dependency LOAD." |
04672e32e3b0
(custom-autoload, custom-variable-p): New functions.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
48951
diff
changeset
|
552 (put symbol 'custom-autoload t) |
04672e32e3b0
(custom-autoload, custom-variable-p): New functions.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
48951
diff
changeset
|
553 (custom-add-load symbol load)) |
04672e32e3b0
(custom-autoload, custom-variable-p): New functions.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
48951
diff
changeset
|
554 |
04672e32e3b0
(custom-autoload, custom-variable-p): New functions.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
48951
diff
changeset
|
555 ;; This test is also in the C code of `user-variable-p'. |
04672e32e3b0
(custom-autoload, custom-variable-p): New functions.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
48951
diff
changeset
|
556 (defun custom-variable-p (variable) |
64149
8633ed45b13c
(custom-variable-p): Make it recursively follow aliases. Mention that
Luc Teirlinck <teirllm@auburn.edu>
parents:
64091
diff
changeset
|
557 "Return non-nil if VARIABLE is a custom variable. |
8633ed45b13c
(custom-variable-p): Make it recursively follow aliases. Mention that
Luc Teirlinck <teirllm@auburn.edu>
parents:
64091
diff
changeset
|
558 This recursively follows aliases." |
8633ed45b13c
(custom-variable-p): Make it recursively follow aliases. Mention that
Luc Teirlinck <teirllm@auburn.edu>
parents:
64091
diff
changeset
|
559 (setq variable (indirect-variable variable)) |
49099
04672e32e3b0
(custom-autoload, custom-variable-p): New functions.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
48951
diff
changeset
|
560 (or (get variable 'standard-value) |
04672e32e3b0
(custom-autoload, custom-variable-p): New functions.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
48951
diff
changeset
|
561 (get variable 'custom-autoload))) |
04672e32e3b0
(custom-autoload, custom-variable-p): New functions.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
48951
diff
changeset
|
562 |
44911
0edc2b27187b
(custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents:
44683
diff
changeset
|
563 ;;; Loading files needed to customize a symbol. |
0edc2b27187b
(custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents:
44683
diff
changeset
|
564 ;;; This is in custom.el because menu-bar.el needs it for toggle cmds. |
0edc2b27187b
(custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents:
44683
diff
changeset
|
565 |
0edc2b27187b
(custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents:
44683
diff
changeset
|
566 (defvar custom-load-recursion nil |
0edc2b27187b
(custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents:
44683
diff
changeset
|
567 "Hack to avoid recursive dependencies.") |
0edc2b27187b
(custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents:
44683
diff
changeset
|
568 |
0edc2b27187b
(custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents:
44683
diff
changeset
|
569 (defun custom-load-symbol (symbol) |
0edc2b27187b
(custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents:
44683
diff
changeset
|
570 "Load all dependencies for SYMBOL." |
0edc2b27187b
(custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents:
44683
diff
changeset
|
571 (unless custom-load-recursion |
47822
46f8bf0fc7b4
(custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47677
diff
changeset
|
572 (let ((custom-load-recursion t)) |
52207
c26f56efcd5d
(custom-load-symbol): Load cus-load and cus-start first.
Richard M. Stallman <rms@gnu.org>
parents:
50123
diff
changeset
|
573 ;; Load these files if not already done, |
c26f56efcd5d
(custom-load-symbol): Load cus-load and cus-start first.
Richard M. Stallman <rms@gnu.org>
parents:
50123
diff
changeset
|
574 ;; to make sure we know all the dependencies of SYMBOL. |
c26f56efcd5d
(custom-load-symbol): Load cus-load and cus-start first.
Richard M. Stallman <rms@gnu.org>
parents:
50123
diff
changeset
|
575 (condition-case nil |
c26f56efcd5d
(custom-load-symbol): Load cus-load and cus-start first.
Richard M. Stallman <rms@gnu.org>
parents:
50123
diff
changeset
|
576 (require 'cus-load) |
c26f56efcd5d
(custom-load-symbol): Load cus-load and cus-start first.
Richard M. Stallman <rms@gnu.org>
parents:
50123
diff
changeset
|
577 (error nil)) |
c26f56efcd5d
(custom-load-symbol): Load cus-load and cus-start first.
Richard M. Stallman <rms@gnu.org>
parents:
50123
diff
changeset
|
578 (condition-case nil |
c26f56efcd5d
(custom-load-symbol): Load cus-load and cus-start first.
Richard M. Stallman <rms@gnu.org>
parents:
50123
diff
changeset
|
579 (require 'cus-start) |
c26f56efcd5d
(custom-load-symbol): Load cus-load and cus-start first.
Richard M. Stallman <rms@gnu.org>
parents:
50123
diff
changeset
|
580 (error nil)) |
47822
46f8bf0fc7b4
(custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47677
diff
changeset
|
581 (dolist (load (get symbol 'custom-loads)) |
46f8bf0fc7b4
(custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47677
diff
changeset
|
582 (cond ((symbolp load) (condition-case nil (require load) (error nil))) |
46f8bf0fc7b4
(custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47677
diff
changeset
|
583 ;; This is subsumed by the test below, but it's much faster. |
44911
0edc2b27187b
(custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents:
44683
diff
changeset
|
584 ((assoc load load-history)) |
0edc2b27187b
(custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents:
44683
diff
changeset
|
585 ;; This was just (assoc (locate-library load) load-history) |
0edc2b27187b
(custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents:
44683
diff
changeset
|
586 ;; but has been optimized not to load locate-library |
0edc2b27187b
(custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents:
44683
diff
changeset
|
587 ;; if not necessary. |
47822
46f8bf0fc7b4
(custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47677
diff
changeset
|
588 ((let ((regexp (concat "\\(\\`\\|/\\)" (regexp-quote load) |
46f8bf0fc7b4
(custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47677
diff
changeset
|
589 "\\(\\'\\|\\.\\)")) |
46f8bf0fc7b4
(custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47677
diff
changeset
|
590 (found nil)) |
44911
0edc2b27187b
(custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents:
44683
diff
changeset
|
591 (dolist (loaded load-history) |
45366
c9338efa3fd9
(custom-load-symbol): Verify that LOADED is a string.
Richard M. Stallman <rms@gnu.org>
parents:
44911
diff
changeset
|
592 (and (stringp (car loaded)) |
c9338efa3fd9
(custom-load-symbol): Verify that LOADED is a string.
Richard M. Stallman <rms@gnu.org>
parents:
44911
diff
changeset
|
593 (string-match regexp (car loaded)) |
44911
0edc2b27187b
(custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents:
44683
diff
changeset
|
594 (setq found t))) |
0edc2b27187b
(custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents:
44683
diff
changeset
|
595 found)) |
0edc2b27187b
(custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents:
44683
diff
changeset
|
596 ;; Without this, we would load cus-edit recursively. |
0edc2b27187b
(custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents:
44683
diff
changeset
|
597 ;; We are still loading it when we call this, |
0edc2b27187b
(custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents:
44683
diff
changeset
|
598 ;; and it is not in load-history yet. |
0edc2b27187b
(custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents:
44683
diff
changeset
|
599 ((equal load "cus-edit")) |
47822
46f8bf0fc7b4
(custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47677
diff
changeset
|
600 (t (condition-case nil (load load) (error nil)))))))) |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
601 |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
602 (defvar custom-known-themes '(user standard) |
63927
7f7d0de05845
(custom-declare-variable): Fix typos in comment.
Luc Teirlinck <teirllm@auburn.edu>
parents:
61530
diff
changeset
|
603 "Themes that have been defined with `deftheme'. |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
604 The default value is the list (user standard). The theme `standard' |
65341
6990826a916f
Custom Theme bugfixes.
Chong Yidong <cyd@stupidchicken.com>
parents:
65334
diff
changeset
|
605 contains the settings before custom themes are applied. The |
64441
d0cd5eb4d042
(custom-known-themes): Delete duplicate words.
Juri Linkov <juri@jurta.org>
parents:
64303
diff
changeset
|
606 theme `user' contains all the settings the user customized and saved. |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
607 Additional themes declared with the `deftheme' macro will be added to |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
608 the front of this list.") |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
609 |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
610 (defsubst custom-theme-p (theme) |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
611 "Non-nil when THEME has been defined." |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
612 (memq theme custom-known-themes)) |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
613 |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
614 (defsubst custom-check-theme (theme) |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
615 "Check whether THEME is valid, and signal an error if it is not." |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
616 (unless (custom-theme-p theme) |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
617 (error "Unknown theme `%s'" theme))) |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
618 |
17334 | 619 ;;; Initializing. |
620 | |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
621 (defun custom-push-theme (prop symbol theme mode value) |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
622 "Record a value for face or variable SYMBOL in custom theme THEME. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
623 PROP is`theme-face' for a face, `theme-value' for a variable. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
624 The value is specified by (THEME MODE VALUE), which is interpreted |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
625 by `custom-theme-value'. |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
626 |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
627 MODE can be either the symbol `set' or the symbol `reset'. If it is the |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
628 symbol `set', then VALUE is the value to use. If it is the symbol |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
629 `reset', then VALUE is another theme, whose value for this face or |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
630 variable should be used. |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
631 |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
632 In the following example for the variable `goto-address-url-face', the |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
633 theme `subtle-hacker' uses the same value for the variable as the theme |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
634 `gnome2': |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
635 |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
636 \((standard set bold) |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
637 \(gnome2 set info-xref) |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
638 \(jonadab set underline) |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
639 \(subtle-hacker reset gnome2)) |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
640 |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
641 |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
642 If a value has been stored for themes A B and C, and a new value |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
643 is to be stored for theme C, then the old value of C is discarded. |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
644 If a new value is to be stored for theme B, however, the old value |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
645 of B is not discarded because B is not the car of the list. |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
646 |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
647 For variables, list property PROP is `theme-value'. |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
648 For faces, list property PROP is `theme-face'. |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
649 This is used in `custom-do-theme-reset', for example. |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
650 |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
651 The list looks the same in any case; the examples shows a possible |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
652 value of the `theme-face' property for the face `region': |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
653 |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
654 \((gnome2 set ((t (:foreground \"cyan\" :background \"dark cyan\")))) |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
655 \(standard set ((((class color) (background dark)) |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
656 \(:background \"blue\")) |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
657 \(t (:background \"gray\"))))) |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
658 |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
659 This records values for the `standard' and the `gnome2' themes. |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
660 The user has not customized the face; had he done that, |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
661 the list would contain an entry for the `user' theme, too. |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
662 See `custom-known-themes' for a list of known themes." |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
663 (let* ((old (get symbol prop)) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
664 (setting (assq theme old))) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
665 ;; Alter an existing theme-setting for the symbol, |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
666 ;; or add a new one. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
667 (if setting |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
668 (progn |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
669 (setcar (cdr setting) mode) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
670 (setcar (cddr setting) value)) |
65480
c60d119298c4
* custom.el (custom-push-theme): Handle the case where a symbol is
Chong Yidong <cyd@stupidchicken.com>
parents:
65343
diff
changeset
|
671 ;; If no custom theme has been applied yet, first save the |
c60d119298c4
* custom.el (custom-push-theme): Handle the case where a symbol is
Chong Yidong <cyd@stupidchicken.com>
parents:
65343
diff
changeset
|
672 ;; current values to the 'standard theme. |
c60d119298c4
* custom.el (custom-push-theme): Handle the case where a symbol is
Chong Yidong <cyd@stupidchicken.com>
parents:
65343
diff
changeset
|
673 (if (null old) |
c60d119298c4
* custom.el (custom-push-theme): Handle the case where a symbol is
Chong Yidong <cyd@stupidchicken.com>
parents:
65343
diff
changeset
|
674 (if (and (eq prop 'theme-value) |
c60d119298c4
* custom.el (custom-push-theme): Handle the case where a symbol is
Chong Yidong <cyd@stupidchicken.com>
parents:
65343
diff
changeset
|
675 (boundp symbol)) |
c60d119298c4
* custom.el (custom-push-theme): Handle the case where a symbol is
Chong Yidong <cyd@stupidchicken.com>
parents:
65343
diff
changeset
|
676 (setq old |
c60d119298c4
* custom.el (custom-push-theme): Handle the case where a symbol is
Chong Yidong <cyd@stupidchicken.com>
parents:
65343
diff
changeset
|
677 (list (list 'standard 'set (symbol-value symbol)))) |
c60d119298c4
* custom.el (custom-push-theme): Handle the case where a symbol is
Chong Yidong <cyd@stupidchicken.com>
parents:
65343
diff
changeset
|
678 (if (facep symbol) |
c60d119298c4
* custom.el (custom-push-theme): Handle the case where a symbol is
Chong Yidong <cyd@stupidchicken.com>
parents:
65343
diff
changeset
|
679 (setq old (list (list 'standard 'set (list |
c60d119298c4
* custom.el (custom-push-theme): Handle the case where a symbol is
Chong Yidong <cyd@stupidchicken.com>
parents:
65343
diff
changeset
|
680 (append '(t) (custom-face-attributes-get symbol nil))))))))) |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
681 (put symbol prop (cons (list theme mode value) old))) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
682 ;; Record, for each theme, all its settings. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
683 (put theme 'theme-settings |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
684 (cons (list prop symbol theme mode value) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
685 (get theme 'theme-settings))))) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
686 |
22606
36171df7d571
(custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22499
diff
changeset
|
687 (defvar custom-local-buffer nil |
36171df7d571
(custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22499
diff
changeset
|
688 "Non-nil, in a Customization buffer, means customize a specific buffer. |
36171df7d571
(custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22499
diff
changeset
|
689 If this variable is non-nil, it should be a buffer, |
36171df7d571
(custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22499
diff
changeset
|
690 and it means customize the local bindings of that buffer. |
36171df7d571
(custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22499
diff
changeset
|
691 This variable is a permanent local, and it normally has a local binding |
36171df7d571
(custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22499
diff
changeset
|
692 in every Customization buffer.") |
36171df7d571
(custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22499
diff
changeset
|
693 (put 'custom-local-buffer 'permanent-local t) |
36171df7d571
(custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22499
diff
changeset
|
694 |
17334 | 695 (defun custom-set-variables (&rest args) |
59385
24b54016dd51
(custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents:
56558
diff
changeset
|
696 "Install user customizations of variable values specified in ARGS. |
24b54016dd51
(custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents:
56558
diff
changeset
|
697 These settings are registered as theme `user'. |
48821
d886606b4f3a
(defcustom, custom-set-variables): Doc fix.
Dave Love <fx@gnu.org>
parents:
48476
diff
changeset
|
698 The arguments should each be a list of the form: |
17334 | 699 |
59385
24b54016dd51
(custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents:
56558
diff
changeset
|
700 (SYMBOL EXP [NOW [REQUEST [COMMENT]]]) |
17334 | 701 |
59385
24b54016dd51
(custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents:
56558
diff
changeset
|
702 This stores EXP (without evaluating it) as the saved value for SYMBOL. |
24b54016dd51
(custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents:
56558
diff
changeset
|
703 If NOW is present and non-nil, then also evaluate EXP and set |
24b54016dd51
(custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents:
56558
diff
changeset
|
704 the default value for the SYMBOL to the value of EXP. |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
705 |
59385
24b54016dd51
(custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents:
56558
diff
changeset
|
706 REQUEST is a list of features we must require in order to |
24b54016dd51
(custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents:
56558
diff
changeset
|
707 handle SYMBOL properly. |
25683 | 708 COMMENT is a comment string about SYMBOL." |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
709 (apply 'custom-theme-set-variables 'user args)) |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
710 |
60413
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
711 (defun custom-reevaluate-setting (symbol) |
64239
bcc16dd12f8b
(custom-reevaluate-setting): Doc fix.
Luc Teirlinck <teirllm@auburn.edu>
parents:
64228
diff
changeset
|
712 "Reset the value of SYMBOL by re-evaluating its saved or standard value. |
bcc16dd12f8b
(custom-reevaluate-setting): Doc fix.
Luc Teirlinck <teirllm@auburn.edu>
parents:
64228
diff
changeset
|
713 Use the :set function to do so. This is useful for customizable options |
bcc16dd12f8b
(custom-reevaluate-setting): Doc fix.
Luc Teirlinck <teirllm@auburn.edu>
parents:
64228
diff
changeset
|
714 that are defined before their standard value can really be computed. |
bcc16dd12f8b
(custom-reevaluate-setting): Doc fix.
Luc Teirlinck <teirllm@auburn.edu>
parents:
64228
diff
changeset
|
715 E.g. dumped variables whose default depends on run-time information." |
60413
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
716 (funcall (or (get symbol 'custom-set) 'set-default) |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
717 symbol |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
718 (eval (car (or (get symbol 'saved-value) (get symbol 'standard-value)))))) |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
719 |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
720 (defun custom-theme-set-variables (theme &rest args) |
59385
24b54016dd51
(custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents:
56558
diff
changeset
|
721 "Initialize variables for theme THEME according to settings in ARGS. |
24b54016dd51
(custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents:
56558
diff
changeset
|
722 Each of the arguments in ARGS should be a list of this form: |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
723 |
59385
24b54016dd51
(custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents:
56558
diff
changeset
|
724 (SYMBOL EXP [NOW [REQUEST [COMMENT]]]) |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
725 |
59385
24b54016dd51
(custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents:
56558
diff
changeset
|
726 This stores EXP (without evaluating it) as the saved value for SYMBOL. |
24b54016dd51
(custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents:
56558
diff
changeset
|
727 If NOW is present and non-nil, then also evaluate EXP and set |
24b54016dd51
(custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents:
56558
diff
changeset
|
728 the default value for the SYMBOL to the value of EXP. |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
729 |
59385
24b54016dd51
(custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents:
56558
diff
changeset
|
730 REQUEST is a list of features we must require in order to |
24b54016dd51
(custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents:
56558
diff
changeset
|
731 handle SYMBOL properly. |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
732 COMMENT is a comment string about SYMBOL. |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
733 |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
734 Several properties of THEME and SYMBOL are used in the process: |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
735 |
59385
24b54016dd51
(custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents:
56558
diff
changeset
|
736 If THEME's property `theme-immediate' is non-nil, this is equivalent of |
24b54016dd51
(custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents:
56558
diff
changeset
|
737 providing the NOW argument to all symbols in the argument list: |
24b54016dd51
(custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents:
56558
diff
changeset
|
738 evaluate each EXP and set the corresponding SYMBOL. However, |
24b54016dd51
(custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents:
56558
diff
changeset
|
739 there's a difference in the handling of SYMBOL's property |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
740 `force-value': if NOW is non-nil, SYMBOL's property `force-value' is set to |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
741 the symbol `rogue', else if THEME's property `theme-immediate' is non-nil, |
59385
24b54016dd51
(custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents:
56558
diff
changeset
|
742 SYMBOL's property `force-value' is set to the symbol `immediate'. |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
743 |
59385
24b54016dd51
(custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents:
56558
diff
changeset
|
744 EXP itself is saved unevaluated as SYMBOL property `saved-value' and |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
745 in SYMBOL's list property `theme-value' \(using `custom-push-theme')." |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
746 (custom-check-theme theme) |
60413
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
747 (setq args |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
748 (sort args |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
749 (lambda (a1 a2) |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
750 (let* ((sym1 (car a1)) |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
751 (sym2 (car a2)) |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
752 (1-then-2 (memq sym1 (get sym2 'custom-dependencies))) |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
753 (2-then-1 (memq sym2 (get sym1 'custom-dependencies)))) |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
754 (cond ((and 1-then-2 2-then-1) |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
755 (error "Circular custom dependency between `%s' and `%s'" |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
756 sym1 sym2)) |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
757 (2-then-1 nil) |
65093
1aae62fd4a80
(custom-theme-set-variables): Sort minor modes last.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
758 ;; Put minor modes and symbols with :require last. |
1aae62fd4a80
(custom-theme-set-variables): Sort minor modes last.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
759 ;; Putting minor modes last ensures that the mode |
1aae62fd4a80
(custom-theme-set-variables): Sort minor modes last.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
760 ;; function will see other customized values rather |
1aae62fd4a80
(custom-theme-set-variables): Sort minor modes last.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
761 ;; than default values. |
1aae62fd4a80
(custom-theme-set-variables): Sort minor modes last.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
762 (t (or (nth 3 a2) |
1aae62fd4a80
(custom-theme-set-variables): Sort minor modes last.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
763 (eq (get sym2 'custom-set) |
1aae62fd4a80
(custom-theme-set-variables): Sort minor modes last.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
764 'custom-set-minor-mode)))))))) |
60413
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
765 (while args |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
766 (let ((entry (car args))) |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
767 (if (listp entry) |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
768 (let* ((symbol (indirect-variable (nth 0 entry))) |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
769 (value (nth 1 entry)) |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
770 (now (nth 2 entry)) |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
771 (requests (nth 3 entry)) |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
772 (comment (nth 4 entry)) |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
773 set) |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
774 (when requests |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
775 (put symbol 'custom-requests requests) |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
776 (mapc 'require requests)) |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
777 (setq set (or (get symbol 'custom-set) 'custom-set-default)) |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
778 (put symbol 'saved-value (list value)) |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
779 (put symbol 'saved-variable-comment comment) |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
780 (custom-push-theme 'theme-value symbol theme 'set value) |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
781 ;; Allow for errors in the case where the setter has |
31362
652b5c65769a
(custom-set-variables): Print message about errors in
Dave Love <fx@gnu.org>
parents:
29761
diff
changeset
|
782 ;; changed between versions, say, but let the user know. |
652b5c65769a
(custom-set-variables): Print message about errors in
Dave Love <fx@gnu.org>
parents:
29761
diff
changeset
|
783 (condition-case data |
24438
4a78f6354310
(custom-set-variables): Protect against setter errors.
Dave Love <fx@gnu.org>
parents:
23354
diff
changeset
|
784 (cond (now |
4a78f6354310
(custom-set-variables): Protect against setter errors.
Dave Love <fx@gnu.org>
parents:
23354
diff
changeset
|
785 ;; Rogue variable, set it now. |
4a78f6354310
(custom-set-variables): Protect against setter errors.
Dave Love <fx@gnu.org>
parents:
23354
diff
changeset
|
786 (put symbol 'force-value t) |
4a78f6354310
(custom-set-variables): Protect against setter errors.
Dave Love <fx@gnu.org>
parents:
23354
diff
changeset
|
787 (funcall set symbol (eval value))) |
4a78f6354310
(custom-set-variables): Protect against setter errors.
Dave Love <fx@gnu.org>
parents:
23354
diff
changeset
|
788 ((default-boundp symbol) |
4a78f6354310
(custom-set-variables): Protect against setter errors.
Dave Love <fx@gnu.org>
parents:
23354
diff
changeset
|
789 ;; Something already set this, overwrite it. |
4a78f6354310
(custom-set-variables): Protect against setter errors.
Dave Love <fx@gnu.org>
parents:
23354
diff
changeset
|
790 (funcall set symbol (eval value)))) |
49588
37645a051842
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49522
diff
changeset
|
791 (error |
31362
652b5c65769a
(custom-set-variables): Print message about errors in
Dave Love <fx@gnu.org>
parents:
29761
diff
changeset
|
792 (message "Error setting %s: %s" symbol data))) |
60413
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
793 (setq args (cdr args)) |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
794 (and (or now (default-boundp symbol)) |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
795 (put symbol 'variable-comment comment))) |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
796 ;; Old format, a plist of SYMBOL VALUE pairs. |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
797 (message "Warning: old format `custom-set-variables'") |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
798 (ding) |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
799 (sit-for 2) |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
800 (let ((symbol (indirect-variable (nth 0 args))) |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
801 (value (nth 1 args))) |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
802 (put symbol 'saved-value (list value)) |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
803 (custom-push-theme 'theme-value symbol theme 'set value)) |
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
804 (setq args (cdr (cdr args))))))) |
17334 | 805 |
22606
36171df7d571
(custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22499
diff
changeset
|
806 (defun custom-set-default (variable value) |
36171df7d571
(custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22499
diff
changeset
|
807 "Default :set function for a customizable variable. |
36171df7d571
(custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22499
diff
changeset
|
808 Normally, this sets the default value of VARIABLE to VALUE, |
36171df7d571
(custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22499
diff
changeset
|
809 but if `custom-local-buffer' is non-nil, |
36171df7d571
(custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22499
diff
changeset
|
810 this sets the local binding in that buffer instead." |
36171df7d571
(custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22499
diff
changeset
|
811 (if custom-local-buffer |
36171df7d571
(custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22499
diff
changeset
|
812 (with-current-buffer custom-local-buffer |
36171df7d571
(custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22499
diff
changeset
|
813 (set variable value)) |
36171df7d571
(custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22499
diff
changeset
|
814 (set-default variable value))) |
36171df7d571
(custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22499
diff
changeset
|
815 |
50123
7c924263658d
(custom-set-minor-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49588
diff
changeset
|
816 (defun custom-set-minor-mode (variable value) |
7c924263658d
(custom-set-minor-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49588
diff
changeset
|
817 ":set function for minor mode variables. |
7c924263658d
(custom-set-minor-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49588
diff
changeset
|
818 Normally, this sets the default value of VARIABLE to nil if VALUE |
7c924263658d
(custom-set-minor-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49588
diff
changeset
|
819 is nil and to t otherwise, |
7c924263658d
(custom-set-minor-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49588
diff
changeset
|
820 but if `custom-local-buffer' is non-nil, |
7c924263658d
(custom-set-minor-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49588
diff
changeset
|
821 this sets the local binding in that buffer instead." |
7c924263658d
(custom-set-minor-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49588
diff
changeset
|
822 (if custom-local-buffer |
7c924263658d
(custom-set-minor-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49588
diff
changeset
|
823 (with-current-buffer custom-local-buffer |
61432
7279141eb80e
(custom-set-minor-mode): Any non-nil value for the variable should
Luc Teirlinck <teirllm@auburn.edu>
parents:
60413
diff
changeset
|
824 (funcall variable (if value 1 0))) |
7279141eb80e
(custom-set-minor-mode): Any non-nil value for the variable should
Luc Teirlinck <teirllm@auburn.edu>
parents:
60413
diff
changeset
|
825 (funcall variable (if value 1 0)))) |
50123
7c924263658d
(custom-set-minor-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49588
diff
changeset
|
826 |
44683
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
827 (defun custom-quote (sexp) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
828 "Quote SEXP iff it is not self quoting." |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
829 (if (or (memq sexp '(t nil)) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
830 (keywordp sexp) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
831 (and (listp sexp) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
832 (memq (car sexp) '(lambda))) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
833 (stringp sexp) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
834 (numberp sexp) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
835 (vectorp sexp) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
836 ;;; (and (fboundp 'characterp) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
837 ;;; (characterp sexp)) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
838 ) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
839 sexp |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
840 (list 'quote sexp))) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
841 |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
842 (defun customize-mark-to-save (symbol) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
843 "Mark SYMBOL for later saving. |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
844 |
49588
37645a051842
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49522
diff
changeset
|
845 If the default value of SYMBOL is different from the standard value, |
44683
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
846 set the `saved-value' property to a list whose car evaluates to the |
49522
4dd5da1ea3dc
* font-lock.el (lisp-font-lock-keywords-1): Match `deftheme'.
John Paul Wallington <jpw@pobox.com>
parents:
49099
diff
changeset
|
847 default value. Otherwise, set it to nil. |
44683
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
848 |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
849 To actually save the value, call `custom-save-all'. |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
850 |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
851 Return non-nil iff the `saved-value' property actually changed." |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
852 (let* ((get (or (get symbol 'custom-get) 'default-value)) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
853 (value (funcall get symbol)) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
854 (saved (get symbol 'saved-value)) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
855 (standard (get symbol 'standard-value)) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
856 (comment (get symbol 'customized-variable-comment))) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
857 ;; Save default value iff different from standard value. |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
858 (if (or (null standard) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
859 (not (equal value (condition-case nil |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
860 (eval (car standard)) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
861 (error nil))))) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
862 (put symbol 'saved-value (list (custom-quote value))) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
863 (put symbol 'saved-value nil)) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
864 ;; Clear customized information (set, but not saved). |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
865 (put symbol 'customized-value nil) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
866 ;; Save any comment that might have been set. |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
867 (when comment |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
868 (put symbol 'saved-variable-comment comment)) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
869 (not (equal saved (get symbol 'saved-value))))) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
870 |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
871 (defun customize-mark-as-set (symbol) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
872 "Mark current value of SYMBOL as being set from customize. |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
873 |
49588
37645a051842
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49522
diff
changeset
|
874 If the default value of SYMBOL is different from the saved value if any, |
44683
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
875 or else if it is different from the standard value, set the |
49588
37645a051842
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49522
diff
changeset
|
876 `customized-value' property to a list whose car evaluates to the |
49522
4dd5da1ea3dc
* font-lock.el (lisp-font-lock-keywords-1): Match `deftheme'.
John Paul Wallington <jpw@pobox.com>
parents:
49099
diff
changeset
|
877 default value. Otherwise, set it to nil. |
44683
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
878 |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
879 Return non-nil iff the `customized-value' property actually changed." |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
880 (let* ((get (or (get symbol 'custom-get) 'default-value)) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
881 (value (funcall get symbol)) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
882 (customized (get symbol 'customized-value)) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
883 (old (or (get symbol 'saved-value) (get symbol 'standard-value)))) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
884 ;; Mark default value as set iff different from old value. |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
885 (if (or (null old) |
49588
37645a051842
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49522
diff
changeset
|
886 (not (equal value (condition-case nil |
44683
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
887 (eval (car old)) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
888 (error nil))))) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
889 (put symbol 'customized-value (list (custom-quote value))) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
890 (put symbol 'customized-value nil)) |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
891 ;; Changed? |
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
892 (not (equal customized (get symbol 'customized-value))))) |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
893 |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
894 ;;; Defining themes. |
44683
17031c88f781
(customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents:
42556
diff
changeset
|
895 |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
896 ;; deftheme is used at the beginning of the file that records a theme. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
897 |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
898 (defmacro deftheme (theme &optional doc &rest args) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
899 "Declare custom theme THEME. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
900 The optional argument DOC is a doc string describing the theme. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
901 The remaining arguments should have the form |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
902 |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
903 [KEYWORD VALUE]... |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
904 |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
905 The following KEYWORD's are defined: |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
906 |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
907 :short-description |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
908 VALUE is a short (one line) description of the theme. If not |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
909 given, DOC is used. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
910 :immediate |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
911 If VALUE is non-nil, variables specified in this theme are set |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
912 immediately when loading the theme. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
913 :variable-set-string |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
914 VALUE is a string used to indicate that a variable takes its |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
915 setting from this theme. It is passed to FORMAT with the name |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
916 of the theme as an additional argument. If not given, a |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
917 generic description is used. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
918 :variable-reset-string |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
919 VALUE is a string used in the case a variable has been forced |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
920 to its value in this theme. It is passed to FORMAT with the |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
921 name of the theme as an additional argument. If not given, a |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
922 generic description is used. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
923 :face-set-string |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
924 VALUE is a string used to indicate that a face takes its |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
925 setting from this theme. It is passed to FORMAT with the name |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
926 of the theme as an additional argument. If not given, a |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
927 generic description is used. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
928 :face-reset-string |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
929 VALUE is a string used in the case a face has been forced to |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
930 its value in this theme. It is passed to FORMAT with the name |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
931 of the theme as an additional argument. If not given, a |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
932 generic description is used. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
933 |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
934 Any theme `foo' should be defined in a file called `foo-theme.el'; |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
935 see `custom-make-theme-feature' for more information." |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
936 (let ((feature (custom-make-theme-feature theme))) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
937 ;; It is better not to use backquote in this file, |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
938 ;; because that makes a bootstrapping problem |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
939 ;; if you need to recompile all the Lisp files using interpreted code. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
940 (nconc (list 'custom-declare-theme |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
941 (list 'quote theme) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
942 (list 'quote feature) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
943 doc) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
944 args))) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
945 |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
946 (defun custom-declare-theme (theme feature &optional doc &rest args) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
947 "Like `deftheme', but THEME is evaluated as a normal argument. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
948 FEATURE is the feature this theme provides. This symbol is created |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
949 from THEME by `custom-make-theme-feature'." |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
950 (add-to-list 'custom-known-themes theme) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
951 (put theme 'theme-feature feature) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
952 (when doc |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
953 (put theme 'theme-documentation doc)) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
954 (while args |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
955 (let ((arg (car args))) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
956 (setq args (cdr args)) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
957 (unless (symbolp arg) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
958 (error "Junk in args %S" args)) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
959 (let ((keyword arg) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
960 (value (car args))) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
961 (unless args |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
962 (error "Keyword %s is missing an argument" keyword)) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
963 (setq args (cdr args)) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
964 (cond ((eq keyword :short-description) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
965 (put theme 'theme-short-description value)) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
966 ((eq keyword :immediate) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
967 (put theme 'theme-immediate value)) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
968 ((eq keyword :variable-set-string) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
969 (put theme 'theme-variable-set-string value)) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
970 ((eq keyword :variable-reset-string) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
971 (put theme 'theme-variable-reset-string value)) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
972 ((eq keyword :face-set-string) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
973 (put theme 'theme-face-set-string value)) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
974 ((eq keyword :face-reset-string) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
975 (put theme 'theme-face-reset-string value))))))) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
976 |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
977 (defun custom-make-theme-feature (theme) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
978 "Given a symbol THEME, create a new symbol by appending \"-theme\". |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
979 Store this symbol in the `theme-feature' property of THEME. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
980 Calling `provide-theme' to provide THEME actually puts `THEME-theme' |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
981 into `features'. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
982 |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
983 This allows for a file-name convention for autoloading themes: |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
984 Every theme X has a property `provide-theme' whose value is \"X-theme\". |
65334
2c6c9fd9d86b
*** empty log message ***
Chong Yidong <cyd@stupidchicken.com>
parents:
65093
diff
changeset
|
985 \(load-theme X) then attempts to load the file `X-theme.el'." |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
986 (intern (concat (symbol-name theme) "-theme"))) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
987 |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
988 ;;; Loading themes. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
989 |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
990 ;; The variable and face settings of a theme are recorded in |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
991 ;; the `theme-settings' property of the theme name. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
992 ;; This property's value is a list of elements, each of the form |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
993 ;; (PROP SYMBOL THEME MODE VALUE), where PROP is `theme-value' or `theme-face' |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
994 ;; and SYMBOL is the face or variable name. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
995 ;; THEME is the theme name itself; that's redundant, but simplifies things. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
996 ;; MODE is `set' or `reset'. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
997 ;; If MODE is `set', then VALUE is an expression that specifies the |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
998 ;; theme's setting for SYMBOL. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
999 ;; If MODE is `reset', then VALUE is another theme, |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1000 ;; and it means to use the value from that theme. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1001 |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1002 ;; Each variable has a `theme-value' property that describes all the |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1003 ;; settings of enabled themes that apply to it. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1004 ;; Each face name has a `theme-face' property that describes all the |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1005 ;; settings of enabled themes that apply to it. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1006 ;; The property value is a list of settings, each with the form |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1007 ;; (THEME MODE VALUE). THEME, MODE and VALUE are as above. |
64221 | 1008 ;; Each of these lists is ordered by decreasing theme precedence. |
1009 ;; Thus, the first element is always the one that is in effect. | |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1010 |
64221 | 1011 ;; Disabling a theme removes its settings from the `theme-value' and |
1012 ;; `theme-face' properties, but the theme's own `theme-settings' | |
1013 ;; property remains unchanged. | |
1014 | |
1015 ;; Loading a theme implicitly enables it. Enabling a theme adds its | |
1016 ;; settings to the symbols' `theme-value' and `theme-face' properties, | |
1017 ;; or moves them to the front of those lists if they're already present. | |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1018 |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1019 (defvar custom-loaded-themes nil |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1020 "Custom themes that have been loaded.") |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1021 |
63927
7f7d0de05845
(custom-declare-variable): Fix typos in comment.
Luc Teirlinck <teirllm@auburn.edu>
parents:
61530
diff
changeset
|
1022 (defcustom custom-theme-directory |
7f7d0de05845
(custom-declare-variable): Fix typos in comment.
Luc Teirlinck <teirllm@auburn.edu>
parents:
61530
diff
changeset
|
1023 (if (eq system-type 'ms-dos) |
7f7d0de05845
(custom-declare-variable): Fix typos in comment.
Luc Teirlinck <teirllm@auburn.edu>
parents:
61530
diff
changeset
|
1024 ;; MS-DOS cannot have initial dot. |
7f7d0de05845
(custom-declare-variable): Fix typos in comment.
Luc Teirlinck <teirllm@auburn.edu>
parents:
61530
diff
changeset
|
1025 "~/_emacs.d/" |
7f7d0de05845
(custom-declare-variable): Fix typos in comment.
Luc Teirlinck <teirllm@auburn.edu>
parents:
61530
diff
changeset
|
1026 "~/.emacs.d/") |
7f7d0de05845
(custom-declare-variable): Fix typos in comment.
Luc Teirlinck <teirllm@auburn.edu>
parents:
61530
diff
changeset
|
1027 "Directory in which Custom theme files should be written. |
65334
2c6c9fd9d86b
*** empty log message ***
Chong Yidong <cyd@stupidchicken.com>
parents:
65093
diff
changeset
|
1028 `load-theme' searches this directory in addition to load-path. |
63927
7f7d0de05845
(custom-declare-variable): Fix typos in comment.
Luc Teirlinck <teirllm@auburn.edu>
parents:
61530
diff
changeset
|
1029 The command `customize-create-theme' writes the files it produces |
7f7d0de05845
(custom-declare-variable): Fix typos in comment.
Luc Teirlinck <teirllm@auburn.edu>
parents:
61530
diff
changeset
|
1030 into this directory." |
7f7d0de05845
(custom-declare-variable): Fix typos in comment.
Luc Teirlinck <teirllm@auburn.edu>
parents:
61530
diff
changeset
|
1031 :type 'string |
7f7d0de05845
(custom-declare-variable): Fix typos in comment.
Luc Teirlinck <teirllm@auburn.edu>
parents:
61530
diff
changeset
|
1032 :group 'customize |
7f7d0de05845
(custom-declare-variable): Fix typos in comment.
Luc Teirlinck <teirllm@auburn.edu>
parents:
61530
diff
changeset
|
1033 :version "22.1") |
7f7d0de05845
(custom-declare-variable): Fix typos in comment.
Luc Teirlinck <teirllm@auburn.edu>
parents:
61530
diff
changeset
|
1034 |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1035 (defun custom-theme-loaded-p (theme) |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1036 "Return non-nil if THEME has been loaded." |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1037 (memq theme custom-loaded-themes)) |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1038 |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1039 (defvar custom-enabled-themes '(user) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1040 "Custom themes currently enabled, highest precedence first. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1041 The first one is always `user'.") |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1042 |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1043 (defun custom-theme-enabled-p (theme) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1044 "Return non-nil if THEME is enabled." |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1045 (memq theme custom-enabled-themes)) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1046 |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1047 (defun provide-theme (theme) |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1048 "Indicate that this file provides THEME. |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1049 Add THEME to `custom-loaded-themes', and `provide' whatever |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1050 feature name is stored in THEME's property `theme-feature'. |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1051 |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1052 Usually the `theme-feature' property contains a symbol created |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1053 by `custom-make-theme-feature'." |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1054 (custom-check-theme theme) |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1055 (provide (get theme 'theme-feature)) |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1056 (push theme custom-loaded-themes) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1057 ;; Loading a theme also installs its settings, |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1058 ;; so mark it as "enabled". |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1059 (push theme custom-enabled-themes) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1060 ;; `user' must always be the highest-precedence enabled theme. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1061 ;; Make that remain true. (This has the effect of making user settings |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1062 ;; override the ones just loaded, too.) |
65334
2c6c9fd9d86b
*** empty log message ***
Chong Yidong <cyd@stupidchicken.com>
parents:
65093
diff
changeset
|
1063 (enable-theme 'user)) |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1064 |
65334
2c6c9fd9d86b
*** empty log message ***
Chong Yidong <cyd@stupidchicken.com>
parents:
65093
diff
changeset
|
1065 (defun load-theme (theme) |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1066 "Try to load a theme's settings from its file. |
65334
2c6c9fd9d86b
*** empty log message ***
Chong Yidong <cyd@stupidchicken.com>
parents:
65093
diff
changeset
|
1067 This also enables the theme; use `disable-theme' to disable it." |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1068 |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1069 ;; THEME's feature is stored in THEME's `theme-feature' property. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1070 ;; Usually the `theme-feature' property contains a symbol created |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1071 ;; by `custom-make-theme-feature'. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1072 |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1073 ;; Note we do no check for validity of the theme here. |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1074 ;; This allows to pull in themes by a file-name convention |
65334
2c6c9fd9d86b
*** empty log message ***
Chong Yidong <cyd@stupidchicken.com>
parents:
65093
diff
changeset
|
1075 (interactive "SCustom theme name: ") |
63927
7f7d0de05845
(custom-declare-variable): Fix typos in comment.
Luc Teirlinck <teirllm@auburn.edu>
parents:
61530
diff
changeset
|
1076 (let ((load-path (if (file-directory-p custom-theme-directory) |
7f7d0de05845
(custom-declare-variable): Fix typos in comment.
Luc Teirlinck <teirllm@auburn.edu>
parents:
61530
diff
changeset
|
1077 (cons custom-theme-directory load-path) |
7f7d0de05845
(custom-declare-variable): Fix typos in comment.
Luc Teirlinck <teirllm@auburn.edu>
parents:
61530
diff
changeset
|
1078 load-path))) |
7f7d0de05845
(custom-declare-variable): Fix typos in comment.
Luc Teirlinck <teirllm@auburn.edu>
parents:
61530
diff
changeset
|
1079 (require (or (get theme 'theme-feature) |
7f7d0de05845
(custom-declare-variable): Fix typos in comment.
Luc Teirlinck <teirllm@auburn.edu>
parents:
61530
diff
changeset
|
1080 (custom-make-theme-feature theme))))) |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1081 |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1082 ;;; How to load and enable various themes as part of `user'. |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1083 |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1084 (defun custom-theme-load-themes (by-theme &rest body) |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1085 "Load the themes specified by BODY. |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1086 Record them as required by theme BY-THEME. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1087 |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1088 BODY is a sequence of either |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1089 |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1090 THEME |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1091 Load THEME and enable it. |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1092 \(reset THEME) |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1093 Undo all the settings made by THEME |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1094 \(hidden THEME) |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1095 Load THEME but do not enable it. |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1096 |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1097 All the themes loaded for BY-THEME are recorded in BY-THEME's property |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1098 `theme-loads-themes'." |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1099 (custom-check-theme by-theme) |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1100 (let ((themes-loaded (get by-theme 'theme-loads-themes))) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1101 (dolist (theme body) |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1102 (cond ((and (consp theme) (eq (car theme) 'reset)) |
65334
2c6c9fd9d86b
*** empty log message ***
Chong Yidong <cyd@stupidchicken.com>
parents:
65093
diff
changeset
|
1103 (disable-theme (cadr theme))) |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1104 ((and (consp theme) (eq (car theme) 'hidden)) |
65334
2c6c9fd9d86b
*** empty log message ***
Chong Yidong <cyd@stupidchicken.com>
parents:
65093
diff
changeset
|
1105 (load-theme (cadr theme)) |
2c6c9fd9d86b
*** empty log message ***
Chong Yidong <cyd@stupidchicken.com>
parents:
65093
diff
changeset
|
1106 (disable-theme (cadr theme))) |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1107 (t |
65334
2c6c9fd9d86b
*** empty log message ***
Chong Yidong <cyd@stupidchicken.com>
parents:
65093
diff
changeset
|
1108 (load-theme theme))) |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1109 (push theme themes-loaded)) |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1110 (put by-theme 'theme-loads-themes themes-loaded))) |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1111 |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1112 (defun custom-load-themes (&rest body) |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1113 "Load themes for the USER theme as specified by BODY. |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1114 |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1115 See `custom-theme-load-themes' for more information on BODY." |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1116 (apply 'custom-theme-load-themes 'user body)) |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1117 |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1118 ;;; Enabling and disabling loaded themes. |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1119 |
65334
2c6c9fd9d86b
*** empty log message ***
Chong Yidong <cyd@stupidchicken.com>
parents:
65093
diff
changeset
|
1120 (defun enable-theme (theme) |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1121 "Reenable all variable and face settings defined by THEME. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1122 The newly enabled theme gets the highest precedence (after `user'). |
67123
6e41569f62c8
* custom.el (enable-theme): Signal error if argument is not a
Chong Yidong <cyd@stupidchicken.com>
parents:
67064
diff
changeset
|
1123 If it is already enabled, just give it highest precedence (after `user'). |
6e41569f62c8
* custom.el (enable-theme): Signal error if argument is not a
Chong Yidong <cyd@stupidchicken.com>
parents:
67064
diff
changeset
|
1124 |
6e41569f62c8
* custom.el (enable-theme): Signal error if argument is not a
Chong Yidong <cyd@stupidchicken.com>
parents:
67064
diff
changeset
|
1125 This signals an error if THEME does not specify any theme |
6e41569f62c8
* custom.el (enable-theme): Signal error if argument is not a
Chong Yidong <cyd@stupidchicken.com>
parents:
67064
diff
changeset
|
1126 settings. Theme settings are set using `load-theme'." |
65334
2c6c9fd9d86b
*** empty log message ***
Chong Yidong <cyd@stupidchicken.com>
parents:
65093
diff
changeset
|
1127 (interactive "SEnable Custom theme: ") |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1128 (let ((settings (get theme 'theme-settings))) |
67123
6e41569f62c8
* custom.el (enable-theme): Signal error if argument is not a
Chong Yidong <cyd@stupidchicken.com>
parents:
67064
diff
changeset
|
1129 (if (and (not (eq theme 'user)) (null settings)) |
6e41569f62c8
* custom.el (enable-theme): Signal error if argument is not a
Chong Yidong <cyd@stupidchicken.com>
parents:
67064
diff
changeset
|
1130 (error "No theme settings defined in %s." (symbol-name theme))) |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1131 (dolist (s settings) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1132 (let* ((prop (car s)) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1133 (symbol (cadr s)) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1134 (spec-list (get symbol prop))) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1135 (put symbol prop (cons (cddr s) (assq-delete-all theme spec-list))) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1136 (if (eq prop 'theme-value) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1137 (custom-theme-recalc-variable symbol) |
67123
6e41569f62c8
* custom.el (enable-theme): Signal error if argument is not a
Chong Yidong <cyd@stupidchicken.com>
parents:
67064
diff
changeset
|
1138 (if (facep symbol) |
6e41569f62c8
* custom.el (enable-theme): Signal error if argument is not a
Chong Yidong <cyd@stupidchicken.com>
parents:
67064
diff
changeset
|
1139 (custom-theme-recalc-face symbol)))))) |
64228
90c5009c1621
(custom-enable-theme): Don't add theme to `custom-enabled-themes' with `push'
Juanma Barranquero <lekktu@gmail.com>
parents:
64226
diff
changeset
|
1140 (setq custom-enabled-themes |
90c5009c1621
(custom-enable-theme): Don't add theme to `custom-enabled-themes' with `push'
Juanma Barranquero <lekktu@gmail.com>
parents:
64226
diff
changeset
|
1141 (cons theme (delq theme custom-enabled-themes))) |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1142 ;; `user' must always be the highest-precedence enabled theme. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1143 (unless (eq theme 'user) |
65334
2c6c9fd9d86b
*** empty log message ***
Chong Yidong <cyd@stupidchicken.com>
parents:
65093
diff
changeset
|
1144 (enable-theme 'user))) |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1145 |
65334
2c6c9fd9d86b
*** empty log message ***
Chong Yidong <cyd@stupidchicken.com>
parents:
65093
diff
changeset
|
1146 (defun disable-theme (theme) |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1147 "Disable all variable and face settings defined by THEME. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1148 See `custom-known-themes' for a list of known themes." |
65334
2c6c9fd9d86b
*** empty log message ***
Chong Yidong <cyd@stupidchicken.com>
parents:
65093
diff
changeset
|
1149 (interactive "SDisable Custom theme: ") |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1150 (let ((settings (get theme 'theme-settings))) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1151 (dolist (s settings) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1152 (let* ((prop (car s)) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1153 (symbol (cadr s)) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1154 (spec-list (get symbol prop))) |
65341
6990826a916f
Custom Theme bugfixes.
Chong Yidong <cyd@stupidchicken.com>
parents:
65334
diff
changeset
|
1155 (put symbol prop (assq-delete-all theme spec-list)) |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1156 (if (eq prop 'theme-value) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1157 (custom-theme-recalc-variable symbol) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1158 (custom-theme-recalc-face symbol))))) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1159 (setq custom-enabled-themes |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1160 (delq theme custom-enabled-themes))) |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1161 |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1162 (defun custom-theme-value (theme setting-list) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1163 "Determine the value specified for THEME according to SETTING-LIST. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1164 Returns a list whose car is the specified value, if we |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1165 find one; nil otherwise. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1166 |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1167 SETTING-LIST is an alist with themes as its key. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1168 Each element has the form: |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1169 |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1170 \(THEME MODE VALUE) |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1171 |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1172 MODE is either the symbol `set' or the symbol `reset'. See |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1173 `custom-push-theme' for more information on the format of |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1174 SETTING-LIST." |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1175 ;; Note we do _NOT_ signal an error if the theme is unknown |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1176 ;; it might have gone away without the user knowing. |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1177 (let ((elt (cdr (assoc theme setting-list)))) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1178 (if elt |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1179 (if (eq (car elt) 'set) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1180 (cdr elt) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1181 ;; `reset' means refer to another theme's value in the same alist. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1182 (custom-theme-value (cadr elt) setting-list))))) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1183 |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1184 (defun custom-variable-theme-value (variable) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1185 "Return (list VALUE) indicating the custom theme value of VARIABLE. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1186 That is to say, it specifies what the value should be according to |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1187 currently enabled custom themes. |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1188 |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1189 This function returns nil if no custom theme specifies a value for VARIABLE." |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1190 (let* ((theme-value (get variable 'theme-value))) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1191 (if theme-value |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1192 (custom-theme-value (car (car theme-value)) theme-value)))) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1193 |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1194 (defun custom-theme-recalc-variable (variable) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1195 "Set VARIABLE according to currently enabled custom themes." |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1196 (let ((valspec (custom-variable-theme-value variable))) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1197 (when valspec |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1198 (put variable 'saved-value valspec)) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1199 (unless valspec |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1200 (setq valspec (get variable 'standard-value))) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1201 (when valspec |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1202 (if (or (get 'force-value variable) (default-boundp variable)) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1203 (funcall (or (get variable 'custom-set) 'set-default) variable |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1204 (eval (car valspec))))))) |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1205 |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1206 (defun custom-theme-recalc-face (face) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1207 "Set FACE according to currently enabled custom themes." |
65341
6990826a916f
Custom Theme bugfixes.
Chong Yidong <cyd@stupidchicken.com>
parents:
65334
diff
changeset
|
1208 (let ((theme-faces (reverse (get face 'theme-face)))) |
6990826a916f
Custom Theme bugfixes.
Chong Yidong <cyd@stupidchicken.com>
parents:
65334
diff
changeset
|
1209 (dolist (spec theme-faces) |
6990826a916f
Custom Theme bugfixes.
Chong Yidong <cyd@stupidchicken.com>
parents:
65334
diff
changeset
|
1210 (face-spec-set face (car (cddr spec)))))) |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1211 |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1212 (defun custom-theme-reset-variables (theme &rest args) |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1213 "Reset the specs in THEME of some variables to their values in other themes. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1214 Each of the arguments ARGS has this form: |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1215 |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1216 (VARIABLE FROM-THEME) |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1217 |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1218 This means reset VARIABLE to its value in FROM-THEME." |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1219 (custom-check-theme theme) |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1220 (dolist (arg args) |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1221 (custom-push-theme 'theme-value (car arg) theme 'reset (cadr arg)))) |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1222 |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1223 (defun custom-reset-variables (&rest args) |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1224 "Reset the specs of some variables to their values in certain themes. |
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1225 This creates settings in the `user' theme. |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1226 |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1227 Each of the arguments ARGS has this form: |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1228 |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1229 (VARIABLE FROM-THEME) |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1230 |
64220
38b6647b9ed4
(custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents:
64200
diff
changeset
|
1231 This means reset VARIABLE to its value in FROM-THEME." |
48951
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1232 (apply 'custom-theme-reset-variables 'user args)) |
d77bc55dd27b
(custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48821
diff
changeset
|
1233 |
17334 | 1234 ;;; The End. |
1235 | |
18882
539611251037
(custom-declare-variable-list): Process already-declared
Richard M. Stallman <rms@gnu.org>
parents:
18033
diff
changeset
|
1236 ;; Process the defcustoms for variables loaded before this file. |
539611251037
(custom-declare-variable-list): Process already-declared
Richard M. Stallman <rms@gnu.org>
parents:
18033
diff
changeset
|
1237 (while custom-declare-variable-list |
539611251037
(custom-declare-variable-list): Process already-declared
Richard M. Stallman <rms@gnu.org>
parents:
18033
diff
changeset
|
1238 (apply 'custom-declare-variable (car custom-declare-variable-list)) |
539611251037
(custom-declare-variable-list): Process already-declared
Richard M. Stallman <rms@gnu.org>
parents:
18033
diff
changeset
|
1239 (setq custom-declare-variable-list (cdr custom-declare-variable-list))) |
539611251037
(custom-declare-variable-list): Process already-declared
Richard M. Stallman <rms@gnu.org>
parents:
18033
diff
changeset
|
1240 |
17334 | 1241 (provide 'custom) |
1242 | |
60413
28b5c27160e8
(custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60020
diff
changeset
|
1243 ;; arch-tag: 041b6116-aabe-4f9a-902d-74092bc3dab2 |
25683 | 1244 ;;; custom.el ends here |