]> code.delx.au - gnu-emacs/blobdiff - lisp/cus-theme.el
* net/tramp.el (tramp-read-passwd): Cached passwords shall still be used.
[gnu-emacs] / lisp / cus-theme.el
index 0a421da925c53f6a91ea556eb725b3e70ab8f166..91dc1d9f3e9058bfb0f63889d2f71c56eac8dc6c 100644 (file)
@@ -1,6 +1,7 @@
 ;;; cus-theme.el -- custom theme creation user interface
 ;;
-;; Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+;; Copyright (C) 2001, 2002, 2003, 2004, 2005,
+;;   2006, 2007, 2008, 2009 Free Software Foundation, Inc.
 ;;
 ;; Author: Alex Schroeder <alex@gnu.org>
 ;; Maintainer: FSF
@@ -8,10 +9,10 @@
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -19,9 +20,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Code:
 
@@ -37,7 +36,6 @@
     (suppress-keymap map)
     (define-key map "n" 'widget-forward)
     (define-key map "p" 'widget-backward)
-    (define-key map [mouse-1] 'widget-move-and-invoke)
     map)
   "Keymap for `custom-new-theme-mode'.")
 
@@ -99,7 +97,7 @@ the directory " custom-theme-directory "\n\n")
   (widget-insert "  ")
   (widget-create 'push-button
                 :notify (lambda (&rest ignore)
-                          (when (y-or-n-p "Discard current changes?")
+                          (when (y-or-n-p "Discard current changes? ")
                             (kill-buffer (current-buffer))
                             (customize-create-theme)))
                 "Reset Buffer")
@@ -137,7 +135,7 @@ the directory " custom-theme-directory "\n\n")
   (widget-insert "\n")
   (widget-create 'push-button
                 :notify (lambda (&rest ignore)
-                          (when (y-or-n-p "Discard current changes?")
+                          (when (y-or-n-p "Discard current changes? ")
                             (kill-buffer (current-buffer))
                             (customize-create-theme)))
                 "Reset Buffer")
@@ -154,20 +152,25 @@ the directory " custom-theme-directory "\n\n")
 
 (defun custom-theme-add-variable (symbol)
   (interactive "vVariable name: ")
-  (save-excursion
-    (goto-char custom-theme-insert-variable-marker)
-    (if (assq symbol custom-theme-variables)
-       (message "%s is already in the theme" (symbol-name symbol))
-      (widget-insert "\n")
-      (let ((widget (widget-create 'custom-variable
-                                  :tag (custom-unlispify-tag-name symbol)
-                                  :custom-level 0
-                                  :action 'custom-theme-variable-action
-                                  :custom-state 'unknown
-                                  :value symbol)))
-       (push (cons symbol widget) custom-theme-variables)
-       (custom-magic-reset widget))
-      (widget-setup))))
+  (cond ((assq symbol custom-theme-variables)
+        (message "%s is already in the theme" (symbol-name symbol)))
+       ((not (boundp symbol))
+        (message "%s is not defined as a variable" (symbol-name symbol)))
+       ((eq symbol 'custom-enabled-themes)
+        (message "Custom theme cannot contain `custom-enabled-themes'"))
+       (t
+        (save-excursion
+          (goto-char custom-theme-insert-variable-marker)
+          (widget-insert "\n")
+          (let ((widget (widget-create 'custom-variable
+                                       :tag (custom-unlispify-tag-name symbol)
+                                       :custom-level 0
+                                       :action 'custom-theme-variable-action
+                                       :custom-state 'unknown
+                                       :value symbol)))
+            (push (cons symbol widget) custom-theme-variables)
+            (custom-magic-reset widget))
+          (widget-setup)))))
 
 (defvar custom-theme-variable-menu
   `(("Reset to Current" custom-redraw
@@ -220,20 +223,23 @@ Optional EVENT is the location for the menu."
 
 (defun custom-theme-add-face (symbol)
   (interactive (list (read-face-name "Face name" nil nil)))
-  (save-excursion
-    (goto-char custom-theme-insert-face-marker)
-    (if (assq symbol custom-theme-faces)
-       (message "%s is already in the theme" (symbol-name symbol))
-      (widget-insert "\n")
-      (let ((widget (widget-create 'custom-face
-                                  :tag (custom-unlispify-tag-name symbol)
-                                  :custom-level 0
-                                  :action 'custom-theme-face-action
-                                  :custom-state 'unknown
-                                  :value symbol)))
-       (push (cons symbol widget) custom-theme-faces)
-       (custom-magic-reset widget)
-       (widget-setup)))))
+  (cond ((assq symbol custom-theme-faces)
+        (message "%s is already in the theme" (symbol-name symbol)))
+       ((not (facep symbol))
+        (message "%s is not defined as a face" (symbol-name symbol)))
+       (t
+        (save-excursion
+          (goto-char custom-theme-insert-face-marker)
+          (widget-insert "\n")
+          (let ((widget (widget-create 'custom-face
+                                       :tag (custom-unlispify-tag-name symbol)
+                                       :custom-level 0
+                                       :action 'custom-theme-face-action
+                                       :custom-state 'unknown
+                                       :value symbol)))
+            (push (cons symbol widget) custom-theme-faces)
+            (custom-magic-reset widget)
+            (widget-setup))))))
 
 (defvar custom-theme-face-menu
   `(("Reset to Theme Value" custom-face-reset-theme
@@ -282,7 +288,7 @@ Optional EVENT is the location for the menu."
 (defun custom-theme-visit-theme ()
   (interactive)
   (when (or (null custom-theme-variables)
-           (if (y-or-n-p "Discard current changes?")
+           (if (y-or-n-p "Discard current changes? ")
                (progn (customize-create-theme) t)))
     (let ((theme (call-interactively 'custom-theme-merge-theme)))
       (unless (eq theme 'user)
@@ -400,5 +406,5 @@ It includes all faces in list FACES."
       (unless (looking-at "\n")
        (princ "\n")))))
 
-;;; arch-tag: cd6919bc-63af-410e-bae2-b6702e762344
+;; arch-tag: cd6919bc-63af-410e-bae2-b6702e762344
 ;;; cus-theme.el ends here