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: John Kitchin
Subject: Re: [O] [org-contacts] How to show avatar image on org headings?
Date: Wed, 9 May 2018 07:03:25 -0700

there are a couple of typos in your code, and the regexp doesn't seem to match the property you want for some reason. 

This seems to do what you want.

#+begin_src emacs-lisp
(defun org-contacts-icon-property-image-overlay (&optional limit)
  (when (re-search-forward org-heading-regexp limit t)
    (let ((beg (match-beginning 0))
          (end (match-end 0))
          (image-file (org-entry-get nil "ICON"))
  org-contacts-icon-property-image
  org-contacts-icon-property-image-overlay)
      (when (and (not (ov-at beg)) (file-exists-p image-file))
        (setq org-contacts-icon-property-image (create-image (expand-file-name image-file)
     'imagemagick nil :width 100))
        (setq org-contacts-icon-property-image-overlay (make-overlay beg (+ 1 beg)))
(overlay-put org-contacts-icon-property-image-overlay 'before-string (propertize " "
                    'display org-contacts-icon-property-image))
        (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 

John

-----------------------------------
Professor John Kitchin 
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803

On Mon, May 7, 2018 at 7:57 PM, John Kitchin <address@hidden> wrote:
you might find this
http://kitchingroup.cheme.cmu.edu/blog/2016/03/21/Displaying-image-overlays-on-image-filenames-in-Emacs/
potentially useful for what you want.

stardiviner writes:

> I want to show org-contacts avatar image on org-headings.
> Use overlay, or there is other better methods?
>
> A sample org-contacts snippet looks like this:
>
> * [] John KK
> :PROPERTIES:
> :AVATAR: john kk.jpg []
> :END:
>
> I want to display the image at [] on heading, or replace "john kk.jpg"
> with [] image.
>
> BTW, another question, how to get property's value? and how to iterate
> on all heading elements then auto display image when open Contacts.org
> file?


--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu


reply via email to

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