Allow to preview LaTeX fragments in temporary buffers

* lisp/org.el (org-toggle-latex-fragment): Allow to preview fragments
  even when current buffer is not visiting a file.
This commit is contained in:
Nicolas Goaziou 2016-02-14 00:07:37 +01:00
parent caf66ea779
commit d846817f9d
2 changed files with 4 additions and 5 deletions

View File

@ -208,6 +208,7 @@ When defining a "columnview" dynamic block, it is now possible to add
an :indent parameter, much like the one in the clock table. an :indent parameter, much like the one in the clock table.
On the other hand, stars no longer appear in an ITEM field. On the other hand, stars no longer appear in an ITEM field.
*** Preview LaTeX snippets in buffers not visiting files
** New functions ** New functions
*** ~org-next-line-empty-p~ *** ~org-next-line-empty-p~
It replaces the deprecated ~next~ argument to ~org-previous-line-empty-p~. It replaces the deprecated ~next~ argument to ~org-previous-line-empty-p~.

View File

@ -18956,8 +18956,6 @@ headline. With a double prefix ARG \\[universal-argument] \
\\[universal-argument] preview or clear images \\[universal-argument] preview or clear images
for all fragments in the buffer." for all fragments in the buffer."
(interactive "P") (interactive "P")
(unless (buffer-file-name (buffer-base-buffer))
(user-error "Can't preview LaTeX fragment in a non-file buffer"))
(when (display-graphic-p) (when (display-graphic-p)
(catch 'exit (catch 'exit
(save-excursion (save-excursion
@ -19005,11 +19003,11 @@ for all fragments in the buffer."
(narrow-to-region beg end)))))) (narrow-to-region beg end))))))
(let ((file (buffer-file-name (buffer-base-buffer)))) (let ((file (buffer-file-name (buffer-base-buffer))))
(org-format-latex (org-format-latex
(concat org-latex-preview-ltxpng-directory (concat org-latex-preview-ltxpng-directory "org-ltxpng")
(file-name-sans-extension (file-name-nondirectory file)))
;; Emacs cannot overlay images from remote hosts. ;; Emacs cannot overlay images from remote hosts.
;; Create it in `temporary-file-directory' instead. ;; Create it in `temporary-file-directory' instead.
(if (file-remote-p file) temporary-file-directory (if (or (not file) (file-remote-p file))
temporary-file-directory
default-directory) default-directory)
'overlays msg 'forbuffer 'overlays msg 'forbuffer
org-latex-create-formula-image-program))) org-latex-create-formula-image-program)))