unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: storm@cua.dk (Kim F. Storm)
Cc: emacs-devel@gnu.org
Subject: Re: Shall we use etc/images more?
Date: Wed, 14 Sep 2005 10:55:14 +0200	[thread overview]
Message-ID: <m3wtlk58r1.fsf@kfs-l.imdomain.dk> (raw)
In-Reply-To: <878xy0axgf.fsf@stupidchicken.com> (Chong Yidong's message of "Wed, 14 Sep 2005 04:02:40 -0400")

Chong Yidong <cyd@stupidchicken.com> writes:

> How about this patch?  It changes find-image to look for an image file
> in etc/images first, then in etc/, then in the load-path.  The last
> two are for backward compatibility, the idea being that images should
> go into etc/images by default.
>

IMO, This is a good approach.

However, I would suggest that you define an image-load-path
variable like this:

(defvar image-load-path '("etc/images/" "etc/" load-path)
  "List of directories and other load paths to search for images.
If element is a string, it defines a directory to search.
Non-absolute directories are relative to `data-directory'.
If element is a variable symbol, the value of that variable
is used as a load-path of directories to search.")


Then modify this part of your patch

> ! 		 (if (or (file-readable-p
> ! 			  (setq found
> ! 				(expand-file-name
> ! 				 file
> ! 				 (concat data-directory "/images"))))
> ! 			 (file-readable-p
> ! 			  (setq found
> ! 				(expand-file-name file data-directory)))
> ! 			 (let ((path load-path))
> ! 			   (setq found nil)
> ! 			   (while (and (not found) path)
> ! 			     (unless (file-readable-p
> ! 				      (setq found (expand-file-name
> ! 						   file (car path))))
> ! 			       (setq found nil))
> ! 			     (setq path (cdr path)))
> ! 			   found))

to call the function below like this:

   (setq found (image-search-load-path file image-load-path))


(defun image-search-load-path (file path)
  (let (found)
    (while (and (not found) (consp path))
       (cond
         ((stringp (car path))
          (setq found (expand-file-name file
                        (expand-file-name (car path) data-directory))
         ((and (symbolp (car path) (boundp (car path)))
          (setq found (image-search-load-path file (symbol-value (car path)))))))))
       (setq path (cdr path)))
    found))


WDYT?
        
> For example, if foobar.el needs an image that is installed into
> etc/images/foobar/foo.xpm, it calls
>
> (defimage foo-image ((:type xpm :file "foobar/foo.xpm" ....)))
>
>
> *** emacs/lisp/image.el.~1.48.~	2005-08-06 18:13:43.000000000 -0400
> --- emacs/lisp/image.el	2005-09-14 03:55:29.000000000 -0400
> ***************
> *** 286,292 ****
>   specification to be returned.  Return nil if no specification is
>   satisfied.
>   
> ! The image is looked for first on `load-path' and then in `data-directory'."
>     (let (image)
>       (while (and specs (null image))
>         (let* ((spec (car specs))
> --- 286,293 ----
>   specification to be returned.  Return nil if no specification is
>   satisfied.
>   
> ! The image is looked for first in `data-directory'/images, then in
> ! `data-directory', then in `load-path'."
>     (let (image)
>       (while (and specs (null image))
>         (let* ((spec (car specs))
> ***************
> *** 296,315 ****
>   	     found)
>   	(when (image-type-available-p type)
>   	  (cond ((stringp file)
> ! 		 (let ((path load-path))
> ! 		   (while (and (not found) path)
> ! 		     (let ((try-file (expand-file-name file (car path))))
> ! 		       (when (file-readable-p try-file)
> ! 			 (setq found try-file)))
> ! 		     (setq path (cdr path)))
> ! 		   (unless found
> ! 		     (let ((try-file (expand-file-name file data-directory)))
> ! 		       (if (file-readable-p try-file)
> ! 			   (setq found try-file))))
> ! 		   (if found
> ! 		       (setq image
> ! 			     (cons 'image (plist-put (copy-sequence spec)
> ! 						     :file found))))))
>   		((not (null data))
>   		 (setq image (cons 'image spec)))))
>   	(setq specs (cdr specs))))
> --- 297,323 ----
>   	     found)
>   	(when (image-type-available-p type)
>   	  (cond ((stringp file)
> ! 		 (if (or (file-readable-p
> ! 			  (setq found
> ! 				(expand-file-name
> ! 				 file
> ! 				 (concat data-directory "/images"))))
> ! 			 (file-readable-p
> ! 			  (setq found
> ! 				(expand-file-name file data-directory)))
> ! 			 (let ((path load-path))
> ! 			   (setq found nil)
> ! 			   (while (and (not found) path)
> ! 			     (unless (file-readable-p
> ! 				      (setq found (expand-file-name
> ! 						   file (car path))))
> ! 			       (setq found nil))
> ! 			     (setq path (cdr path)))
> ! 			   found))
> ! 		     ;; image file found
> ! 		     (setq image
> ! 			   (cons 'image (plist-put (copy-sequence spec)
> ! 						   :file found)))))
>   		((not (null data))
>   		 (setq image (cons 'image spec)))))
>   	(setq specs (cdr specs))))
>
>
> _______________________________________________
> Emacs-devel mailing list
> Emacs-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-devel
>
>

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

  reply	other threads:[~2005-09-14  8:55 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-07  2:37 Shall we use etc/images more? Bill Wohler
2005-09-07  8:30 ` Kim F. Storm
     [not found] ` <E1EDCMR-00043d-Vd@fencepost.gnu.org>
2005-09-08  5:47   ` Bill Wohler
2005-09-12  4:57     ` Richard M. Stallman
2005-09-12  6:07       ` Bill Wohler
2005-09-13 15:54         ` Richard M. Stallman
     [not found]         ` <E1EFD6x-0000cn-Qd@fencepost.gnu.org>
2005-09-14  1:50           ` Bill Wohler
2005-09-15 13:00             ` Richard M. Stallman
2005-09-15 18:36               ` Bill Wohler
2005-09-16  6:16                 ` Richard M. Stallman
2005-09-30 18:00                   ` Bill Wohler
2005-09-14  8:02         ` Chong Yidong
2005-09-14  8:55           ` Kim F. Storm [this message]
2005-09-14 23:54             ` Chong Yidong
2005-09-14 14:08               ` Kim F. Storm
2005-09-15 13:00                 ` Richard M. Stallman
2005-09-16  2:28               ` Katsumi Yamaoka
2005-09-12 22:43     ` Bill Wohler
2005-09-13  9:23       ` Kim F. Storm
2005-09-13 19:51         ` Eli Zaretskii
2005-09-14  1:45         ` Bill Wohler
2005-09-14  6:41           ` Mark D. Baushke
2005-09-15  2:41           ` Richard M. Stallman
2005-09-15 18:48             ` Bill Wohler
2005-09-29 21:45         ` Bill Wohler
2005-09-30  0:40           ` Bill Wohler
2005-09-30 14:22             ` Chong Yidong
2005-09-30 20:01             ` Richard M. Stallman
2005-10-15  6:45               ` Bill Wohler
2005-10-15 15:00                 ` Romain Francoise
2005-10-15 17:43                   ` Bill Wohler
2005-10-15 18:52                     ` Romain Francoise
2005-10-16 14:41                 ` Richard M. Stallman
2005-10-16 18:00                   ` Bill Wohler
2005-10-17 17:30                     ` Richard M. Stallman
2005-10-17 22:21               ` lisp/toolbar is gone (was: Shall we use etc/images more?) Bill Wohler
2005-10-18  8:03                 ` Andreas Schwab
2005-09-13 15:55       ` Shall we use etc/images more? Richard M. Stallman
  -- strict thread matches above, loose matches on Subject: below --
2005-05-30 22:39 The MH-E repository Bill Wohler
2005-05-30 23:27 ` Juanma Barranquero
2005-05-31  0:21 ` Miles Bader
2005-05-31  7:08 ` Jérôme Marant
2005-05-31  7:46   ` Miles Bader
2005-05-31  8:17     ` Jérôme Marant
2005-05-31  8:59       ` Mark D. Baushke
2005-05-31  9:30         ` Jérôme Marant
2005-05-31 15:21       ` Bill Wohler
2005-05-31  9:03   ` Eli Zaretskii
2005-05-31 17:47   ` Richard Stallman
2005-05-31 20:00     ` Jérôme Marant
2005-06-01 17:22       ` Richard Stallman
2005-06-02  5:31       ` packaging (was: The MH-E repository) Janusz S. Bień
2005-06-03  8:01         ` Richard Stallman
2005-05-31  8:56 ` The MH-E repository Kim F. Storm
2005-05-31 10:07   ` Mark D. Baushke
2005-05-31 17:47     ` Richard Stallman
2005-05-31 18:16       ` Mark D. Baushke
2005-05-31 18:39         ` chad brown
2005-06-01 17:24         ` Richard Stallman
2005-05-31 22:00       ` Kim F. Storm
2005-05-31 13:08 ` Stefan Monnier
2005-05-31 17:09   ` Bill Wohler
2005-05-31 18:06     ` Mark D. Baushke
2005-05-31 19:13       ` Stefan Monnier
2005-07-05  4:35       ` Richard M. Stallman
2005-07-05 18:28         ` Bill Wohler
2005-07-11  1:22           ` Mark D. Baushke
2005-05-31 21:39     ` Miles Bader
2005-05-31 17:46 ` Richard Stallman
2005-06-01  9:39 ` Richard Stallman
2005-06-01 16:50 ` Bill Wohler
2005-06-02  6:40   ` Richard Stallman
2005-06-02 18:32     ` Bill Wohler
2005-06-03 22:30       ` Richard Stallman
2005-06-03 23:25         ` Bill Wohler
2005-06-04  9:44           ` [Savannah-help-public] " Sylvain Beucler
2005-06-04 12:30             ` Miles Bader
2005-06-04 16:13               ` Bill Wohler
2005-06-04 16:52                 ` Sylvain Beucler
2005-09-30 22:49                   ` Bill Wohler
2005-10-01 17:04                     ` Sylvain Beucler
2005-10-03 23:14                       ` Bill Wohler
2005-10-04 12:17                         ` Sylvain Beucler
2005-10-04 20:13                           ` Bill Wohler
2005-06-04 17:59             ` Richard Stallman
     [not found] ` <wohler@newt.com>
2005-06-01 13:47   ` Peter S Galbraith
2005-06-01 14:27     ` Bill Wohler
2005-06-02  6:40     ` Richard Stallman
2005-09-16 19:12   ` Shall we use etc/images more? Peter S Galbraith

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3wtlk58r1.fsf@kfs-l.imdomain.dk \
    --to=storm@cua.dk \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).