Mercurial > emacs
annotate lisp/cus-theme.el @ 73981:8ce8b7c070f5
** CC mode defun-finding issues.
Fixed by acm's 2006-11-08 checkin.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Mon, 13 Nov 2006 16:16:06 +0000 |
parents | 2ce9bf47e864 |
children | e3694f1cb928 7f3f771c85fa |
rev | line source |
---|---|
48952 | 1 ;;; cus-theme.el -- custom theme creation user interface |
2 ;; | |
68651
3bd95f4f2941
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
68161
diff
changeset
|
3 ;; Copyright (C) 2001, 2002, 2003, 2004, 2005, |
3bd95f4f2941
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
68161
diff
changeset
|
4 ;; 2006 Free Software Foundation, Inc. |
48952 | 5 ;; |
6 ;; Author: Alex Schroeder <alex@gnu.org> | |
7 ;; Maintainer: FSF | |
8 ;; Keywords: help, faces | |
9 | |
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. | |
48952 | 26 |
27 ;;; Code: | |
28 | |
29 (require 'widget) | |
30 (require 'cus-edit) | |
31 | |
32 (eval-when-compile | |
33 (require 'wid-edit)) | |
34 | |
67950
87b213a028b3
* cus-theme.el (custom-new-theme-mode-map): New variable.
Chong Yidong <cyd@stupidchicken.com>
parents:
67949
diff
changeset
|
35 (defvar custom-new-theme-mode-map |
87b213a028b3
* cus-theme.el (custom-new-theme-mode-map): New variable.
Chong Yidong <cyd@stupidchicken.com>
parents:
67949
diff
changeset
|
36 (let ((map (make-keymap))) |
87b213a028b3
* cus-theme.el (custom-new-theme-mode-map): New variable.
Chong Yidong <cyd@stupidchicken.com>
parents:
67949
diff
changeset
|
37 (set-keymap-parent map widget-keymap) |
87b213a028b3
* cus-theme.el (custom-new-theme-mode-map): New variable.
Chong Yidong <cyd@stupidchicken.com>
parents:
67949
diff
changeset
|
38 (suppress-keymap map) |
87b213a028b3
* cus-theme.el (custom-new-theme-mode-map): New variable.
Chong Yidong <cyd@stupidchicken.com>
parents:
67949
diff
changeset
|
39 (define-key map "n" 'widget-forward) |
87b213a028b3
* cus-theme.el (custom-new-theme-mode-map): New variable.
Chong Yidong <cyd@stupidchicken.com>
parents:
67949
diff
changeset
|
40 (define-key map "p" 'widget-backward) |
87b213a028b3
* cus-theme.el (custom-new-theme-mode-map): New variable.
Chong Yidong <cyd@stupidchicken.com>
parents:
67949
diff
changeset
|
41 map) |
87b213a028b3
* cus-theme.el (custom-new-theme-mode-map): New variable.
Chong Yidong <cyd@stupidchicken.com>
parents:
67949
diff
changeset
|
42 "Keymap for `custom-new-theme-mode'.") |
87b213a028b3
* cus-theme.el (custom-new-theme-mode-map): New variable.
Chong Yidong <cyd@stupidchicken.com>
parents:
67949
diff
changeset
|
43 |
63928
e559c2c766bc
(custom-new-theme-mode): New function.
Luc Teirlinck <teirllm@auburn.edu>
parents:
61603
diff
changeset
|
44 (define-derived-mode custom-new-theme-mode nil "New-Theme" |
e559c2c766bc
(custom-new-theme-mode): New function.
Luc Teirlinck <teirllm@auburn.edu>
parents:
61603
diff
changeset
|
45 "Major mode for the buffer created by `customize-create-theme'. |
e559c2c766bc
(custom-new-theme-mode): New function.
Luc Teirlinck <teirllm@auburn.edu>
parents:
61603
diff
changeset
|
46 Do not call this mode function yourself. It is only meant for internal |
e559c2c766bc
(custom-new-theme-mode): New function.
Luc Teirlinck <teirllm@auburn.edu>
parents:
61603
diff
changeset
|
47 use by `customize-create-theme'." |
67950
87b213a028b3
* cus-theme.el (custom-new-theme-mode-map): New variable.
Chong Yidong <cyd@stupidchicken.com>
parents:
67949
diff
changeset
|
48 (use-local-map custom-new-theme-mode-map) |
87b213a028b3
* cus-theme.el (custom-new-theme-mode-map): New variable.
Chong Yidong <cyd@stupidchicken.com>
parents:
67949
diff
changeset
|
49 (define-key custom-new-theme-mode-map [mouse-1] 'widget-move-and-invoke) |
67948
5bf588b1a01e
* cus-theme.el (custom-new-theme-mode): Use cus-edit faces.
Chong Yidong <cyd@stupidchicken.com>
parents:
65341
diff
changeset
|
50 (set (make-local-variable 'widget-documentation-face) 'custom-documentation) |
5bf588b1a01e
* cus-theme.el (custom-new-theme-mode): Use cus-edit faces.
Chong Yidong <cyd@stupidchicken.com>
parents:
65341
diff
changeset
|
51 (set (make-local-variable 'widget-button-face) custom-button) |
5bf588b1a01e
* cus-theme.el (custom-new-theme-mode): Use cus-edit faces.
Chong Yidong <cyd@stupidchicken.com>
parents:
65341
diff
changeset
|
52 (set (make-local-variable 'widget-button-pressed-face) custom-button-pressed) |
67961
52f526ce11f6
* cus-edit.el (custom-button-mouse): New variable.
Chong Yidong <cyd@stupidchicken.com>
parents:
67951
diff
changeset
|
53 (set (make-local-variable 'widget-mouse-face) custom-button-mouse) |
67948
5bf588b1a01e
* cus-theme.el (custom-new-theme-mode): Use cus-edit faces.
Chong Yidong <cyd@stupidchicken.com>
parents:
65341
diff
changeset
|
54 (when custom-raised-buttons |
5bf588b1a01e
* cus-theme.el (custom-new-theme-mode): Use cus-edit faces.
Chong Yidong <cyd@stupidchicken.com>
parents:
65341
diff
changeset
|
55 (set (make-local-variable 'widget-push-button-prefix) "") |
5bf588b1a01e
* cus-theme.el (custom-new-theme-mode): Use cus-edit faces.
Chong Yidong <cyd@stupidchicken.com>
parents:
65341
diff
changeset
|
56 (set (make-local-variable 'widget-push-button-suffix) "") |
5bf588b1a01e
* cus-theme.el (custom-new-theme-mode): Use cus-edit faces.
Chong Yidong <cyd@stupidchicken.com>
parents:
65341
diff
changeset
|
57 (set (make-local-variable 'widget-link-prefix) "") |
5bf588b1a01e
* cus-theme.el (custom-new-theme-mode): Use cus-edit faces.
Chong Yidong <cyd@stupidchicken.com>
parents:
65341
diff
changeset
|
58 (set (make-local-variable 'widget-link-suffix) ""))) |
63928
e559c2c766bc
(custom-new-theme-mode): New function.
Luc Teirlinck <teirllm@auburn.edu>
parents:
61603
diff
changeset
|
59 (put 'custom-new-theme-mode 'mode-class 'special) |
e559c2c766bc
(custom-new-theme-mode): New function.
Luc Teirlinck <teirllm@auburn.edu>
parents:
61603
diff
changeset
|
60 |
67982
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
61 (defvar custom-theme-name nil) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
62 (defvar custom-theme-variables nil) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
63 (defvar custom-theme-faces nil) |
63928
e559c2c766bc
(custom-new-theme-mode): New function.
Luc Teirlinck <teirllm@auburn.edu>
parents:
61603
diff
changeset
|
64 (defvar custom-theme-description) |
67982
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
65 (defvar custom-theme-insert-variable-marker) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
66 (defvar custom-theme-insert-face-marker) |
63928
e559c2c766bc
(custom-new-theme-mode): New function.
Luc Teirlinck <teirllm@auburn.edu>
parents:
61603
diff
changeset
|
67 |
50203
3803afb52e4f
(custom-theme-create): Add autoload cookie.
John Paul Wallington <jpw@pobox.com>
parents:
49588
diff
changeset
|
68 ;;;###autoload |
50287
51b6a93f7e19
(customize-create-theme): Rename from
John Paul Wallington <jpw@pobox.com>
parents:
50203
diff
changeset
|
69 (defun customize-create-theme () |
48952 | 70 "Create a custom theme." |
71 (interactive) | |
67982
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
72 (switch-to-buffer (generate-new-buffer "*New Custom Theme*")) |
63928
e559c2c766bc
(custom-new-theme-mode): New function.
Luc Teirlinck <teirllm@auburn.edu>
parents:
61603
diff
changeset
|
73 (let ((inhibit-read-only t)) |
e559c2c766bc
(custom-new-theme-mode): New function.
Luc Teirlinck <teirllm@auburn.edu>
parents:
61603
diff
changeset
|
74 (erase-buffer)) |
e559c2c766bc
(custom-new-theme-mode): New function.
Luc Teirlinck <teirllm@auburn.edu>
parents:
61603
diff
changeset
|
75 (custom-new-theme-mode) |
48952 | 76 (make-local-variable 'custom-theme-name) |
77 (make-local-variable 'custom-theme-variables) | |
78 (make-local-variable 'custom-theme-faces) | |
79 (make-local-variable 'custom-theme-description) | |
67982
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
80 (make-local-variable 'custom-theme-insert-variable-marker) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
81 (make-local-variable 'custom-theme-insert-face-marker) |
48952 | 82 (widget-insert "This buffer helps you write a custom theme elisp file. |
63928
e559c2c766bc
(custom-new-theme-mode): New function.
Luc Teirlinck <teirllm@auburn.edu>
parents:
61603
diff
changeset
|
83 This will help you share your customizations with other people. |
e559c2c766bc
(custom-new-theme-mode): New function.
Luc Teirlinck <teirllm@auburn.edu>
parents:
61603
diff
changeset
|
84 |
67982
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
85 Insert the names of all variables and faces you want the theme to include. |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
86 Invoke \"Save Theme\" to save the theme. The theme file will be saved to |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
87 the directory " custom-theme-directory "\n\n") |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
88 (widget-create 'push-button |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
89 :tag "Visit Theme" |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
90 :help-echo "Insert the settings of a pre-defined theme." |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
91 :action (lambda (widget &optional event) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
92 (call-interactively 'custom-theme-visit-theme))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
93 (widget-insert " ") |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
94 (widget-create 'push-button |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
95 :tag "Merge Theme" |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
96 :help-echo "Merge in the settings of a pre-defined theme." |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
97 :action (lambda (widget &optional event) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
98 (call-interactively 'custom-theme-merge-theme))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
99 (widget-insert " ") |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
100 (widget-create 'push-button |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
101 :notify (lambda (&rest ignore) |
72386
2ce9bf47e864
* cus-theme.el (customize-create-theme)
Romain Francoise <romain@orebokech.com>
parents:
68912
diff
changeset
|
102 (when (y-or-n-p "Discard current changes? ") |
67982
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
103 (kill-buffer (current-buffer)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
104 (customize-create-theme))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
105 "Reset Buffer") |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
106 (widget-insert " ") |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
107 (widget-create 'push-button |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
108 :notify (function custom-theme-write) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
109 "Save Theme") |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
110 (widget-insert "\n") |
63928
e559c2c766bc
(custom-new-theme-mode): New function.
Luc Teirlinck <teirllm@auburn.edu>
parents:
61603
diff
changeset
|
111 |
67982
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
112 (widget-insert "\n\nTheme name: ") |
48952 | 113 (setq custom-theme-name |
114 (widget-create 'editable-field | |
115 :size 10 | |
116 user-login-name)) | |
117 (widget-insert "\n\nDocumentation:\n") | |
118 (setq custom-theme-description | |
49588
37645a051842
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48952
diff
changeset
|
119 (widget-create 'text |
48952 | 120 :value (format-time-string "Created %Y-%m-%d."))) |
121 (widget-insert "\n") | |
122 (widget-create 'push-button | |
67982
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
123 :tag "Insert Variable" |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
124 :help-echo "Add another variable to this theme." |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
125 :action (lambda (widget &optional event) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
126 (call-interactively 'custom-theme-add-variable))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
127 (widget-insert "\n") |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
128 (setq custom-theme-insert-variable-marker (point-marker)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
129 (widget-insert "\n") |
48952 | 130 (widget-create 'push-button |
67982
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
131 :tag "Insert Face" |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
132 :help-echo "Add another face to this theme." |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
133 :action (lambda (widget &optional event) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
134 (call-interactively 'custom-theme-add-face))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
135 (widget-insert "\n") |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
136 (setq custom-theme-insert-face-marker (point-marker)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
137 (widget-insert "\n") |
48952 | 138 (widget-create 'push-button |
139 :notify (lambda (&rest ignore) | |
72386
2ce9bf47e864
* cus-theme.el (customize-create-theme)
Romain Francoise <romain@orebokech.com>
parents:
68912
diff
changeset
|
140 (when (y-or-n-p "Discard current changes? ") |
67982
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
141 (kill-buffer (current-buffer)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
142 (customize-create-theme))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
143 "Reset Buffer") |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
144 (widget-insert " ") |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
145 (widget-create 'push-button |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
146 :notify (function custom-theme-write) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
147 "Save Theme") |
48952 | 148 (widget-insert "\n") |
67982
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
149 (widget-setup) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
150 (goto-char (point-min)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
151 (message "")) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
152 |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
153 ;;; Theme variables |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
154 |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
155 (defun custom-theme-add-variable (symbol) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
156 (interactive "vVariable name: ") |
68161 | 157 (cond ((assq symbol custom-theme-variables) |
158 (message "%s is already in the theme" (symbol-name symbol))) | |
159 ((not (boundp symbol)) | |
160 (message "%s is not defined as a variable" (symbol-name symbol))) | |
161 ((eq symbol 'custom-enabled-themes) | |
162 (message "Custom theme cannot contain `custom-enabled-themes'")) | |
163 (t | |
164 (save-excursion | |
165 (goto-char custom-theme-insert-variable-marker) | |
68159
fca6909a92e8
* cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents:
67982
diff
changeset
|
166 (widget-insert "\n") |
fca6909a92e8
* cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents:
67982
diff
changeset
|
167 (let ((widget (widget-create 'custom-variable |
fca6909a92e8
* cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents:
67982
diff
changeset
|
168 :tag (custom-unlispify-tag-name symbol) |
fca6909a92e8
* cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents:
67982
diff
changeset
|
169 :custom-level 0 |
fca6909a92e8
* cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents:
67982
diff
changeset
|
170 :action 'custom-theme-variable-action |
fca6909a92e8
* cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents:
67982
diff
changeset
|
171 :custom-state 'unknown |
fca6909a92e8
* cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents:
67982
diff
changeset
|
172 :value symbol))) |
fca6909a92e8
* cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents:
67982
diff
changeset
|
173 (push (cons symbol widget) custom-theme-variables) |
fca6909a92e8
* cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents:
67982
diff
changeset
|
174 (custom-magic-reset widget)) |
fca6909a92e8
* cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents:
67982
diff
changeset
|
175 (widget-setup))))) |
67982
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
176 |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
177 (defvar custom-theme-variable-menu |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
178 `(("Reset to Current" custom-redraw |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
179 (lambda (widget) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
180 (and (boundp (widget-value widget)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
181 (memq (widget-get widget :custom-state) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
182 '(themed modified changed))))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
183 ("Reset to Theme Value" custom-variable-reset-theme |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
184 (lambda (widget) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
185 (let ((theme (intern (widget-value custom-theme-name))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
186 (symbol (widget-value widget)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
187 found) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
188 (and (custom-theme-p theme) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
189 (dolist (setting (get theme 'theme-settings) found) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
190 (if (and (eq (cadr setting) symbol) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
191 (eq (car setting) 'theme-value)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
192 (setq found t))))))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
193 ("---" ignore ignore) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
194 ("Delete" custom-theme-delete-variable nil)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
195 "Alist of actions for the `custom-variable' widget in Custom Theme Mode. |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
196 See the documentation for `custom-variable'.") |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
197 |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
198 (defun custom-theme-variable-action (widget &optional event) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
199 "Show the Custom Theme Mode menu for a `custom-variable' widget. |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
200 Optional EVENT is the location for the menu." |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
201 (let ((custom-variable-menu custom-theme-variable-menu)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
202 (custom-variable-action widget event))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
203 |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
204 (defun custom-variable-reset-theme (widget) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
205 "Reset WIDGET to its value for the currently edited theme." |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
206 (let ((theme (intern (widget-value custom-theme-name))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
207 (symbol (widget-value widget)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
208 found) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
209 (dolist (setting (get theme 'theme-settings)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
210 (if (and (eq (cadr setting) symbol) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
211 (eq (car setting) 'theme-value)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
212 (setq found setting))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
213 (widget-value-set (car (widget-get widget :children)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
214 (nth 3 found))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
215 (widget-put widget :custom-state 'themed) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
216 (custom-redraw-magic widget) |
48952 | 217 (widget-setup)) |
218 | |
67982
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
219 (defun custom-theme-delete-variable (widget) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
220 (setq custom-theme-variables |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
221 (assq-delete-all (widget-value widget) custom-theme-variables)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
222 (widget-delete widget)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
223 |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
224 ;;; Theme faces |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
225 |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
226 (defun custom-theme-add-face (symbol) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
227 (interactive (list (read-face-name "Face name" nil nil))) |
68161 | 228 (cond ((assq symbol custom-theme-faces) |
229 (message "%s is already in the theme" (symbol-name symbol))) | |
230 ((not (facep symbol)) | |
231 (message "%s is not defined as a face" (symbol-name symbol))) | |
232 (t | |
233 (save-excursion | |
234 (goto-char custom-theme-insert-face-marker) | |
68159
fca6909a92e8
* cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents:
67982
diff
changeset
|
235 (widget-insert "\n") |
fca6909a92e8
* cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents:
67982
diff
changeset
|
236 (let ((widget (widget-create 'custom-face |
fca6909a92e8
* cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents:
67982
diff
changeset
|
237 :tag (custom-unlispify-tag-name symbol) |
fca6909a92e8
* cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents:
67982
diff
changeset
|
238 :custom-level 0 |
fca6909a92e8
* cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents:
67982
diff
changeset
|
239 :action 'custom-theme-face-action |
fca6909a92e8
* cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents:
67982
diff
changeset
|
240 :custom-state 'unknown |
fca6909a92e8
* cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents:
67982
diff
changeset
|
241 :value symbol))) |
fca6909a92e8
* cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents:
67982
diff
changeset
|
242 (push (cons symbol widget) custom-theme-faces) |
fca6909a92e8
* cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents:
67982
diff
changeset
|
243 (custom-magic-reset widget) |
fca6909a92e8
* cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents:
67982
diff
changeset
|
244 (widget-setup)))))) |
67982
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
245 |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
246 (defvar custom-theme-face-menu |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
247 `(("Reset to Theme Value" custom-face-reset-theme |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
248 (lambda (widget) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
249 (let ((theme (intern (widget-value custom-theme-name))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
250 (symbol (widget-value widget)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
251 found) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
252 (and (custom-theme-p theme) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
253 (dolist (setting (get theme 'theme-settings) found) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
254 (if (and (eq (cadr setting) symbol) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
255 (eq (car setting) 'theme-face)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
256 (setq found t))))))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
257 ("---" ignore ignore) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
258 ("Delete" custom-theme-delete-face nil)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
259 "Alist of actions for the `custom-variable' widget in Custom Theme Mode. |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
260 See the documentation for `custom-variable'.") |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
261 |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
262 (defun custom-theme-face-action (widget &optional event) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
263 "Show the Custom Theme Mode menu for a `custom-face' widget. |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
264 Optional EVENT is the location for the menu." |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
265 (let ((custom-face-menu custom-theme-face-menu)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
266 (custom-face-action widget event))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
267 |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
268 (defun custom-face-reset-theme (widget) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
269 "Reset WIDGET to its value for the currently edited theme." |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
270 (let ((theme (intern (widget-value custom-theme-name))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
271 (symbol (widget-value widget)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
272 found) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
273 (dolist (setting (get theme 'theme-settings)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
274 (if (and (eq (cadr setting) symbol) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
275 (eq (car setting) 'theme-face)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
276 (setq found setting))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
277 (widget-value-set (car (widget-get widget :children)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
278 (nth 3 found))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
279 (widget-put widget :custom-state 'themed) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
280 (custom-redraw-magic widget) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
281 (widget-setup)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
282 |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
283 (defun custom-theme-delete-face (widget) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
284 (setq custom-theme-faces |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
285 (assq-delete-all (widget-value widget) custom-theme-faces)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
286 (widget-delete widget)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
287 |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
288 ;;; Reading and writing |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
289 |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
290 (defun custom-theme-visit-theme () |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
291 (interactive) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
292 (when (or (null custom-theme-variables) |
72386
2ce9bf47e864
* cus-theme.el (customize-create-theme)
Romain Francoise <romain@orebokech.com>
parents:
68912
diff
changeset
|
293 (if (y-or-n-p "Discard current changes? ") |
67982
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
294 (progn (customize-create-theme) t))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
295 (let ((theme (call-interactively 'custom-theme-merge-theme))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
296 (unless (eq theme 'user) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
297 (widget-value-set custom-theme-name (symbol-name theme))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
298 (widget-value-set custom-theme-description |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
299 (or (get theme 'theme-documentation) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
300 (format-time-string "Created %Y-%m-%d."))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
301 (widget-setup)))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
302 |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
303 (defun custom-theme-merge-theme (theme) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
304 (interactive "SCustom theme name: ") |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
305 (unless (eq theme 'user) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
306 (load-theme theme)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
307 (let ((settings (get theme 'theme-settings))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
308 (dolist (setting settings) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
309 (if (eq (car setting) 'theme-value) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
310 (custom-theme-add-variable (cadr setting)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
311 (custom-theme-add-face (cadr setting))))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
312 (disable-theme theme) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
313 theme) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
314 |
48952 | 315 (defun custom-theme-write (&rest ignore) |
67982
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
316 (let* ((name (widget-value custom-theme-name)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
317 (filename (expand-file-name (concat name "-theme.el") |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
318 custom-theme-directory)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
319 (doc (widget-value custom-theme-description)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
320 (vars custom-theme-variables) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
321 (faces custom-theme-faces)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
322 (cond ((or (string-equal name "") |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
323 (string-equal name "user") |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
324 (string-equal name "changed")) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
325 (error "Custom themes cannot be named `%s'" name)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
326 ((string-match " " name) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
327 (error "Custom theme names should not contain spaces")) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
328 ((if (file-exists-p filename) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
329 (not (y-or-n-p |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
330 (format "File %s exists. Overwrite? " filename)))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
331 (error "Aborted"))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
332 (with-temp-buffer |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
333 (emacs-lisp-mode) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
334 (unless (file-exists-p custom-theme-directory) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
335 (make-directory (file-name-as-directory custom-theme-directory) t)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
336 (setq buffer-file-name filename) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
337 (erase-buffer) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
338 (insert "(deftheme " name) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
339 (if doc (insert "\n \"" doc "\"")) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
340 (insert ")\n") |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
341 (custom-theme-write-variables name vars) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
342 (custom-theme-write-faces name faces) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
343 (insert "\n(provide-theme '" name ")\n") |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
344 (save-buffer)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
345 (dolist (var vars) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
346 (widget-put (cdr var) :custom-state 'saved) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
347 (custom-redraw-magic (cdr var))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
348 (dolist (face faces) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
349 (widget-put (cdr face) :custom-state 'saved) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
350 (custom-redraw-magic (cdr face))))) |
48952 | 351 |
352 (defun custom-theme-write-variables (theme vars) | |
353 "Write a `custom-theme-set-variables' command for THEME. | |
354 It includes all variables in list VARS." | |
355 (when vars | |
356 (let ((standard-output (current-buffer))) | |
357 (princ "\n(custom-theme-set-variables\n") | |
358 (princ " '") | |
359 (princ theme) | |
360 (princ "\n") | |
67982
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
361 (mapc (lambda (spec) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
362 (let* ((symbol (car spec)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
363 (child (car-safe (widget-get (cdr spec) :children))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
364 (value (if child |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
365 (widget-value child) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
366 ;; For hidden widgets, use the standard value |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
367 (get symbol 'standard-value)))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
368 (when (boundp symbol) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
369 (unless (bolp) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
370 (princ "\n")) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
371 (princ " '(") |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
372 (prin1 symbol) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
373 (princ " ") |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
374 (prin1 (custom-quote value)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
375 (princ ")")))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
376 vars) |
48952 | 377 (if (bolp) |
378 (princ " ")) | |
379 (princ ")") | |
380 (unless (looking-at "\n") | |
381 (princ "\n"))))) | |
382 | |
383 (defun custom-theme-write-faces (theme faces) | |
384 "Write a `custom-theme-set-faces' command for THEME. | |
385 It includes all faces in list FACES." | |
386 (when faces | |
387 (let ((standard-output (current-buffer))) | |
388 (princ "\n(custom-theme-set-faces\n") | |
389 (princ " '") | |
390 (princ theme) | |
391 (princ "\n") | |
67982
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
392 (mapc (lambda (spec) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
393 (let* ((symbol (car spec)) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
394 (child (car-safe (widget-get (cdr spec) :children))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
395 (value (if child (widget-value child)))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
396 (when (and (facep symbol) child) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
397 (unless (bolp) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
398 (princ "\n")) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
399 (princ " '(") |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
400 (prin1 symbol) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
401 (princ " ") |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
402 (prin1 value) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
403 (princ ")")))) |
a711a44049e2
* cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents:
67961
diff
changeset
|
404 faces) |
48952 | 405 (if (bolp) |
406 (princ " ")) | |
407 (princ ")") | |
408 (unless (looking-at "\n") | |
409 (princ "\n"))))) | |
410 | |
52401 | 411 ;;; arch-tag: cd6919bc-63af-410e-bae2-b6702e762344 |
48952 | 412 ;;; cus-theme.el ends here |