* Problem exporting to LaTeX/PDF from command line @ 2010-04-19 15:49 Francesco Pizzolante [not found] ` <87d3xv5to7.fsf-pwAqS3aGAJQybS5Ee8rs3A@public.gmane.org> 0 siblings, 1 reply; 4+ messages in thread From: Francesco Pizzolante @ 2010-04-19 15:49 UTC (permalink / raw) To: mailing-list-org-mode Hi, I'm trying to write a shell script in order to convert/export Org files to LaTeX/PDF from the command line (org2tex/org2pdf). The whole process works well, except that it seems that some bits of the exportation are not executed. Here's an example of what I do. I'm using the org-interaction.el file from Blorgit: --8<---------------cut here---------------start------------->8--- (require 'org) (require 'cl) (setq font-lock-mode t) (defun refresh-then-find-file (file) "Find file ensuring that the latest changes on disk are represented in the file." (let (file-buf) (while (setq file-buf (get-file-buffer file)) (kill-buffer file-buf)) (find-file file))) (defmacro with-temp-filebuffer (file &rest body) "Open FILE into a temporary buffer execute BODY there like `progn', then kill the FILE buffer returning the result of evaluating BODY." (let ((temp-result (make-symbol "temp-result")) (temp-file (make-symbol "temp-file"))) `(let (,temp-result ,temp-file) (refresh-then-find-file ,file) (setf ,temp-file (current-buffer)) (setf ,temp-result (progn ,@body)) (kill-buffer ,temp-file) ,temp-result))) ;; (defvar org-interaction-prefix ".exported_") (defvar org-interaction-prefix "") (defun org-file-to-html (file-path) "Open up an org file, publish it to html, and then return the html as a string." (let* ((file-name (file-name-nondirectory file-path)) (file-dir (file-name-directory file-path)) (html-path (expand-file-name (concat org-interaction-prefix file-name) file-dir))) (if (and (file-exists-p html-path) (< 0 (time-to-seconds (time-subtract (nth 5 (file-attributes html-path)) (nth 5 (file-attributes file-path)))))) html-path (with-temp-filebuffer file-path (org-mode) (save-window-excursion (org-export-as-html-to-buffer nil) (write-file html-path) (kill-buffer (current-buffer))))))) (defun org-file-to-latex (file-path) "Open up an org file, publish it to latex, and then return the latex as a string." (let* ((file-name (file-name-nondirectory file-path)) (file-dir (file-name-directory file-path)) (latex-path (expand-file-name (concat org-interaction-prefix file-name ".tex") file-dir))) (if (and (file-exists-p latex-path) (< 0 (time-to-seconds (time-subtract (nth 5 (file-attributes latex-path)) (nth 5 (file-attributes file-path)))))) latex-path (with-temp-filebuffer file-path (org-mode) (save-window-excursion (org-export-as-latex-to-buffer nil) (write-file latex-path) (kill-buffer (current-buffer))))))) (defun org-file-to-pdf (file-path) "Open up an org file and export it as pdf." (let* ((file-name (file-name-sans-extension file-path)) (file-dir (file-name-directory file-path)) (org-tmp-path (make-temp-file "org-file-to-pdf-")) (pdf-tmp-path (concat org-tmp-path ".pdf")) (tex-tmp-path (concat org-tmp-path ".tex")) (pdf-path (expand-file-name (concat org-interaction-prefix file-name ".pdf") file-dir))) (if (and (file-exists-p pdf-path) (< 0 (time-to-seconds (time-subtract (nth 5 (file-attributes pdf-path)) (nth 5 (file-attributes file-path)))))) pdf-path (with-temp-filebuffer file-path (write-file org-tmp-path) (org-mode) (save-window-excursion (org-export-as-pdf nil) (rename-file pdf-tmp-path pdf-path t) (delete-file org-tmp-path) ;; (delete-file tex-tmp-path) (kill-buffer (current-buffer))))))) ;; customization ;; (setq org-export-blocks-witheld '(hidden comment)) ;; Start the server ;; (server-start) ;; save the emacsclient server socket location ;; (with-temp-file "/tmp/emacsclient-socket-dir" ;; (insert server-socket-dir)) --8<---------------cut here---------------end--------------->8--- Here's the file I'm trying to convert (test.org): --8<---------------cut here---------------start------------->8--- #+TITLE: Features report #+AUTHOR: Francesco Pizzolante #+EMAIL: fpz-djc/iPCCuDYQheJpep6IedvLeJWuRmrY@public.gmane.org #+DATE: 2010-04-19 #+DESCRIPTION: #+KEYWORDS: #+LANGUAGE: en_US #+LaTeX_CLASS_OPTIONS: [a4paper] * First test ** tatatata --8<---------------cut here---------------end--------------->8--- On the command line, I run the following command: --8<---------------cut here---------------start------------->8--- emacs --batch -l org-interaction.el --eval "(org-file-to-latex \"~/test.org\")" --8<---------------cut here---------------end--------------->8--- My observation is that the #+LATEX_CLASS_OPTIONS are not taken into account. I can add any option there, I always see the default one (11pt). It is really strange because if I add a #+LATEX_CLASS directive, this one is well taken into account and I get the desired class. I don't know whether it's a bug somewhere or whether I miss some arguments somewhere... I also tested whith Blorgit and it is the same behavior (options not exported). Thanks a lot for your help, Francesco _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode-mXXj517/zsQ@public.gmane.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <87d3xv5to7.fsf-pwAqS3aGAJQybS5Ee8rs3A@public.gmane.org>]
* Re: Problem exporting to LaTeX/PDF from command line [not found] ` <87d3xv5to7.fsf-pwAqS3aGAJQybS5Ee8rs3A@public.gmane.org> @ 2010-04-20 8:06 ` Francesco Pizzolante 2010-04-20 15:12 ` Nick Dokos 0 siblings, 1 reply; 4+ messages in thread From: Francesco Pizzolante @ 2010-04-20 8:06 UTC (permalink / raw) To: mailing-list-org-mode Hi, I forgot to mention that, of course, when I do the same operation within Emacs, using the C-c C-e l, the file is exported without problem. Any idea? Thanks, Francesco Francesco Pizzolante wrote: > Hi, > > I'm trying to write a shell script in order to convert/export Org files to > LaTeX/PDF from the command line (org2tex/org2pdf). The whole process works > well, except that it seems that some bits of the exportation are not executed. > > Here's an example of what I do. > > I'm using the org-interaction.el file from Blorgit: > > (require 'org) > (require 'cl) > > (setq font-lock-mode t) > > (defun refresh-then-find-file (file) > "Find file ensuring that the latest changes on disk are > represented in the file." > (let (file-buf) > (while (setq file-buf (get-file-buffer file)) > (kill-buffer file-buf)) > (find-file file))) > > (defmacro with-temp-filebuffer (file &rest body) > "Open FILE into a temporary buffer execute BODY there like > `progn', then kill the FILE buffer returning the result of > evaluating BODY." > (let ((temp-result (make-symbol "temp-result")) > (temp-file (make-symbol "temp-file"))) > `(let (,temp-result ,temp-file) > (refresh-then-find-file ,file) > (setf ,temp-file (current-buffer)) > (setf ,temp-result (progn ,@body)) > (kill-buffer ,temp-file) > ,temp-result))) > > ;; (defvar org-interaction-prefix ".exported_") > (defvar org-interaction-prefix "") > > (defun org-file-to-html (file-path) > "Open up an org file, publish it to html, and then return the > html as a string." > (let* ((file-name (file-name-nondirectory file-path)) > (file-dir (file-name-directory file-path)) > (html-path (expand-file-name (concat org-interaction-prefix file-name) file-dir))) > (if (and (file-exists-p html-path) > (< 0 (time-to-seconds > (time-subtract > (nth 5 (file-attributes html-path)) > (nth 5 (file-attributes file-path)))))) > html-path > (with-temp-filebuffer > file-path > (org-mode) > (save-window-excursion > (org-export-as-html-to-buffer nil) > (write-file html-path) > (kill-buffer (current-buffer))))))) > > (defun org-file-to-latex (file-path) > "Open up an org file, publish it to latex, and then return the > latex as a string." > (let* ((file-name (file-name-nondirectory file-path)) > (file-dir (file-name-directory file-path)) > (latex-path (expand-file-name (concat org-interaction-prefix file-name ".tex") file-dir))) > (if (and (file-exists-p latex-path) > (< 0 (time-to-seconds > (time-subtract > (nth 5 (file-attributes latex-path)) > (nth 5 (file-attributes file-path)))))) > latex-path > (with-temp-filebuffer > file-path > (org-mode) > (save-window-excursion > (org-export-as-latex-to-buffer nil) > (write-file latex-path) > (kill-buffer (current-buffer))))))) > > (defun org-file-to-pdf (file-path) > "Open up an org file and export it as pdf." > (let* ((file-name (file-name-sans-extension file-path)) > (file-dir (file-name-directory file-path)) > (org-tmp-path (make-temp-file "org-file-to-pdf-")) > (pdf-tmp-path (concat org-tmp-path ".pdf")) > (tex-tmp-path (concat org-tmp-path ".tex")) > (pdf-path (expand-file-name (concat org-interaction-prefix file-name ".pdf") file-dir))) > (if (and (file-exists-p pdf-path) > (< 0 (time-to-seconds > (time-subtract > (nth 5 (file-attributes pdf-path)) > (nth 5 (file-attributes file-path)))))) > pdf-path > (with-temp-filebuffer > file-path > (write-file org-tmp-path) > (org-mode) > (save-window-excursion > (org-export-as-pdf nil) > (rename-file pdf-tmp-path pdf-path t) > (delete-file org-tmp-path) > ;; (delete-file tex-tmp-path) > (kill-buffer (current-buffer))))))) > > ;; customization > ;; (setq org-export-blocks-witheld '(hidden comment)) > > ;; Start the server > ;; (server-start) > > ;; save the emacsclient server socket location > ;; (with-temp-file "/tmp/emacsclient-socket-dir" > ;; (insert server-socket-dir)) > > > Here's the file I'm trying to convert (test.org): > > #+TITLE: Features report > #+AUTHOR: Francesco Pizzolante > #+EMAIL: fpz-djc/iPCCuDYQheJpep6IedvLeJWuRmrY@public.gmane.org > #+DATE: 2010-04-19 > #+DESCRIPTION: > #+KEYWORDS: > #+LANGUAGE: en_US > > #+LaTeX_CLASS_OPTIONS: [a4paper] > > * First test > ** tatatata > > > On the command line, I run the following command: > > emacs --batch -l org-interaction.el --eval "(org-file-to-latex \"~/test.org\")" > > > My observation is that the #+LATEX_CLASS_OPTIONS are not taken into account. I > can add any option there, I always see the default one (11pt). > > It is really strange because if I add a #+LATEX_CLASS directive, this one is > well taken into account and I get the desired class. > > I don't know whether it's a bug somewhere or whether I miss some arguments > somewhere... > > I also tested whith Blorgit and it is the same behavior (options not > exported). > > Thanks a lot for your help, > Francesco _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode-mXXj517/zsQ@public.gmane.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Problem exporting to LaTeX/PDF from command line 2010-04-20 8:06 ` Francesco Pizzolante @ 2010-04-20 15:12 ` Nick Dokos 2010-04-20 15:38 ` Nick Dokos 0 siblings, 1 reply; 4+ messages in thread From: Nick Dokos @ 2010-04-20 15:12 UTC (permalink / raw) To: Francesco Pizzolante; +Cc: nicholas.dokos, mailing-list-org-mode Francesco Pizzolante <fpz@missioncriticalit.com> wrote: > Hi, > > I forgot to mention that, of course, when I do the same operation within > Emacs, using the C-c C-e l, the file is exported without problem. > > Any idea? > I tried a little debugging on this, but I didn't get very far before I ran out of time. The re-search-forward for "#+LaTeX_CLASS_OPTIONS" in org-export-latex-set-initial-vars fails and it looks to me like a rather subtle problem: the temp file buffer looks empty. Whether that's the fault of the with-temp-file-buffer macro or something else, I'm not sure. Nick > > Francesco Pizzolante wrote: > > Hi, > > > > I'm trying to write a shell script in order to convert/export Org files to > > LaTeX/PDF from the command line (org2tex/org2pdf). The whole process works > > well, except that it seems that some bits of the exportation are not executed. > > > > Here's an example of what I do. > > > > I'm using the org-interaction.el file from Blorgit: > > > > (require 'org) > > (require 'cl) > > > > (setq font-lock-mode t) > > > > (defun refresh-then-find-file (file) > > "Find file ensuring that the latest changes on disk are > > represented in the file." > > (let (file-buf) > > (while (setq file-buf (get-file-buffer file)) > > (kill-buffer file-buf)) > > (find-file file))) > > > > (defmacro with-temp-filebuffer (file &rest body) > > "Open FILE into a temporary buffer execute BODY there like > > `progn', then kill the FILE buffer returning the result of > > evaluating BODY." > > (let ((temp-result (make-symbol "temp-result")) > > (temp-file (make-symbol "temp-file"))) > > `(let (,temp-result ,temp-file) > > (refresh-then-find-file ,file) > > (setf ,temp-file (current-buffer)) > > (setf ,temp-result (progn ,@body)) > > (kill-buffer ,temp-file) > > ,temp-result))) > > > > ;; (defvar org-interaction-prefix ".exported_") > > (defvar org-interaction-prefix "") > > > > (defun org-file-to-html (file-path) > > "Open up an org file, publish it to html, and then return the > > html as a string." > > (let* ((file-name (file-name-nondirectory file-path)) > > (file-dir (file-name-directory file-path)) > > (html-path (expand-file-name (concat org-interaction-prefix file-name) file-dir))) > > (if (and (file-exists-p html-path) > > (< 0 (time-to-seconds > > (time-subtract > > (nth 5 (file-attributes html-path)) > > (nth 5 (file-attributes file-path)))))) > > html-path > > (with-temp-filebuffer > > file-path > > (org-mode) > > (save-window-excursion > > (org-export-as-html-to-buffer nil) > > (write-file html-path) > > (kill-buffer (current-buffer))))))) > > > > (defun org-file-to-latex (file-path) > > "Open up an org file, publish it to latex, and then return the > > latex as a string." > > (let* ((file-name (file-name-nondirectory file-path)) > > (file-dir (file-name-directory file-path)) > > (latex-path (expand-file-name (concat org-interaction-prefix file-name ".tex") file-dir))) > > (if (and (file-exists-p latex-path) > > (< 0 (time-to-seconds > > (time-subtract > > (nth 5 (file-attributes latex-path)) > > (nth 5 (file-attributes file-path)))))) > > latex-path > > (with-temp-filebuffer > > file-path > > (org-mode) > > (save-window-excursion > > (org-export-as-latex-to-buffer nil) > > (write-file latex-path) > > (kill-buffer (current-buffer))))))) > > > > (defun org-file-to-pdf (file-path) > > "Open up an org file and export it as pdf." > > (let* ((file-name (file-name-sans-extension file-path)) > > (file-dir (file-name-directory file-path)) > > (org-tmp-path (make-temp-file "org-file-to-pdf-")) > > (pdf-tmp-path (concat org-tmp-path ".pdf")) > > (tex-tmp-path (concat org-tmp-path ".tex")) > > (pdf-path (expand-file-name (concat org-interaction-prefix file-name ".pdf") file-dir))) > > (if (and (file-exists-p pdf-path) > > (< 0 (time-to-seconds > > (time-subtract > > (nth 5 (file-attributes pdf-path)) > > (nth 5 (file-attributes file-path)))))) > > pdf-path > > (with-temp-filebuffer > > file-path > > (write-file org-tmp-path) > > (org-mode) > > (save-window-excursion > > (org-export-as-pdf nil) > > (rename-file pdf-tmp-path pdf-path t) > > (delete-file org-tmp-path) > > ;; (delete-file tex-tmp-path) > > (kill-buffer (current-buffer))))))) > > > > ;; customization > > ;; (setq org-export-blocks-witheld '(hidden comment)) > > > > ;; Start the server > > ;; (server-start) > > > > ;; save the emacsclient server socket location > > ;; (with-temp-file "/tmp/emacsclient-socket-dir" > > ;; (insert server-socket-dir)) > > > > > > Here's the file I'm trying to convert (test.org): > > > > #+TITLE: Features report > > #+AUTHOR: Francesco Pizzolante > > #+EMAIL: fpz@missioncriticalit.com > > #+DATE: 2010-04-19 > > #+DESCRIPTION: > > #+KEYWORDS: > > #+LANGUAGE: en_US > > > > #+LaTeX_CLASS_OPTIONS: [a4paper] > > > > * First test > > ** tatatata > > > > > > On the command line, I run the following command: > > > > emacs --batch -l org-interaction.el --eval "(org-file-to-latex \"~/test.org\")" > > > > > > My observation is that the #+LATEX_CLASS_OPTIONS are not taken into account. I > > can add any option there, I always see the default one (11pt). > > > > It is really strange because if I add a #+LATEX_CLASS directive, this one is > > well taken into account and I get the desired class. > > > > I don't know whether it's a bug somewhere or whether I miss some arguments > > somewhere... > > > > I also tested whith Blorgit and it is the same behavior (options not > > exported). > > > > Thanks a lot for your help, > > Francesco > > > _______________________________________________ > Emacs-orgmode mailing list > Please use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Problem exporting to LaTeX/PDF from command line 2010-04-20 15:12 ` Nick Dokos @ 2010-04-20 15:38 ` Nick Dokos 0 siblings, 0 replies; 4+ messages in thread From: Nick Dokos @ 2010-04-20 15:38 UTC (permalink / raw) To: nicholas.dokos; +Cc: mailing-list-org-mode Nick Dokos <nicholas.dokos@hp.com> wrote: > Francesco Pizzolante <fpz@missioncriticalit.com> wrote: > > > Hi, > > > > I forgot to mention that, of course, when I do the same operation within > > Emacs, using the C-c C-e l, the file is exported without problem. > > > > Any idea? > > > > I tried a little debugging on this, but I didn't get very far before I > ran out of time. The re-search-forward for "#+LaTeX_CLASS_OPTIONS" in > org-export-latex-set-initial-vars fails and it looks to me like a rather > subtle problem: the temp file buffer looks empty. Whether that's the > fault of the with-temp-file-buffer macro or something else, I'm not > sure. > Still not sure what is going on, but this modified org-interaction.el file (it loads the necessary org-XXX.el files explicitly - be sure to change the load-path appropriately) seems to work for me. I have not tried to load org-XXX.elc files to see whether that works or not. Nick --------------------------------------------------------------------------- (add-to-list 'load-path "/home/nick/src/emacs/org/org-mode/lisp") (load-library "org.el") (load-library "org-latex.el") (load-library "org-list.el") (load-library "org-macs.el") (load-library "org-compat.el") (require 'cl) (setq font-lock-mode t) (defun refresh-then-find-file (file) "Find file ensuring that the latest changes on disk are represented in the file." (let (file-buf) (while (setq file-buf (get-file-buffer file)) (kill-buffer file-buf)) (find-file file))) (defmacro with-temp-filebuffer (file &rest body) "Open FILE into a temporary buffer execute BODY there like `progn', then kill the FILE buffer returning the result of evaluating BODY." (let ((temp-result (make-symbol "temp-result")) (temp-file (make-symbol "temp-file"))) `(let (,temp-result ,temp-file) (refresh-then-find-file ,file) (setf ,temp-file (current-buffer)) (setf ,temp-result (progn ,@body)) (kill-buffer ,temp-file) ,temp-result))) ;; (defvar org-interaction-prefix ".exported_") (defvar org-interaction-prefix "") (defun org-file-to-html (file-path) "Open up an org file, publish it to html, and then return the html as a string." (let* ((file-name (file-name-nondirectory file-path)) (file-dir (file-name-directory file-path)) (html-path (expand-file-name (concat org-interaction-prefix file-name) file-dir))) (if (and (file-exists-p html-path) (< 0 (time-to-seconds (time-subtract (nth 5 (file-attributes html-path)) (nth 5 (file-attributes file-path)))))) html-path (with-temp-filebuffer file-path (org-mode) (save-window-excursion (org-export-as-html-to-buffer nil) (write-file html-path) (kill-buffer (current-buffer))))))) (defun org-file-to-latex (file-path) "Open up an org file, publish it to latex, and then return the latex as a string." (let* ((file-name (file-name-nondirectory file-path)) (file-dir (file-name-directory file-path)) (latex-path (expand-file-name (concat org-interaction-prefix file-name ".tex") file-dir))) (if (and (file-exists-p latex-path) (< 0 (time-to-seconds (time-subtract (nth 5 (file-attributes latex-path)) (nth 5 (file-attributes file-path)))))) latex-path (with-temp-filebuffer file-path (org-mode) (save-window-excursion (org-export-as-latex-to-buffer nil) (write-file latex-path) (kill-buffer (current-buffer))))))) (defun org-file-to-pdf (file-path) "Open up an org file and export it as pdf." (let* ((file-name (file-name-sans-extension file-path)) (file-dir (file-name-directory file-path)) (org-tmp-path (make-temp-file "org-file-to-pdf-")) (pdf-tmp-path (concat org-tmp-path ".pdf")) (tex-tmp-path (concat org-tmp-path ".tex")) (pdf-path (expand-file-name (concat org-interaction-prefix file-name ".pdf") file-dir))) (if (and (file-exists-p pdf-path) (< 0 (time-to-seconds (time-subtract (nth 5 (file-attributes pdf-path)) (nth 5 (file-attributes file-path)))))) pdf-path (with-temp-filebuffer file-path (write-file org-tmp-path) (org-mode) (save-window-excursion (org-export-as-pdf nil) (rename-file pdf-tmp-path pdf-path t) (delete-file org-tmp-path) ;; (delete-file tex-tmp-path) (kill-buffer (current-buffer))))))) ;; customization ;; (setq org-export-blocks-witheld '(hidden comment)) ;; Start the server ;; (server-start) ;; save the emacsclient server socket location ;; (with-temp-file "/tmp/emacsclient-socket-dir" ;; (insert server-socket-dir)) ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-04-20 15:39 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-04-19 15:49 Problem exporting to LaTeX/PDF from command line Francesco Pizzolante [not found] ` <87d3xv5to7.fsf-pwAqS3aGAJQybS5Ee8rs3A@public.gmane.org> 2010-04-20 8:06 ` Francesco Pizzolante 2010-04-20 15:12 ` Nick Dokos 2010-04-20 15:38 ` Nick Dokos
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).