commit-womb
[Top][All Lists]
Advanced

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

[commit-womb] addressbook addressbook.el ChangeLog


From: Xavier Maillard
Subject: [commit-womb] addressbook addressbook.el ChangeLog
Date: Thu, 10 May 2007 20:36:26 +0000

CVSROOT:        /sources/womb
Module name:    addressbook
Changes by:     Xavier Maillard <zeDek> 07/05/10 20:36:26

Modified files:
        .              : addressbook.el ChangeLog 

Log message:
        Use URL package again to fetch photo field

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/addressbook/addressbook.el?cvsroot=womb&r1=1.27&r2=1.28
http://cvs.savannah.gnu.org/viewcvs/addressbook/ChangeLog?cvsroot=womb&r1=1.25&r2=1.26

Patches:
Index: addressbook.el
===================================================================
RCS file: /sources/womb/addressbook/addressbook.el,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- addressbook.el      9 May 2007 12:12:45 -0000       1.27
+++ addressbook.el      10 May 2007 20:36:26 -0000      1.28
@@ -5,7 +5,7 @@
 ;; Maintainer: Jose E. Marchesi
 ;; Keywords: contacts, applications
 
-;; $Id: addressbook.el,v 1.27 2007/05/09 12:12:45 jemarch Exp $
+;; $Id: addressbook.el,v 1.28 2007/05/10 20:36:26 zeDek Exp $
 
 ;; This file is NOT part of GNU Emacs.
 
@@ -86,7 +86,8 @@
 
 (defgroup addrbook nil
   "Addressbook subsytem"
-  :group 'applications)
+  :group 'applications
+  :link '(url-link "http://www.emacswiki.org/cgi-bin/wiki/AddressBook";))
 
 (defgroup addrbook-hooks nil
   "Addressbook hooks"
@@ -838,11 +839,8 @@
 Only display it if not already displayed and/or image type is
 supported and if `display-images-p' is non nil.
 
-ATTR-INDEX can represent eith an inlined data or an offline url."
-  ;; Photographs has a type and may be:
-  ;;
-  ;; 1. Inline
-  ;; 2. Offline (URL)
+ATTR-INDEX can represent eith an inlined data or an offline url.
+When ressource is of type URL, we use url package to get the image data."
   (let* ((card (addrbook-get-card addrbook-current-card))
          (attr (vcard-get-attribute card attr-index))
          (attr-value (car (vcard-attr-get-values attr)))
@@ -855,6 +853,7 @@
     ;; Determine emacs image type
     (setq image-type
           (cadr (assoc photo-type addrbook-image-types)))
+
     ;; Display the image or a link
     (when (and addrbook-display-images
                (display-images-p)
@@ -866,18 +865,23 @@
       (let ((image-data
             (if (equal photo-value "url")
                 (save-excursion
-                  ;; FIXME: use a regexp to do pattern matching
-                  (let ((filename
-                         (if (string-match "\\`file:\\(.+\\)" attr-value)
-                             (match-string 1 attr-value))))
-                    (if (and filename (file-readable-p filename))
-                        (with-temp-buffer
-                          (insert-file-contents-literally filename)
-                          (string-as-unibyte (buffer-string))))))
+                  (require 'url)
+
+                  (let ((image-buffer (url-retrieve-synchronously attr-value)))
+                    (if image-buffer
+                        (unwind-protect
+                            (with-current-buffer image-buffer
+                              ;; FIXME: could be more robust
+                              (goto-char (point-min))
+                              (re-search-forward "^\r?$" nil 1)
+                              (forward-line)
+                              (delete-region (point-min) (point))
+
+                              (setq image-data (string-as-unibyte 
(buffer-string))))
+                          (kill-buffer image-buffer)))))
               attr-value)))
 
        ;; Display the image
-       ;; FIXME: hide photo filed when displaying image
        (save-excursion
          (goto-char (point-min))
          (goto-char (line-end-position))

Index: ChangeLog
===================================================================
RCS file: /sources/womb/addressbook/ChangeLog,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- ChangeLog   9 May 2007 12:12:45 -0000       1.25
+++ ChangeLog   10 May 2007 20:36:26 -0000      1.26
@@ -1,3 +1,11 @@
+2007-05-10  Xavier Maillard  <address@hidden>
+
+       * addressbook.el (addrbook-contact-display-attribute-photo-logo):
+       Introduce url package again so that we can fetch local or remote
+       image. Only require url when we are sure we need it and use
+       string-as-unibyte to get data.
+       (addrbook): Added :link property
+
 2007-05-09  Jose E. Marchesi  <address@hidden>
 
        * addressbook.el: outline-mode like headlines




reply via email to

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