emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: John Kitchin <jkitchin@andrew.cmu.edu>
To: stardiviner <numbchild@gmail.com>
Cc: org-mode <emacs-orgmode@gnu.org>
Subject: Re: [org-contacts] How to show avatar image on org headings?
Date: Wed, 9 May 2018 07:03:25 -0700	[thread overview]
Message-ID: <CAJ51ETodxeZg5Ru-Xt9S90ogTa7p+XrDDFWvzXYw3j-jCpGgMA@mail.gmail.com> (raw)
In-Reply-To: <m2tvri97ng.fsf@andrew.cmu.edu>

[-- Attachment #1: Type: text/plain, Size: 2494 bytes --]

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
@johnkitchin
http://kitchingroup.cheme.cmu.edu


On Mon, May 7, 2018 at 7:57 PM, John Kitchin <jkitchin@andrew.cmu.edu>
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
>

[-- Attachment #2: Type: text/html, Size: 4054 bytes --]

  parent reply	other threads:[~2018-05-09 14:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-07  2:00 [org-contacts] How to show avatar image on org headings? stardiviner
2018-05-08  2:57 ` John Kitchin
2018-05-09 13:31   ` stardiviner
2018-05-09 14:03   ` John Kitchin [this message]
2018-05-10  1:20     ` stardiviner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJ51ETodxeZg5Ru-Xt9S90ogTa7p+XrDDFWvzXYw3j-jCpGgMA@mail.gmail.com \
    --to=jkitchin@andrew.cmu.edu \
    --cc=emacs-orgmode@gnu.org \
    --cc=numbchild@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).