From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/62134 Path: news.gmane.org!not-for-mail From: Bill Wohler Newsgroups: gmane.mail.mh-e.devel,gmane.emacs.gnus.general Subject: Re: image-load-path/load-path function Date: Thu, 02 Mar 2006 16:49:52 -0800 Organization: Newt Software Message-ID: <18269.1141346992@olgas.newt.com> References: <17903.1141256030@olgas.newt.com> <19737.1141261645@olgas.newt.com> <4021.1141273863@mixed> <12647.1141331413@olgas.newt.com> NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1141347023 26285 80.91.229.2 (3 Mar 2006 00:50:23 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 3 Mar 2006 00:50:23 +0000 (UTC) Original-X-From: mh-e-devel-admin@lists.sourceforge.net Fri Mar 03 01:50:17 2006 Return-path: Envelope-to: gmmd-mh-e-devel@m.gmane.org Original-Received: from lists-outbound.sourceforge.net ([66.35.250.225]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FEyUg-0007dn-5k for gmmd-mh-e-devel@m.gmane.org; Fri, 03 Mar 2006 01:50:07 +0100 Original-Received: from sc8-sf-list1-b.sourceforge.net (sc8-sf-list1-b.sourceforge.net [10.3.1.7]) by sc8-sf-spam1.sourceforge.net (Postfix) with ESMTP id 55354886DB; Thu, 2 Mar 2006 16:50:05 -0800 (PST) Original-Received: from sc8-sf-mx2-b.sourceforge.net ([10.3.1.92] helo=mail.sourceforge.net) by sc8-sf-list1.sourceforge.net with esmtp (Exim 4.30) id 1FEyUW-0002W7-UC for mh-e-devel@lists.sourceforge.net; Thu, 02 Mar 2006 16:49:56 -0800 Original-Received: from pop-savannah.atl.sa.earthlink.net ([207.69.195.69]) by mail.sourceforge.net with esmtp (Exim 4.44) id 1FEyUU-0006uC-Pl for mh-e-devel@lists.sourceforge.net; Thu, 02 Mar 2006 16:49:57 -0800 Original-Received: from h-64-105-35-154.snvacaid.dynamic.covad.net ([64.105.35.154] helo=olgas.newt.com) by pop-savannah.atl.sa.earthlink.net with esmtp (Exim 3.36 #10) id 1FEyUS-0000eU-00; Thu, 02 Mar 2006 19:49:52 -0500 Original-Received: by olgas.newt.com (Postfix, from userid 1000) id 66C781717A; Thu, 2 Mar 2006 16:49:52 -0800 (PST) Original-Received: from olgas.newt.com (localhost [127.0.0.1]) by olgas.newt.com (Postfix) with ESMTP id 632A016FA9; Thu, 2 Mar 2006 16:49:52 -0800 (PST) Original-To: mh-e-devel@lists.sourceforge.net, ding@gnus.org In-reply-to: Comments: In-reply-to Reiner Steib message dated "Thu, 02 Mar 2006 23:05:02 +0100." X-Mailer: MH-E 7.92+cvs; nmh 1.1; GNU Emacs 22.0.50.7 X-Image-URL: http://www.newt.com/wohler/images/bill-diving.png Mail-Followup-To: mh-e-devel@lists.sourceforge.net, ding@gnus.org X-Spam-Score: 1.0 (+) X-Spam-Report: Spam Filtering performed by sourceforge.net. See http://spamassassin.org/tag/ for more details. Report problems to http://sf.net/tracker/?func=add&group_id=1&atid=200001 1.0 FORGED_RCVD_HELO Received: contains a forged HELO Original-Sender: mh-e-devel-admin@lists.sourceforge.net Errors-To: mh-e-devel-admin@lists.sourceforge.net X-BeenThere: mh-e-devel@lists.sourceforge.net X-Mailman-Version: 2.0.9-sf.net Precedence: bulk List-Unsubscribe: , List-Id: Forum for the MH-E developers List-Post: List-Help: List-Subscribe: , List-Archive: X-Original-Date: Thu, 02 Mar 2006 16:49:52 -0800 Xref: news.gmane.org gmane.mail.mh-e.devel:11825 gmane.emacs.gnus.general:62134 Archived-At: Rainer, I copied your *-image-load-path function, changed gmm to mh, made a couple of changes (listed below), and updated our software to use scoped copies of image-load-path/load-path. - Delete mh-image-directory variable per previous email. - Remove periods from (error) strings per Emacs conventions. See Info node `(elisp)Programming Tips'. - Remove quotes around %s. There isn't an explicit Emacs convention about this, but it's used in less than 10% of the cases so I made it an MH-E convention. - Add comment before a bit that took me a minute to grok. I think we're ready to move it to image.el. Let me know if you think I should proceed. I think the name image-load-path would be fine: If you ask for the variable image-load-path, you get the image load path, if you ask for the function image-load-path, you get the image load path. Seems consistent. What do you think? (defun mh-image-load-path (library image &optional path) "Return a suitable search path for images of LIBRARY. Images for LIBRARY are searched for in \"../../etc/images\" and \"../etc/images\" relative to the files in \"lisp/LIBRARY\", in `image-load-path', or in `load-path'. This function returns value of `load-path' augmented with the path to IMAGE. If PATH is given, it is used instead of `load-path'." (unless library (error "No library specified")) (unless image (error "No image specified")) (let ((mh-image-directory)) (cond ;; Try relative setting. ((let (mh-library-name d1ei d2ei) ;; First, find library in the load-path. (setq mh-library-name (locate-library library)) (if (not mh-library-name) (error "Cannot find library %s in load-path" library)) ;; And then set mh-image-directory relative to that. (setq ;; Go down 2 levels. d2ei (expand-file-name (concat (file-name-directory mh-library-name) "../../etc/images")) ;; Go down 1 level. d1ei (expand-file-name (concat (file-name-directory mh-library-name) "../etc/images"))) (setq mh-image-directory ;; Set it to nil if image is not found. (cond ((file-exists-p (expand-file-name image d2ei)) d2ei) ((file-exists-p (expand-file-name image d1ei)) d1ei))))) ;; Check for images in image-load-path or load-path. ((let ((img image) (dir (or ;; Images in image-load-path. (mh-image-search-load-path image) ;; Images in load-path. (locate-library image))) parent) ;; Since the image might be in a nested directory ;; (for example, mail/attach.pbm), adjust `mh-image-directory' ;; accordingly. (and dir (setq dir (file-name-directory dir)) (progn (while (setq parent (file-name-directory img)) (setq img (directory-file-name parent) dir (expand-file-name "../" dir))) (setq mh-image-directory dir)))))) ;; (unless (file-exists-p mh-image-directory) (error "Directory %s in mh-image-directory does not exist" mh-image-directory)) (unless (file-exists-p (expand-file-name image mh-image-directory)) (error "Directory %s in mh-image-directory does not contain image %s" mh-image-directory image)) ;; Return augmented `image-load-path' or `load-path'. (cond ((and path (symbolp path)) (nconc (list mh-image-directory) (delete mh-image-directory (if (boundp path) (copy-sequence (symbol-value path)) nil)))) (t (nconc (list mh-image-directory) (delete mh-image-directory (copy-sequence load-path))))))) -- Bill Wohler http://www.newt.com/wohler/ GnuPG ID:610BD9AD Maintainer of comp.mail.mh FAQ and MH-E. Vote Libertarian! If you're passed on the right, you're in the wrong lane. ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642