emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* running the new exporter asynchronously?
@ 2012-11-28  8:34 Alan Schmitt
  2012-11-28 13:25 ` Nicolas Goaziou
  0 siblings, 1 reply; 6+ messages in thread
From: Alan Schmitt @ 2012-11-28  8:34 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

I'm compiling a fairly large set of slides, that also contain quite a
bit of code that is executed (it's a course on JavaScript which shows
some of the language peculiarities). Thus exporting these slides takes a
while. Unfortunately, when it's compiling, it's completely locking my
emacs. Would there be a way for the export process to be asynchronous
and not lock emacs?

Thanks,

Alan

PS: mandatory comics about compilation time http://xkcd.com/303/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: running the new exporter asynchronously?
  2012-11-28  8:34 running the new exporter asynchronously? Alan Schmitt
@ 2012-11-28 13:25 ` Nicolas Goaziou
  2012-11-28 13:45   ` Eric Schulte
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2012-11-28 13:25 UTC (permalink / raw)
  To: Alan Schmitt; +Cc: emacs-orgmode

Hello,

Alan Schmitt <alan.schmitt@polytechnique.org> writes:

> Would there be a way for the export process to be asynchronous and not
> lock emacs?

Not yet. 

Actually that's, in my roadmap, the single last feature to implement
before moving the new export engine into core.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: running the new exporter asynchronously?
  2012-11-28 13:25 ` Nicolas Goaziou
@ 2012-11-28 13:45   ` Eric Schulte
  2012-11-28 15:13     ` Alan Schmitt
  2012-11-28 20:46     ` Myles English
  0 siblings, 2 replies; 6+ messages in thread
From: Eric Schulte @ 2012-11-28 13:45 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Alan Schmitt, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 830 bytes --]

Nicolas Goaziou <n.goaziou@gmail.com> writes:

> Hello,
>
> Alan Schmitt <alan.schmitt@polytechnique.org> writes:
>
>> Would there be a way for the export process to be asynchronous and not
>> lock emacs?
>
> Not yet. 
>
> Actually that's, in my roadmap, the single last feature to implement
> before moving the new export engine into core.
>
>
> Regards,

In the interim it, one solution which I personally like for large
projects is to offload compilation into an external batch Emacs process.
I find this not only useful for compilation while working, but if you
place all relevant config into an init.el file loaded by the batch
Emacs, this also makes it possible to share and compile the project
separate of your personal Emacs config.

Attached is a bare-bones Makefile supporting this sort of work-flow.

Hope this helps,


[-- Attachment #2: Makefile --]
[-- Type: text/plain, Size: 525 bytes --]

EMACS=emacs
BATCH_EMACS=$(EMACS) --batch -Q -l init.el

%.html: %.org
	$(BATCH_EMACS) $*.org -f org-export-as-html

%.tex: %.org
	$(BATCH_EMACS) $*.org -f org-export-as-latex

%.txt: %.org init.el
	$(BATCH_EMACS) $*.org -f org-export-as-utf8

%.pdf: %.tex
	if pdflatex $*.tex </dev/null; then \
		true; \
	else \
		stat=$$?; touch $*.pdf; exit $$stat; \
	fi
	bibtex $*
	while grep "Rerun to get" $*.log; do \
		if pdflatex $*.tex </dev/null; then \
			true; \
		else \
			stat=$$?; touch $*.pdf; exit $$stat; \
		fi; \
	done

[-- Attachment #3: Type: text/plain, Size: 46 bytes --]


-- 
Eric Schulte
http://cs.unm.edu/~eschulte

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: running the new exporter asynchronously?
  2012-11-28 13:45   ` Eric Schulte
