aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorChong Yidong2011-06-14 01:06:26 -0400
committerChong Yidong2011-06-14 01:06:26 -0400
commitc5dd5a516c9f0f4b622452c42e34e95ca2e2fae5 (patch)
tree4a811ae80c86691b1ad0a7ffd454621739a6299e /lisp
parentb9958282dc60f74c942f34412123ddc76f7c592e (diff)
downloademacs-c5dd5a516c9f0f4b622452c42e34e95ca2e2fae5.tar.gz
emacs-c5dd5a516c9f0f4b622452c42e34e95ca2e2fae5.zip
Print theme summaries in *Custom Themes* buffer.
* lisp/cus-theme.el (describe-theme-1): Use custom-theme-p. (custom-theme-summary): New function. (customize-themes): Use it. * etc/themes/light-blue-theme.el: * etc/themes/misterioso-theme.el: * etc/themes/tango-dark-theme.el: * etc/themes/tango-theme.el: * etc/themes/tsdh-dark-theme.el: * etc/themes/tsdh-light-theme.el: * etc/themes/wheatgrass-theme.el: * etc/themes/wombat-theme.el: Tweak summaries for better listability.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/cus-theme.el73
2 files changed, 57 insertions, 22 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 7dac139c295..2cf968505af 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12011-06-14 Chong Yidong <cyd@stupidchicken.com>
2
3 * cus-theme.el (describe-theme-1): Use custom-theme-p.
4 (custom-theme-summary): New function.
5 (customize-themes): Use it.
6
12011-06-13 Glenn Morris <rgm@gnu.org> 72011-06-13 Glenn Morris <rgm@gnu.org>
2 8
3 * cus-dep.el (custom-make-dependencies): Use up command-line-args-left. 9 * cus-dep.el (custom-make-dependencies): Use up command-line-args-left.
diff --git a/lisp/cus-theme.el b/lisp/cus-theme.el
index 86fb43be72a..7f926c85e56 100644
--- a/lisp/cus-theme.el
+++ b/lisp/cus-theme.el
@@ -483,25 +483,24 @@ It includes all faces in list FACES."
483 'help-theme-def fn) 483 'help-theme-def fn)
484 (princ "'")) 484 (princ "'"))
485 (princ ".\n") 485 (princ ".\n")
486 (if (not (memq theme custom-known-themes)) 486 (if (custom-theme-p theme)
487 (progn 487 (progn
488 (princ "It is not loaded.") 488 (if (custom-theme-enabled-p theme)
489 ;; Attempt to grab the theme documentation 489 (princ "It is loaded and enabled.")
490 (when fn 490 (princ "It is loaded but disabled."))
491 (with-temp-buffer 491 (setq doc (get theme 'theme-documentation)))
492 (insert-file-contents fn) 492 (princ "It is not loaded.")
493 (let ((sexp (let ((read-circle nil)) 493 ;; Attempt to grab the theme documentation
494 (condition-case nil 494 (when fn
495 (read (current-buffer)) 495 (with-temp-buffer
496 (end-of-file nil))))) 496 (insert-file-contents fn)
497 (and sexp (listp sexp) 497 (let ((sexp (let ((read-circle nil))
498 (eq (car sexp) 'deftheme) 498 (condition-case nil
499 (setq doc (nth 2 sexp))))))) 499 (read (current-buffer))
500 (if (custom-theme-enabled-p theme) 500 (end-of-file nil)))))
501 (princ "It is loaded and enabled.") 501 (and sexp (listp sexp)
502 (princ "It is loaded but disabled.")) 502 (eq (car sexp) 'deftheme)
503 (setq doc (get theme 'theme-documentation))) 503 (setq doc (nth 2 sexp)))))))
504
505 (princ "\n\nDocumentation:\n") 504 (princ "\n\nDocumentation:\n")
506 (princ (if (stringp doc) 505 (princ (if (stringp doc)
507 doc 506 doc
@@ -605,26 +604,56 @@ Theme files are named *-theme.el in `"))
605 (widget-create 'checkbox 604 (widget-create 'checkbox
606 :value custom-theme-allow-multiple-selections 605 :value custom-theme-allow-multiple-selections
607 :action 'custom-theme-selections-toggle) 606 :action 'custom-theme-selections-toggle)
608 (widget-insert (propertize " Allow more than one theme at a time" 607 (widget-insert (propertize " Select more than one theme at a time"
609 'face '(variable-pitch (:height 0.9)))) 608 'face '(variable-pitch (:height 0.9))))
610 609
611 (widget-insert "\n\nAvailable Custom Themes:\n") 610 (widget-insert "\n\nAvailable Custom Themes:\n")
612 (let (widget) 611 (let ((help-echo "mouse-2: Enable this theme for this session")
612 widget)
613 (dolist (theme (custom-available-themes)) 613 (dolist (theme (custom-available-themes))
614 (setq widget (widget-create 'checkbox 614 (setq widget (widget-create 'checkbox
615 :value (custom-theme-enabled-p theme) 615 :value (custom-theme-enabled-p theme)
616 :theme-name theme 616 :theme-name theme
617 :help-echo help-echo
617 :action 'custom-theme-checkbox-toggle)) 618 :action 'custom-theme-checkbox-toggle))
618 (push (cons theme widget) custom--listed-themes) 619 (push (cons theme widget) custom--listed-themes)
619 (widget-create-child-and-convert widget 'push-button 620 (widget-create-child-and-convert widget 'push-button
620 :button-face-get 'ignore 621 :button-face-get 'ignore
621 :mouse-face-get 'ignore 622 :mouse-face-get 'ignore
622 :value (format " %s" theme) 623 :value (format " %s" theme)
623 :action 'widget-parent-action) 624 :action 'widget-parent-action
624 (widget-insert ?\n))) 625 :help-echo help-echo)
626 (widget-insert " -- "
627 (propertize (custom-theme-summary theme)
628 'face 'shadow)
629 ?\n)))
625 (goto-char (point-min)) 630 (goto-char (point-min))
626 (widget-setup)) 631 (widget-setup))
627 632
633(defun custom-theme-summary (theme)
634 "Return the summary line of THEME."
635 (let (doc)
636 (if (custom-theme-p theme)
637 (setq doc (get theme 'theme-documentation))
638 (let ((fn (locate-file (concat (symbol-name theme) "-theme.el")
639 (custom-theme--load-path)
640 '("" "c"))))
641 (when fn
642 (with-temp-buffer
643 (insert-file-contents fn)
644 (let ((sexp (let ((read-circle nil))
645 (condition-case nil
646 (read (current-buffer))
647 (end-of-file nil)))))
648 (and sexp (listp sexp)
649 (eq (car sexp) 'deftheme)
650 (setq doc (nth 2 sexp))))))))
651 (cond ((null doc)
652 "(no documentation available)")
653 ((string-match ".*" doc)
654 (match-string 0 doc))
655 (t doc))))
656
628(defun custom-theme-checkbox-toggle (widget &optional event) 657(defun custom-theme-checkbox-toggle (widget &optional event)
629 (let ((this-theme (widget-get widget :theme-name))) 658 (let ((this-theme (widget-get widget :theme-name)))
630 (if (widget-value widget) 659 (if (widget-value widget)