diff options
author | Bastien Guerry <bzg@altern.org> | 2014-07-28 01:24:56 +0200 |
---|---|---|
committer | Bastien Guerry <bzg@altern.org> | 2014-07-28 01:24:56 +0200 |
commit | 9139521186ca5c130d74ef7f44fa325434c9cdcc (patch) | |
tree | 9ff5d00a85c2606f737481e56ac19c1fb7d158bd | |
parent | 96323cf2aa1f25f75eb13a49501aa185c8719fd3 (diff) | |
download | org-mode-9139521186ca5c130d74ef7f44fa325434c9cdcc.tar.gz |
Complete commit 9e006d11
* org.el (org-preview-latex-fragment): Remove LaTeX fragments
overlays when they are displayed. Fix message.
-rw-r--r-- | lisp/org.el | 67 |
1 files changed, 35 insertions, 32 deletions
diff --git a/lisp/org.el b/lisp/org.el index 2a71037..825d76c 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -18563,38 +18563,41 @@ The images can be removed again with \\[org-ctrl-c-ctrl-c]." (interactive "P") (unless buffer-file-name (user-error "Can't preview LaTeX fragment in a non-file buffer")) - (when (display-graphic-p) - (org-remove-latex-fragment-image-overlays) - (save-excursion - (save-restriction - (let (beg end at msg) - (cond - ((or (equal subtree '(16)) - (not (save-excursion - (re-search-backward org-outline-regexp-bol nil t)))) - (setq beg (point-min) end (point-max) - msg "Creating images for buffer...%s")) - ((equal subtree '(4)) - (org-back-to-heading) - (setq beg (point) end (org-end-of-subtree t) - msg "Creating images for subtree...%s")) - (t - (if (setq at (org-inside-LaTeX-fragment-p)) - (goto-char (max (point-min) (- (cdr at) 2))) - (org-back-to-heading)) - (setq beg (point) end (progn (outline-next-heading) (point)) - msg (if at "Creating image...%s" - "Creating images for entry...%s")))) - (message msg "") - (narrow-to-region beg end) - (goto-char beg) - (org-format-latex - (concat org-latex-preview-ltxpng-directory (file-name-sans-extension - (file-name-nondirectory - buffer-file-name))) - default-directory 'overlays msg at 'forbuffer - org-latex-create-formula-image-program) - (message msg "done. Use `C-c C-c' to remove images.")))))) + (if org-latex-fragment-image-overlays + (progn (org-remove-latex-fragment-image-overlays) + (message "LaTeX fragments images removed")) + (when (display-graphic-p) + (org-remove-latex-fragment-image-overlays) + (save-excursion + (save-restriction + (let (beg end at msg) + (cond + ((or (equal subtree '(16)) + (not (save-excursion + (re-search-backward org-outline-regexp-bol nil t)))) + (setq beg (point-min) end (point-max) + msg "Creating images for buffer...%s")) + ((equal subtree '(4)) + (org-back-to-heading) + (setq beg (point) end (org-end-of-subtree t) + msg "Creating images for subtree...%s")) + (t + (if (setq at (org-inside-LaTeX-fragment-p)) + (goto-char (max (point-min) (- (cdr at) 2))) + (org-back-to-heading)) + (setq beg (point) end (progn (outline-next-heading) (point)) + msg (if at "Creating image...%s" + "Creating images for entry...%s")))) + (message msg "") + (narrow-to-region beg end) + (goto-char beg) + (org-format-latex + (concat org-latex-preview-ltxpng-directory + (file-name-sans-extension + (file-name-nondirectory buffer-file-name))) + default-directory 'overlays msg at 'forbuffer + org-latex-create-formula-image-program) + (message msg "done. Use `C-c C-x C-l' to remove images."))))))) (defun org-format-latex (prefix &optional dir overlays msg at forbuffer processing-type) |