@ 2012-11-28 15:13     ` Alan Schmitt
  2012-11-28 16:50       ` Eric Schulte
  2012-11-28 20:46     ` Myles English
  1 sibling, 1 reply; 6+ messages in thread
From: Alan Schmitt @ 2012-11-28 15:13 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode, Nicolas Goaziou

Eric Schulte <schulte.eric@gmail.com> writes:

> In the interim it, one solution which I personally like for large
> projects is to offload compilation into an external batch Emacs process.
> I find this not only useful for compilation while working, but if you
> place all relevant config into an init.el file loaded by the batch
> Emacs, this also makes it possible to share and compile the project
> separate of your personal Emacs config.
>
> Attached is a bare-bones Makefile supporting this sort of work-flow.

This is really neat, thanks a lot! I'll definitely use this for my next
course.

Do you use a shell to run make or do you call it directly from emacs?

Alan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: running the new exporter asynchronously?
  2012-11-28 15:13     ` Alan Schmitt
@ 2012-11-28 16:50       ` Eric Schulte
  0 siblings, 0 replies; 6+ messages in thread
From: Eric Schulte @ 2012-11-28 16:50 UTC (permalink / raw)
  To: Alan Schmitt; +Cc: Org Mode Mailing List

Alan Schmitt <alan.schmitt@polytechnique.org> writes:

> Eric Schulte <schulte.eric@gmail.com> writes:
>
>> In the interim it, one solution which I personally like for large
>> projects is to offload compilation into an external batch Emacs process.
>> I find this not only useful for compilation while working, but if you
>> place all relevant config into an init.el file loaded by the batch
>> Emacs, this also makes it possible to share and compile the project
>> separate of your personal Emacs config.
>>
>> Attached is a bare-bones Makefile supporting this sort of work-flow.
>
> This is really neat, thanks a lot! I'll definitely use this for my next
> course.
>

Good to hear.

>
> Do you use a shell to run make or do you call it directly from emacs?
>

I always have a shell open, so I generally prefer to run from there.
You could also just run "M-x compile", which runs make asynchronously
and presents the output in a useful format.

Cheers,

>
> Alan

-- 
Eric Schulte
http://cs.unm.edu/~eschulte

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: running the new exporter asynchronously?
  2012-11-28 13:45   ` Eric Schulte
  2012-11-28 15:13     ` Alan Schmitt
@ 2012-11-28 20:46     ` Myles English
  1 sibling, 0 replies; 6+ messages in thread
From: Myles English @ 2012-11-28 20:46 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode, Alan Schmitt, Nicolas Goaziou


Hi,

Eric Schulte writes:

> In the interim it, one solution which I personally like for large
> projects is to offload compilation into an external batch Emacs process.
> I find this not only useful for compilation while working, but if you
> place all relevant config into an init.el file loaded by the batch
> Emacs, this also makes it possible to share and compile the project
> separate of your personal Emacs config.
>
> Attached is a bare-bones Makefile supporting this sort of work-flow.

This is probably too complicated for your immediate requirements but it
is a good opportunity to share my solution using CMake.  It does add
more complexity though.  It is for pdf production and uses something
called UseLATEX.cmake.  The main advantages are that:

- it can also regenerate all my plots from standalone (e.g.) R scripts,
  so I don't have to do everything in org if I don't want to
- it does 'out of source' builds
- I don't know the make syntax
- it would probably work on different OS

Here is the non-barebones example:

