* org-create-formula-image-with-imagemagick conflicts with org-latex-pdf-process
@ 2013-02-26 6:09 Florian Beck
2013-02-26 8:39 ` Nicolas Goaziou
0 siblings, 1 reply; 4+ messages in thread
From: Florian Beck @ 2013-02-26 6:09 UTC (permalink / raw)
To: emacs-orgmode
`org-create-formula-image-with-imagemagick' doesn't handle the case that
`org-latex-pdf-process' is set to a function.
To reproduce:
- set `org-latex-pdf-process' to a function
- (setq org-latex-create-formula-image-program 'imagemagick)
this makes preview fail
- set #+OPTIONS: latex:imagemagick => html export broken
However, just calling this function from
`org-create-formula-image-with-imagemagick' would not be a good idea.
How about adding a new variable `org-latex-formula-pdf-process'?
--
Florian Beck
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: org-create-formula-image-with-imagemagick conflicts with org-latex-pdf-process
2013-02-26 6:09 org-create-formula-image-with-imagemagick conflicts with org-latex-pdf-process Florian Beck
@ 2013-02-26 8:39 ` Nicolas Goaziou
2013-02-26 11:37 ` Florian Beck
0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Goaziou @ 2013-02-26 8:39 UTC (permalink / raw)
To: Florian Beck; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 708 bytes --]
Hello,
Florian Beck <fb@miszellen.de> writes:
> `org-create-formula-image-with-imagemagick' doesn't handle the case that
> `org-latex-pdf-process' is set to a function.
>
> To reproduce:
>
> - set `org-latex-pdf-process' to a function
> - (setq org-latex-create-formula-image-program 'imagemagick)
> this makes preview fail
> - set #+OPTIONS: latex:imagemagick => html export broken
>
> However, just calling this function from
> `org-create-formula-image-with-imagemagick' would not be a good idea.
> How about adding a new variable `org-latex-formula-pdf-process'?
What about re-using the existing tool from "ox-latex.el"? What do you
think of the following patch?
Regards,
--
Nicolas Goaziou
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Use-org-latex-compile-when-processing-formulas-with-.patch --]
[-- Type: text/x-patch, Size: 5236 bytes --]
From 40dabf94dae93d2935982a7d04f3b7804069b733 Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <n.goaziou@gmail.com>
Date: Tue, 26 Feb 2013 09:28:59 +0100
Subject: [PATCH] Use `org-latex-compile' when processing formulas with
imagemagick
* lisp/ox-latex.el (org-latex-compile): Add an optional argument for
latex snippet previewing.
* lisp/org.el (org-create-formula-image-with-imagemagick): Use
`org-latex-compile' instead of rewriting it.
---
lisp/org.el | 36 ++----------------------------------
lisp/ox-latex.el | 15 ++++++++++-----
2 files changed, 12 insertions(+), 39 deletions(-)
diff --git a/lisp/org.el b/lisp/org.el
index 55cd00e..03bd8f3 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -18167,7 +18167,7 @@ share a good deal of logic."
(delete-file (concat texfilebase e))))
pngfile))))
-(defvar org-latex-pdf-process) ; From ox-latex.el
+(declare-function org-latex-compile "org-latex" (texfile &optional snippet))
(defun org-create-formula-image-with-imagemagick (string tofile options buffer)
"This calls convert, which is included into imagemagick."
(require 'ox-latex)
@@ -18204,39 +18204,7 @@ share a good deal of logic."
string
"\n}\n"
"\n\\end{document}\n")))
- (let ((dir default-directory) cmd cmds latex-frags-cmds)
- (condition-case nil
- (progn
- (cd tmpdir)
- (setq cmds org-latex-pdf-process)
- (while cmds
- (setq latex-frags-cmds (pop cmds))
- (if (listp latex-frags-cmds)
- (setq cmds nil)
- (setq latex-frags-cmds (list (car org-latex-pdf-process)))))
- (while latex-frags-cmds
- (setq cmd (pop latex-frags-cmds))
- (while (string-match "%b" cmd)
- (setq cmd (replace-match
- (save-match-data
- (shell-quote-argument texfile))
- t t cmd)))
- (while (string-match "%f" cmd)
- (setq cmd (replace-match
- (save-match-data
- (shell-quote-argument
- (file-name-nondirectory texfile)))
- t t cmd)))
- (while (string-match "%o" cmd)
- (setq cmd (replace-match
- (save-match-data
- (shell-quote-argument
- (file-name-directory texfile)))
- t t cmd)))
- (setq cmd (split-string cmd))
- (eval (append (list 'call-process (pop cmd) nil nil nil) cmd))))
- (error nil))
- (cd dir))
+ (org-latex-compile texfile t)
(if (not (file-exists-p pdffile))
(progn (message "Failed to create pdf file from %s" texfile) nil)
(condition-case nil
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 3b0924c..5ebfe7e 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -2774,12 +2774,16 @@ Return PDF file's name."
(org-latex-export-to-latex
nil subtreep visible-only body-only ext-plist))))
-(defun org-latex-compile (texfile)
+(defun org-latex-compile (texfile &optional snippet)
"Compile a TeX file.
TEXFILE is the name of the file being compiled. Processing is
done through the command specified in `org-latex-pdf-process'.
+When optional argument SNIPPET is non-nil, TEXFILE is a temporary
+file used to preview a LaTeX snippet. In this case, do not
+create a log buffer and do not bother removing log files.
+
Return PDF file name or an error if it couldn't be produced."
(let* ((base-name (file-name-sans-extension (file-name-nondirectory texfile)))
(full-name (file-truename texfile))
@@ -2788,7 +2792,7 @@ Return PDF file name or an error if it couldn't be produced."
;; not to whatever value the current buffer may have.
(default-directory (file-name-directory full-name))
errors)
- (message (format "Processing LaTeX file %s ..." texfile))
+ (unless snippet (message (format "Processing LaTeX file %s ..." texfile)))
(save-window-excursion
(cond
;; A function is provided: Apply it.
@@ -2798,7 +2802,8 @@ Return PDF file name or an error if it couldn't be produced."
;; values in each command before applying it. Output is
;; redirected to "*Org PDF LaTeX Output*" buffer.
((consp org-latex-pdf-process)
- (let ((outbuf (get-buffer-create "*Org PDF LaTeX Output*")))
+ (let ((outbuf (and (not snippet)
+ (get-buffer-create "*Org PDF LaTeX Output*"))))
(mapc
(lambda (command)
(shell-command
@@ -2811,7 +2816,7 @@ Return PDF file name or an error if it couldn't be produced."
outbuf))
org-latex-pdf-process)
;; Collect standard errors from output buffer.
- (setq errors (org-latex--collect-errors outbuf))))
+ (setq errors (and (not snippet) (org-latex--collect-errors outbuf)))))
(t (error "No valid command to process to PDF")))
(let ((pdffile (concat out-dir base-name ".pdf")))
;; Check for process failure. Provide collected errors if
@@ -2821,7 +2826,7 @@ Return PDF file name or an error if it couldn't be produced."
(when errors (concat ": " errors))))
;; Else remove log files, when specified, and signal end of
;; process to user, along with any error encountered.
- (when org-latex-remove-logfiles
+ (when (and (not snippet) org-latex-remove-logfiles)
(dolist (ext org-latex-logfiles-extensions)
(let ((file (concat out-dir base-name "." ext)))
(when (file-exists-p file) (delete-file file)))))
--
1.8.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: org-create-formula-image-with-imagemagick conflicts with org-latex-pdf-process
2013-02-26 8:39 ` Nicolas Goaziou
@ 2013-02-26 11:37 ` Florian Beck
2013-02-26 12:47 ` Nicolas Goaziou
0 siblings, 1 reply; 4+ messages in thread
From: Florian Beck @ 2013-02-26 11:37 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode
Hello Nicolas,
> What about re-using the existing tool from "ox-latex.el"? What do you
> think of the following patch?
Very highly, this works perfectly. Thank you.
Unfortunatly, html export doesn't support imagemagick yet.
`org-html-latex-fragment' and `org-html-latex-environment' only handle
mathjax and dvipng. (I've added imagemagick to the dvipng case, and this
seems to work without any problems.)
--
Florian Beck
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: org-create-formula-image-with-imagemagick conflicts with org-latex-pdf-process
2013-02-26 11:37 ` Florian Beck
@ 2013-02-26 12:47 ` Nicolas Goaziou
0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Goaziou @ 2013-02-26 12:47 UTC (permalink / raw)
To: Florian Beck; +Cc: emacs-orgmode
Florian Beck <fb@miszellen.de> writes:
> Very highly, this works perfectly. Thank you.
Patch applied.
> Unfortunatly, html export doesn't support imagemagick yet.
> `org-html-latex-fragment' and `org-html-latex-environment' only handle
> mathjax and dvipng. (I've added imagemagick to the dvipng case, and this
> seems to work without any problems.)
Do you want to prepare a patch for that?
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-02-26 12:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-26 6:09 org-create-formula-image-with-imagemagick conflicts with org-latex-pdf-process Florian Beck
2013-02-26 8:39 ` Nicolas Goaziou
2013-02-26 11:37 ` Florian Beck
2013-02-26 12:47 ` Nicolas Goaziou
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).