aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorDavid Ponce2005-09-30 06:28:53 +0000
committerDavid Ponce2005-09-30 06:28:53 +0000
commit01c5577a875e794fbf2b18a961efb6316afc0e55 (patch)
tree9144811154ebe1e8b9f3b16cc797a203b3255fa4 /lisp
parent50a9d14ad2d185c75fe79ba040acf81003e8955c (diff)
downloademacs-01c5577a875e794fbf2b18a961efb6316afc0e55.tar.gz
emacs-01c5577a875e794fbf2b18a961efb6316afc0e55.zip
(tree-widget-themes-load-path): New variable.
(tree-widget-themes-directory): Doc fix. (tree-widget-image-formats) [Emacs]: Doc fix. (tree-widget--locate-sub-directory): New function. (tree-widget-themes-directory): Use it.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/tree-widget.el106
1 files changed, 64 insertions, 42 deletions
diff --git a/lisp/tree-widget.el b/lisp/tree-widget.el
index d29e224f549..708dc294f8d 100644
--- a/lisp/tree-widget.el
+++ b/lisp/tree-widget.el
@@ -131,14 +131,29 @@
131 :type 'boolean 131 :type 'boolean
132 :group 'tree-widget) 132 :group 'tree-widget)
133 133
134(defvar tree-widget-themes-load-path
135 '(load-path
136 (let ((dir (if (fboundp 'locate-data-directory)
137 (locate-data-directory "tree-widget") ;; XEmacs
138 data-directory)))
139 (and dir (list dir (expand-file-name "images" dir))))
140 )
141 "List of locations where to search for the themes sub-directory.
142Each element is an expression that will be evaluated to return a
143single directory or a list of directories to search.
144
145The default is to search in the `load-path' first, then in the
146\"images\" sub directory in the data directory, then in the data
147directory.
148The data directory is the value of the variable `data-directory' on
149Emacs, and what `(locate-data-directory \"tree-widget\")' returns on
150XEmacs.")
151
134(defcustom tree-widget-themes-directory "tree-widget" 152(defcustom tree-widget-themes-directory "tree-widget"
135 "*Name of the directory where to look up for image themes. 153 "*Name of the directory where to look up for image themes.
136When nil use the directory where the tree-widget library is located. 154When nil use the directory where the tree-widget library is located.
137When a relative name is specified, try to locate that sub directory in 155When a relative name is specified, try to locate that sub directory in
138`load-path', then in the data directory, and use the first one found. 156the locations specified in `tree-widget-themes-load-path'.
139The data directory is the value of the variable `data-directory' on
140Emacs, and what `(locate-data-directory \"tree-widget\")' returns on
141XEmacs.
142The default is to use the \"tree-widget\" relative name." 157The default is to use the \"tree-widget\" relative name."
143 :type '(choice (const :tag "Default" "tree-widget") 158 :type '(choice (const :tag "Default" "tree-widget")
144 (const :tag "With the library" nil) 159 (const :tag "With the library" nil)
@@ -236,7 +251,7 @@ Give the image the specified properties PROPS."
236 (apply 'create-image `(,file ,type nil ,@props))) 251 (apply 'create-image `(,file ,type nil ,@props)))
237 (defsubst tree-widget-image-formats () 252 (defsubst tree-widget-image-formats ()
238 "Return the alist of image formats/file name extensions. 253 "Return the alist of image formats/file name extensions.
239See also the option `widget-image-file-name-suffixes'." 254See also the option `widget-image-conversion'."
240 (delq nil 255 (delq nil
241 (mapcar 256 (mapcar
242 #'(lambda (fmt) 257 #'(lambda (fmt)
@@ -264,47 +279,54 @@ Does nothing if NAME is already the current theme."
264 (make-vector 4 nil)) 279 (make-vector 4 nil))
265 (aset tree-widget--theme 0 name))) 280 (aset tree-widget--theme 0 name)))
266 281
282(defun tree-widget--locate-sub-directory (name path)
283 "Locate the sub-directory NAME in PATH.
284Return the absolute name of the directory found, or nil if not found."
285 (let (dir elt)
286 (while (and (not dir) (consp path))
287 (setq elt (condition-case nil (eval (car path)) (error nil))
288 path (cdr path))
289 (cond
290 ((stringp elt)
291 (setq dir (expand-file-name name elt))
292 (or (file-accessible-directory-p dir)
293 (setq dir nil)))
294 ((and elt (not (equal elt (car path))))
295 (setq dir (tree-widget--locate-sub-directory name elt)))))
296 dir))
297
267(defun tree-widget-themes-directory () 298(defun tree-widget-themes-directory ()
268 "Locate the directory where to search for a theme. 299 "Locate the directory where to search for a theme.
269It is defined in variable `tree-widget-themes-directory'. 300It is defined in variable `tree-widget-themes-directory'.
270Return the absolute name of the directory found, or nil if the 301Return the absolute name of the directory found, or nil if the
271specified directory is not accessible." 302specified directory is not accessible."
272 (let ((found (aref tree-widget--theme 1))) 303 (let ((found (aref tree-widget--theme 1)))
273 (if found 304 (cond
274 ;; The directory is available in the cache. 305 ;; The directory was not found.
275 (unless (eq found 'void) found) 306 ((eq found 'void)
276 (cond 307 (setq found nil))
277 ;; Use the directory where tree-widget is located. 308 ;; The directory is available in the cache.
278 ((null tree-widget-themes-directory) 309 (found)
279 (setq found (locate-library "tree-widget")) 310 ;; Use the directory where this library is located.
280 (when found 311 ((null tree-widget-themes-directory)
281 (setq found (file-name-directory found)) 312 (setq found (locate-library "tree-widget"))
282 (or (file-accessible-directory-p found) 313 (when found
283 (setq found nil)))) 314 (setq found (file-name-directory found))
284 ;; Check accessibility of absolute directory name.
285 ((file-name-absolute-p tree-widget-themes-directory)
286 (setq found (expand-file-name tree-widget-themes-directory))
287 (or (file-accessible-directory-p found) 315 (or (file-accessible-directory-p found)
288 (setq found nil))) 316 (setq found nil))))
289 ;; Locate a sub-directory in `load-path' and data directory. 317 ;; Check accessibility of absolute directory name.
290 (t 318 ((file-name-absolute-p tree-widget-themes-directory)
291 (let ((path 319 (setq found (expand-file-name tree-widget-themes-directory))
292 (append load-path 320 (or (file-accessible-directory-p found)
293 (list (if (fboundp 'locate-data-directory) 321 (setq found nil)))
294 ;; XEmacs 322 ;; Locate a sub-directory in `tree-widget-themes-load-path'.
295 (locate-data-directory "tree-widget") 323 (t
296 ;; Emacs 324 (setq found (tree-widget--locate-sub-directory
297 data-directory))))) 325 tree-widget-themes-directory
298 (while (and path (not found)) 326 tree-widget-themes-load-path))))
299 (when (car path) 327 ;; Store the result in the cache for later use.
300 (setq found (expand-file-name 328 (aset tree-widget--theme 1 (or found 'void))
301 tree-widget-themes-directory (car path))) 329 found))
302 (or (file-accessible-directory-p found)
303 (setq found nil)))
304 (setq path (cdr path))))))
305 ;; Store the result in the cache for later use.
306 (aset tree-widget--theme 1 (or found 'void))
307 found)))
308 330
309(defsubst tree-widget-set-image-properties (props) 331(defsubst tree-widget-set-image-properties (props)
310 "In current theme, set images properties to PROPS." 332 "In current theme, set images properties to PROPS."
@@ -351,9 +373,9 @@ XEmacs in the variables `tree-widget-image-properties-emacs', and
351 plist)) 373 plist))
352 374
353(defconst tree-widget--cursors 375(defconst tree-widget--cursors
354 ;; Pointer shapes when the mouse pointer is over tree-widget images. 376 ;; Pointer shapes when the mouse pointer is over inactive
355 ;; This feature works since Emacs 22, and ignored on older versions, 377 ;; tree-widget images. This feature works since Emacs 22, and
356 ;; and XEmacs. 378 ;; ignored on older versions, and XEmacs.
357 '( 379 '(
358 ("guide" . arrow) 380 ("guide" . arrow)
359 ("no-guide" . arrow) 381 ("no-guide" . arrow)