>> Would you like this to be part of org.el or should I spin out an >> org-image-preview.el feature+library? > > Spin out will be easier when for my rebase :) Please find attached the draft of a patch implementing a general link-preview system. ---- The idea is the following: 1. Introduce the :preview link parameter. This is a function that is passed an overlay placed over a link (along with some other link details) and should adorn the overlay however the link should be previewed. Typically this is by adding an image to the overlay, but it can be more general. This has a few advantages over the current system: - The code is much more modular. - Previewing image links is no longer "special": all links can have custom preview behavior. Users or package authors can specify how they want each link type to be previewed. - About 300 lines of code have been moved out of org.el, with more removals to come (details below). 2. A :preview function for links of type "file" or "attachment" is provided -- it is the old org-display-inline-images function, but broken up into a couple of more modular functions. - Note: the new preview behavior for image files should be identical, no changes or breaking changes are expected. 3. Introduce a new org-link-preview command. This command has the same prefix arg behaviors as org-latex-preview, and previews each link using its :preview function. This is a drop-in replacement for org-toggle-inline-images-command and org-toggle-inline-images. org-toggle-inline-images-command has been removed, and org-toggle-inline-images has been moved to org-compat. There are a couple of other commands for use from elisp: org-link-preview-region and org-link-preview-clear. Advantages: - Uniform preview behavior across Org preview types (links, latex) - Can preview individual links, links in the section or across the buffer. - Can preview, refresh existing previews or disable them independently using different prefix arg behaviors (no need to toggle/run twice). 4. Bind C-c C-x C-v to org-link-preview. ---- Organization: I didn't create a new feature/library: All the link-preview code is part of ol.el. I think it fits well there. I can move the code for creating and examining images from org.el to a new org-image.el or org-image-utils.el library if required. ---- Not yet handled or final: - Link abbreviations: I'm using org-link-any-re to find links, and this appears to be handling link abbreviations fine. So there is no special code to handle link abbreviations. But I'm not sure. - Updating NEWS and the manual. I can do this at the end, before merging. - The calling convention for the :preview function is not final. Right now it is given the overlay, the link type and the link path. But other link details can be required -- for example, image links need to read the org keywords for the image width and alignment, so I end up calling (org-element-context) again inside the :preview function. ---- I'll send a short example of using org-link-preview to asynchronously preview youtube links as thumbnails soon. Karthik