For below org mode code example:

#+BEGIN_SRC plantuml :file test.png
Alice -> Bob: synchronous call
Alice ->> Bob: asynchronous call


After press C-c C-c, the result is as above. If I need to show it as image, I have to run "M-x org-display-inline-image" command.

Is it possible to combine the "C-c C-c" and "M-x org-display-inline-image" together? It's better to still use "C-c C-c" shortcut.

  • If you are just looking to always have the image inlined, you can put #+STARTUP: inlineimages somewhere in your org file. (And C-c C-c that so you don't need to reopen your buffer) – Archenoth Feb 7 '17 at 17:19
  • 1
    @Archenoth Actually my cause is: 1. Update source code. 2. Press C-c C-c to execute the code. 3. Output is text but not image. I wish everytime after press C-c C-c, I can get the image displayed inline. Your suggestion works if user didn't change the code. – beetlej Feb 7 '17 at 17:56
  • Thank you for reminding me! I had forgotten I had already done something about this. – Archenoth Feb 7 '17 at 22:06

Why not redefine C-c C-c in Org mode then? Use this keybinding. Put it in your emacs init.el file and restart emacs:

(define-key org-mode-map (kbd "C-c C-c")
  (lambda () (interactive) (org-ctrl-c-ctrl-c)

addendum: is this global or local?

Local to org-mode only.

  • Sounds like return a error: Wrong type argument: listp, t. BTW, will this redefine globally or just for org mode? – beetlej Feb 7 '17 at 19:42
  • @beetlej try tweak it as below: (define-key org-mode-map (kbd "C-c C-c") (lambda () (interactive) (org-ctrl-c-ctrl-c) (org-display-inline-images))) – lucky1928 Feb 7 '17 at 20:49
  • local only, also fixed the error typo in the answer above – Emacs User Feb 7 '17 at 20:53
  • For me it's working with org-display-inline-images. – Bas Peeters Apr 2 '20 at 17:22

There is both a hook for evaluating code blocks (org-babel-after-execute-hook), and a function for updating inline images. (org-redisplay-inline-images)

Combine these two and you should be good to go!

(add-hook 'org-babel-after-execute-hook 'org-redisplay-inline-images)

C-c C-c updating inline images

  • 1
    Great, it works also. BTW, is org-babel-after-execute-hook for all org command or just for this command? maybe I only wish to hook C-c C-c command but not others! – beetlej Feb 8 '17 at 16:21
  • 1
    This hook will only affect code blocks in Org buffers. Actually, if you wanted to do more then that, you would need to do a bit of extra work. – Archenoth Feb 8 '17 at 16:56
  • 3
    WOW!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! THANK YOU! – Guilherme Salomé Aug 2 '19 at 20:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.