emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/org-contacts 00560d5f4f 117/154: Try to support differe


From: ELPA Syncer
Subject: [elpa] externals/org-contacts 00560d5f4f 117/154: Try to support different type of AVATAR property.
Date: Fri, 9 Sep 2022 15:58:53 -0400 (EDT)

branch: externals/org-contacts
commit 00560d5f4fbc78098565339039f9cac1b3608a69
Author: stardiviner <numbchild@gmail.com>
Commit: stardiviner <numbchild@gmail.com>

    Try to support different type of AVATAR property.
    
    - Support [[file:dir/filename.png]] link
    - Support empty value
    - Support default value
---
 org-contacts.el | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/org-contacts.el b/org-contacts.el
index 551e1e7aa4..a167ad2e79 100644
--- a/org-contacts.el
+++ b/org-contacts.el
@@ -898,13 +898,24 @@ address."
   (setq pom (or pom (point)))
   (catch 'icon
     ;; Use `org-contacts-icon-property'
-    (let ((image-data (org-entry-get pom org-contacts-icon-property)))
-      (when image-data
+    (let ((image-path (let ((avatar (org-entry-get pom 
org-contacts-icon-property))
+                            (link-matcher-regexp 
"\\[\\[\\([^]]*\\)\\]\\(\\[\\(.*\\)\\]\\)?\\]"))
+                        (cond
+                         ;; [[file:dir/filename.png]]
+                         ((string-match-p "\\[\\[.*\\]\\]" avatar)
+                          (when (string-match link-matcher-regexp avatar)
+                            (expand-file-name (substring 
(match-string-no-properties 1 avatar) 5 nil)
+                                              (file-name-directory (first 
org-contacts-files)))))
+                         ;; "" (empty string)
+                         ((string-empty-p avatar) nil)
+                         (t (expand-file-name avatar (file-name-directory 
(first org-contacts-files))))))))
+      (when image-path
         (throw 'icon
                (if (fboundp 'gnus-rescale-image)
-                   (gnus-rescale-image (create-image image-data)
+                   ;; FIXME `gnus-rescale-image' does not support rescale 
`create-image' spec.
+                   (gnus-rescale-image (create-image image-path)
                                        (cons org-contacts-icon-size 
org-contacts-icon-size))
-                 (create-image image-data)))))
+                 (create-image image-path)))))
     ;; Next, try Gravatar
     (when org-contacts-icon-use-gravatar
       (let* ((gravatar-size org-contacts-icon-size)



reply via email to

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