annotate lisp/cus-theme.el @ 112398:0bfcbd0b704b

* gnus-art.el (gnus-button-alist, gnus-button-handle-info-keystrokes): Don't confuse the "ret" of "retrograde" with RET.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Fri, 21 Jan 2011 12:38:33 -0500
parents ef719132ddfa
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
48952
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; cus-theme.el -- custom theme creation user interface
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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,
112218
376148b31b5e Add 2011 to FSF/AIST copyright years.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
4 ;; 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
48952
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;;
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Author: Alex Schroeder <alex@gnu.org>
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; Maintainer: FSF
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; Keywords: help, faces
110015
280c8ae2476d Add "Package:" file headers to denote built-in packages.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
9 ;; Package: emacs
48952
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; This file is part of GNU Emacs.
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
13 ;; GNU Emacs is free software: you can redistribute it and/or modify
48952
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
15 ;; the Free Software Foundation, either version 3 of the License, or
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
16 ;; (at your option) any later version.
48952
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; GNU General Public License for more details.
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
48952
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;;; Code:
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 (require 'widget)
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 (require 'cus-edit)
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 (eval-when-compile
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 (require 'wid-edit))
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33
67950
87b213a028b3 * cus-theme.el (custom-new-theme-mode-map): New variable.
Chong Yidong <cyd@stupidchicken.com>
parents: 67949
diff changeset
34 (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
35 (let ((map (make-keymap)))
87b213a028b3 * cus-theme.el (custom-new-theme-mode-map): New variable.
Chong Yidong <cyd@stupidchicken.com>
parents: 67949
diff changeset
36 (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
37 (suppress-keymap map)
110938
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
38 (define-key map "\C-x\C-s" 'custom-theme-write)
67950
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
111017
9506df1b7b65 Allow hiding of modified custom widgets.
Chong Yidong <cyd@stupidchicken.com>
parents: 111016
diff changeset
44 (define-derived-mode custom-new-theme-mode nil "Custom-Theme"
110938
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
45 "Major mode for editing Custom themes.
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
46 Do not call this mode function yourself. It is meant for internal use."
67950
87b213a028b3 * cus-theme.el (custom-new-theme-mode-map): New variable.
Chong Yidong <cyd@stupidchicken.com>
parents: 67949
diff changeset
47 (use-local-map custom-new-theme-mode-map)
110938
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
48 (custom--initialize-widget-variables)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
49 (set (make-local-variable 'revert-buffer-function) 'custom-theme-revert))
63928
e559c2c766bc (custom-new-theme-mode): New function.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61603
diff changeset
50 (put 'custom-new-theme-mode 'mode-class 'special)
e559c2c766bc (custom-new-theme-mode): New function.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61603
diff changeset
51
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
52 (defvar custom-theme-name nil)
111018
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
53 ;; Each element has the form (VAR CHECKBOX-WIDGET VAR-WIDGET)
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
54 (defvar custom-theme-variables nil)
111018
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
55 ;; Each element has the form (FACE CHECKBOX-WIDGET FACE-WIDGET)
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
56 (defvar custom-theme-faces nil)
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
57 (defvar custom-theme-description nil)
111018
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
58 (defvar custom-theme--migrate-settings nil)
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
59 (defvar custom-theme-insert-variable-marker nil)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
60 (defvar custom-theme-insert-face-marker nil)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
61
110955
c84f553cca36 Add some default custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110938
diff changeset
62 (defvar custom-theme--listed-faces '(default cursor fixed-pitch
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
63 variable-pitch escape-glyph minibuffer-prompt highlight region
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
64 shadow secondary-selection trailing-whitespace
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
65 font-lock-builtin-face font-lock-comment-delimiter-face
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
66 font-lock-comment-face font-lock-constant-face
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
67 font-lock-doc-face font-lock-function-name-face
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
68 font-lock-keyword-face font-lock-negation-char-face
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
69 font-lock-preprocessor-face font-lock-regexp-grouping-backslash
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
70 font-lock-regexp-grouping-construct font-lock-string-face
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
71 font-lock-type-face font-lock-variable-name-face
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
72 font-lock-warning-face button link link-visited fringe
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
73 header-line tooltip mode-line mode-line-buffer-id
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
74 mode-line-emphasis mode-line-highlight mode-line-inactive
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
75 isearch isearch-fail lazy-highlight match next-error
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
76 query-replace)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
77 "Faces listed by default in the *Custom Theme* buffer.")
63928
e559c2c766bc (custom-new-theme-mode): New function.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61603
diff changeset
78
110938
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
79 (defvar custom-theme--save-name)
63928
e559c2c766bc (custom-new-theme-mode): New function.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61603
diff changeset
80
50203
3803afb52e4f (custom-theme-create): Add autoload cookie.
John Paul Wallington <jpw@pobox.com>
parents: 49588
diff changeset
81 ;;;###autoload
110938
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
82 (defun customize-create-theme (&optional theme buffer)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
83 "Create or edit a custom theme.
111018
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
84 THEME, if non-nil, should be an existing theme to edit. If THEME
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
85 is `user', provide an option to remove these as custom settings.
111013
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
86 BUFFER, if non-nil, should be a buffer to use; the default is
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
87 named *Custom Theme*."
48952
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 (interactive)
110938
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
89 (switch-to-buffer (get-buffer-create (or buffer "*Custom Theme*")))
63928
e559c2c766bc (custom-new-theme-mode): New function.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61603
diff changeset
90 (let ((inhibit-read-only t))
111013
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
91 (erase-buffer)
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
92 (dolist (ov (overlays-in (point-min) (point-max)))
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
93 (delete-overlay ov)))
63928
e559c2c766bc (custom-new-theme-mode): New function.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61603
diff changeset
94 (custom-new-theme-mode)
48952
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 (make-local-variable 'custom-theme-name)
110938
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
96 (set (make-local-variable 'custom-theme--save-name) theme)
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
97 (set (make-local-variable 'custom-theme-faces) nil)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
98 (set (make-local-variable 'custom-theme-variables) nil)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
99 (set (make-local-variable 'custom-theme-description) "")
111018
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
100 (set (make-local-variable 'custom-theme--migrate-settings) nil)
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
101 (make-local-variable 'custom-theme-insert-face-marker)
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
102 (make-local-variable 'custom-theme-insert-variable-marker)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
103 (make-local-variable 'custom-theme--listed-faces)
63928
e559c2c766bc (custom-new-theme-mode): New function.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61603
diff changeset
104
111018
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
105 (if (eq theme 'user)
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
106 (widget-insert "This buffer contains all the Custom settings you have made.
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
107 You can convert them into a new custom theme, and optionally
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
108 remove them from your saved Custom file.\n\n"))
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
109
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
110 (widget-create 'push-button
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
111 :tag " Visit Theme "
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
112 :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
113 :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
114 (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
115 (widget-insert " ")
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
116 (widget-create 'push-button
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
117 :tag " Merge Theme "
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
118 :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
119 :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
120 (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
121 (widget-insert " ")
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
122 (widget-create 'push-button
111018
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
123 :tag " Revert "
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
124 :help-echo "Revert this buffer to its original state."
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
125 :action (lambda (&rest ignored) (revert-buffer)))
63928
e559c2c766bc (custom-new-theme-mode): New function.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61603
diff changeset
126
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
127 (widget-insert "\n\nTheme name : ")
48952
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 (setq custom-theme-name
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 (widget-create 'editable-field
111018
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
130 :value (if (and theme (not (eq theme 'user)))
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
131 (symbol-name theme)
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
132 "")))
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
133 (widget-insert "Description: ")
48952
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 (setq custom-theme-description
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48952
diff changeset
135 (widget-create 'text
48952
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 :value (format-time-string "Created %Y-%m-%d.")))
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
137 (widget-create 'push-button
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
138 :notify (function custom-theme-write)
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
139 " Save Theme ")
111018
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
140 (when (eq theme 'user)
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
141 (setq custom-theme--migrate-settings t)
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
142 (widget-insert " ")
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
143 (widget-create 'checkbox
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
144 :value custom-theme--migrate-settings
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
145 :action (lambda (widget &optional event)
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
146 (when (widget-value widget)
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
147 (widget-toggle-action widget event)
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
148 (setq custom-theme--migrate-settings
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
149 (widget-value widget)))))
111020
9d2f59f15c3e Fix a misleading widget message in the last checkin.
Chong Yidong <cyd@stupidchicken.com>
parents: 111018
diff changeset
150 (widget-insert (propertize " Remove saved theme settings from Custom save file."
111018
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
151 'face '(variable-pitch (:height 0.9)))))
111013
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
152
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
153 (let (vars values faces face-specs)
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
154
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
155 ;; Load the theme settings.
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
156 (when theme
111018
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
157 (unless (eq theme 'user)
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
158 (load-theme theme t))
111013
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
159 (dolist (setting (get theme 'theme-settings))
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
160 (if (eq (car setting) 'theme-value)
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
161 (progn (push (nth 1 setting) vars)
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
162 (push (nth 3 setting) values))
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
163 (push (nth 1 setting) faces)
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
164 (push (nth 3 setting) face-specs))))
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
165
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
166 ;; If THEME is non-nil, insert all of that theme's faces.
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
167 ;; Otherwise, insert those in `custom-theme--listed-faces'.
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
168 (widget-insert "\n\n Theme faces:\n ")
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
169 (if theme
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
170 (while faces
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
171 (custom-theme-add-face-1 (pop faces) (pop face-specs)))
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
172 (dolist (face custom-theme--listed-faces)
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
173 (custom-theme-add-face-1 face nil)))
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
174 (setq custom-theme-insert-face-marker (point-marker))
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
175 (widget-insert " ")
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
176 (widget-create 'push-button
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
177 :tag "Insert Additional Face"
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
178 :help-echo "Add another face to this theme."
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
179 :follow-link 'mouse-face
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
180 :button-face 'custom-link
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
181 :mouse-face 'highlight
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
182 :pressed-face 'highlight
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
183 :action (lambda (widget &optional event)
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
184 (call-interactively 'custom-theme-add-face)))
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
185
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
186 ;; If THEME is non-nil, insert all of that theme's variables.
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
187 (widget-insert "\n\n Theme variables:\n ")
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
188 (if theme
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
189 (while vars
111018
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
190 (if (eq (car vars) 'custom-enabled-themes)
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
191 (progn (pop vars) (pop values))
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
192 (custom-theme-add-var-1 (pop vars) (pop values)))))
111013
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
193 (setq custom-theme-insert-variable-marker (point-marker))
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
194 (widget-insert " ")
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
195 (widget-create 'push-button
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
196 :tag "Insert Variable"
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
197 :help-echo "Add another variable to this theme."
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
198 :follow-link 'mouse-face
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
199 :button-face 'custom-link
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
200 :mouse-face 'highlight
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
201 :pressed-face 'highlight
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
202 :action (lambda (widget &optional event)
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
203 (call-interactively 'custom-theme-add-variable)))
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
204 (widget-insert ?\n)
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
205 (widget-setup)
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
206 (goto-char (point-min))
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
207 (message "")))
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
208
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
209 (defun custom-theme-revert (ignore-auto noconfirm)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
210 (when (or noconfirm (y-or-n-p "Discard current changes? "))
110938
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
211 (customize-create-theme custom-theme--save-name (current-buffer))))
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
212
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
213 ;;; Theme variables
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
214
111013
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
215 (defun custom-theme-add-variable (var value)
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
216 "Add a widget for VAR (a symbol) to the *New Custom Theme* buffer.
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
217 VALUE should be a value to which to set the widget; when called
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
218 interactively, this defaults to the current value of VAR."
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
219 (interactive
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
220 (let ((v (read-variable "Variable name: ")))
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
221 (list v (symbol-value v))))
111018
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
222 (let ((entry (assq var custom-theme-variables)))
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
223 (cond ((null entry)
111013
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
224 ;; If VAR is not yet in the buffer, add it.
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
225 (save-excursion
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
226 (goto-char custom-theme-insert-variable-marker)
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
227 (custom-theme-add-var-1 var value)
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
228 (move-marker custom-theme-insert-variable-marker (point))
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
229 (widget-setup)))
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
230 ;; Otherwise, alter that var widget.
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
231 (t
111018
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
232 (widget-value-set (nth 1 entry) t)
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
233 (let ((widget (nth 2 entry)))
111013
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
234 (widget-put widget :shown-value (list value))
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
235 (custom-redraw widget))))))
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
236
111013
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
237 (defun custom-theme-add-var-1 (symbol val)
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
238 (widget-insert " ")
111018
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
239 (push (list symbol
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
240 (prog1 (widget-create 'checkbox
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
241 :value t
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
242 :help-echo "Enable/disable this variable.")
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
243 (widget-insert " "))
111013
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
244 (widget-create 'custom-variable
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
245 :tag (custom-unlispify-tag-name symbol)
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
246 :value symbol
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
247 :shown-value (list val)
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
248 :notify 'ignore
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
249 :custom-level 0
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
250 :custom-state 'hidden
111017
9506df1b7b65 Allow hiding of modified custom widgets.
Chong Yidong <cyd@stupidchicken.com>
parents: 111016
diff changeset
251 :custom-style 'simple))
111013
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
252 custom-theme-variables)
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
253 (widget-insert " "))
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
254
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
255 ;;; Theme faces
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
256
111013
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
257 (defun custom-theme-add-face (face &optional spec)
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
258 "Add a widget for FACE (a symbol) to the *New Custom Theme* buffer.
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
259 SPEC, if non-nil, should be a face spec to which to set the widget."
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
260 (interactive (list (read-face-name "Face name" nil nil) nil))
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
261 (unless (or (facep face) spec)
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
262 (error "`%s' has no face definition" face))
111018
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
263 (let ((entry (assq face custom-theme-faces)))
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
264 (cond ((null entry)
111013
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
265 ;; If FACE is not yet in the buffer, add it.
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
266 (save-excursion
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
267 (goto-char custom-theme-insert-face-marker)
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
268 (custom-theme-add-face-1 face spec)
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
269 (move-marker custom-theme-insert-face-marker (point))
111013
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
270 (widget-setup)))
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
271 ;; Otherwise, if SPEC is supplied, alter that face widget.
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
272 (spec
111018
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
273 (widget-value-set (nth 1 entry) t)
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
274 (let ((widget (nth 2 entry)))
111013
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
275 (widget-put widget :shown-value spec)
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
276 (custom-redraw widget)))
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
277 ((called-interactively-p 'interactive)
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
278 (error "`%s' is already present" face)))))
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
279
111013
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
280 (defun custom-theme-add-face-1 (symbol spec)
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
281 (widget-insert " ")
111018
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
282 (push (list symbol
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
283 (prog1
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
284 (widget-create 'checkbox
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
285 :value t
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
286 :help-echo "Enable/disable this face.")
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
287 (widget-insert " "))
111013
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
288 (widget-create 'custom-face
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
289 :tag (custom-unlispify-tag-name symbol)
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
290 :documentation-shown t
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
291 :value symbol
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
292 :custom-state 'hidden
111017
9506df1b7b65 Allow hiding of modified custom widgets.
Chong Yidong <cyd@stupidchicken.com>
parents: 111016
diff changeset
293 :custom-style 'simple
111013
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
294 :shown-value spec
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
295 :sample-indent 34))
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
296 custom-theme-faces)
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
297 (widget-insert " "))
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
298
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
299 ;;; Reading and writing
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
300
111013
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
301 (defun custom-theme-visit-theme (theme)
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
302 "Load the custom theme THEME's settings into the current buffer."
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
303 (interactive
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
304 (list
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
305 (intern (completing-read "Find custom theme: "
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
306 (mapcar 'symbol-name
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
307 (custom-available-themes))))))
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
308 (unless (custom-theme-name-valid-p theme)
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
309 (error "No valid theme named `%s'" theme))
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
310 (cond ((not (eq major-mode 'custom-new-theme-mode))
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
311 (customize-create-theme theme))
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
312 ((y-or-n-p "Discard current changes? ")
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
313 (setq custom-theme--save-name theme)
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
314 (custom-theme-revert nil t))))
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
315
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
316 (defun custom-theme-merge-theme (theme)
111013
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
317 "Merge the custom theme THEME's settings into the current buffer."
110938
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
318 (interactive
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
319 (list
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
320 (intern (completing-read "Merge custom theme: "
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
321 (mapcar 'symbol-name
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
322 (custom-available-themes))))))
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
323 (unless (eq theme 'user)
111013
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
324 (unless (custom-theme-name-valid-p theme)
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
325 (error "Invalid theme name `%s'" theme))
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
326 (load-theme theme t))
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
327 (let ((settings (reverse (get theme 'theme-settings))))
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
328 (dolist (setting settings)
111013
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
329 (funcall (if (eq (car setting) 'theme-value)
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
330 'custom-theme-add-variable
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
331 'custom-theme-add-face)
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
332 (nth 1 setting)
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
333 (nth 3 setting))))
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
334 theme)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
335
48952
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 (defun custom-theme-write (&rest ignore)
111013
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
337 "Write the current custom theme to its theme file."
110938
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
338 (interactive)
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
339 (let* ((name (widget-value custom-theme-name))
111018
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
340 (doc (widget-value custom-theme-description))
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
341 (vars custom-theme-variables)
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
342 (faces custom-theme-faces)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
343 filename)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
344 (when (string-equal name "")
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
345 (setq name (read-from-minibuffer "Theme name: " (user-login-name)))
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
346 (widget-value-set custom-theme-name name))
110938
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
347 (unless (custom-theme-name-valid-p (intern name))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
348 (error "Custom themes cannot be named `%s'" name))
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
349
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
350 (setq filename (expand-file-name (concat name "-theme.el")
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
351 custom-theme-directory))
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
352 (and (file-exists-p filename)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
353 (not (y-or-n-p (format "File %s exists. Overwrite? " filename)))
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
354 (error "Aborted"))
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
355
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
356 (with-temp-buffer
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
357 (emacs-lisp-mode)
111016
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 111013
diff changeset
358 (unless (file-directory-p custom-theme-directory)
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
359 (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
360 (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
361 (erase-buffer)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
362 (insert "(deftheme " name)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
363 (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
364 (insert ")\n")
111018
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
365 (custom-theme-write-variables name (reverse vars))
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
366 (custom-theme-write-faces name (reverse faces))
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
367 (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
368 (save-buffer))
111018
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
369 (message "Theme written to %s" filename)
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
370
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
371 (when custom-theme--migrate-settings
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
372 ;; Remove these settings from the Custom file.
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
373 (let ((custom-reset-standard-variables-list '(t))
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
374 (custom-reset-standard-faces-list '(t)))
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
375 (dolist (var vars)
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
376 (when (and (not (eq (car var) 'custom-enabled-themes))
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
377 (widget-get (nth 1 var) :value))
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
378 (widget-apply (nth 2 var) :custom-mark-to-reset-standard)))
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
379 (dolist (face faces)
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
380 (when (widget-get (nth 1 face) :value)
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
381 (widget-apply (nth 2 face) :custom-mark-to-reset-standard)))
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
382 (custom-save-all))
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
383 (let ((custom-theme-load-path (list 'custom-theme-directory)))
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
384 (load-theme (intern name))))))
48952
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386 (defun custom-theme-write-variables (theme vars)
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 "Write a `custom-theme-set-variables' command for THEME.
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388 It includes all variables in list VARS."
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389 (when vars
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390 (let ((standard-output (current-buffer)))
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 (princ "\n(custom-theme-set-variables\n")
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 (princ " '")
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393 (princ theme)
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 (princ "\n")
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
395 (dolist (spec vars)
111018
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
396 (when (widget-get (nth 1 spec) :value)
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
397 (let* ((symbol (nth 0 spec))
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
398 (widget (nth 2 spec))
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
399 (child (car-safe (widget-get widget :children)))
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
400 (value (if child
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
401 (widget-value child)
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
402 ;; Child is null if the widget is closed (hidden).
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
403 (car (widget-get widget :shown-value)))))
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
404 (when (boundp symbol)
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
405 (unless (bolp)
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
406 (princ "\n"))
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
407 (princ " '(")
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
408 (prin1 symbol)
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
409 (princ " ")
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
410 (prin1 (custom-quote value))
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
411 (princ ")")))))
48952
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 (if (bolp)
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 (princ " "))
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414 (princ ")")
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 (unless (looking-at "\n")
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 (princ "\n")))))
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 (defun custom-theme-write-faces (theme faces)
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 "Write a `custom-theme-set-faces' command for THEME.
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 It includes all faces in list FACES."
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 (when faces
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 (let ((standard-output (current-buffer)))
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 (princ "\n(custom-theme-set-faces\n")
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 (princ " '")
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 (princ theme)
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 (princ "\n")
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
427 (dolist (spec faces)
111018
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
428 (when (widget-get (nth 1 spec) :value)
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
429 (let* ((symbol (nth 0 spec))
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
430 (widget (nth 2 spec))
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
431 (value
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
432 (if (car-safe (widget-get widget :children))
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
433 (custom-face-widget-to-spec widget)
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
434 ;; Child is null if the widget is closed (hidden).
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
435 (widget-get widget :shown-value))))
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
436 (when (and (facep symbol) value)
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
437 (princ (if (bolp) " '(" "\n '("))
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
438 (prin1 symbol)
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
439 (princ " ")
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
440 (prin1 value)
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
441 (princ ")")))))
111013
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
442 (if (bolp) (princ " "))
48952
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 (princ ")")
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 (unless (looking-at "\n")
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445 (princ "\n")))))
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446
110938
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
447
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
448 ;;; Describing Custom themes.
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
449
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
450 ;;;###autoload
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
451 (defun describe-theme (theme)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
452 "Display a description of the Custom theme THEME (a symbol)."
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
453 (interactive
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
454 (list
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
455 (intern (completing-read "Describe custom theme: "
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
456 (mapcar 'symbol-name
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
457 (custom-available-themes))))))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
458 (unless (custom-theme-name-valid-p theme)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
459 (error "Invalid theme name `%s'" theme))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
460 (help-setup-xref (list 'describe-theme theme)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
461 (called-interactively-p 'interactive))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
462 (with-help-window (help-buffer)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
463 (with-current-buffer standard-output
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
464 (describe-theme-1 theme))))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
465
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
466 (defun describe-theme-1 (theme)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
467 (prin1 theme)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
468 (princ " is a custom theme")
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
469 (let ((fn (locate-file (concat (symbol-name theme) "-theme.el")
111016
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 111013
diff changeset
470 (custom-theme--load-path)
110955
c84f553cca36 Add some default custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110938
diff changeset
471 '("" "c")))
c84f553cca36 Add some default custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110938
diff changeset
472 doc)
110938
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
473 (when fn
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
474 (princ " in `")
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
475 (help-insert-xref-button (file-name-nondirectory fn)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
476 'help-theme-def fn)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
477 (princ "'"))
110955
c84f553cca36 Add some default custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110938
diff changeset
478 (princ ".\n")
c84f553cca36 Add some default custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110938
diff changeset
479 (if (not (memq theme custom-known-themes))
c84f553cca36 Add some default custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110938
diff changeset
480 (progn
c84f553cca36 Add some default custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110938
diff changeset
481 (princ "It is not loaded.")
c84f553cca36 Add some default custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110938
diff changeset
482 ;; Attempt to grab the theme documentation
c84f553cca36 Add some default custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110938
diff changeset
483 (when fn
c84f553cca36 Add some default custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110938
diff changeset
484 (with-temp-buffer
c84f553cca36 Add some default custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110938
diff changeset
485 (insert-file-contents fn)
c84f553cca36 Add some default custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110938
diff changeset
486 (let ((sexp (let ((read-circle nil))
c84f553cca36 Add some default custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110938
diff changeset
487 (condition-case nil
c84f553cca36 Add some default custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110938
diff changeset
488 (read (current-buffer))
c84f553cca36 Add some default custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110938
diff changeset
489 (end-of-file nil)))))
c84f553cca36 Add some default custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110938
diff changeset
490 (and sexp (listp sexp)
c84f553cca36 Add some default custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110938
diff changeset
491 (eq (car sexp) 'deftheme)
c84f553cca36 Add some default custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110938
diff changeset
492 (setq doc (nth 2 sexp)))))))
c84f553cca36 Add some default custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110938
diff changeset
493 (if (custom-theme-enabled-p theme)
c84f553cca36 Add some default custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110938
diff changeset
494 (princ "It is loaded and enabled.")
c84f553cca36 Add some default custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110938
diff changeset
495 (princ "It is loaded but disabled."))
c84f553cca36 Add some default custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110938
diff changeset
496 (setq doc (get theme 'theme-documentation)))
c84f553cca36 Add some default custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110938
diff changeset
497
c84f553cca36 Add some default custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110938
diff changeset
498 (princ "\n\nDocumentation:\n")
c84f553cca36 Add some default custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110938
diff changeset
499 (princ (if (stringp doc)
c84f553cca36 Add some default custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110938
diff changeset
500 doc
c84f553cca36 Add some default custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110938
diff changeset
501 "No documentation available.")))
110938
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
502 (princ "\n\nYou can ")
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
503 (help-insert-xref-button "customize" 'help-theme-edit theme)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
504 (princ " this theme."))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
505
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
506
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
507 ;;; Theme chooser
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
508
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
509 (defvar custom--listed-themes)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
510
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
511 (defcustom custom-theme-allow-multiple-selections nil
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
512 "Whether to allow multi-selections in the *Custom Themes* buffer."
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
513 :type 'boolean
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
514 :group 'custom-buffer)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
515
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
516 (defvar custom-theme-choose-mode-map
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
517 (let ((map (make-keymap)))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
518 (set-keymap-parent map widget-keymap)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
519 (suppress-keymap map)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
520 (define-key map "\C-x\C-s" 'custom-theme-save)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
521 (define-key map "n" 'widget-forward)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
522 (define-key map "p" 'widget-backward)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
523 (define-key map "?" 'custom-describe-theme)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
524 map)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
525 "Keymap for `custom-theme-choose-mode'.")
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
526
111017
9506df1b7b65 Allow hiding of modified custom widgets.
Chong Yidong <cyd@stupidchicken.com>
parents: 111016
diff changeset
527 (define-derived-mode custom-theme-choose-mode nil "Themes"
110938
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
528 "Major mode for selecting Custom themes.
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
529 Do not call this mode function yourself. It is meant for internal use."
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
530 (use-local-map custom-theme-choose-mode-map)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
531 (custom--initialize-widget-variables)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
532 (set (make-local-variable 'revert-buffer-function)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
533 (lambda (ignore-auto noconfirm)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
534 (when (or noconfirm (y-or-n-p "Discard current choices? "))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
535 (customize-themes (current-buffer))))))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
536 (put 'custom-theme-choose-mode 'mode-class 'special)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
537
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
538 ;;;###autoload
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
539 (defun customize-themes (&optional buffer)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
540 "Display a selectable list of Custom themes.
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
541 When called from Lisp, BUFFER should be the buffer to use; if
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
542 omitted, a buffer named *Custom Themes* is used."
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
543 (interactive)
112198
0c7ac8e7d5ee * cus-theme.el (customize-themes): Use switch-to-buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 111020
diff changeset
544 (switch-to-buffer (get-buffer-create (or buffer "*Custom Themes*")))
110938
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
545 (let ((inhibit-read-only t))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
546 (erase-buffer))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
547 (custom-theme-choose-mode)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
548 (set (make-local-variable 'custom--listed-themes) nil)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
549 (make-local-variable 'custom-theme-allow-multiple-selections)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
550 (and (null custom-theme-allow-multiple-selections)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
551 (> (length custom-enabled-themes) 1)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
552 (setq custom-theme-allow-multiple-selections t))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
553
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
554 (widget-insert
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
555 (substitute-command-keys
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
556 "Type RET or click to enable/disable listed custom themes.
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
557 Type \\[custom-describe-theme] to describe the theme at point.
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
558 Theme files are named *-theme.el in `"))
111016
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 111013
diff changeset
559 (widget-create 'link :value "custom-theme-load-path"
110938
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
560 :button-face 'custom-link
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
561 :mouse-face 'highlight
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
562 :pressed-face 'highlight
111016
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 111013
diff changeset
563 :help-echo "Describe `custom-theme-load-path'."
110938
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
564 :keymap custom-mode-link-map
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
565 :follow-link 'mouse-face
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
566 :action (lambda (widget &rest ignore)
111016
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 111013
diff changeset
567 (describe-variable 'custom-theme-load-path)))
110938
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
568 (widget-insert "'.\n\n")
111013
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
569
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
570 ;; If the user has made customizations, display a warning and
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
571 ;; provide buttons to disable or convert them.
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
572 (let ((user-settings (get 'user 'theme-settings)))
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
573 (unless (or (null user-settings)
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
574 (and (null (cdr user-settings))
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
575 (eq (caar user-settings) 'theme-value)
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
576 (eq (cadr (car user-settings)) 'custom-enabled-themes)))
111018
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
577 (widget-insert
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
578 (propertize
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
579 " Note: Your custom settings take precedence over theme settings.
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
580 To migrate your settings into a theme, click "
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
581 'face 'font-lock-warning-face))
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
582 (widget-create 'link :value "here"
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
583 :button-face 'custom-link
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
584 :mouse-face 'highlight
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
585 :pressed-face 'highlight
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
586 :help-echo "Migrate."
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
587 :keymap custom-mode-link-map
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
588 :follow-link 'mouse-face
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
589 :action (lambda (widget &rest ignore)
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
590 (customize-create-theme 'user)))
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
591 (widget-insert ".\n\n")))
111013
5ffdb52c377c Bugfixes for `customize-create-theme'.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
592
110938
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
593 (widget-create 'push-button
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
594 :tag " Save Theme Settings "
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
595 :help-echo "Save the selected themes for future sessions."
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
596 :action 'custom-theme-save)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
597 (widget-insert ?\n)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
598 (widget-create 'checkbox
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
599 :value custom-theme-allow-multiple-selections
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
600 :action 'custom-theme-selections-toggle)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
601 (widget-insert (propertize " Allow more than one theme at a time"
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
602 'face '(variable-pitch (:height 0.9))))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
603
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
604 (widget-insert "\n\nAvailable Custom Themes:\n")
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
605 (let (widget)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
606 (dolist (theme (custom-available-themes))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
607 (setq widget (widget-create 'checkbox
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
608 :value (custom-theme-enabled-p theme)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
609 :theme-name theme
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
610 :action 'custom-theme-checkbox-toggle))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
611 (push (cons theme widget) custom--listed-themes)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
612 (widget-create-child-and-convert widget 'push-button
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
613 :button-face-get 'ignore
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
614 :mouse-face-get 'ignore
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
615 :value (format " %s" theme)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
616 :action 'widget-parent-action)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
617 (widget-insert ?\n)))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
618 (goto-char (point-min))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
619 (widget-setup))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
620
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
621 (defun custom-theme-checkbox-toggle (widget &optional event)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
622 (let ((this-theme (widget-get widget :theme-name)))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
623 (if (widget-value widget)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
624 ;; Disable the theme.
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
625 (disable-theme this-theme)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
626 ;; Enable the theme.
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
627 (unless custom-theme-allow-multiple-selections
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
628 ;; If only one theme is allowed, disable all other themes and
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
629 ;; uncheck their boxes.
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
630 (dolist (theme custom-enabled-themes)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
631 (and (not (eq theme this-theme))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
632 (assq theme custom--listed-themes)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
633 (disable-theme theme)))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
634 (dolist (theme custom--listed-themes)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
635 (unless (eq (car theme) this-theme)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
636 (widget-value-set (cdr theme) nil)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
637 (widget-apply (cdr theme) :notify (cdr theme) event))))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
638 (load-theme this-theme)))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
639 ;; Mark `custom-enabled-themes' as "set for current session".
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
640 (put 'custom-enabled-themes 'customized-value
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
641 (list (custom-quote custom-enabled-themes)))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
642 ;; Check/uncheck the widget.
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
643 (widget-toggle-action widget event))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
644
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
645 (defun custom-describe-theme ()
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
646 "Describe the Custom theme on the current line."
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
647 (interactive)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
648 (let ((widget (widget-at (line-beginning-position))))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
649 (and widget
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
650 (describe-theme (widget-get widget :theme-name)))))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
651
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
652 (defun custom-theme-save (&rest ignore)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
653 (interactive)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
654 (customize-save-variable 'custom-enabled-themes custom-enabled-themes)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
655 (message "Custom themes saved for future sessions."))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
656
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
657 (defun custom-theme-selections-toggle (widget &optional event)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
658 (when (widget-value widget)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
659 ;; Deactivate multiple-selections.
111018
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
660 (if (< 1 (length (delq nil (mapcar (lambda (x) (widget-value (cdr x)))
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
661 custom--listed-themes))))
110938
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
662 (error "More than one theme is currently selected")))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
663 (widget-toggle-action widget event)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
664 (setq custom-theme-allow-multiple-selections (widget-value widget)))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110896
diff changeset
665
48952
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
666 ;;; cus-theme.el ends here