I have the path to a pdf file or a png file (whichever is easiest to show, but bonus points for showing both).

How do I show the image in a new buffer? (It makes no sense to show it inline since it is a graph representation of the makefile I am writing.)

2 Answers 2


You should be able to open the file directly - C-x C-f, and Emacs will display it as you expect.

If you're running GNU/Linux, the pdf-tools package provides a much-improved experience for viewing pdfs than the built-in Emacs viewer. pdf-tools isn't available for Windows, and I think may require some extra work on to get it running on Macs (?).

To do this in an elisp program, use the function (find-file <path>), where is the path to your file, as a string. e.g., (find-file "~/.emacs.d/init.el") will open your init file.

  • Is there a way to open the file like that, but in a function? Thanks, btw. Apr 15, 2016 at 14:29
  • Yes, see the revised answer.
    – Tyler
    Apr 15, 2016 at 14:42
  • And I was messing around with image-mode and similar. Much too easy. Apr 15, 2016 at 17:28

As an alternative to find-file, if the image is referenced by URL, then browse-url-emacs is also an option.

(browse-url-emacs url)

Will download the image and generate a temporary buffer displaying it inline.

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.