annotate lisp/cus-theme.el @ 110937:51080327d173

lisp/net/telnet.el: "Fix" commented code.
author Juanma Barranquero <lekktu@gmail.com>
date Tue, 12 Oct 2010 04:45:24 +0200
parents 0d6d71f9b91a
children 17bbe431e616
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,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
4 ;; 2006, 2007, 2008, 2009, 2010 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)
87b213a028b3 * cus-theme.el (custom-new-theme-mode-map): New variable.
Chong Yidong <cyd@stupidchicken.com>
parents: 67949
diff changeset
38 (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
39 (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
40 map)
87b213a028b3 * cus-theme.el (custom-new-theme-mode-map): New variable.
Chong Yidong <cyd@stupidchicken.com>
parents: 67949
diff changeset
41 "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
42
63928
e559c2c766bc (custom-new-theme-mode): New function.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61603
diff changeset
43 (define-derived-mode custom-new-theme-mode nil "New-Theme"
e559c2c766bc (custom-new-theme-mode): New function.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61603
diff changeset
44 "Major mode for the buffer created by `customize-create-theme'.
e559c2c766bc (custom-new-theme-mode): New function.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61603
diff changeset
45 Do not call this mode function yourself. It is only meant for internal
e559c2c766bc (custom-new-theme-mode): New function.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61603
diff changeset
46 use by `customize-create-theme'."
67950
87b213a028b3 * cus-theme.el (custom-new-theme-mode-map): New variable.
Chong Yidong <cyd@stupidchicken.com>
parents: 67949
diff changeset
47 (use-local-map custom-new-theme-mode-map)
87b213a028b3 * cus-theme.el (custom-new-theme-mode-map): New variable.
Chong Yidong <cyd@stupidchicken.com>
parents: 67949
diff changeset
48 (define-key custom-new-theme-mode-map [mouse-1] 'widget-move-and-invoke)
67948
5bf588b1a01e * cus-theme.el (custom-new-theme-mode): Use cus-edit faces.
Chong Yidong <cyd@stupidchicken.com>
parents: 65341
diff changeset
49 (set (make-local-variable 'widget-documentation-face) 'custom-documentation)
5bf588b1a01e * cus-theme.el (custom-new-theme-mode): Use cus-edit faces.
Chong Yidong <cyd@stupidchicken.com>
parents: 65341
diff changeset
50 (set (make-local-variable 'widget-button-face) custom-button)
5bf588b1a01e * cus-theme.el (custom-new-theme-mode): Use cus-edit faces.
Chong Yidong <cyd@stupidchicken.com>
parents: 65341
diff changeset
51 (set (make-local-variable 'widget-button-pressed-face) custom-button-pressed)
67961
52f526ce11f6 * cus-edit.el (custom-button-mouse): New variable.
Chong Yidong <cyd@stupidchicken.com>
parents: 67951
diff changeset
52 (set (make-local-variable 'widget-mouse-face) custom-button-mouse)
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
53 (set (make-local-variable 'revert-buffer-function) 'custom-theme-revert)
67948
5bf588b1a01e * cus-theme.el (custom-new-theme-mode): Use cus-edit faces.
Chong Yidong <cyd@stupidchicken.com>
parents: 65341
diff changeset
54 (when custom-raised-buttons
5bf588b1a01e * cus-theme.el (custom-new-theme-mode): Use cus-edit faces.
Chong Yidong <cyd@stupidchicken.com>
parents: 65341
diff changeset
55 (set (make-local-variable 'widget-push-button-prefix) "")
5bf588b1a01e * cus-theme.el (custom-new-theme-mode): Use cus-edit faces.
Chong Yidong <cyd@stupidchicken.com>
parents: 65341
diff changeset
56 (set (make-local-variable 'widget-push-button-suffix) "")
5bf588b1a01e * cus-theme.el (custom-new-theme-mode): Use cus-edit faces.
Chong Yidong <cyd@stupidchicken.com>
parents: 65341
diff changeset
57 (set (make-local-variable 'widget-link-prefix) "")
5bf588b1a01e * cus-theme.el (custom-new-theme-mode): Use cus-edit faces.
Chong Yidong <cyd@stupidchicken.com>
parents: 65341
diff changeset
58 (set (make-local-variable 'widget-link-suffix) "")))
63928
e559c2c766bc (custom-new-theme-mode): New function.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61603
diff changeset
59 (put 'custom-new-theme-mode 'mode-class 'special)
e559c2c766bc (custom-new-theme-mode): New function.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61603
diff changeset
60
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
61 (defvar custom-theme-name nil)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
62 (defvar custom-theme-variables nil)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
63 (defvar custom-theme-faces nil)
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
64 (defvar custom-theme-description nil)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
65 (defvar custom-theme-insert-variable-marker nil)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
66 (defvar custom-theme-insert-face-marker nil)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
67
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
68 (defvar custom-theme--listed-faces '(default fixed-pitch
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
69 variable-pitch escape-glyph minibuffer-prompt highlight region
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
70 shadow secondary-selection trailing-whitespace
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
71 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
72 font-lock-comment-face font-lock-constant-face
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
73 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
74 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
75 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
76 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
77 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
78 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
79 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
80 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
81 isearch isearch-fail lazy-highlight match next-error
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
82 query-replace)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
83 "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
84
50203
3803afb52e4f (custom-theme-create): Add autoload cookie.
John Paul Wallington <jpw@pobox.com>
parents: 49588
diff changeset
85 ;;;###autoload
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
86 (defun customize-create-theme (&optional buffer)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
87 "Create a custom theme.
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
88 BUFFER, if non-nil, should be a buffer to use."
48952
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 (interactive)
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
90 (switch-to-buffer (or buffer (generate-new-buffer "*Custom Theme*")))
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
91 ;; Save current faces
63928
e559c2c766bc (custom-new-theme-mode): New function.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61603
diff changeset
92 (let ((inhibit-read-only t))
e559c2c766bc (custom-new-theme-mode): New function.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61603
diff changeset
93 (erase-buffer))
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)
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
96 (set (make-local-variable 'custom-theme-faces) nil)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
97 (set (make-local-variable 'custom-theme-variables) nil)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
98 (set (make-local-variable 'custom-theme-description) "")
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
99 (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
100 (make-local-variable 'custom-theme-insert-variable-marker)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
101 (make-local-variable 'custom-theme--listed-faces)
63928
e559c2c766bc (custom-new-theme-mode): New function.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61603
diff changeset
102
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
103 (widget-create 'push-button
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
104 :tag " Visit Theme "
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
105 :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
106 :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
107 (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
108 (widget-insert " ")
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
109 (widget-create 'push-button
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
110 :tag " Merge Theme "
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
111 :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
112 :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
113 (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
114 (widget-insert " ")
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
115 (widget-create 'push-button :notify 'revert-buffer " Revert ")
63928
e559c2c766bc (custom-new-theme-mode): New function.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61603
diff changeset
116
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
117 (widget-insert "\n\nTheme name : ")
48952
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 (setq custom-theme-name
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
119 (widget-create 'editable-field))
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
120 (widget-insert "Description: ")
48952
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 (setq custom-theme-description
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48952
diff changeset
122 (widget-create 'text
48952
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 :value (format-time-string "Created %Y-%m-%d.")))
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
124 (widget-insert " ")
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
125 (widget-create 'push-button
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
126 :notify (function custom-theme-write)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
127 " Save Theme ")
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
128 ;; Face widgets
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
129 (widget-insert "\n\n Theme faces:\n")
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
130 (let (widget)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
131 (dolist (face custom-theme--listed-faces)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
132 (widget-insert " ")
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
133 (setq widget (widget-create 'custom-face
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
134 :documentation-shown t
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
135 :tag (custom-unlispify-tag-name face)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
136 :value face
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
137 :display-style 'concise
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
138 :custom-state 'hidden
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
139 :sample-indent 34))
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
140 (custom-magic-reset widget)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
141 (push (cons face widget) custom-theme-faces)))
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
142 (insert " ")
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
143 (setq custom-theme-insert-face-marker (point-marker))
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
144 (insert " ")
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
145 (widget-create 'push-button
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
146 :tag "Insert Additional Face"
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
147 :help-echo "Add another face to this theme."
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
148 :follow-link 'mouse-face
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
149 :button-face 'custom-link
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
150 :mouse-face 'highlight
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
151 :pressed-face 'highlight
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
152 :action (lambda (widget &optional event)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
153 (call-interactively 'custom-theme-add-face)))
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
154 (widget-insert "\n\n Theme variables:\n ")
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
155 (setq custom-theme-insert-variable-marker (point-marker))
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
156 (widget-insert ?\s)
48952
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 (widget-create 'push-button
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
158 :tag "Insert Variable"
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
159 :help-echo "Add another variable to this theme."
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
160 :follow-link 'mouse-face
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
161 :button-face 'custom-link
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
162 :mouse-face 'highlight
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
163 :pressed-face 'highlight
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
164 :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
165 (call-interactively 'custom-theme-add-variable)))
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
166 (widget-insert ?\n)
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
167 (widget-setup)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
168 (goto-char (point-min))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
169 (message ""))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
170
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
171 (defun custom-theme-revert (ignore-auto noconfirm)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
172 (when (or noconfirm (y-or-n-p "Discard current changes? "))
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
173 (erase-buffer)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
174 (customize-create-theme (current-buffer))))
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
175
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
176 ;;; Theme variables
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
177
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
178 (defun custom-theme-add-variable (symbol)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
179 (interactive "vVariable name: ")
68161
b219be97e734 Minor fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 68160
diff changeset
180 (cond ((assq symbol custom-theme-variables)
b219be97e734 Minor fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 68160
diff changeset
181 (message "%s is already in the theme" (symbol-name symbol)))
b219be97e734 Minor fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 68160
diff changeset
182 ((not (boundp symbol))
b219be97e734 Minor fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 68160
diff changeset
183 (message "%s is not defined as a variable" (symbol-name symbol)))
b219be97e734 Minor fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 68160
diff changeset
184 ((eq symbol 'custom-enabled-themes)
b219be97e734 Minor fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 68160
diff changeset
185 (message "Custom theme cannot contain `custom-enabled-themes'"))
b219be97e734 Minor fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 68160
diff changeset
186 (t
b219be97e734 Minor fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 68160
diff changeset
187 (save-excursion
b219be97e734 Minor fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 68160
diff changeset
188 (goto-char custom-theme-insert-variable-marker)
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
189 (widget-insert " ")
68159
fca6909a92e8 * cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents: 67982
diff changeset
190 (let ((widget (widget-create 'custom-variable
fca6909a92e8 * cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents: 67982
diff changeset
191 :tag (custom-unlispify-tag-name symbol)
fca6909a92e8 * cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents: 67982
diff changeset
192 :custom-level 0
fca6909a92e8 * cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents: 67982
diff changeset
193 :action 'custom-theme-variable-action
fca6909a92e8 * cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents: 67982
diff changeset
194 :custom-state 'unknown
fca6909a92e8 * cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents: 67982
diff changeset
195 :value symbol)))
fca6909a92e8 * cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents: 67982
diff changeset
196 (push (cons symbol widget) custom-theme-variables)
fca6909a92e8 * cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents: 67982
diff changeset
197 (custom-magic-reset widget))
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
198 (widget-insert " ")
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
199 (move-marker custom-theme-insert-variable-marker (point))
68159
fca6909a92e8 * cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents: 67982
diff changeset
200 (widget-setup)))))
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
201
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
202 (defvar custom-theme-variable-menu
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
203 `(("Reset to Current" custom-redraw
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
204 (lambda (widget)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
205 (and (boundp (widget-value widget))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
206 (memq (widget-get widget :custom-state)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
207 '(themed modified changed)))))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
208 ("Reset to Theme Value" custom-variable-reset-theme
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
209 (lambda (widget)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
210 (let ((theme (intern (widget-value custom-theme-name)))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
211 (symbol (widget-value widget))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
212 found)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
213 (and (custom-theme-p theme)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
214 (dolist (setting (get theme 'theme-settings) found)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
215 (if (and (eq (cadr setting) symbol)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
216 (eq (car setting) 'theme-value))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
217 (setq found t)))))))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
218 ("---" ignore ignore)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
219 ("Delete" custom-theme-delete-variable nil))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
220 "Alist of actions for the `custom-variable' widget in Custom Theme Mode.
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
221 See the documentation for `custom-variable'.")
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
222
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
223 (defun custom-theme-variable-action (widget &optional event)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
224 "Show the Custom Theme Mode menu for a `custom-variable' widget.
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
225 Optional EVENT is the location for the menu."
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
226 (let ((custom-variable-menu custom-theme-variable-menu))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
227 (custom-variable-action widget event)))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
228
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
229 (defun custom-variable-reset-theme (widget)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
230 "Reset WIDGET to its value for the currently edited theme."
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
231 (let ((theme (intern (widget-value custom-theme-name)))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
232 (symbol (widget-value widget))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
233 found)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
234 (dolist (setting (get theme 'theme-settings))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
235 (if (and (eq (cadr setting) symbol)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
236 (eq (car setting) 'theme-value))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
237 (setq found setting)))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
238 (widget-value-set (car (widget-get widget :children))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
239 (nth 3 found)))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
240 (widget-put widget :custom-state 'themed)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
241 (custom-redraw-magic widget)
48952
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 (widget-setup))
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
244 (defun custom-theme-delete-variable (widget)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
245 (setq custom-theme-variables
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
246 (assq-delete-all (widget-value widget) custom-theme-variables))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
247 (widget-delete widget))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
248
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
249 ;;; Theme faces
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
250
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
251 (defun custom-theme-add-face (symbol)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
252 (interactive (list (read-face-name "Face name" nil nil)))
68161
b219be97e734 Minor fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 68160
diff changeset
253 (cond ((assq symbol custom-theme-faces)
b219be97e734 Minor fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 68160
diff changeset
254 (message "%s is already in the theme" (symbol-name symbol)))
b219be97e734 Minor fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 68160
diff changeset
255 ((not (facep symbol))
b219be97e734 Minor fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 68160
diff changeset
256 (message "%s is not defined as a face" (symbol-name symbol)))
b219be97e734 Minor fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 68160
diff changeset
257 (t
b219be97e734 Minor fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 68160
diff changeset
258 (save-excursion
b219be97e734 Minor fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 68160
diff changeset
259 (goto-char custom-theme-insert-face-marker)
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
260 (widget-insert " ")
68159
fca6909a92e8 * cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents: 67982
diff changeset
261 (let ((widget (widget-create 'custom-face
fca6909a92e8 * cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents: 67982
diff changeset
262 :tag (custom-unlispify-tag-name symbol)
fca6909a92e8 * cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents: 67982
diff changeset
263 :custom-level 0
fca6909a92e8 * cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents: 67982
diff changeset
264 :action 'custom-theme-face-action
fca6909a92e8 * cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents: 67982
diff changeset
265 :custom-state 'unknown
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
266 :display-style 'concise
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
267 :sample-indent 34
68159
fca6909a92e8 * cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents: 67982
diff changeset
268 :value symbol)))
fca6909a92e8 * cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents: 67982
diff changeset
269 (push (cons symbol widget) custom-theme-faces)
fca6909a92e8 * cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents: 67982
diff changeset
270 (custom-magic-reset widget)
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
271 (widget-insert " ")
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
272 (move-marker custom-theme-insert-face-marker (point))
68159
fca6909a92e8 * cus-theme.el (custom-theme-add-variable, custom-theme-add-face):
Chong Yidong <cyd@stupidchicken.com>
parents: 67982
diff changeset
273 (widget-setup))))))
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
274
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
275 (defvar custom-theme-face-menu
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
276 `(("Reset to Theme Value" custom-face-reset-theme
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
277 (lambda (widget)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
278 (let ((theme (intern (widget-value custom-theme-name)))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
279 (symbol (widget-value widget))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
280 found)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
281 (and (custom-theme-p theme)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
282 (dolist (setting (get theme 'theme-settings) found)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
283 (if (and (eq (cadr setting) symbol)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
284 (eq (car setting) 'theme-face))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
285 (setq found t)))))))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
286 ("---" ignore ignore)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
287 ("Delete" custom-theme-delete-face nil))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
288 "Alist of actions for the `custom-variable' widget in Custom Theme Mode.
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
289 See the documentation for `custom-variable'.")
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
290
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
291 (defun custom-theme-face-action (widget &optional event)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
292 "Show the Custom Theme Mode menu for a `custom-face' widget.
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
293 Optional EVENT is the location for the menu."
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
294 (let ((custom-face-menu custom-theme-face-menu))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
295 (custom-face-action widget event)))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
296
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
297 (defun custom-face-reset-theme (widget)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
298 "Reset WIDGET to its value for the currently edited theme."
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
299 (let ((theme (intern (widget-value custom-theme-name)))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
300 (symbol (widget-value widget))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
301 found)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
302 (dolist (setting (get theme 'theme-settings))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
303 (if (and (eq (cadr setting) symbol)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
304 (eq (car setting) 'theme-face))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
305 (setq found setting)))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
306 (widget-value-set (car (widget-get widget :children))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
307 (nth 3 found)))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
308 (widget-put widget :custom-state 'themed)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
309 (custom-redraw-magic widget)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
310 (widget-setup))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
311
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
312 (defun custom-theme-delete-face (widget)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
313 (setq custom-theme-faces
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
314 (assq-delete-all (widget-value widget) custom-theme-faces))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
315 (widget-delete widget))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
316
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
317 ;;; Reading and writing
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
318
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
319 (defun custom-theme-visit-theme ()
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
320 (interactive)
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
321 (when (or (and (null custom-theme-variables)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
322 (null custom-theme-faces))
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
323 (and (y-or-n-p "Discard current changes? ")
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
324 (progn (revert-buffer) t)))
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
325 (let ((theme (call-interactively 'custom-theme-merge-theme)))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
326 (unless (eq theme 'user)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
327 (widget-value-set custom-theme-name (symbol-name theme)))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
328 (widget-value-set custom-theme-description
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
329 (or (get theme 'theme-documentation)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
330 (format-time-string "Created %Y-%m-%d.")))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
331 (widget-setup))))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
332
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
333 (defun custom-theme-merge-theme (theme)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
334 (interactive "SCustom theme name: ")
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
335 (unless (eq theme 'user)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
336 (load-theme theme))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
337 (let ((settings (get theme 'theme-settings)))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
338 (dolist (setting settings)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
339 (if (eq (car setting) 'theme-value)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
340 (custom-theme-add-variable (cadr setting))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
341 (custom-theme-add-face (cadr setting)))))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
342 (disable-theme theme)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
343 theme)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
344
48952
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345 (defun custom-theme-write (&rest ignore)
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
346 (let* ((name (widget-value custom-theme-name))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
347 (doc (widget-value custom-theme-description))
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
348 (vars custom-theme-variables)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
349 (faces custom-theme-faces)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
350 filename)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
351 (when (string-equal name "")
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
352 (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
353 (widget-value-set custom-theme-name name))
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
354 (cond ((or (string-equal name "")
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
355 (string-equal name "user")
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
356 (string-equal name "changed"))
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
357 (error "Custom themes cannot be named `%s'" name))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
358 ((string-match " " name)
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
359 (error "Custom theme names should not contain spaces")))
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
360
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
361 (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
362 custom-theme-directory))
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
363 (and (file-exists-p filename)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
364 (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
365 (error "Aborted"))
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
366
67982
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
367 (with-temp-buffer
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
368 (emacs-lisp-mode)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
369 (unless (file-exists-p custom-theme-directory)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
370 (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
371 (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
372 (erase-buffer)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
373 (insert "(deftheme " name)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
374 (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
375 (insert ")\n")
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
376 (custom-theme-write-variables name vars)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
377 (custom-theme-write-faces name faces)
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
378 (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
379 (save-buffer))
a711a44049e2 * cus-theme.el: Rewrite the Custom New Theme Mode interface.
Chong Yidong <cyd@stupidchicken.com>
parents: 67961
diff changeset
380 (dolist (var vars)
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
381 (when (widget-get (cdr var) :children)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
382 (widget-put (cdr var) :custom-state 'saved)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
383 (custom-redraw-magic (cdr var))))
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
384 (dolist (face custom-theme-faces)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
385 (when (widget-get (cdr face) :children)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
386 (widget-put (cdr face) :custom-state 'saved)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
387 (custom-redraw-magic (cdr face))))))
48952
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389 (defun custom-theme-write-variables (theme vars)
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390 "Write a `custom-theme-set-variables' command for THEME.
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 It includes all variables in list VARS."
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 (when vars
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393 (let ((standard-output (current-buffer)))
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 (princ "\n(custom-theme-set-variables\n")
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395 (princ " '")
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396 (princ theme)
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397 (princ "\n")
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
398 (dolist (spec vars)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
399 (let* ((symbol (car spec))
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
400 (child (car-safe (widget-get (cdr spec) :children)))
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
401 (value (if child
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
402 (widget-value child)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
403 ;; For hidden widgets, use the standard value
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
404 (get symbol 'standard-value))))
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
405 (when (boundp symbol)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
406 (unless (bolp)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
407 (princ "\n"))
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
408 (princ " '(")
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
409 (prin1 symbol)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
410 (princ " ")
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
411 (prin1 (custom-quote value))
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
412 (princ ")"))))
48952
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 (if (bolp)
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 (princ ")")
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 (unless (looking-at "\n")
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 (princ "\n")))))
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 (defun custom-theme-write-faces (theme faces)
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 "Write a `custom-theme-set-faces' command for THEME.
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 It includes all faces in list FACES."
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 (when faces
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 (let ((standard-output (current-buffer)))
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 (princ "\n(custom-theme-set-faces\n")
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 (princ " '")
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 (princ theme)
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 (princ "\n")
110896
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
428 (dolist (spec faces)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
429 (let* ((symbol (car spec))
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
430 (widget (cdr spec))
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
431 (child (car-safe (widget-get widget :children)))
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
432 (state (if child
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
433 (widget-get widget :custom-state)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
434 (custom-face-state symbol)))
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
435 (value
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
436 (cond ((eq state 'standard)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
437 nil) ; do nothing
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
438 (child
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
439 (custom-face-widget-to-spec widget))
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
440 (t
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
441 ;; Widget is closed (hidden), but the face has
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
442 ;; a non-standard value. Try to extract that
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
443 ;; value and save it.
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
444 (custom-face-get-current-spec symbol)))))
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
445 (when (and (facep symbol) value)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
446 (if (bolp)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
447 (princ " '(")
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
448 (princ "\n '("))
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
449 (prin1 symbol)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
450 (princ " ")
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
451 (prin1 value)
0d6d71f9b91a Interface improvements to cus-theme.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
452 (princ ")"))))
48952
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
453 (if (bolp)
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454 (princ " "))
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
455 (princ ")")
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456 (unless (looking-at "\n")
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457 (princ "\n")))))
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458
93975
1e3a407766b9 Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 79721
diff changeset
459 ;; arch-tag: cd6919bc-63af-410e-bae2-b6702e762344
48952
ac7ebc63415a New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
460 ;;; cus-theme.el ends here