Fix AVATAR property value not exist problem

This commit is contained in:
stardiviner 2021-10-30 18:19:56 +08:00
parent c8408cf44e
commit 038a608e79

View file

@ -898,17 +898,17 @@ address."
(setq pom (or pom (point))) (setq pom (or pom (point)))
(catch 'icon (catch 'icon
;; Use `org-contacts-icon-property' ;; Use `org-contacts-icon-property'
(let ((image-path (let ((avatar (org-entry-get pom org-contacts-icon-property)) (let ((image-path (if-let ((avatar (org-entry-get pom org-contacts-icon-property))
(link-matcher-regexp "\\[\\[\\([^]]*\\)\\]\\(\\[\\(.*\\)\\]\\)?\\]")) (link-matcher-regexp "\\[\\[\\([^]]*\\)\\]\\(\\[\\(.*\\)\\]\\)?\\]"))
(cond (cond
;; [[file:dir/filename.png]] ;; [[file:dir/filename.png]]
((string-match-p "\\[\\[.*\\]\\]" avatar) ((string-match-p "\\[\\[.*\\]\\]" avatar)
(when (string-match link-matcher-regexp avatar) (when (string-match link-matcher-regexp avatar)
(expand-file-name (substring (match-string-no-properties 1 avatar) 5 nil) (expand-file-name (substring (match-string-no-properties 1 avatar) 5 nil)
(file-name-directory (first org-contacts-files))))) (file-name-directory (first org-contacts-files)))))
;; "" (empty string) ;; "" (empty string)
((string-empty-p avatar) nil) ((string-empty-p avatar) nil)
(t (expand-file-name avatar (file-name-directory (first org-contacts-files)))))))) (t (expand-file-name avatar (file-name-directory (first org-contacts-files))))))))
(when image-path (when image-path
(throw 'icon (throw 'icon
(if (featurep 'imagemagick) (if (featurep 'imagemagick)