bongo-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bongo-patches] Add `image-type-from-file-name' to `bongo-emacs21.el'


From: Daniel Brockman
Subject: [bongo-patches] Add `image-type-from-file-name' to `bongo-emacs21.el'
Date: Mon, 12 Feb 2007 07:31:17 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.51 (gnu/linux)

2007-02-12  Daniel Brockman  <address@hidden>

        Add `image-type-from-file-name' to `bongo-emacs21.el'.

diff -rN -u old-bongo/bongo.el new-bongo/bongo.el
--- old-bongo/bongo.el  2007-02-12 07:31:11.000000000 +0100
+++ new-bongo/bongo.el  2007-02-12 07:31:11.000000000 +0100
@@ -110,6 +110,10 @@
       'read-directory-name)
     (defalias 'bongo-run-mode-hooks
       'run-mode-hooks)
+    (defalias 'bongo-read-number
+      'read-number)
+    (defalias 'bongo-image-type-from-file-name
+      'image-type-from-file-name)
     (defalias 'bongo-process-get
       'process-get)
     (defalias 'bongo-process-put
@@ -740,7 +744,7 @@
   (find-image
    (list (list :ascent 'center
                :file file-name
-               :type (image-type-from-file-name file-name)
+               :type (bongo-image-type-from-file-name file-name)
                :background (face-background
                             (or background-face 'default) nil t)))))
 
@@ -5294,8 +5298,8 @@
              (let* ((track-count (bongo-cdda-track-count device))
                     (range-string (when track-count
                                     (format " (1-%d)" track-count))))
-               (read-number (format "Audio CD track number%s: "
-                                    (or range-string "")))))
+               (bongo-read-number (format "Audio CD track number%s: "
+                                          (or range-string "")))))
            nil device)))
   (when (and (null cddb-info) bongo-use-cddb)
     (setq cddb-info (bongo-cddb-info device)))
@@ -6174,7 +6178,7 @@
             (cond ((null unit)
                    (error "This player does not support seeking"))
                   ((eq unit 'frames)
-                   (read-number "Seek to (in frames): "))
+                   (bongo-read-number "Seek to (in frames): "))
                   ((eq unit 'seconds)
                    (let ((total-time
                           (bongo-player-total-time bongo-player)))
diff -rN -u old-bongo/bongo-emacs21.el new-bongo/bongo-emacs21.el
--- old-bongo/bongo-emacs21.el  2007-02-12 07:31:11.000000000 +0100
+++ new-bongo/bongo-emacs21.el  2007-02-12 07:31:11.000000000 +0100
@@ -6,7 +6,7 @@
 ;; Author: Daniel Brockman <address@hidden>
 ;; URL: http://www.brockman.se/software/bongo/
 ;; Created: December 27, 2006
-;; Updated: February 6, 2007
+;; Updated: February 12, 2007
 
 ;; This file is free software; you can redistribute it and/or
 ;; modify it under the terms of the GNU General Public License as
@@ -81,6 +81,35 @@
            t)))
     n))
 
+;;; The following were copied from `image.el.'
+
+(defconst image-type-file-name-regexps
+  '(("\\.png\\'" . png)
+    ("\\.gif\\'" . gif)
+    ("\\.jpe?g\\'" . jpeg)
+    ("\\.bmp\\'" . bmp)
+    ("\\.xpm\\'" . xpm)
+    ("\\.pbm\\'" . pbm)
+    ("\\.xbm\\'" . xbm)
+    ("\\.ps\\'" . postscript)
+    ("\\.tiff?\\'" . tiff))
+  "Alist of (REGEXP . IMAGE-TYPE) pairs used to identify image files.
+When the name of an image file match REGEXP, it is assumed to
+be of image type IMAGE-TYPE.")
+
+(defun image-type-from-file-name (file)
+  "Determine the type of image file FILE from its name.
+Value is a symbol specifying the image type, or nil if type cannot
+be determined."
+  (let ((types image-type-file-name-regexps)
+       type)
+    (while types
+      (if (string-match (car (car types)) file)
+         (setq type (cdr (car types))
+               types nil)
+       (setq types (cdr types))))
+    type))
+
 ;;; The following macros were copied from `byte-run.el'.
 
 (defmacro bongo-define-obsolete-function-alias
-- 
Daniel Brockman <address@hidden>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]