Re: [O] Example of Make file for Org Mode LaTeX to pdf

2016-03-08 Thread Robert Love
I have gotten many good ideas from these replies to my question.  Thanks to all.

> On Mar 7, 2016, at 10:10 AM, Loris Bennett  wrote:
> 
> Eric S Fraga  writes:
> 
>> On Monday,  7 Mar 2016 at 09:55, Loris Bennett wrote:
>> 
>> [...]
>> 
>>> Would you be able to share what you load in custom.el and esf-org.el, or
>>> a least explain what needs to be done?
>> 
>> My custom.el is the emacs customisations (for variables and faces that
>> usually ends up in your .emacs) and esf-org.el is my full org
>> initialisation which is rather large and convoluted.  There is nothing
>> in either of those that should help solve the problem you are
>> having... but, then again, I'm not sure why you are having the problem
>> you encounter!
>> 
>> Do you get the same backtrace with -Q as in the previous post?
> 
> Apart from the Debian gubbins, yes.  However, I seem to have solved the
> problem.
> 
> With the following ~/.emacs_minimal
> 
>  (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
> 
> I get:
> 
>  $ emacs /home/loris/org/gtd.org -Q -batch --load ~/.emacs_minmal -eval 
> '(org-icalendar-export-to-ics))' --kill
>  Symbol's value as variable is void: org-agenda-default-appointment-duration
> 
> However, with ~/.emacs_minimal as
> 
>  (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
>  (org-agenda-to-appt)
> 
> I get
> 
>  $ emacs /home/loris/org/gtd.org -Q -batch --load ~/.emacs_minmal -eval 
> '(org-icalendar-export-to-ics))' --kill
>  No event to add
>  Saving file /home/loris/org/gtd.ics...
>  Wrote /home/loris/org/gtd.ics
> 
> So I was just being too minimalist.  org-agenda-to-appt seems to be some
> cruft I copied from here:
> 
>  http://sachachua.com/blog/2007/11/setting-up-appointment-reminders-in-org/
> 
> I'll go and look what it does whether I still need it.
> 
> Cheers,
> 
> Loris
> 
> -- 
> This signature is currently under construction.


— 
Bob Love
"Neil Armstrong was the first human on the moon. Neil A backwards is alien." 

Listening to:  Promontory  by  Circa Paleo











Re: [O] Example of Make file for Org Mode LaTeX to pdf

2016-03-07 Thread Loris Bennett
Eric S Fraga  writes:

> On Monday,  7 Mar 2016 at 09:55, Loris Bennett wrote:
>
> [...]
>
>> Would you be able to share what you load in custom.el and esf-org.el, or
>> a least explain what needs to be done?
>
> My custom.el is the emacs customisations (for variables and faces that
> usually ends up in your .emacs) and esf-org.el is my full org
> initialisation which is rather large and convoluted.  There is nothing
> in either of those that should help solve the problem you are
> having... but, then again, I'm not sure why you are having the problem
> you encounter!
>
> Do you get the same backtrace with -Q as in the previous post?

Apart from the Debian gubbins, yes.  However, I seem to have solved the
problem.

With the following ~/.emacs_minimal

  (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))

I get:

  $ emacs /home/loris/org/gtd.org -Q -batch --load ~/.emacs_minmal -eval 
'(org-icalendar-export-to-ics))' --kill
  Symbol's value as variable is void: org-agenda-default-appointment-duration

However, with ~/.emacs_minimal as

  (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
  (org-agenda-to-appt)

I get

  $ emacs /home/loris/org/gtd.org -Q -batch --load ~/.emacs_minmal -eval 
'(org-icalendar-export-to-ics))' --kill
  No event to add
  Saving file /home/loris/org/gtd.ics...
  Wrote /home/loris/org/gtd.ics

So I was just being too minimalist.  org-agenda-to-appt seems to be some
cruft I copied from here:

  http://sachachua.com/blog/2007/11/setting-up-appointment-reminders-in-org/

I'll go and look what it does whether I still need it.

Cheers,

Loris

-- 
This signature is currently under construction.




Re: [O] Example of Make file for Org Mode LaTeX to pdf

2016-03-07 Thread Eric S Fraga
On Monday,  7 Mar 2016 at 09:55, Loris Bennett wrote:

[...]

> Would you be able to share what you load in custom.el and esf-org.el, or
> a least explain what needs to be done?

My custom.el is the emacs customisations (for variables and faces that
usually ends up in your .emacs) and esf-org.el is my full org
initialisation which is rather large and convoluted.  There is nothing
in either of those that should help solve the problem you are
having... but, then again, I'm not sure why you are having the problem
you encounter!

Do you get the same backtrace with -Q as in the previous post?

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 25.0.90.1, Org release_8.3.3-535-g7213aa



Re: [O] Example of Make file for Org Mode LaTeX to pdf

2016-03-07 Thread Nick Dokos
Here's a simple (GNU make) makefile to export something in batch mode:

--8<---cut here---start->8---
%.html: %.org
emacs -batch -l batch-export.el --eval "(batch-org-export-as 'html)" $<

%.pdf:  %.tex
latexmk --shell-escape -pdf -xelatex $<

%.tex: %.org
emacs -batch -l batch-export.el --eval "(batch-org-export-as 'latex)" $<
--8<---cut here---end--->8---

Starting from foo.org, say

  make foo.html foo.pdf

to produce the indicated exports.

I don't remember where I picked up the batch-org-export-as function, but
whoever wrote it, thanks! You might be able to simplify it: I've been
carrying it around unchanged for a couple of years, so there may be
simpler ways to do things nowadays, but AFAIK it works well with org
8.x. Here's the bach-export.el file (obviously the path in the second
line will need to be changed to suit your circumstances - I'm not sure
if the (require 'org-loaddefs) needs to be changed if e.g. you are using
org from ELPA - you might have to add a (package-initialize) too in this
case):

--8<---cut here---start->8---
;;; -*- mode: emacs-lisp -*-
(add-to-list 'load-path (expand-file-name "~/src/emacs/org/org-mode/lisp"))

(add-to-list 'auto-mode-alist '("\\.\\(org\\|org_archive\\|txt\\)$" . org-mode))

(setq org-export-backends '(html latex))

(require 'org-loaddefs)

(defun org-export-file-to (backend src dest)
  (with-temp-buffer
(insert-file-contents src)
(org-export-to-file backend dest)))

(setq file-suffixes
  '((html . ".html")
(latex . ".tex")
(pdf . ".pdf")))

(defun org-export-dest (backend f)
  (concat (file-name-sans-extension f) (cdr (assoc backend file-suffixes

(defun batch-org-export-as (backend  noforce)
  "Run `org-export-as' with the given backend  on the files remaining on the 
command line.
Use this from the command line, with `-batch'; it won't work in
an interactive Emacs.  Each file is processed even if an error
occurred previously.  For example, invoke \"emacs -batch -f
batch-byte-compile $emacs/ ~/*.el\".  If NOFORCE is non-nil,
don't recompile a file that seems to be already up-to-date."
  ;; command-line-args-left is what is left of the command line, from
  ;; startup.el.
  (defvar command-line-args-left)   ;Avoid 'free variable' warning
  (if (not noninteractive)
  (error "`batch-org-export-as' is to be used only with -batch"))
  (let ((error nil))
(while command-line-args-left
  (if (file-directory-p (expand-file-name (car command-line-args-left)))
  ;; Directory as argument.
  (let (source dest)
(dolist (file (directory-files (car command-line-args-left)))
  (if (and (string-match emacs-lisp-file-regexp file)
   (not (auto-save-file-name-p file))
   (setq source
 (expand-file-name file
   (car command-line-args-left)))
   (setq dest (org-export-dest backend source))
   (file-exists-p dest)
   (file-newer-than-file-p source dest))
  (if (null (org-export-file-to backend source dest))
  (setq error t)
;; Specific file argument
(let* ((source (car command-line-args-left))
   (dest (org-export-dest backend source)))
  (if (or (not noforce)
  (or (not (file-exists-p dest))
  (file-newer-than-file-p source dest)))
(if (null (org-export-file-to backend (car command-line-args-left) 
dest))
(setq error t)
  (setq command-line-args-left (cdr command-line-args-left)))
(kill-emacs (if error 1 0

--8<---cut here---end--->8---

HTH.
--
Nick




Re: [O] Example of Make file for Org Mode LaTeX to pdf

2016-03-07 Thread Loris Bennett
Hi Eric,

Eric S Fraga  writes:

> On Friday,  4 Mar 2016 at 23:43, Robert Love wrote:
>> Does anyone have a make file example that has emacs load an .org file,
>> process it into LaTeX and export as PDF, all from the command line
>> without the user doing anything more than type ‘make’?  All examples
>> appreciated.
>
> I don't a makefile but I do have a single shell command that exports my
> agenda to an ics file for uploading to google's calendar:
>
> emacs -Q --batch --debug-init \
> --directory=${HOME}/s/emacs \
> --load=custom.el \
> --load=esf-org.el --visit=${DIARY}.org 
> --eval='(org-icalendar-export-to-ics)'
>
> HTH

I was interested in doing exactly this, but got the error described
here:

http://article.gmane.org/gmane.emacs.orgmode/105491

Would you be able to share what you load in custom.el and esf-org.el, or
a least explain what needs to be done?

Cheers,

Loris

-- 
This signature is currently under construction.




Re: [O] Example of Make file for Org Mode LaTeX to pdf

2016-03-06 Thread Eric S Fraga
On Friday,  4 Mar 2016 at 23:43, Robert Love wrote:
> Does anyone have a make file example that has emacs load an .org file,
> process it into LaTeX and export as PDF, all from the command line
> without the user doing anything more than type ‘make’?  All examples
> appreciated.

I don't a makefile but I do have a single shell command that exports my
agenda to an ics file for uploading to google's calendar:

--8<---cut here---start->8---
emacs -Q --batch --debug-init \
--directory=${HOME}/s/emacs \
--load=custom.el \
--load=esf-org.el --visit=${DIARY}.org 
--eval='(org-icalendar-export-to-ics)'
--8<---cut here---end--->8---

HTH
-- 
: Eric S Fraga (0xFFFCF67D), Emacs 25.0.91.1, Org release_8.3.4-626-gb62d55



Re: [O] Example of Make file for Org Mode LaTeX to pdf

2016-03-06 Thread John Kitchin
* Export org-files using a Makefile

#+BEGIN_SRC makefile :tangle Makefile
pdf:
rm -f make-org.pdf
emacs -batch make-org.org -f org-latex-export-to-pdf
open make-org.pdf
#+END_SRC


works for me.

Robert Love writes:

> Does anyone have a make file example that has emacs load an .org file, 
> process it into LaTeX and export as PDF, all from the
> command line without the user doing anything more than type ‘make’? All 
> examples appreciated.
>
> —
> Bob Love
> "Insisting on perfect safety is for people who don't have the balls to live 
> in the real world." -- Mary Shafer, NASA Dryden


--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu



Re: [O] Example of Make file for Org Mode LaTeX to pdf

2016-03-06 Thread Myles English

Hello Bob,

Robert Love writes:

> Does anyone have a make file example that has emacs load an .org file,
> process it into LaTeX and export as PDF, all from the command line
> without the user doing anything more than type ‘make’?   All examples
> appreciated.

Fraid I don't have a makefile but I do have a CMakeLists.txt that CMake
uses to generate a makefile.  This method uses a CMake module called
UseLATEX.cmake to generate the PDF.  I haven't used it for a couple of
years so it might be a bit outdated.

The CMakeLists.txt also contains an example of how to generate all the R
graphics for the document.

If it looks a bit over complicated for your requirements perhaps just
looking at the line that contains "COMMAND emacs" would be useful for
you.

Hopefully someone else will show a nice, simple, self-contained example.

Myles


#+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("processing ${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 'ox)
  (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-latex-listings 'minted)
  (setq org-latex-with-hyperref nil)
 (add-to-list 'org-latex-packages-alist '(\\"\\" 
\\"minted\\"))
  
  (add-to-list 'org-latex-classes 
'(\\"mynewthesis\\" \\"\\documentclass[11pt]{mythesis}\\"
 (\\"\\chapter{%s}\\" . \\"\\chapter*{%s}\\")
 (\\"\\section{%s}\\" . \\"\\section*{%s}\\")
 (\\"\\subsection{%s}\\" . \\"\\subsection*{%s}\\")
 (\\"\\subsubsection{%s}\\" . \\"\\subsubsection*{%s}\\")
 (\\"\\paragraph{%s}\\" . \\"\\paragraph*{%s}\\")))
 (setq org-export-with-todo-keywords nil)
 (load-library 

[O] Example of Make file for Org Mode LaTeX to pdf

2016-03-06 Thread Robert Love
Does anyone have a make file example that has emacs load an .org file, process 
it into LaTeX and export as PDF, all from the command line without the user 
doing anything more than type ‘make’?   All examples appreciated.

— 
Bob Love
"Insisting on perfect safety is for people who don't have the balls to live in 
the real world." -- Mary Shafer, NASA Dryden