I use openwith to open images and a number of other types of files in external applications.

It works a treat, but gets in the way of displaying inline images in org-mode buffers: When I do C-c C-x C-v (org-toggle-inline-images) with openwith-mode turned on, the first image file linked in the current buffer is opened in an external viewer. The contents of the buffer itself don't change, i.e., no images are displayed inside the buffer.

Q: How can I stop openwith-mode from interfering with the display of inline images in org-mode?

1 Answer 1


Internally, org-toggle-inline-images calls org-display-inline-images to handle display of inline images. You can advise this function to turn off openwith-mode while it is doing its thing, and to turn it back on afterwards:

(defadvice org-display-inline-images
  (around handle-openwith
          (&optional include-linked refresh beg end) activate compile)
  (if openwith-mode
        (openwith-mode -1)
        (openwith-mode 1))

With this in place, no external viewers are opened when doing C-c C-x C-v in an org-mode buffer containing inline images.

  • 1
    Was just about to suggest advice. Might I suggest one modification to test whether or not openwith-mode is t before toggling it off and on? With the current code, you would inadvertently turn on openwith-mode if it were off before you called org-display-inline-images.
    – Dan
    Commented Nov 6, 2014 at 13:26
  • @Dan Good idea, thanks! I modified the code accordingly.
    – itsjeyd
    Commented Nov 6, 2014 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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