#+BEGIN_SRC sh :tangle CMakeLists.txt
    cmake_minimum_required(VERSION 2.8)
    
    project(thesis NONE)
          
    include(/usr/share/cmake-2.8/Modules/UseLATEX.cmake)
    
    # Set R executable
    set(R_COMPILE "/usr/bin/Rscript")
          # Set the location of data files
          ##set(DATA_DIR data)
          # Set the location of the directory for image files
    set(IMAGE_DIR graphicsauto)
    
          # Get a list of R files
    file(GLOB_RECURSE R_FILES "R/*.R")
    
    file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/R DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
    file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_DIR})
    
    foreach(file ${R_FILES})
    message("proceessing ${file}")
    get_filename_component(basename "${file}" NAME_WE)
    
              # Command to run R
    if(R_COMPILE)
        message("Adding ........... ${CMAKE_CURRENT_BINARY_DIR}/R/${basename}.R")
          
        add_custom_command(
            OUTPUT
            ${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_DIR}/${basename}.eps
            DEPENDS
            ${CMAKE_CURRENT_BINARY_DIR}/R/${basename}.R
                    #      ${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_DIR}/${DATA_DIR}
            COMMAND
            ${R_COMPILE}
            ARGS
            ${CMAKE_CURRENT_BINARY_DIR}/R/${basename}.R
            ${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_DIR}/${basename}.eps
        )
        message("Running ${R_COMPILE} ${CMAKE_CURRENT_BINARY_DIR}/R/${basename}.R ${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_DIR}/${basename}.eps")
          
        endif(R_COMPILE)
          
              # Make a list of all R files (for ADD_LATEX_DOCUMENT depend)
        set(ALL_R_FILES ${ALL_R_FILES}
            ${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_DIR}/${basename}.eps
        )
        endforeach(file)
          
          # ------- export mainThesis.org -----------------------
        latex_get_output_path(OUTPUT_DIR)  
        file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/mainThesis.org DESTINATION ${OUTPUT_DIR}/ )
        file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/thesis.el DESTINATION ${OUTPUT_DIR}/ )
    
        add_custom_target( orgfile ALL
            DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/mainThesis.org )
    
        add_custom_target( elfile ALL
            DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/thesis.el )
        
        add_custom_command(
            OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/mainThesis.tex
            COMMAND emacs -Q --batch --eval \"(progn
                (add-to-list 'load-path
                       (expand-file-name \\"~/.emacs.d/plugins/org-mode/lisp/\\"))
                     (add-to-list 'load-path
                    (expand-file-name \\"~/.emacs.d/plugins/org-mode/contrib/lisp/\\" t))
                (require 'org)
                     (require 'org-export)
                (require 'org-exp)
                     (require 'org-inlinetask)
                (require 'ob-plantuml)
                     (setq org-plantuml-jar-path \\"/home/myles/Downloads/plantuml.jar\\")
                     (org-babel-do-load-languages
                      'org-babel-load-languages
                    '((emacs-lisp . t)
                        (sh . t)
                        (plantuml . t)))
                     (setq org-confirm-babel-evaluate nil)
                   (setq org-export-with-todo-keywords nil)
               (load-library \\"/home/myles/lib/lisp/my-export.el\\")
               (add-to-list 'org-export-before-processing-hook 'my-export-delete-headlines-tagged-noheading)
            (load-file \\"thesis.el\\")
                (find-file \\"${CMAKE_CURRENT_BINARY_DIR}/mainThesis.org\\")
                (org-e-latex-export-to-latex))\"
            DEPENDS orgfile elfile
            COMMENT "Exporting orgmode file to LaTeX using emacs")
        
        add_custom_target( mainfile ALL
            DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/mainThesis.tex )
        
        add_latex_document(master.tex
            BIBFILES texlib/mybiblatex.bib
            INPUTS tex/title.tex
            tex/FEM_ch.tex
            tex/multiphase_flow.tex
            tex/sharedMemory_sec.tex
            tex/programming_ch.tex
            tex/bibliography.tex
            texlib/mystyle.sty
            tex/linked_nodes_test.tex
            IMAGE_DIRS ${IMAGE_DIR} ../graphics/thirdParty ../graphics/VE
            DEPENDS ${ALL_R_FILES}
            DEFAULT_PDF
            USE_NOMENCL)
#+END_SRC


Myles

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-11-28 20:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-28  8:34 running the new exporter asynchronously? Alan Schmitt
2012-11-28 13:25 ` Nicolas Goaziou
2012-11-28 13:45   ` Eric Schulte
2012-11-28 15:13     ` Alan Schmitt
2012-11-28 16:50       ` Eric Schulte
2012-11-28 20:46     ` Myles English

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).