From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/62146 Path: news.gmane.org!not-for-mail From: Reiner Steib Newsgroups: gmane.mail.mh-e.devel,gmane.emacs.gnus.general Subject: Re: image-load-path/load-path function Date: Fri, 03 Mar 2006 17:38:28 +0100 Message-ID: References: <17903.1141256030@olgas.newt.com> <19737.1141261645@olgas.newt.com> <4021.1141273863@mixed> <12647.1141331413@olgas.newt.com> <18269.1141346992@olgas.newt.com> Reply-To: Reiner Steib NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1141404025 5778 80.91.229.2 (3 Mar 2006 16:40:25 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 3 Mar 2006 16:40:25 +0000 (UTC) Cc: ding@gnus.org Original-X-From: mh-e-devel-admin@lists.sourceforge.net Fri Mar 03 17:40:21 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 1FFDJE-0007Ml-0S for gmmd-mh-e-devel@m.gmane.org; Fri, 03 Mar 2006 17:39:17 +0100 Original-Received: from sc8-sf-list1-b.sourceforge.net (sc8-sf-list1-b.sourceforge.net [10.3.1.7]) by sc8-sf-spam2.sourceforge.net (Postfix) with ESMTP id A84CF13F20; Fri, 3 Mar 2006 08:39:10 -0800 (PST) Original-Received: from sc8-sf-mx1-b.sourceforge.net ([10.3.1.91] helo=mail.sourceforge.net) by sc8-sf-list1.sourceforge.net with esmtp (Exim 4.30) id 1FFDId-0004H8-9v for mh-e-devel@lists.sourceforge.net; Fri, 03 Mar 2006 08:38:39 -0800 Original-Received: from mail.uni-ulm.de ([134.60.1.1]) by mail.sourceforge.net with esmtps (TLSv1:AES256-SHA:256) (Exim 4.44) id 1FFDIb-0004le-O2 for mh-e-devel@lists.sourceforge.net; Fri, 03 Mar 2006 08:38:39 -0800 Original-Received: from bridgekeeper.physik.uni-ulm.de (bridgekeeper.physik.uni-ulm.de [134.60.10.123]) by mail.uni-ulm.de (8.13.4/8.13.4) with ESMTP id k23GcSii025322; Fri, 3 Mar 2006 17:38:29 +0100 (MET) Original-Received: by bridgekeeper.physik.uni-ulm.de (Postfix, from userid 170) id 6DECB11361; Fri, 3 Mar 2006 17:38:28 +0100 (CET) Original-To: mh-e-devel@lists.sourceforge.net Mail-Followup-To: mh-e-devel@lists.sourceforge.net, ding@gnus.org X-Face: /U7=m^"/-Dn61mAl{g9e3>\G5Tp,oEX|V)g2I1hBk\ML;)7A?6cmB-y7y?'NA^J<=oz7syB =(McAwIHgLX!.B?R3X}98d@?>CrT094KLWh]WU4gDpnL/")MS(XoQTv`Oq225uL>+;CpPXo$N5e>N> $tPd-gbB^F{gQS#1ase]XO~D4p4M"3+F-7~u]dy3I?Pb8RO*H-EFeWDUf?Rf,d]pv\Jvh2Cht!A=im yKAS2Z%Ao^;}W/qzMvMm In-Reply-To: <18269.1141346992@olgas.newt.com> (Bill Wohler's message of "Thu, 02 Mar 2006 16:49:52 -0800") User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux) X-DCC-EATSERVER-Metrics: gemini 1166; Body=2 Fuz1=2 Fuz2=2 X-Spam-Score: 0.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 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: Fri, 03 Mar 2006 17:38:28 +0100 Xref: news.gmane.org gmane.mail.mh-e.devel:11832 gmane.emacs.gnus.general:62146 Archived-At: --=-=-= On Fri, Mar 03 2006, Bill Wohler wrote: > 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? Maybe `image-relative-load-path' or `image-load-path-relative' to make it more clear? > (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'." Adding a calling example to doc string won't hurt. Maybe emphasize that IMAGE must include the extension, e.g. .xpm (maybe not necessary when we give an example). > (let ((mh-image-directory)) [...] > ((let (mh-library-name d1ei d2ei) The local variables mh-image-directory and mh-library-name should have a non-prefixed name e.g. image-dir and library-name. This would also make synching more easy. See the attached patch against emacs/lisp/mh-e/mh-utils.el. > (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)) As mh-image-directory cannot be not a user-specified directory anymore, I doubt that these errors are very useful. But if you'd like to keep these two `error' calls, we should add an optional no-error argument as suggested by Katsumi Yamaoka. We would set this to t in Gnus and the function would use `message' or `error' depending on its value. Bye, Reiner. -- ,,, (o o) ---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/ --=-=-= Content-Type: text/x-patch Content-Disposition: inline --- mh-utils.el 03 Mar 2006 13:59:57 +0100 1.57 +++ mh-utils.el 03 Mar 2006 17:34:28 +0100 @@ -94,25 +94,25 @@ `load-path'." (unless library (error "No library specified")) (unless image (error "No image specified")) - (let ((mh-image-directory)) + (let ((image-dir)) (cond ;; Try relative setting. - ((let (mh-library-name d1ei d2ei) + ((let (library-name d1ei d2ei) ;; First, find library in the load-path. - (setq mh-library-name (locate-library library)) - (if (not mh-library-name) + (setq library-name (locate-library library)) + (if (not library-name) (error "Cannot find library %s in load-path" library)) - ;; And then set mh-image-directory relative to that. + ;; And then set image-dir relative to that. (setq ;; Go down 2 levels. d2ei (expand-file-name - (concat (file-name-directory mh-library-name) + (concat (file-name-directory library-name) "../../etc/images")) ;; Go down 1 level. d1ei (expand-file-name - (concat (file-name-directory mh-library-name) + (concat (file-name-directory library-name) "../etc/images"))) - (setq mh-image-directory + (setq image-dir ;; 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))))) @@ -125,7 +125,7 @@ (locate-library image))) parent) ;; Since the image might be in a nested directory - ;; (for example, mail/attach.pbm), adjust `mh-image-directory' + ;; (for example, mail/attach.pbm), adjust `image-dir' ;; accordingly. (and dir (setq dir (file-name-directory dir)) @@ -133,24 +133,24 @@ (while (setq parent (file-name-directory img)) (setq img (directory-file-name parent) dir (expand-file-name "../" dir))) - (setq mh-image-directory dir)))))) + (setq image-dir 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)) + (unless (file-exists-p image-dir) + (error "Directory %s in image-dir does not exist" + image-dir)) + (unless (file-exists-p (expand-file-name image image-dir)) + (error "Directory %s in image-dir does not contain image %s" + image-dir image)) ;; Return augmented `image-load-path' or `load-path'. (cond ((and path (symbolp path)) - (nconc (list mh-image-directory) - (delete mh-image-directory + (nconc (list image-dir) + (delete image-dir (if (boundp path) (copy-sequence (symbol-value path)) nil)))) (t - (nconc (list mh-image-directory) - (delete mh-image-directory + (nconc (list image-dir) + (delete image-dir (copy-sequence load-path))))))) ;;;###mh-autoload --=-=-=-- ------------------------------------------------------- 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