I use preview-latex for displaying LaTeX results in an Emacs window. I use preview-at-point to toggle back and forth between code and output. However if I am not on Latex code (by mistake, maybe I missed my intended line by one, or two) then preview-at-point tries to compile everything, brings up the "other" window, and fails. All this process slows things down.
My question is how can I disable this compilation (attempt)? If no toggling is possible, then preview should not do anything. Is there a setting for preview-latex for that? Or perhaps a function I can override?
error in process sentinel: LaTeX found no preview images
Thanks,
The real work is done by preview-region
so we can advise that to be a noop in certain cases. The following is not perfect since I don't think there is a way to know ahead of time what is going to previewed—the user can specify any environment or macro to be previewed. If, for example, you only care about math previews then you can remove the previewable-environments
pieces.
(defvar previewable-environments
"List of environments that should be previewed."
'("tabular" "tabular*" "tikzpicture" "..."))
(defadvice preview-region (around preview-at-point-no-long-pauses activate)
"Make `preview-at-point' a no-op if mark is inactive and point is not on a preview."
(when (or (not (eq this-command 'preview-at-point))
(TeX-active-mark)
(texmathp)
(member (LaTeX-current-environment) previewable-environments))
ad-do-it))