diff options
| author | David Ponce | 2005-09-30 06:28:53 +0000 |
|---|---|---|
| committer | David Ponce | 2005-09-30 06:28:53 +0000 |
| commit | 01c5577a875e794fbf2b18a961efb6316afc0e55 (patch) | |
| tree | 9144811154ebe1e8b9f3b16cc797a203b3255fa4 /lisp | |
| parent | 50a9d14ad2d185c75fe79ba040acf81003e8955c (diff) | |
| download | emacs-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.el | 106 |
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. | ||
| 142 | Each element is an expression that will be evaluated to return a | ||
| 143 | single directory or a list of directories to search. | ||
| 144 | |||
| 145 | The default is to search in the `load-path' first, then in the | ||
| 146 | \"images\" sub directory in the data directory, then in the data | ||
| 147 | directory. | ||
| 148 | The data directory is the value of the variable `data-directory' on | ||
| 149 | Emacs, and what `(locate-data-directory \"tree-widget\")' returns on | ||
| 150 | XEmacs.") | ||
| 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. |
| 136 | When nil use the directory where the tree-widget library is located. | 154 | When nil use the directory where the tree-widget library is located. |
| 137 | When a relative name is specified, try to locate that sub directory in | 155 | When 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. | 156 | the locations specified in `tree-widget-themes-load-path'. |
| 139 | The data directory is the value of the variable `data-directory' on | ||
| 140 | Emacs, and what `(locate-data-directory \"tree-widget\")' returns on | ||
| 141 | XEmacs. | ||
| 142 | The default is to use the \"tree-widget\" relative name." | 157 | The 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. |
| 239 | See also the option `widget-image-file-name-suffixes'." | 254 | See 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. | ||
| 284 | Return 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. |
| 269 | It is defined in variable `tree-widget-themes-directory'. | 300 | It is defined in variable `tree-widget-themes-directory'. |
| 270 | Return the absolute name of the directory found, or nil if the | 301 | Return the absolute name of the directory found, or nil if the |
| 271 | specified directory is not accessible." | 302 | specified 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) |