aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuc Teirlinck2005-07-02 22:53:04 +0000
committerLuc Teirlinck2005-07-02 22:53:04 +0000
commit077ad61cf82241450fd11d80b348a171a031d447 (patch)
tree1bace8eabc25a9a8b4767c5466116e3371de2dcb
parent9c4b6e94bf6c993cb1ecea4ebd9f683c9b4c63fc (diff)
downloademacs-077ad61cf82241450fd11d80b348a171a031d447.tar.gz
emacs-077ad61cf82241450fd11d80b348a171a031d447.zip
(custom-new-theme-mode): New function.
(custom-theme-name, custom-theme-variables, custom-theme-faces) (custom-theme-description): Add compiler defvars. (customize-create-theme): Add doc to the "*New Custom Theme*" buffer. Use `custom-new-theme-mode'. (custom-theme-write): Put the created buffer in emacs-lisp-mode and save it to the `custom-theme-directory'. Make this the default directory of the buffer.
-rw-r--r--lisp/cus-theme.el36
1 files changed, 30 insertions, 6 deletions
diff --git a/lisp/cus-theme.el b/lisp/cus-theme.el
index 41240303037..a40b40aabf2 100644
--- a/lisp/cus-theme.el
+++ b/lisp/cus-theme.el
@@ -31,6 +31,18 @@
31(eval-when-compile 31(eval-when-compile
32 (require 'wid-edit)) 32 (require 'wid-edit))
33 33
34(define-derived-mode custom-new-theme-mode nil "New-Theme"
35 "Major mode for the buffer created by `customize-create-theme'.
36Do not call this mode function yourself. It is only meant for internal
37use by `customize-create-theme'."
38 (set-keymap-parent custom-new-theme-mode-map widget-keymap))
39(put 'custom-new-theme-mode 'mode-class 'special)
40
41(defvar custom-theme-name)
42(defvar custom-theme-variables)
43(defvar custom-theme-faces)
44(defvar custom-theme-description)
45
34;;;###autoload 46;;;###autoload
35(defun customize-create-theme () 47(defun customize-create-theme ()
36 "Create a custom theme." 48 "Create a custom theme."
@@ -38,15 +50,23 @@
38 (if (get-buffer "*New Custom Theme*") 50 (if (get-buffer "*New Custom Theme*")
39 (kill-buffer "*New Custom Theme*")) 51 (kill-buffer "*New Custom Theme*"))
40 (switch-to-buffer "*New Custom Theme*") 52 (switch-to-buffer "*New Custom Theme*")
41 (kill-all-local-variables) 53 (let ((inhibit-read-only t))
54 (erase-buffer))
55 (custom-new-theme-mode)
42 (make-local-variable 'custom-theme-name) 56 (make-local-variable 'custom-theme-name)
43 (make-local-variable 'custom-theme-variables) 57 (make-local-variable 'custom-theme-variables)
44 (make-local-variable 'custom-theme-faces) 58 (make-local-variable 'custom-theme-faces)
45 (make-local-variable 'custom-theme-description) 59 (make-local-variable 'custom-theme-description)
46 (let ((inhibit-read-only t))
47 (erase-buffer))
48 (widget-insert "This buffer helps you write a custom theme elisp file. 60 (widget-insert "This buffer helps you write a custom theme elisp file.
49This will help you share your customizations with other people.\n\n") 61This will help you share your customizations with other people.
62
63Just insert the names of all variables and faces you want the theme
64to include. Then clicking mouse-2 or pressing RET on the [Done] button
65will write a theme file that sets all these variables and faces to their
66current global values. It will write that file into the directory given
67by the variable `custom-theme-directory', usually \"~/.emacs.d/\".
68
69To undo all your edits to the buffer, use the [Reset] button.\n\n")
50 (widget-insert "Theme name: ") 70 (widget-insert "Theme name: ")
51 (setq custom-theme-name 71 (setq custom-theme-name
52 (widget-create 'editable-field 72 (widget-create 'editable-field
@@ -81,7 +101,6 @@ This will help you share your customizations with other people.\n\n")
81 (bury-buffer)) 101 (bury-buffer))
82 "Bury Buffer") 102 "Bury Buffer")
83 (widget-insert "\n") 103 (widget-insert "\n")
84 (use-local-map widget-keymap)
85 (widget-setup)) 104 (widget-setup))
86 105
87(defun custom-theme-write (&rest ignore) 106(defun custom-theme-write (&rest ignore)
@@ -90,6 +109,10 @@ This will help you share your customizations with other people.\n\n")
90 (variables (widget-value custom-theme-variables)) 109 (variables (widget-value custom-theme-variables))
91 (faces (widget-value custom-theme-faces))) 110 (faces (widget-value custom-theme-faces)))
92 (switch-to-buffer (concat name "-theme.el")) 111 (switch-to-buffer (concat name "-theme.el"))
112 (emacs-lisp-mode)
113 (unless (file-exists-p custom-theme-directory)
114 (make-directory (file-name-as-directory custom-theme-directory) t))
115 (setq default-directory custom-theme-directory)
93 (setq buffer-file-name (expand-file-name (concat name "-theme.el"))) 116 (setq buffer-file-name (expand-file-name (concat name "-theme.el")))
94 (let ((inhibit-read-only t)) 117 (let ((inhibit-read-only t))
95 (erase-buffer)) 118 (erase-buffer))
@@ -100,7 +123,8 @@ This will help you share your customizations with other people.\n\n")
100 (insert ")\n") 123 (insert ")\n")
101 (custom-theme-write-variables name variables) 124 (custom-theme-write-variables name variables)
102 (custom-theme-write-faces name faces) 125 (custom-theme-write-faces name faces)
103 (insert "\n(provide-theme '" name ")\n"))) 126 (insert "\n(provide-theme '" name ")\n")
127 (save-buffer)))
104 128
105(defun custom-theme-write-variables (theme vars) 129(defun custom-theme-write-variables (theme vars)
106 "Write a `custom-theme-set-variables' command for THEME. 130 "Write a `custom-theme-set-variables' command for THEME.