Gnus development mailing list
 help / color / mirror / Atom feed
From: Reiner Steib <reinersteib+gmane@imap.cc>
Cc: ding@gnus.org
Subject: Re: image-load-path/load-path function
Date: Fri, 03 Mar 2006 17:38:28 +0100	[thread overview]
Message-ID: <v9ek1jfpq3.fsf@marauder.physik.uni-ulm.de> (raw)
In-Reply-To: <18269.1141346992@olgas.newt.com> (Bill Wohler's message of "Thu, 02 Mar 2006 16:49:52 -0800")

[-- Attachment #1: Type: text/plain, Size: 2170 bytes --]

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/

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 3503 bytes --]

--- 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

  parent reply	other threads:[~2006-03-03 16:38 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-20 22:22 Customizable tool bars Reiner Steib
2006-01-25 16:40 ` Reiner Steib
2006-01-26  0:53   ` Katsumi Yamaoka
2006-01-26  1:39     ` Steve Youngs
2006-01-26  2:35       ` Katsumi Yamaoka
2006-01-26  4:28         ` Steve Youngs
2006-01-26  5:14           ` Katsumi Yamaoka
2006-01-26  9:19             ` Reiner Steib
2006-01-26 11:31               ` Katsumi Yamaoka
2006-01-26  9:24     ` Reiner Steib
2006-01-26 10:52       ` Katsumi Yamaoka
2006-01-26 15:04         ` Reiner Steib
2006-01-30 23:45           ` Katsumi Yamaoka
2006-02-21 22:23   ` Reiner Steib
2006-02-22  5:04     ` Katsumi Yamaoka
2006-02-22 12:19       ` image-load-path/load-path function (was: Customizable tool bars) Reiner Steib
2006-02-22 14:53         ` image-load-path/load-path function Reiner Steib
2006-02-23  8:23           ` Katsumi Yamaoka
2006-02-23 11:50             ` Reiner Steib
2006-02-23 13:19               ` Katsumi Yamaoka
2006-02-23 15:17                 ` Reiner Steib
2006-02-24  8:03                   ` Katsumi Yamaoka
2006-02-24  8:40                     ` Katsumi Yamaoka
2006-02-23 18:13               ` Bill Wohler
2006-03-01 23:33         ` Bill Wohler
2006-03-02  1:07           ` Bill Wohler
2006-03-02  4:31             ` Peter S Galbraith
2006-03-02 17:13               ` Reiner Steib
2006-03-02 20:30                 ` Bill Wohler
2006-03-02 22:05                   ` Reiner Steib
2006-03-03  0:49                     ` Bill Wohler
2006-03-03  0:52                       ` Bill Wohler
2006-03-03 16:38                       ` Reiner Steib [this message]
2006-03-03 22:46                         ` Bill Wohler
2006-03-03 22:47                         ` Bill Wohler
2006-03-04 16:27                           ` Reiner Steib
2006-03-04 17:55                             ` Bill Wohler
2006-03-06 16:11                               ` Bill Wohler
2006-03-11  2:16                                 ` Bill Wohler
     [not found]                         ` <8096.1141420620@olgas.newt.com>
2006-03-04 23:33                           ` Bill Wohler
2006-03-02 16:59           ` Reiner Steib
2006-03-02 17:22             ` Bill Wohler
2006-02-22 12:23       ` Customizable tool bars Reiner Steib
2006-03-01 17:41       ` Reiner Steib
2006-03-01 18:26         ` Romain Francoise
2006-03-02 16:30           ` Reiner Steib
2006-03-01 19:35         ` Michael Piotrowski
2006-03-01 22:51           ` Reiner Steib
2006-03-02  0:00           ` Katsumi Yamaoka
2006-03-02 11:16             ` Michael Piotrowski
2006-03-02 16:31               ` Reiner Steib
2006-03-02 18:00                 ` Michael Piotrowski
2006-03-01 22:49         ` Katsumi Yamaoka
2006-03-02 10:49           ` Reiner Steib
2006-03-02 23:34             ` Katsumi Yamaoka
2006-03-03 10:35               ` Reiner Steib
2006-03-06  4:00                 ` Katsumi Yamaoka
2006-03-06 10:32                   ` Reiner Steib
2006-03-06 12:16                     ` Katsumi Yamaoka
2006-03-03 16:47               ` low-color variants of the Gnome icons (was: Customizable tool bars) Reiner Steib

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

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

  git send-email \
    --in-reply-to=v9ek1jfpq3.fsf@marauder.physik.uni-ulm.de \
    --to=reinersteib+gmane@imap.cc \
    --cc=Reiner.Steib@gmx.de \
    --cc=ding@gnus.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.
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 NNTP newsgroup(s).