emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: stardiviner <numbchild@gmail.com>
To: John Kitchin <jkitchin@andrew.cmu.edu>
Cc: org-mode <emacs-orgmode@gnu.org>
Subject: Re: [org-contacts] How to show avatar image on org headings?
Date: Wed, 09 May 2018 21:31:02 +0800	[thread overview]
Message-ID: <87wowdx8fd.fsf@gmail.com> (raw)
In-Reply-To: <m2tvri97ng.fsf@andrew.cmu.edu>

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	other threads:[~2018-05-09 13:31 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 [this message]
2018-05-09 14:03   ` John Kitchin
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=87wowdx8fd.fsf@gmail.com \
    --to=numbchild@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=jkitchin@andrew.cmu.edu \
    /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).