* export (as latex) a large number of org files in a directory
@ 2009-08-30 14:11 Stephen Tucker
2009-08-30 15:04 ` Nick Dokos
0 siblings, 1 reply; 7+ messages in thread
From: Stephen Tucker @ 2009-08-30 14:11 UTC (permalink / raw
To: emacs-orgmode
Hi, I am trying to export a bunch of .org files stored in a directory as latex files. I have tried two methods:
(1) -------------------------------------------------------------------------------------------
At the bash prompt (I am using OS X):
bash$ emacs --batch
--load=/Applications/Emacs.app/Contents/Resources/lisp/org/org.elc
--visit=file.org --funcall org-export-as-latex-batch'
and I get an error:
"Cannot open load file: subst-ksc"
If I can get this to work, then I can embed this system call in a shell script and call it iteratively on a list of .org files retrieved from, say, Python or Bash (changing 'file.org' appropriately each time).
(2) -------------------------------------------------------------------------------------------
I created the following function which is intended to take a filename argument, load it into a temporary buffer, and export that buffer as a latex file. I thought to apply (map) this function to a list of file names generated by the directory-files() function.
(defun orgexpastex (filenm)
(let (buffer-file-name)
(with-temp-buffer
(setq buffer-file-name "test")
(insert-file-contents filenm)
(org-export-as-latex 3)) ;;or (org-export-as-latex-batch))
)
)
But, upon testing this function,
(orgexpastex "file.org")
I get
[-] = =*Backtrace*--------------------------------------------------------------
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
re-search-forward(nil nil t)
org-export-remove-headline-metadata((:for-LaTeX t :emph-multiline t
:add-text nil :comments nil :skip-before-1st-heading nil :LaTeX-fragments nil
:timestamps t :footnotes t))
org-export-preprocess-string("" :for-LaTeX t :emph-multiline t :add-text nil
:comments nil :skip-before-1st-heading nil :LaTeX-fragments nil :timestamps t
:footnotes t)
org-export-latex-first-lines((:latex-image-options "width=10em"
:exclude-tags ("noexport") :select-tags ("export") :auto-postamble t
[...snip...]
-------------------------------------------------------------------------------------------
I wonder if it is obvious to anyone what I am doing wrong, or if there is a better way to go about exporting a bunch of org files with a program.
Thanks much!
Stephen
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: export (as latex) a large number of org files in a directory
2009-08-30 14:11 export (as latex) a large number of org files in a directory Stephen Tucker
@ 2009-08-30 15:04 ` Nick Dokos
2009-08-30 19:11 ` Stephen Tucker
2009-09-02 15:21 ` Sébastien Vauban
0 siblings, 2 replies; 7+ messages in thread
From: Nick Dokos @ 2009-08-30 15:04 UTC (permalink / raw
To: Stephen Tucker; +Cc: emacs-orgmode
Stephen Tucker <brown_emu@yahoo.com> wrote:
> Hi, I am trying to export a bunch of .org files stored in a directory as latex files. I have tried two methods:
>
> (1) -------------------------------------------------------------------------------------------
> At the bash prompt (I am using OS X):
>
> bash$ emacs --batch
> --load=/Applications/Emacs.app/Contents/Resources/lisp/org/org.elc
> --visit=file.org --funcall org-export-as-latex-batch'
>
> and I get an error:
> "Cannot open load file: subst-ksc"
>
> If I can get this to work, then I can embed this system call in a shell script and call it iteratively on a list of .org files retrieved from, say, Python or Bash (changing 'file.org' appropriately each time).
>
Did you escape the newlines? If you cut-n-pasted from the
org-export-as-latex-batch help, you fell into the trap :-) Maybe the
documentation of the function could be changed to add the backslashes?
The following script (I call it org-to-latex) works fine on linux:
--8<---------------cut here---------------start------------->8---
#! /bin/bash
orglib=$HOME/elisp/org-mode/lisp
emacs --batch \
--load=$orglib/org.elc \
--eval "(setq org-export-headline-levels 2)" \
--visit=$1 --funcall org-export-as-latex-batch
--8<---------------cut here---------------end--------------->8---
You can add a loop in it too - or do the loop by hand:
--8<---------------cut here---------------start------------->8---
for x in *.org
do
org-to-latex $x
done
--8<---------------cut here---------------end--------------->8---
HTH,
Nick
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: export (as latex) a large number of org files in a directory
2009-08-30 15:04 ` Nick Dokos
@ 2009-08-30 19:11 ` Stephen Tucker
2009-08-31 2:27 ` Nick Dokos
2009-09-02 15:21 ` Sébastien Vauban
1 sibling, 1 reply; 7+ messages in thread
From: Stephen Tucker @ 2009-08-30 19:11 UTC (permalink / raw
To: nicholas.dokos; +Cc: emacs-orgmode
Hi Nick, thanks for the response! Actually in the code that I had pasted, the emacs --batch call is all on one line (so no need to escape newlines there). I tried your code with both
orglib=/Applications/Emacs.app/Contents/Resources/lisp/org
and
orglib=$HOME/elisp/org-mode/lisp
but got
Cannot open load file: org-macs
in both cases I also added a line,
--eval "(load \"/Applications/Emacs.app/Contents/Resources/lisp/org/org.elc\")" \
to replace the --load option but same deal.
I do in fact have org-macs in my 'orglib' directories so I tried loading them explicitly (with multiple --load specifications), but it still doesn't work (Still "Cannot open load file" pointing to some org file or subst-ksc, depending on how many or in what order org .el files are loaded). Any more ideas?
Thanks...!
Stephen
----- Original Message ----
From: Nick Dokos <nicholas.dokos@hp.com>
To: Stephen Tucker <brown_emu@yahoo.com>
Cc: emacs-orgmode@gnu.org; nicholas.dokos@hp.com
Sent: Sunday, August 30, 2009 8:04:06 AM
Subject: Re: [Orgmode] export (as latex) a large number of org files in a directory
Stephen Tucker <brown_emu@yahoo.com> wrote:
> Hi, I am trying to export a bunch of .org files stored in a directory as latex files. I have tried two methods:
>
> (1) -------------------------------------------------------------------------------------------
> At the bash prompt (I am using OS X):
>
> bash$ emacs --batch
> --load=/Applications/Emacs.app/Contents/Resources/lisp/org/org.elc
> --visit=file.org --funcall org-export-as-latex-batch'
>
> and I get an error:
> "Cannot open load file: subst-ksc"
>
> If I can get this to work, then I can embed this system call in a shell script and call it iteratively on a list of .org files retrieved from, say, Python or Bash (changing 'file.org' appropriately each time).
>
Did you escape the newlines? If you cut-n-pasted from the
org-export-as-latex-batch help, you fell into the trap :-) Maybe the
documentation of the function could be changed to add the backslashes?
The following script (I call it org-to-latex) works fine on linux:
--8<---------------cut here---------------start------------->8---
#! /bin/bash
orglib=$HOME/elisp/org-mode/lisp
emacs --batch \
--load=$orglib/org.elc \
--eval "(setq org-export-headline-levels 2)" \
--visit=$1 --funcall org-export-as-latex-batch
--8<---------------cut here---------------end--------------->8---
You can add a loop in it too - or do the loop by hand:
--8<---------------cut here---------------start------------->8---
for x in *.org
do
org-to-latex $x
done
--8<---------------cut here---------------end--------------->8---
HTH,
Nick
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: export (as latex) a large number of org files in a directory
2009-08-30 19:11 ` Stephen Tucker
@ 2009-08-31 2:27 ` Nick Dokos
2009-08-31 4:38 ` Nick Dokos
0 siblings, 1 reply; 7+ messages in thread
From: Nick Dokos @ 2009-08-31 2:27 UTC (permalink / raw
To: Stephen Tucker; +Cc: emacs-orgmode
Stephen Tucker <brown_emu@yahoo.com> wrote:
> Hi Nick,
> thanks for the response! Actually in the code that I had pasted, the
> emacs --batch call is all on one line (so no need to escape newlines
> there). I tried your code with both
> orglib=/Applications/Emacs.app/Contents/Resources/lisp/org
> and
> orglib=$HOME/elisp/org-mode/lisp
You need the former - the latter is where I keep my org.el[c]
> but got
> Cannot open load file: org-macs
> in both cases I also added a line,
> --eval "(load \"/Applications/Emacs.app/Contents/Resources/lisp/org/org.elc\")" \
> to replace the --load option but same deal.
> I do in fact have org-macs in my 'orglib' directories so I tried
> loading them explicitly (with multiple --load specifications), but it
> still doesn't work (Still "Cannot open load file" pointing to some org
> file or subst-ksc, depending on how many or in what order org .el
> files are loaded). Any more ideas?
>
The problem is probably that --batch implies -q, so .emacs is *not*
loaded and you don't get your load-path customizations. Maybe
something like this will work (the quoting gets hairy, so pay
close attention to all the details):
--8<---------------cut here---------------start------------->8---
#! /bin/bash
orglib=/Applications/Emacs.app/Contents/Resources/lisp/org
emacs --batch \
--eval "(add-to-list 'load-path \"$orglib\")"
--load=$orglib/org.elc \
--eval "(setq org-export-headline-levels 2)" \
--visit=$1 --funcall org-export-as-latex-batch
--8<---------------cut here---------------end--------------->8---
HTH,
Nick
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: export (as latex) a large number of org files in a directory
2009-08-31 2:27 ` Nick Dokos
@ 2009-08-31 4:38 ` Nick Dokos
2009-08-31 5:58 ` Stephen Tucker
0 siblings, 1 reply; 7+ messages in thread
From: Nick Dokos @ 2009-08-31 4:38 UTC (permalink / raw
To: nicholas.dokos; +Cc: Stephen Tucker, emacs-orgmode
Nick Dokos <nicholas.dokos@hp.com> wrote:
> Stephen Tucker <brown_emu@yahoo.com> wrote:
>
> > Hi Nick,
>
> > thanks for the response! Actually in the code that I had pasted, the
> > emacs --batch call is all on one line (so no need to escape newlines
> > there). I tried your code with both
>
> > orglib=/Applications/Emacs.app/Contents/Resources/lisp/org
> > and
> > orglib=$HOME/elisp/org-mode/lisp
>
> You need the former - the latter is where I keep my org.el[c]
>
> > but got
> > Cannot open load file: org-macs
> > in both cases I also added a line,
> > --eval "(load \"/Applications/Emacs.app/Contents/Resources/lisp/org/org.elc\")" \
> > to replace the --load option but same deal.
> > I do in fact have org-macs in my 'orglib' directories so I tried
> > loading them explicitly (with multiple --load specifications), but it
> > still doesn't work (Still "Cannot open load file" pointing to some org
> > file or subst-ksc, depending on how many or in what order org .el
> > files are loaded). Any more ideas?
> >
>
> The problem is probably that --batch implies -q, so .emacs is *not*
> loaded and you don't get your load-path customizations. Maybe
> something like this will work (the quoting gets hairy, so pay
> close attention to all the details):
>
> #! /bin/bash
>
> orglib=/Applications/Emacs.app/Contents/Resources/lisp/org
> emacs --batch \
> --eval "(add-to-list 'load-path \"$orglib\")"
\ # need a backslash here.
> --load=$orglib/org.elc \
> --eval "(setq org-export-headline-levels 2)" \
> --visit=$1 --funcall org-export-as-latex-batch
>
>
... and I just noticed that I missed a backslash on the added line.
Sorry about that.
Nick
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: export (as latex) a large number of org files in a directory
2009-08-31 4:38 ` Nick Dokos
@ 2009-08-31 5:58 ` Stephen Tucker
0 siblings, 0 replies; 7+ messages in thread
From: Stephen Tucker @ 2009-08-31 5:58 UTC (permalink / raw
To: nicholas.dokos; +Cc: emacs-orgmode
Thanks yet again! That makes sense... works now!!
> I tried your code with both
>
> > orglib=/Applications/Emacs.app/Contents/Resources/lisp/org
> > and
> > orglib=$HOME/elisp/org-mode/lisp
>
> You need the former - the latter is where I keep my org.el[c]
(sorry, forgot to mention that I created and copied my files to the latter directory to try it out)
> #! /bin/bash
>
> orglib=/Applications/Emacs.app/Contents/Resources/lisp/org
> emacs --batch \
> --eval "(add-to-list 'load-path \"$orglib\")"
\ # need a backslash here.
> --load=$orglib/org.elc \
> --eval "(setq org-export-headline-levels 2)" \
> --visit=$1 --funcall org-export-as-latex-batch
>
(yes, caught that!)
Thanks again very much, Nick - this had been on my mind for a while.
Stephen
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: export (as latex) a large number of org files in a directory
2009-08-30 15:04 ` Nick Dokos
2009-08-30 19:11 ` Stephen Tucker
@ 2009-09-02 15:21 ` Sébastien Vauban
1 sibling, 0 replies; 7+ messages in thread
From: Sébastien Vauban @ 2009-09-02 15:21 UTC (permalink / raw
To: emacs-orgmode-mXXj517/zsQ
Hi Nick and the others,
Nick Dokos wrote:
> Stephen Tucker <brown_emu-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:
>
>> Hi, I am trying to export a bunch of .org files stored in a directory as
>> latex files.
>
> The following script (I call it org-to-latex) works fine on linux:
>
> #! /bin/bash
>
> orglib=$HOME/elisp/org-mode/lisp
> emacs --batch \
> --load=$orglib/org.elc \
> --eval "(setq org-export-headline-levels 2)" \
> --visit=$1 --funcall org-export-as-latex-batch
Another solution is a Makefile, such as this one:
--8<---------------cut here---------------start------------->8---
## Makefile for Web site (+ PDF equivalent)
# Time-stamp: <2009-09-02 Wed 16:43 sva on mundaneum>
# Defined rules for users:
#
# - (make called without parameter)
# Generate all PDF
#
# - clean
# Delete all temporary files
#
# - realclean
# Do `make clean' plus remove all generated files
# where to find a recent version of Org-mode
ORGLIB = $(HOME)/Downloads/emacs/site-lisp/org-mode/lisp
# publish HTML directory
DISTDIR = ../public_html
# platform-specific setup (to override ORGLIB and/or DISTDIR)
-include Make.params
PDFLATEX = pdflatex --interaction=batchmode
RM = rm -f
RMEXT = *.log *.aux *.toc *.lot *.lof *.out *.ilg *.idx *.ind *.blg *.bbl \
*.glg *.glx *.glo *.gls *.tex
RMOUT = *.pdf $(DISTDIR)/*.html
# all source files
ORG=$(wildcard *.org)
# all exported PDF files
PDF=$(patsubst %.org, %.pdf, $(ORG))
# all TEX files
TEX=$(patsubst %.org, %.tex, $(ORG))
# all published HTML files
HTML=$(patsubst %.org, $(DISTDIR)/%.html, $(ORG))
.PHONY: all html pdf clean realclean
# avoid make to delete intermediate `%.tex' target
.PRECIOUS: %.tex
.DEFAULT_GOAL := all
all: html pdf
html: $(HTML)
pdf: $(PDF) clean
tex: $(TEX)
$(DISTDIR)/%.html: %.org
@echo
@emacs --batch \
--eval "(add-to-list 'load-path \"$(ORGLIB)\")" \
--load ./Org2HTML.el \
--visit=$^ \
--funcall org-publish-current-file
%.pdf: %.tex
# Runs LaTeX once, then reruns LaTeX as many times as necessary to get rid of
# the "Rerun to get cross-references right" warning message
@echo
@echo "* Running \`pdfLaTeX $^' *"
@$(RM) *.log
@$(PDFLATEX) $^
@while ( grep -e "Rerun .* cross-references" *.log > /dev/null ); \
do \
echo; \
echo "* Re-running \`pdfLaTeX $^' *"; \
$(RM) *.log; \
$(PDFLATEX) $^; \
done
%.tex: %.org
# Pay attention that `--batch' implies `-q', so `.emacs' is *not* loaded and
# you don't get your `load-path' customizations. Hence, this loads the Emacs
# built-in version of Org-mode.
@echo
@emacs --batch \
--eval "(add-to-list 'load-path \"$(ORGLIB)\")" \
--eval "(require 'org)" \
--eval "(require 'org-exp)" \
--eval "(setq org-export-headline-levels 2)" \
--load ./Org2LaTeX.el \
--visit=$^ \
--funcall org-export-as-latex-batch
clean:
-$(RM) $(RMEXT)
realclean: clean
-$(RM) $(RMOUT)
## Makefile ends here
--8<---------------cut here---------------end--------------->8---
It has the advantage of running only the required compilation for the modified
files, and generates both HTML and PDF versions...
A nice thing would be to be able to even merge all the PDF files into one --
but here come questions like in which order, with or without title page, and
so on.
Comments (more than) welcome!
Seb
--
Sébastien Vauban
_______________________________________________
Emacs-orgmode mailing list
Remember: 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] 7+ messages in thread
end of thread, other threads:[~2009-09-02 15:21 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-30 14:11 export (as latex) a large number of org files in a directory Stephen Tucker
2009-08-30 15:04 ` Nick Dokos
2009-08-30 19:11 ` Stephen Tucker
2009-08-31 2:27 ` Nick Dokos
2009-08-31 4:38 ` Nick Dokos
2009-08-31 5:58 ` Stephen Tucker
2009-09-02 15:21 ` Sébastien Vauban
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.