I want the image tooltip code also make work for pdf format, thus I added the pdf keyword to the file extension list of the original code (http://kitchingroup.cheme.cmu.edu/blog/2016/03/21/Displaying-image-overlays-on-image-filenames-in-Emacs/#sec-1)). However it doesn't work with pdf. How can I make this work?
(defvar image-tooltip-re (concat "\\(?3:'\\|\"\\)\\(?1:.*\\."
(regexp-opt '("png" "PNG" "JPG" "jpeg"
"jpg" "JPEG" "eps" "EPS" "pdf"))
"\\)\\(?:\\3\\)")
"Regexp to match image filenames in quotes")
(defun image-tooltip (window object position)
(save-excursion
(goto-char position)
(let (beg end imgfile img s)
(while (not (looking-at image-tooltip-re))
(forward-char -1))
(setq imgfile (match-string-no-properties 1))
(when (file-exists-p imgfile)
(setq img (create-image (expand-file-name imgfile)
'imagemagick nil :width 200))
(propertize "Look in the minibuffer"
'display img)))))
(font-lock-add-keywords
nil
`((,image-tooltip-re
0 '(face font-lock-keyword-face
help-echo image-tooltip))))
(font-lock-fontify-buffer)
(setq x-gtk-use-system-tooltips nil)
"tikz-standalone.pdf"
I think the imagemagick backend should support it, for example I can do display file.pdf
from command line.
pdf-tools
installed, you can use the functionpdf-info-renderpage
, but take of thefile-or-data-p
argument tocreate-image
.(memq 'PDF (imagemagick-types))
returnst
here. So it is supported, even though it takes an unusual amount of time until the tooltip is displayed (~5s).