青田です。

icon のファイル名が重複してしまう場合があるようです。なので、icon のファ
イル名を md5 を使って決定するようにしてみました。

;; 特に今だとサンタ帽子をかぶったアイコンがよく重複してるみたい?

-O を使うため、 --no-clobber 相当のことを自分で判定し、 各url につき一つ
の wget プロセスが起動されます。

naota-icon-name-md5 ブランチにもありますが、ここにも diff を貼っておきま
す。

;; MLに流すのと pull request 出すのとどちらがよいのだろう…。

--
青田

diff --git a/ChangeLog b/ChangeLog
index a5b36a3..713377d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-12-02  Naohiro Aota  <na...@elisp.net>
+
+       * twittering-mode.el (twittering-icon-path): New funciton.
+       (twittering-format-status): Use it.
+       (twittering-get-twits): Ditto; wget now invoked for each icon.
+
 2009-11-18  Alberto Garcia  <agar...@igalia.com>
 
        * twittering-mode.el
diff --git a/twittering-mode.el b/twittering-mode.el
index 2df868e..ed72434 100644
--- a/twittering-mode.el
+++ b/twittering-mode.el
@@ -643,6 +643,10 @@ directory. You should change through 
function'twittering-icon-mode'")
       (goto-char (+ point (if twittering-scroll-mode (- (point-max) end) 0))))
     ))
 
+(defun twittering-icon-path (icon-url)
+  (concat (md5 icon-url nil nil 'iso-2022-7bit)
+         (or (ffap-file-suffix icon-url) ".img")))
+
 (defun twittering-format-status (status format-str)
   ;; Formatting strategy:
   ;; 
@@ -665,7 +669,7 @@ directory. You should change through 
function'twittering-icon-mode'")
            (if (string-match "/\\([^/?]+\\)\\(?:\\?\\|$\\)" profile-image-url)
                (let* ((filename (match-string-no-properties 1
                                                             profile-image-url))
-                      (fullpath (concat twittering-tmp-dir "/" filename)))
+                      (fullpath (concat twittering-tmp-dir "/" 
(twittering-icon-path profile-image-url))))
                  ;; download icons if does not exist
                  (if (file-exists-p fullpath)
                      t
@@ -1239,23 +1243,26 @@ If STATUS-DATUM is already in DATA-VAR, return nil. If 
not, return t."
 
   (if (and twittering-icon-mode window-system)
       (if twittering-image-stack
-         (let ((proc
-                (apply
-                 #'start-process
-                 "wget-images"
-                 (twittering-wget-buffer)
-                 "wget"
-                 (format "--directory-prefix=%s" twittering-tmp-dir)
-                 "--no-clobber"
-                 "--quiet"
-                 twittering-image-stack)))
-           (set-process-sentinel
-            proc
-            (lambda (proc stat)
-              (clear-image-cache)
-              (save-excursion
-                (set-buffer (twittering-wget-buffer))
-                )))))))
+         (dolist (url twittering-image-stack)
+           (let ((file (concat twittering-tmp-dir "/" (twittering-icon-path 
url))))
+           (unless (file-exists-p file)
+             (let ((proc
+                    (funcall
+                     #'start-process
+                     "wget-images"
+                     (twittering-wget-buffer)
+                     "wget"
+                     "--quiet"
+                     (format "--directory-prefix=%s" twittering-tmp-dir)
+                     "-O" file
+                     url)))
+               (set-process-sentinel
+                proc
+                (lambda (proc stat)
+                  (clear-image-cache)
+                  (save-excursion
+                    (set-buffer (twittering-wget-buffer))
+                    ))))))))))
 
 (defun twittering-friends-timeline ()
   (interactive)

------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing. 
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
_______________________________________________
twmode-users mailing list
twmode-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/twmode-users

メールによる返信