From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chong Yidong Newsgroups: gmane.emacs.devel Subject: Re: Shall we use etc/images more? Date: Wed, 14 Sep 2005 19:54:53 -0400 Message-ID: <87wtljurw2.fsf@stupidchicken.com> 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 1126700195 24881 80.91.229.2 (14 Sep 2005 12:16:35 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 14 Sep 2005 12:16:35 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Sep 14 14:16:33 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EFWAA-0000ox-3h for ged-emacs-devel@m.gmane.org; Wed, 14 Sep 2005 14:14:54 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EFWA9-0002oc-5W for ged-emacs-devel@m.gmane.org; Wed, 14 Sep 2005 08:14:53 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EFVxv-00078l-Lu for emacs-devel@gnu.org; Wed, 14 Sep 2005 08:02:16 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EFVxq-00076S-7H for emacs-devel@gnu.org; Wed, 14 Sep 2005 08:02:13 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EFVxo-0006pg-0H for emacs-devel@gnu.org; Wed, 14 Sep 2005 08:02:08 -0400 Original-Received: from [18.95.6.180] (helo=localhost.localdomain) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EFVqp-0005XC-EA for emacs-devel@gnu.org; Wed, 14 Sep 2005 07:54:55 -0400 Original-Received: by localhost.localdomain (Postfix, from userid 1000) id E50FC1E441F; Wed, 14 Sep 2005 19:54:53 -0400 (EDT) Original-To: storm@cua.dk (Kim F. Storm) In-Reply-To: (Kim F. Storm's message of "Wed, 14 Sep 2005 10:55:14 +0200") 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:42915 Archived-At: > IMO, This is a good approach. > > However, I would suggest that you define an image-load-path > variable like this... Good idea. Here's a revised patch: *** emacs/lisp/image.el.~1.48.~ 2005-08-06 18:13:43.000000000 -0400 --- emacs/lisp/image.el 2005-09-14 19:50:41.000000000 -0400 *************** *** 49,54 **** --- 49,61 ---- with one argument, a string containing the image data. If PREDICATE returns a non-nil value, TYPE is the image's type.") + (defvar image-load-path + (list (concat data-directory "images/") data-directory 'load-path) + "List of locations in which to search for image files. + If an element is a string, it defines a directory to search. + If an element is a variable symbol, the value of that variable is + used as a list of directories to search.") + (defun image-jpeg-p (data) "Value is non-nil if DATA, a string, consists of JFIF image data. We accept the tag Exif because that is the same format." *************** *** 269,274 **** --- 276,292 ---- (delete-overlay overlay))) (setq overlays (cdr overlays))))) + (defun image-search-load-path (file path) + (let (found) + (while (and (not found) (consp path)) + (cond + ((stringp (car path)) + (setq found (file-readable-p (expand-file-name (car path))))) + ((and (symbolp (car path)) (boundp (car path))) + (setq found (image-search-load-path + file (symbol-value (car path)))))) + (setq path (cdr path))) + found)) ;;;###autoload (defun find-image (specs) *************** *** 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)) --- 304,310 ---- specification to be returned. Return nil if no specification is satisfied. ! The image is looked for in `image-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)))) --- 314,324 ---- found) (when (image-type-available-p type) (cond ((stringp file) ! (if (setq found (image-search-load-path ! file image-load-path)) ! (setq image ! (cons 'image (plist-put (copy-sequence spec) ! :file found))))) ((not (null data)) (setq image (cons 'image spec))))) (setq specs (cdr specs))))