]> code.delx.au - gnu-emacs/blobdiff - lisp/tree-widget.el
merge trunk
[gnu-emacs] / lisp / tree-widget.el
index 4588cc7899480988b4bce6ad9b84e27666e16366..d07c8b268d3b1420254b7efab9552b0cdff7e49d 100644 (file)
@@ -1,6 +1,6 @@
 ;;; tree-widget.el --- Tree widget
 
-;; Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 
 ;; Author: David Ponce <david@dponce.com>
 ;; Maintainer: David Ponce <david@dponce.com>
@@ -9,20 +9,18 @@
 
 ;; This file is part of GNU Emacs
 
-;; This program 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.
+;; 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 3 of the License, or
+;; (at your option) any later version.
 
-;; This program is distributed in the hope that it will be useful, but
-;; WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-;; General Public License for more details.
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with this program; 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/>.
 
 ;;; Commentary:
 ;;
   :version "22.1"
   :group 'widgets)
 
-(defcustom tree-widget-image-enable
-  (not (or (featurep 'xemacs) (< emacs-major-version 21)))
-  "*Non-nil means that tree-widget will try to use images."
+(defcustom tree-widget-image-enable (if (fboundp 'display-images-p)
+                                        (display-images-p))
+  "Non-nil means that tree-widget will try to use images."
   :type  'boolean
   :group 'tree-widget)
 
                  data-directory)))
       (and dir (list dir (expand-file-name "images" dir))))
     )
-  "List of locations where to search for the themes sub-directory.
-Each element is an expression that will be evaluated to return a
-single directory or a list of directories to search.
-
+  "List of locations in which to search for the themes sub-directory.
+Each element is an expression that will be recursively evaluated until
+it returns a single directory or a list of directories.
 The default is to search in the `load-path' first, then in the
 \"images\" sub directory in the data directory, then in the data
 directory.
@@ -152,23 +149,22 @@ Emacs, and what `(locate-data-directory \"tree-widget\")' returns on
 XEmacs.")
 
 (defcustom tree-widget-themes-directory "tree-widget"
-  "*Name of the directory where to look up for image themes.
+  "Name of the directory in which to look for an image theme.
 When nil use the directory where the tree-widget library is located.
-When a relative name is specified, search in all occurrences of that
-sub directory found in the locations specified in
-`tree-widget-themes-load-path'.
+When it is a relative name, search in all occurrences of that sub
+directory in the path specified by `tree-widget-themes-load-path'.
 The default is to use the \"tree-widget\" relative name."
   :type '(choice (const :tag "Default" "tree-widget")
-                 (const :tag "With the library" nil)
+                 (const :tag "Where is this library" nil)
                  (directory :format "%{%t%}:\n%v"))
   :group 'tree-widget)
 
 (defcustom tree-widget-theme nil
-  "*Name of the theme where to look up for images.
-It must be a sub directory in the directories specified in variable
-`tree-widget-themes-directory'.  The default theme is \"default\".
-When an image is not found in a theme, it is searched in the parent
-theme.
+  "Name of the theme in which to look for images.
+This is a sub directory of the themes directory specified by the
+`tree-widget-themes-directory' option.
+The default theme is \"default\".  When an image is not found in a
+theme, it is searched in its parent theme.
 
 A complete theme must at least contain images with these file names
 with a supported extension (see also `tree-widget-image-formats'):
@@ -201,13 +197,13 @@ icon widgets used to draw the tree.  By default these images are used:
 
 (defcustom tree-widget-image-properties-emacs
   '(:ascent center :mask (heuristic t))
-  "*Default properties of Emacs images."
+  "Default properties of Emacs images."
   :type 'plist
   :group 'tree-widget)
 
 (defcustom tree-widget-image-properties-xemacs
   nil
-  "*Default properties of XEmacs images."
+  "Default properties of XEmacs images."
   :type 'plist
   :group 'tree-widget)
 
@@ -405,19 +401,20 @@ Search first in current theme, then in parent themes (see also the
 function `tree-widget-set-parent-theme').
 Return the first image found having a supported format, or nil if not
 found."
-  (catch 'found
-    (dolist (default-directory (tree-widget-themes-path))
-      (dolist (dir (aref tree-widget--theme 0))
-        (dolist (fmt (tree-widget-image-formats))
-          (dolist (ext (cdr fmt))
-            (setq file (expand-file-name (concat name ext) dir))
-            (and (file-readable-p file)
-                 (file-regular-p file)
-                 (throw 'found
-                        (tree-widget-create-image
-                         (car fmt) file
-                         (tree-widget-image-properties name))))))))
-    nil))
+  (let (file)
+    (catch 'found
+      (dolist (default-directory (tree-widget-themes-path))
+        (dolist (dir (aref tree-widget--theme 0))
+          (dolist (fmt (tree-widget-image-formats))
+            (dolist (ext (cdr fmt))
+              (setq file (expand-file-name (concat name ext) dir))
+              (and (file-readable-p file)
+                   (file-regular-p file)
+                   (throw 'found
+                          (tree-widget-create-image
+                           (car fmt) file
+                           (tree-widget-image-properties name))))))))
+      nil)))
 
 (defun tree-widget-find-image (name)
   "Find the image with NAME in current theme.