emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] [org-contacts] How to show avatar image on org headings?


From: stardiviner
Subject: Re: [O] [org-contacts] How to show avatar image on org headings?
Date: Wed, 09 May 2018 21:31:02 +0800
User-agent: mu4e 1.1.0; emacs 27.0.50

Hi, Kitchin, thanks for your sharing. Following your code example, I did
small modification to use on my case.

Here is my code:

#+begin_src emacs-lisp
(defvar image-overlay-re (concat
                          ":ICON:"
                          "\\(?3:'\\|\"\\)\\(?1:.*\\."
                          (regexp-opt '("png" "PNG"
                                        "jpg" "jpeg" "JPG" "JPEG"
                                        "gif" "GIF"
                                        "eps" "EPS"))
                          "\\)\\(?:\\3\\)")
  "Regexp to match image filenames in quotes")

(defun org-contacts-icon-property-image-overlay (&optional limit)
  (when (re-search-forward image-overlay-re limit t)
    (let ((beg (match-beginning 0))
          (end (match-end 0))
          (image-file (match-string 1)))
      (when (file-exists-p image-file)
        (setq org-contacts-icon-property-iimage (create-image (expand-file-name 
image-file)
                                                              'imagemagick nil 
:width 300))
        (setq org-contacts-icon-property-image-overlay (make-overlay beg end))
        (overlay-put org-contacts-icon-property-image-overlay 'display image)
        (overlay-put org-contacts-icon-property-image-overlay 'face 'default)
        (overlay-put org-contacts-icon-property-image-overlay 
'org-image-overlay t)
        (overlay-put org-contacts-icon-property-image-overlay 
'modification-hooks
                     (list 'org-display-inline-remove-overlay))))))

(font-lock-add-keywords
 nil
 '((org-contacts-icon-property-image-overlay (0 'font-lock-keyword-face t)))
 t)
#+end_src

But when I evaluate upper code, and re-enable org-mode on Contacts.org
file. The :ICON: property value "John.png" is not displayed as image. Is
there something wrong?

I choose to use overlay to auto display image when open org-contacts
file.

--
[ stardiviner ] don't need to convince with trends.
       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3



reply via email to

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