From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: Shall we use etc/images more? Date: Wed, 14 Sep 2005 10:55:14 +0200 Message-ID: References: <14536.1126060623@olgas.newt.com> <20721.1126158478@olgas.newt.com> <3698.1126505253@olgas.newt.com> <878xy0axgf.fsf@stupidchicken.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1126690254 27480 80.91.229.2 (14 Sep 2005 09:30:54 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 14 Sep 2005 09:30:54 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Sep 14 11:30:51 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EFTad-00030R-Bi for ged-emacs-devel@m.gmane.org; Wed, 14 Sep 2005 11:30:03 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EFTab-00009A-EX for ged-emacs-devel@m.gmane.org; Wed, 14 Sep 2005 05:30:02 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EFTCW-0007as-OM for emacs-devel@gnu.org; Wed, 14 Sep 2005 05:05:10 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EFTCO-0007aK-9w for emacs-devel@gnu.org; Wed, 14 Sep 2005 05:05:03 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EFT9V-0007Jk-Sl for emacs-devel@gnu.org; Wed, 14 Sep 2005 05:02:02 -0400 Original-Received: from [195.41.46.235] (helo=pfepa.post.tele.dk) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EFT3G-0005xg-Ne for emacs-devel@gnu.org; Wed, 14 Sep 2005 04:55:35 -0400 Original-Received: from kfs-l.imdomain.dk.cua.dk (unknown [80.165.4.124]) by pfepa.post.tele.dk (Postfix) with SMTP id 9C9E147FECC; Wed, 14 Sep 2005 10:55:28 +0200 (CEST) Original-To: Chong Yidong In-Reply-To: <878xy0axgf.fsf@stupidchicken.com> (Chong Yidong's message of "Wed, 14 Sep 2005 04:02:40 -0400") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:42912 Archived-At: Chong Yidong 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 http://www.cua.dk