Re: [O] emacs & org mode for scholars questions

2015-09-03 Thread Christian Wittern
On 2015-09-02 19:40, John Kitchin wrote:
> Cool! Thanks for the shout out to org-ref!
>
> my jmax starter package (http://github.com/jkitchin/jmax) is basically
> designed for the last point you described. I use it with students (41
> this semester!) as a standalone "package". It isn't as polished as
> prelude or others, but it allows them to do things like I do out of the
> box.

Great slides and a great activity.  I totally agree that we need to teach
our students to use real tools they can use sustainably throughout their
career.

I am developing a package and a bundle for people in Chinese Studies and
neighbouring fields.  This needs a slightly different set of packages and
settings so I don't think a one-size-fits-all approach would be productive
here, neither on the Emacs level, nor on the level of something like jmax. 
I think being able to have something like

$> pip --freeze > requirements   and
$> pip install -r 

[O] Question about todo subheadings and logbook

2015-09-03 Thread Keith M Swartz
Hi all,

I'm currently using org-mode 8.3.1, and I'm curious about a particular
behavior.

If I start to type an item, and then use the C-c C-t shortcut to mark it as
a TODO item, it automatically creates a drawer and adds a LOGBOOK entry to
it. Custom settings are as follows:

(setq org-log-into-drawer 'LOGBOOK
  org-log-state-notes-into-drawer 'LOGBOOK)

I often want to add a subheading (sub-task) to this todo item, so I'll hit
Alt-Enter to do this. When I do, it creates the subheading /between/ the
original todo and the drawer. Is that correct?

My preference - and what I would have assumed to be the correct behavior -
would be to have the subheadings appear /after/ the logbook drawer, as each
subtask can also have a todo state and its own logbook.

I figure there's probably a quick change I can make to
org-insert-todo-subheading or some other function, but wanted to see if: a)
this is how it's supposed to work, and b) if there was an easier way to
achieve what I want, maybe just some keyboard shortcut I'm missing.

Thanks,
Keith
-- 

Keith M Swartz
oneroad...@gmail.com


Re: [O] Block level specification for tex code html export method

2015-09-03 Thread Haochen Xie
Hi Eric,

It's very likely due to this problem as both Andreas and I mentioned in
earlier mails:

Also please follow this link [1] to fix a
> ​bug
>  in htlatex as mentioned in Andreas's mail, or your html export will fail
> silently (showing success on emacs, but no images generated).
>
> ​​
> [1] http://tex.stackexchange.com/a/232739

​​
​Also, please make sure you have htlatex in your emacs' $PATH​.
​​
​Regards,

Haochen​



--

Mail from Haochen Xie

On Fri, Sep 4, 2015 at 3:15 PM, Eric S Fraga  wrote:

> On Thursday,  3 Sep 2015 at 23:38, Nicolas Goaziou wrote:
>
> [...]
>
> > What about
> >
> >   (defmacro by-backend (&rest body)
> > `(case org-export-current-backend ,@body))
>
> Nicolas,
>
> this seems to work!  I thought I had tried something like this but I
> must have got one of the ,@` wrong along the way...
>
> I do have a problem in that the svg file doesn't get created but that
> problem lies elsewhere methinks...
>
> Many thanks.
>
> --
> : Eric S Fraga (0xFFFCF67D), Emacs 25.0.50.2, Org release_8.3.1-188-g410ea6
>
>


Re: [O] Block level specification for tex code html export method

2015-09-03 Thread Eric S Fraga
On Thursday,  3 Sep 2015 at 23:38, Nicolas Goaziou wrote:

[...]

> What about
>
>   (defmacro by-backend (&rest body)
> `(case org-export-current-backend ,@body))

Nicolas,

this seems to work!  I thought I had tried something like this but I
must have got one of the ,@` wrong along the way...

I do have a problem in that the svg file doesn't get created but that
problem lies elsewhere methinks...

Many thanks.

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 25.0.50.2, Org release_8.3.1-188-g410ea6



Re: [O] org-mac-link to Mail.app doesn't work as expected

2015-09-03 Thread Mike McLean
Tobias

It's supposed to work regardless, in fact it stores the Message ID which
should never change.

Is there anything peculiar in your Mail setup?



On Wed, Sep 2, 2015 at 3:10 PM, Tobias Frischholz  wrote:

> Hi there,
>
> I’m using org-mac-link.el (
> http://orgmode.org/worg/org-contrib/org-mac-link.html), which is a
> fantastic tool for grabbing links from various Mac apps.
>
> But somehow it isn’t correctly linking to mails in Mail.app: The links
> work as long as the mails are in my Inbox.
> The link stops working when I’m moving them to my Archive.
>
> Also, fresh links to mails in the Archive also try to open them in my
> Inbox - where they aren’t any more of course.
>
> Is this a bug?
>
>
> Best regards,
> Tobias Frischholz
>
> PGP PUBLIC KEY: http://pgp.mit.edu/pks/lookup?search=0xCD463AC1&op=index
>
>


Re: [O] [PATCH] org-mime: make plain/text mime export a choice

2015-09-03 Thread Jon Miller

Will O'Brien writes:

> On 1 Sep 2015 08:18, "Nicolas Goaziou"  wrote:
>>
>> Is there any reason to keep using "org" exporter if "ascii" is superior?
>> I.e., what about simply replacing 'org with 'ascii?
>>
>
> FWIW
>
> There's a nice use case for exporting as org. If I compose an email which
> includes source code and I send it to a mixed audience, some of whom use
> gnus, and others an html based mua, then I get best of both worlds in terms
> of syntax highlighting, since gnus recognises org src blocks and applies
> appropriate highlighting and those using some other mua get the html
> highlighting as dictated by my own scheme.
>
> This also applies for a single recipient who may access email through gnus
> when available but needs the html version for viewing on, e.g. a handheld
> device.

Okay, thanks. I figured at least a few people would prefer to keep the
plain/text portion in org mode syntax and why I went with the configuration
option route.

At this point, I'm not sure if there is any further hacking left to be done
to the original patch I sent? Are we okay with just leaving the two options
of 'ascii and 'org? 

Thanks,
-- 
Jon Miller



[O] @@beamer:some code@@ in math mode

2015-09-03 Thread Rafael

Apparently the shortcut @@beamer:some code@@ does not work in math
mode. This:

--
This is a test @@beamer:some code@@ to check
\(x=@@beamer:y@@\)
--

exports (in beamer export) to:

--
This is a test some code to check
\(x=@@beamer:y@@\)
--

Could it be made to work in math mode too? I want to apply this
solution: http://tex.stackexchange.com/a/60692/250 to one presentation.

Regards,
Rafael




Re: [O] Block level specification for tex code html export method

2015-09-03 Thread Nicolas Goaziou
Hello,

Andreas Leha  writes:

> This macro is from Eric Schulte initially.  And I guess I would be out
> of luck adapting it to new Org mode versions as well.

What about

  (defmacro by-backend (&rest body)
`(case org-export-current-backend ,@body))
?

Regards,

-- 
Nicolas Goaziou



Re: [O] Block level specification for tex code html export method

2015-09-03 Thread Andreas Leha
Hi Eric,

Thanks for following that up!

Eric S Fraga  writes:
> On Thursday,  3 Sep 2015 at 13:30, Andreas Leha wrote:
>> Hi Alan,
>>
>> Glad you like the example.
>>
>> Three things:
>> 1. It still works for me ;-)
>
> Andreas,
>
> the example doesn't work for me with a quite recent org (updated within
> the past week) and with -Q.

I see.  Another reason for me not to upgrade?   My org is quite old.
(8.3beta (release_8.3beta-1264-g365c19))

>
> By the way, with emacs -Q, I need to "(required 'cl)" for the by-backend
> macro although this is probably done by one of the export files?
>
>> 2. The distorted png might come from the bug in htlatex I mentioned in
>> this thread [1].
>
> The solution has been pointed out by Haochen Xie in this thread
> (":imagemagick yes").  I needed this fix as well to get the png creation
> to work.
>

Good to know!  Thanks for the confirmation.  I missed that.

Note also that it might be necessary to include

 #+header: :headers '("\\usepackage{tikz}")

to the latex block.  This I only need when testing with emacs -Q.  Not
sure why, though.  I was under the impression that global
#+latex_headers should apply in latex source blocks as well?



>> 3. It seems that the by-backend does not work properly for you.  I am
>> not sure about the reason for that.  What org-mode version do you run?
>
> And it doesn't work for me either.  I recently ran into this problem
> myself with a document (long book chapter with many tikz figures) that I
> wrote about 4 months ago.  I had a deadline so couldn't track down what
> was wrong but it is all about the by-backend macro.  No matter what the
> target for export is, the by-backend macro doesn't work.  I tried to fix
> it but no luck, mostly due to my lack of emacs lisp funess...

This macro is from Eric Schulte initially.  And I guess I would be out
of luck adapting it to new Org mode versions as well.

I'd vote for a macro like this to be included in Org mode.  I think it
is quite useful to have and somehow extends the @@latex: ...@ constructs
to babel.  That way updates to org breaking this would be less probable.

Unfortunately, I don't have the time right now to even upgrade Org mode.
So, I cannot offer any testing/bisecting, I am afraid.

Best,
Andreas




Re: [O] Block level specification for tex code html export method

2015-09-03 Thread Andreas Leha
Hi Haochen,

Thanks for following that up!

Haochen Xie  writes:
> ​Hello
> Alan,
>
> I'm not 100% sure, but I think the distorted PNG file is generated by dvipng. 
> It seems that dvipng cannot handle tikz blocks very well, and one must use 
> imagemagick for those blocks. I
> think this line:
>
> #+header: :imagemagick :iminoptions -density 600 :imoutoptions -geometry 800
>
> should be
>
> #+header: :imagemagick yes :iminoptions -density 600 :imoutoptions -geometry 
> 800
>
> so that imagemagick would be used instead of dvipng, which is the global 
> default.

Thanks for that!  I'll keep that in mind.

Regards,
Andreas




>
> As said by Andreas, 
> ​it's probably that ​
> your
> ​​ by
> ​​-backend
> ​​ macro
> ​​ 
> ​is not working​
> properly, or, maybe you are not using a recent enough version of org-mod
> ​​e
> ​​. This
> ​​ 
> ​​magic
> ​, if I remember correctly,​
> ​​ 
> ​​is
>  
> ​​act
> uall
> ​y​
> ​​ done
> ​​ by
> ​​ a
> ​​ special
> ​​ case
> ​​ added
> ​​ to
> ​​ some
> ​​ latex
> ​​ babel
> ​​ export
> ​​ function
> ​​, wh
> ​​ich is contributed by Andreas somehow recently. You may want to try upgrade 
> your org-mode and try again.
>
> Also please follow this link [1] to fix a 
> ​bug
> in htlatex as mentioned in Andreas's mail, or your html export will fail 
> silently (showing success on emacs, but no images generated).
>
> [1] http://tex.stackexchange.com/a/232739
>
> --
>
> Mail from Haochen Xie
>
> On Thu, Sep 3, 2015 at 9:30 PM, Andreas Leha 
>  wrote:
>
>
>  Hi Alan,
>
>  Glad you like the example.
>
>  Three things:
>  1. It still works for me ;-)
>  2. The distorted png might come from the bug in htlatex I mentioned in
>  this thread [1].
>  3. It seems that the by-backend does not work properly for you. I am
>  not sure about the reason for that. What org-mode version do you run?
>
>  HTH,
>  Andreas
>
>  [1] http://tex.stackexchange.com/a/232739
>
>  Alan Schmitt  writes:
>  > Hello Andreas,
>  >
>  > I’m slowly catching up on the org mailing list, and I found your example
>  > very interesting. I tried to run it and it does not seem to work here.
>  > Here is what I did:
>  > - I copied the code below to a file
>  > - I evaluated the last block
>  > - I made sure that latex was one of the org-babel-load-languages
>  > language
>  > - I tried executing the first block, which generated this strange png
>  >
>  >
>  >
>  > - I exported both to html and pdf, and in both cases I would have
>  > a reference to the png instead of the svg/tikz code.
>  >
>  > I’m afraid I’m missing a step. Do you see what I’m doing wrong?
>  >
>  > Thanks,
>  >
>  > Alan
>  >
>  > On 2015-08-12 10:50, Andreas Leha  
> writes:
>  >
>  >> #+LATEX_HEADER: \usepackage{tikz}
>  >>
>  >> First execute the second code block, to define the convenience macro
>  >> and to set the required new variables in ob-latex.el. Then export to
>  >> HTML and to pdf to see the tree exported as an SVG image and as
>  >> embedded tikz respectively.
>  >>
>  >> * Tikz test
>  >> Here's a tree, exported to both html and pdf.
>  >>
>  >> #+header: :file (by-backend (html "tree.svg") (latex "tree.tikz") (t 
> "tree.png"))
>  >> #+header: :imagemagick :iminoptions -density 600 :imoutoptions -geometry 
> 800
>  >> #+header: :results file raw
>  >> #+header: :fit yes
>  >> #+begin_src latex
>  >> \usetikzlibrary{trees}
>  >> \begin{tikzpicture}
>  >> \node [circle, draw, fill=red!20] at (0,0) {1}
>  >> child { node [circle, draw, fill=blue!30] {2}
>  >> child { node [circle, draw, fill=green!30] {3} }
>  >> child { node [circle, draw, fill=yellow!30] {4} }};
>  >> \end{tikzpicture}
>  >> #+end_src
>  >>
>  >> #+results:
>  >> [[file:tree.png]]
>  >>
>  >> * COMMENT setup
>  >> #+begin_src emacs-lisp :results silent
>  >> (setq org-babel-latex-htlatex "htlatex")
>  >> (defmacro by-backend (&rest body)
>  >> `(case (if (boundp 'backend) (org-export-backend-name backend) nil) 
> ,@body))
>  >> #+end_src




Re: [O] Block level specification for tex code html export method

2015-09-03 Thread Eric S Fraga
On Thursday,  3 Sep 2015 at 13:30, Andreas Leha wrote:
> Hi Alan,
>
> Glad you like the example.
>
> Three things:
> 1. It still works for me ;-)

Andreas,

the example doesn't work for me with a quite recent org (updated within
the past week) and with -Q.

By the way, with emacs -Q, I need to "(required 'cl)" for the by-backend
macro although this is probably done by one of the export files?

> 2. The distorted png might come from the bug in htlatex I mentioned in
> this thread [1].

The solution has been pointed out by Haochen Xie in this thread
(":imagemagick yes").  I needed this fix as well to get the png creation
to work.

> 3. It seems that the by-backend does not work properly for you.  I am
> not sure about the reason for that.  What org-mode version do you run?

And it doesn't work for me either.  I recently ran into this problem
myself with a document (long book chapter with many tikz figures) that I
wrote about 4 months ago.  I had a deadline so couldn't track down what
was wrong but it is all about the by-backend macro.  No matter what the
target for export is, the by-backend macro doesn't work.  I tried to fix
it but no luck, mostly due to my lack of emacs lisp funess...

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 25.0.50.2, Org release_8.3.1-188-g410ea6



Re: [O] merge trees?

2015-09-03 Thread Thomas S . Dye
Aloha Matt,

Matt Price  writes:

> sounds interesting, can you send me a copy of the source? I don't usei
> nternal links very much!

Here is a link to the course syllabus and schedule, so you can see the
result:

http://www.tsdye.com/anth_323/anth_323_syllabus.html

My students seem to appreciate the Course Calendar and they definitely
appreciate the ReadTheOrg style.

I've attached the Org mode source, which probably depends on some code
in my library of Babel.  At least you'll be able to see how I structure
the file and use internal links.  I really like using the ID properties
for internal links to headlines, so I'm free to change the headline text
without breaking the link.

Also, there is a bunch of material in the attached file related to
exporting slide-show lectures to pdf, which you can ignore.  I've
stripped out the lecture content because it's not relevant to your
query.

All the best,
Tom

#+TITLE: Fall 2015 ANTH 323 Pacific Islands Archaeology
#+AUTHOR: Thomas S. Dye
#+LATEX_HEADER: \newcommand{\myuni}{University of Hawai`i at M\={a}noa}

 - Classroom: Saunders Hall 345
 - Meeting Times: MWF 12:30--1:20
 - Instructor: Dr. Thomas S. Dye (t...@hawaii.edu)
   - Office: Saunders Hall 346B
   - Office Hour: Friday 11:00--12:00, or by appointment

* Syllabus
  :PROPERTIES:
  :EXPORT_FILE_NAME: anth-323-f15-syllabus
  :EXPORT_TITLE: Fall 2015 Syllabus for ANTH 323
  :END:

This course is an introduction to archaeological research in Oceania,
a region including the islands of Polynesia, Melanesia, and
Micronesia. The exploration of this oceanic world, the ability of
Pacific Islanders to colonize remote, environmentally diverse
landforms, and their success developing a range of island societies
represent remarkable achievements in the history of humanity. We will
examine evidence for systematic long-distance voyaging, the human
colonization of previously uninhabited landscapes, and the independent
evolution of cultures descendant from a common ancestral heritage. The
course is open to both undergraduate and graduate students.

The central questions we address are: What is archaeology's place in
the study of Oceania's past alongside oral history, history,
historical linguistics, comparative ethnography, and genetics?  What
have been archaeology's main contributions to the history of Oceania?
What is the future of archaeology in Oceania?

This class is writing intensive. There will be a research paper (10
pages plus bibliography) and other shorter writing assignments. This
course is designed for upper-division undergraduates and graduate
students. We welcome all students with interests in Oceania. A
background in archaeology is helpful but not a prerequisite.

** Textbook

The required textbook for this semester is Patrick Kirch's /On the
Road of the Winds:/ /An Archaeological History of the Pacific Islands
before European Contact/.

Kirch is an emeritus professor at the University of California
Berkeley.  He grew up in M\amacron{}noa, attended Punahou School, earned a
Bachelor's degree at the University of Pennsylvania, and went on to
earn a PhD in Anthropology at Yale University. He has an unparalleled
range of archaeological experience throughout the Pacific starting
when he was a teenager in Hawai`i and continuing today.  He is:
  - an avid reader about all things Pacific who has made contributions
to the fields of linguistics and anthropology, in addition to archaeology;
  - a strong proponent of a multi-disciplinary approach that
integrates archaeology with various natural sciences, linguistics,
and ethnography;
  - a prolific author with a fluid writing style.

We will read and discuss the book critically, focusing primarily on
the archaeological materials and secondarily on the relationship of
archaeological evidence to other kinds of evidence.  In addition, in
class discussions and through students' term paper research, we will
discuss findings made since the textbook was published more than a
decade ago.

** Class Meetings

The class meets Monday, Wednesday, and Friday from 12:30 to 1:20 in
Saunders Hall 345.  The class is organized as a seminar, so please sit
at the table.

The course is structured to maximize discussion time during class
meetings.  The successful student will come to class well-prepared and
eager to engage in discussion.  In particular, please prepare for
class by completing the reading and pondering the discussion questions.

All inquiry begins with doubt.  Please come to class with questions of
your own!

Tip: Discuss your term paper research in class, as appropriate.  The
responses you get from your instructor and fellow students might help
you understand your term paper topic in a new or interesting way.

** Grading

Your grade will be based on the total number of points you earn in the
mid-term examination, research paper, discussion papers, annotated
maps, and class participation.  Note that you must complete the final
term paper and turn it in on time to 

Re: [O] merge trees?

2015-09-03 Thread Rasmus
Matt Price  writes:

> * Topics
> ** Introduction
> ** Crowds and Publics
> ** Spatial History
>
> * Labs
> ** Intro to HTML
> ** Styling with CSS
> ** The Google Maps Javascript API
>
> The two subtrees can be manipulated independently, then merged to create
> something like:
>
> * Schedule
> ** <2015-09-15>
> *** Seminar: Introduction
> *** Lab: Intro to HTML

You should probably use a key for matching.  Otherwise I can promise you
it will get messy (it seems you want to match based on the location in the
three).

> Is there an easy way to do this already? Or is the best thing to do to
> write a piece of elisp that generates the appropriate structure using
> org-element, and put that code in a babel block?

Probably the best way might be a custom exporter.  ox-koma-script collects
"special headlines" and insert them later.  You could do the same.

> And if the latter, does anyone, um, want to write the code for me?

Sounds like the job of a personal, underpaid slav...  TA!


You can cook some more on this.

 * topics
 :PROPERTIES:
 :outline_prefix:
 :END:
 ** Intro
 :PROPERTIES:
 :outline_class: 1
 :END:
 <2015-09-03 jue>
 Intro text
 ** can I has czz?
 :PROPERTIES:
 :outline_class: 2
 :END:
 <2015-09-05 sáb>
 x
 * labs
 :PROPERTIES:
 :outline_prefix: Lab
 :END:
 ** intro to html
 :PROPERTIES:
 :outline_class: 1
 :END:

 ** lab 
 :PROPERTIES:
 :outline_class: 2
 :END:
 * magic 

 #+BEGIN_SRC emacs-lisp
   (let* ((parse-tree (org-element-parse-buffer))
  (classes (delete-duplicates (org-element-map parse-tree 'headline
(lambda (h) 
  (org-element-property 
:OUTLINE_CLASS h))) 
  :test 'equal))
  (times (org-element-map (org-element-parse-buffer) 'timestamp
   (lambda (time)
 (list (org-export-get-node-property :OUTLINE_CLASS 
time t) 
   (org-element-property :raw-value time))
 )))
  (dataz (mapcar (lambda (class)
   (list :class class
 :schedule (cadr (assoc class times))
 :heads (delq nil
  (org-element-map parse-tree 
'headline
(lambda (h) (and (equal 
class
   
(org-element-property :OUTLINE_CLASS h))
h))
 classes)))
 (with-temp-file "/tmp/outline.org"
   (erase-buffer)
   (insert "* schedule\n")
   (mapc (lambda (data)
   (insert "** " (plist-get data :schedule) "\n")
   ;; Here you could add sorting to get it in the desired order.
   (insert (mapconcat 'org-element-interpret-data 
  (mapcar
   ;; You could add prefixes and so forth
   ;; using the outline-prefix property
   (lambda (h) (let ((l 
(org-element-property :level h)))
(org-element-put-property h 
:level (1+ l
   (plist-get data :heads))
  "\n")))
 dataz)))

 #+END_SRC



-- 
I hear there's rumors on the, uh, Internets. . .




Re: [O] merge trees?

2015-09-03 Thread Matt Price
sounds interesting, can you send me a copy of the source? I don't usei
nternal links very much!


On Thu, Sep 3, 2015 at 1:48 PM, Thomas S. Dye  wrote:

> Aloha Matt,
>
> Matt Price  writes:
>
> > Eveyr year at this time, I struggle with the structure of my course
> > syllabi, and move bits an pieces around with wild abandon.  At the end of
> > my struggles, my course outline will be filled with headings like this:
> > 
> > ** <2015-10-06 Tue> Spatial History
> > Thinking about the visual presentation of information, especially in map
> > form
> > *** Readings
> > + Franco Moretti, /Graphs, Maps, Trees/, ch. 1 ([[
> >
> http://2012.hackinghistory.ca/wp-content/uploads/2012/09/placing-history.pdf][Graphs
> ]]
> > ).
> > + Knowles, A. K. “GIS and History.” [[
> >
> http://2012.hackinghistory.ca/wp-content/uploads/2012/09/pariser-filter-bubble.pdf][/Placing
> > History: How Maps, Spatial Data, and GIS Are Changing Historical
> > Scholarship/]] (2008): 1–13.
> > + Bondenhamer, David J. “History and GIS: Implications for the
> Discipline.”
> > /Placing History: How Maps, Spatial Data, and GIS Are Changing Historical
> > Scholarship/ (2008): 219-234.
> > + Theibault, John. “[[
> >
> http://writinghistory.trincoll.edu/evidence/theibault-2012-spring/][Visualizations
> > and Historical Arguments]].” Writing History in the Digital Age, March
> 23,
> > 2012.
> > *** Lab: Google Maps and Javascript
> > --
> >
> > Unfortunately, the Seminar topics, labs, and readings do not always match
> > up very well. It occurs to me that it would be preferable to maintain
> > separate trees of seminar topics and labs, and merge them, so eg:
> >
> > * Topics
> > ** Introduction
> > ** Crowds and Publics
> > ** Spatial History
> >
> > * Labs
> > ** Intro to HTML
> > ** Styling with CSS
> > ** The Google Maps Javascript API
> >
> > The two subtrees can be manipulated independently, then merged to create
> > something like:
> >
> > * Schedule
> > ** <2015-09-15>
> > *** Seminar: Introduction
> > *** Lab: Intro to HTML
> >
> > (each subheading will also include content, e.g., a description of the
> > class, some lab instructions, etc.).
> >
> > Is there an easy way to do this already? Or is the best thing to do to
> > write a piece of elisp that generates the appropriate structure using
> > org-element, and put that code in a babel block? And if the latter, does
> > anyone, um, want to write the code for me?
> >
>
> I keep separate headings for readings, discussion questions, lectures,
> etc., and don't attach dates directly to the headings.  Then, I put
> together a course calendar as a table that includes links to all the
> relevant parts.  I export this to html, using Fabrice Niessen's
> ReadTheOrg stylesheet, and I'm good to go.  My students like it, too.
>
> Not sure if this is what you're after, but it is working for me.
>
> All the best,
> Tom
> --
> Thomas S. Dye
> http://www.tsdye.com
>


Re: [O] merge trees?

2015-09-03 Thread Thomas S . Dye
Aloha Matt,

Matt Price  writes:

> Eveyr year at this time, I struggle with the structure of my course
> syllabi, and move bits an pieces around with wild abandon.  At the end of
> my struggles, my course outline will be filled with headings like this:
> 
> ** <2015-10-06 Tue> Spatial History
> Thinking about the visual presentation of information, especially in map
> form
> *** Readings
> + Franco Moretti, /Graphs, Maps, Trees/, ch. 1 ([[
> http://2012.hackinghistory.ca/wp-content/uploads/2012/09/placing-history.pdf][Graphs]]
> ).
> + Knowles, A. K. “GIS and History.” [[
> http://2012.hackinghistory.ca/wp-content/uploads/2012/09/pariser-filter-bubble.pdf][/Placing
> History: How Maps, Spatial Data, and GIS Are Changing Historical
> Scholarship/]] (2008): 1–13.
> + Bondenhamer, David J. “History and GIS: Implications for the Discipline.”
> /Placing History: How Maps, Spatial Data, and GIS Are Changing Historical
> Scholarship/ (2008): 219-234.
> + Theibault, John. “[[
> http://writinghistory.trincoll.edu/evidence/theibault-2012-spring/][Visualizations
> and Historical Arguments]].” Writing History in the Digital Age, March 23,
> 2012.
> *** Lab: Google Maps and Javascript
> --
>
> Unfortunately, the Seminar topics, labs, and readings do not always match
> up very well. It occurs to me that it would be preferable to maintain
> separate trees of seminar topics and labs, and merge them, so eg:
>
> * Topics
> ** Introduction
> ** Crowds and Publics
> ** Spatial History
>
> * Labs
> ** Intro to HTML
> ** Styling with CSS
> ** The Google Maps Javascript API
>
> The two subtrees can be manipulated independently, then merged to create
> something like:
>
> * Schedule
> ** <2015-09-15>
> *** Seminar: Introduction
> *** Lab: Intro to HTML
>
> (each subheading will also include content, e.g., a description of the
> class, some lab instructions, etc.).
>
> Is there an easy way to do this already? Or is the best thing to do to
> write a piece of elisp that generates the appropriate structure using
> org-element, and put that code in a babel block? And if the latter, does
> anyone, um, want to write the code for me?
>

I keep separate headings for readings, discussion questions, lectures,
etc., and don't attach dates directly to the headings.  Then, I put
together a course calendar as a table that includes links to all the
relevant parts.  I export this to html, using Fabrice Niessen's
ReadTheOrg stylesheet, and I'm good to go.  My students like it, too. 

Not sure if this is what you're after, but it is working for me.

All the best,
Tom
-- 
Thomas S. Dye
http://www.tsdye.com



[O] Babel, var vrom property drawer in function call?

2015-09-03 Thread Kalev Takkis
Hi list,

Is there a way to use variables defined as :var: in :PROPERTIES: drawer in
function call? Such as

** Some heading
   :PROPERTIES:
   :var:  par1="smth"
   :END:

   #+call: some-function(parameter=par1)


Better yet, is there a way to have the function itself to figure out which
properties are in effect in a place where a function is called from? What I
mean is, when i have a code block

#+name: some-function
#+begin_src sh :results code
   echo $par1
#+end_src

defined under ** Some heading, evaluating the function will echo the value
of par1. But when the function is defined somewhere where par1 is not
defined, calling it under ** Some heading with #+call doesn't work. Can I
somehow instruct org to automatically use the parameter value from the
place where the function is called with #+call, rather than where its body
is defined?

All the best,
Kalev


[O] merge trees?

2015-09-03 Thread Matt Price
Eveyr year at this time, I struggle with the structure of my course
syllabi, and move bits an pieces around with wild abandon.  At the end of
my struggles, my course outline will be filled with headings like this:

** <2015-10-06 Tue> Spatial History
Thinking about the visual presentation of information, especially in map
form
*** Readings
+ Franco Moretti, /Graphs, Maps, Trees/, ch. 1 ([[
http://2012.hackinghistory.ca/wp-content/uploads/2012/09/placing-history.pdf][Graphs]]
).
+ Knowles, A. K. “GIS and History.” [[
http://2012.hackinghistory.ca/wp-content/uploads/2012/09/pariser-filter-bubble.pdf][/Placing
History: How Maps, Spatial Data, and GIS Are Changing Historical
Scholarship/]] (2008): 1–13.
+ Bondenhamer, David J. “History and GIS: Implications for the Discipline.”
/Placing History: How Maps, Spatial Data, and GIS Are Changing Historical
Scholarship/ (2008): 219-234.
+ Theibault, John. “[[
http://writinghistory.trincoll.edu/evidence/theibault-2012-spring/][Visualizations
and Historical Arguments]].” Writing History in the Digital Age, March 23,
2012.
*** Lab: Google Maps and Javascript
--

Unfortunately, the Seminar topics, labs, and readings do not always match
up very well. It occurs to me that it would be preferable to maintain
separate trees of seminar topics and labs, and merge them, so eg:

* Topics
** Introduction
** Crowds and Publics
** Spatial History

* Labs
** Intro to HTML
** Styling with CSS
** The Google Maps Javascript API

The two subtrees can be manipulated independently, then merged to create
something like:

* Schedule
** <2015-09-15>
*** Seminar: Introduction
*** Lab: Intro to HTML

(each subheading will also include content, e.g., a description of the
class, some lab instructions, etc.).

Is there an easy way to do this already? Or is the best thing to do to
write a piece of elisp that generates the appropriate structure using
org-element, and put that code in a babel block? And if the latter, does
anyone, um, want to write the code for me?

Many thanks for your help,
Matt


[O] shell scripts in yasnippet?

2015-09-03 Thread Tobias Frischholz
Hi there,

right now I’m tinkering around with yasnippet.
I was wondering if there’s a possibility to run a shell script and write its 
results in the text file.

Specifically, I’m want to run “fortune” and put the results in a 
#+BEGIN_QUOTE…#+END_QUOTE block.
Would that be possible?
Best regards,
Tobias Frischholz

PGP PUBLIC KEY: http://pgp.mit.edu/pks/lookup?search=0xCD463AC1&op=index



Re: [O] File local circular links

2015-09-03 Thread Nicolas Goaziou
Hello,

Michael Brand  writes:

> I use a hack to work around a missing feature that I would like to
> call "file local circular links". It works until
> release_8.2.10-2341-g8094d01 but stops with
> release_8.2.10-2342-gcfe5bc9
>
> commit cfe5bc97f8b18ccbf49d0764746c7563ce8d29da
> Author: Nicolas Goaziou 
> Date:   Mon Aug 3 01:06:32 2015 +0200
>
> Fix link search
>
> and I would like to ask for some help to get it work again.
>
> File local circular links does this: C-c C-o on line 1 of the file
>
> -
> [[:file local circular link:]]
> some text
> [[:file local circular link:]]
> -
>
> moves to line 3 and C-c C-o again moves back to line 1. (It does not
> follow all links when there are more than two but this limitation is a
> different story.)
>
> The hack that I used so far is
>
> #+BEGIN_SRC emacs-lisp
>   (defun f-org-link-exec (str)
> (let* ((context (org-element-context))
>(link (let ((up (org-element-property :parent context)))
>(if (eq (org-element-type up) 'link) up context)))
>(avoid-pos (org-element-property :begin link)))
>   (cond
>;; [[<>]]: Remove the angular brackets to let `org-link-search'
>;; match `str' as an angular bracket link.
>((string-match "^<<\\(.*\\)>>$" str)
> (let ((org-execute-file-search-functions nil))
>   (org-link-search (match-string 1 str) 'dedicated avoid-pos)))
>;; [[_:xy:]] (abbreviated with "#+LINK: _ file:bla.org:::") or
>;; [[:xy:]]: Bind `org-link-search-must-match-exact-headline' to nil
>;; temporarily.
>((string-match-p "^:.*:$" str)
> (let ((org-execute-file-search-functions nil)
>   (org-link-search-must-match-exact-headline nil))
>   ;; The leading part may be "[[link_abbreviation" or just "[[".
>   (org-link-search (concat "\\[\\[[^:]*" (regexp-quote str) "\\]\\]")
>'fuzzy avoid-pos))
>   (add-hook 'org-execute-file-search-functions 'f-org-link-exec)
> #+END_SRC
>
> The problematic part is the use of org-link-search which changed. In
> the above example it is called as
>
> #+BEGIN_SRC emacs-lisp
>   (let ((org-execute-file-search-functions nil)
> (org-link-search-must-match-exact-headline nil))
> (org-link-search "\\[\\[[^:]*:file local circular link:\\]\\]"))
> #+END_SRC
>
> and after the commit org-link-search errors with "cond: No match for
> fuzzy expression: \[\[[^:]*:file local circular link:\]\]". To me it
> looks like if support for regular expressions for fuzzy links has been
> dropped. I can not use the regexp search here because it invokes the
> org-occur sparse tree.

I don't know anything like regular expression support for fuzzy links.

> How can I deal with this?

Can't you simply do

  (org-link-search ":file local circular link:" (point))

?

You could also use target-links, or define a new type of link that would
trigger a search in the buffer, see `org-add-link-type'.


Regards,

-- 
Nicolas Goaziou



[O] File local circular links

2015-09-03 Thread Michael Brand
Hi all

I use a hack to work around a missing feature that I would like to
call "file local circular links". It works until
release_8.2.10-2341-g8094d01 but stops with
release_8.2.10-2342-gcfe5bc9

commit cfe5bc97f8b18ccbf49d0764746c7563ce8d29da
Author: Nicolas Goaziou 
Date:   Mon Aug 3 01:06:32 2015 +0200

Fix link search

and I would like to ask for some help to get it work again.

File local circular links does this: C-c C-o on line 1 of the file

-
[[:file local circular link:]]
some text
[[:file local circular link:]]
-

moves to line 3 and C-c C-o again moves back to line 1. (It does not
follow all links when there are more than two but this limitation is a
different story.)

The hack that I used so far is

#+BEGIN_SRC emacs-lisp
  (defun f-org-link-exec (str)
(let* ((context (org-element-context))
   (link (let ((up (org-element-property :parent context)))
   (if (eq (org-element-type up) 'link) up context)))
   (avoid-pos (org-element-property :begin link)))
  (cond
   ;; [[<>]]: Remove the angular brackets to let `org-link-search'
   ;; match `str' as an angular bracket link.
   ((string-match "^<<\\(.*\\)>>$" str)
(let ((org-execute-file-search-functions nil))
  (org-link-search (match-string 1 str) 'dedicated avoid-pos)))
   ;; [[_:xy:]] (abbreviated with "#+LINK: _ file:bla.org:::") or
   ;; [[:xy:]]: Bind `org-link-search-must-match-exact-headline' to nil
   ;; temporarily.
   ((string-match-p "^:.*:$" str)
(let ((org-execute-file-search-functions nil)
  (org-link-search-must-match-exact-headline nil))
  ;; The leading part may be "[[link_abbreviation" or just "[[".
  (org-link-search (concat "\\[\\[[^:]*" (regexp-quote str) "\\]\\]")
   'fuzzy avoid-pos))
  (add-hook 'org-execute-file-search-functions 'f-org-link-exec)
#+END_SRC

The problematic part is the use of org-link-search which changed. In
the above example it is called as

#+BEGIN_SRC emacs-lisp
  (let ((org-execute-file-search-functions nil)
(org-link-search-must-match-exact-headline nil))
(org-link-search "\\[\\[[^:]*:file local circular link:\\]\\]"))
#+END_SRC

and after the commit org-link-search errors with "cond: No match for
fuzzy expression: \[\[[^:]*:file local circular link:\]\]". To me it
looks like if support for regular expressions for fuzzy links has been
dropped. I can not use the regexp search here because it invokes the
org-occur sparse tree.

How can I deal with this?

Michael



[O] property list indentation and TODO state changes

2015-09-03 Thread George McNinch
Rather than try to discuss the issue, I'll just give (hopefully
simple enough) steps which will reproduce it.

Visit an org-mode buffer, with the following contents:

#---
#+STARTUP: logdrawer
#+TODO: APPT(a) | DONE(d!)

* APPT <2015-09-03 Thu +1m> ack
  :PROPERTIES:
  :FOO:  Bar
  :END:
#---

With point on the line "* APPT ...", do C-t d i.e. (org-todo) and then
choose "d".

The file is then transformed as follows:

---
#+STARTUP: logdrawer
#+TODO: APPT(a) | DONE(d!)

* APPT <2015-10-03 Wed +1m> ack
:PROPERTIES:
  :FOO:  Bar 
  :END:
  :LOGBOOK:
  :LAST_REPEAT: [2015-09-03 Thu 09:01]
  - State "DONE"   from "APPT"   [2015-09-03 Thu 09:01]
  :END:
---

The behavior of the indentation on the line containing ":PROPERTIES:"
seems odd.

And I think the :LAST_REPEAT: line should have instead appeared in the
property list, rather than in the LOGBOOK.

Note that if instead the starting state is

---
#+STARTUP: logdrawer
#+TODO: APPT(a) | DONE(d!)

* APPT <2015-09-03 Wed +1m> ack
:PROPERTIES:
  :FOO:  Bar 
  :END:
  :LOGBOOK:
  - [2015-09-03 Thu] a comment
  :END:
---

(i..e there is "already a LOGBOOK") then C-t d results in

---
* APPT <2015-10-03 Sat +1m> ack
:PROPERTIES:
  :FOO:  Bar
  :LAST_REPEAT: [2015-09-03 Thu 09:04]
  :END:
  :LOGBOOK:
  - State "DONE"   from "APPT"   [2015-09-03 Thu 09:04]
  - [2015-09-03 Thu] a comment
  :END:
---

so the LAST_REPEAT works as expected, but the indentation is still odd.

org-version: 8.3.1 (from elpa).

Best,
george

-- 
   +=+=+   George McNinch 
   +=+=+   http://gmcninch.math.tufts.edu 




Re: [O] Block level specification for tex code html export method

2015-09-03 Thread Haochen Xie
​Hello
 Alan,

I'm not 100% sure, but I think the distorted PNG file is generated by
dvipng. It seems that dvipng cannot handle tikz blocks very well, and one
must use imagemagick for those blocks. I think this line:

#+header: :imagemagick :iminoptions -density 600 :imoutoptions -geometry 800

should be

#+header: :imagemagick yes :iminoptions -density 600 :imoutoptions
-geometry 800

so that imagemagick would be used instead of dvipng, which is the global
default.

As said by Andreas,
​it's probably that ​
your
​​
by
​​
-backend
​​
macro
​​
​is not working​
 properly, or, maybe you are not using a recent enough version of org-mod
​​
e
​​
. This
​​
​​
magic
​, if I remember correctly,​
​​
​​
is
​​
​​
​​
act
​​
​​
uall
​​
​​
​​
​​
​​
​​
​​
​​
​​
​​
​​
​​
​​
​​
​y​
​​
done
​​
by
​​
a
​​
special
​​
case
​​
added
​​
to
​​
some
​​
latex
​​
babel
​​
export
​​
function
​​
, wh
​​
ich is contributed by Andreas somehow recently. You may want to try upgrade
your org-mode and try again.

Also please follow this link [1] to fix a
​bug
 in htlatex as mentioned in Andreas's mail, or your html export will fail
silently (showing success on emacs, but no images generated).

[1] http://tex.stackexchange.com/a/232739




--

Mail from Haochen Xie

On Thu, Sep 3, 2015 at 9:30 PM, Andreas Leha <
andreas.l...@med.uni-goettingen.de> wrote:

> Hi Alan,
>
> Glad you like the example.
>
> Three things:
> 1. It still works for me ;-)
> 2. The distorted png might come from the bug in htlatex I mentioned in
> this thread [1].
> 3. It seems that the by-backend does not work properly for you.  I am
> not sure about the reason for that.  What org-mode version do you run?
>
> HTH,
> Andreas
>
>
> [1] http://tex.stackexchange.com/a/232739
>
>
>
> Alan Schmitt  writes:
> > Hello Andreas,
> >
> > I’m slowly catching up on the org mailing list, and I found your example
> > very interesting. I tried to run it and it does not seem to work here.
> > Here is what I did:
> > - I copied the code below to a file
> > - I evaluated the last block
> > - I made sure that latex was one of the org-babel-load-languages
> >   language
> > - I tried executing the first block, which generated this strange png
> >
> >
> >
> > - I exported both to html and pdf, and in both cases I would have
> >   a reference to the png instead of the svg/tikz code.
> >
> > I’m afraid I’m missing a step. Do you see what I’m doing wrong?
> >
> > Thanks,
> >
> > Alan
> >
> > On 2015-08-12 10:50, Andreas Leha 
> writes:
> >
> >> #+LATEX_HEADER: \usepackage{tikz}
> >>
> >> First execute the second code block, to define the convenience macro
> >> and to set the required new variables in ob-latex.el.  Then export to
> >> HTML and to pdf to see the tree exported as an SVG image and as
> >> embedded tikz respectively.
> >>
> >> * Tikz test
> >> Here's a tree, exported to both html and pdf.
> >>
> >> #+header: :file (by-backend (html "tree.svg") (latex "tree.tikz") (t
> "tree.png"))
> >> #+header: :imagemagick :iminoptions -density 600 :imoutoptions
> -geometry 800
> >> #+header: :results file raw
> >> #+header: :fit yes
> >> #+begin_src latex
> >>   \usetikzlibrary{trees}
> >>   \begin{tikzpicture}
> >> \node [circle, draw, fill=red!20] at (0,0) {1}
> >> child { node [circle, draw, fill=blue!30] {2}
> >>   child { node [circle, draw, fill=green!30] {3} }
> >>   child { node [circle, draw, fill=yellow!30] {4} }};
> >>   \end{tikzpicture}
> >> #+end_src
> >>
> >> #+results:
> >> [[file:tree.png]]
> >>
> >> * COMMENT setup
> >> #+begin_src emacs-lisp :results silent
> >>   (setq org-babel-latex-htlatex "htlatex")
> >>   (defmacro by-backend (&rest body)
> >> `(case (if (boundp 'backend) (org-export-backend-name backend) nil)
> ,@body))
> >> #+end_src
>
>
>
>
>


Re: [O] Block level specification for tex code html export method

2015-09-03 Thread Andreas Leha
Hi Alan,

Glad you like the example.

Three things:
1. It still works for me ;-)
2. The distorted png might come from the bug in htlatex I mentioned in
this thread [1].
3. It seems that the by-backend does not work properly for you.  I am
not sure about the reason for that.  What org-mode version do you run?

HTH,
Andreas


[1] http://tex.stackexchange.com/a/232739



Alan Schmitt  writes:
> Hello Andreas,
>
> I’m slowly catching up on the org mailing list, and I found your example
> very interesting. I tried to run it and it does not seem to work here.
> Here is what I did:
> - I copied the code below to a file
> - I evaluated the last block
> - I made sure that latex was one of the org-babel-load-languages
>   language
> - I tried executing the first block, which generated this strange png
>   
>
>
> - I exported both to html and pdf, and in both cases I would have
>   a reference to the png instead of the svg/tikz code.
>
> I’m afraid I’m missing a step. Do you see what I’m doing wrong?
>
> Thanks,
>
> Alan
>
> On 2015-08-12 10:50, Andreas Leha  writes:
>
>> #+LATEX_HEADER: \usepackage{tikz}
>>
>> First execute the second code block, to define the convenience macro
>> and to set the required new variables in ob-latex.el.  Then export to
>> HTML and to pdf to see the tree exported as an SVG image and as
>> embedded tikz respectively.
>>
>> * Tikz test
>> Here's a tree, exported to both html and pdf.
>>
>> #+header: :file (by-backend (html "tree.svg") (latex "tree.tikz") (t 
>> "tree.png"))
>> #+header: :imagemagick :iminoptions -density 600 :imoutoptions -geometry 800
>> #+header: :results file raw
>> #+header: :fit yes
>> #+begin_src latex
>>   \usetikzlibrary{trees}
>>   \begin{tikzpicture}
>> \node [circle, draw, fill=red!20] at (0,0) {1}
>> child { node [circle, draw, fill=blue!30] {2}
>>   child { node [circle, draw, fill=green!30] {3} }
>>   child { node [circle, draw, fill=yellow!30] {4} }};
>>   \end{tikzpicture}
>> #+end_src
>>
>> #+results:
>> [[file:tree.png]]
>>
>> * COMMENT setup
>> #+begin_src emacs-lisp :results silent
>>   (setq org-babel-latex-htlatex "htlatex")
>>   (defmacro by-backend (&rest body)
>> `(case (if (boundp 'backend) (org-export-backend-name backend) nil) 
>> ,@body))
>> #+end_src






Re: [O] Block level specification for tex code html export method

2015-09-03 Thread Alan Schmitt
Hello Andreas,

I’m slowly catching up on the org mailing list, and I found your example
very interesting. I tried to run it and it does not seem to work here.
Here is what I did:
- I copied the code below to a file
- I evaluated the last block
- I made sure that latex was one of the org-babel-load-languages
  language
- I tried executing the first block, which generated this strange png
  - I exported both to html and pdf, and in both cases I would have
  a reference to the png instead of the svg/tikz code.

I’m afraid I’m missing a step. Do you see what I’m doing wrong?

Thanks,

Alan

On 2015-08-12 10:50, Andreas Leha  writes:

> #+LATEX_HEADER: \usepackage{tikz}
>
> First execute the second code block, to define the convenience macro
> and to set the required new variables in ob-latex.el.  Then export to
> HTML and to pdf to see the tree exported as an SVG image and as
> embedded tikz respectively.
>
> * Tikz test
> Here's a tree, exported to both html and pdf.
>
> #+header: :file (by-backend (html "tree.svg") (latex "tree.tikz") (t 
> "tree.png"))
> #+header: :imagemagick :iminoptions -density 600 :imoutoptions -geometry 800
> #+header: :results file raw
> #+header: :fit yes
> #+begin_src latex
>   \usetikzlibrary{trees}
>   \begin{tikzpicture}
> \node [circle, draw, fill=red!20] at (0,0) {1}
> child { node [circle, draw, fill=blue!30] {2}
>   child { node [circle, draw, fill=green!30] {3} }
>   child { node [circle, draw, fill=yellow!30] {4} }};
>   \end{tikzpicture}
> #+end_src
>
> #+results:
> [[file:tree.png]]
>
> * COMMENT setup
> #+begin_src emacs-lisp :results silent
>   (setq org-babel-latex-htlatex "htlatex")
>   (defmacro by-backend (&rest body)
> `(case (if (boundp 'backend) (org-export-backend-name backend) nil) 
> ,@body))
> #+end_src

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7
Last week athmospheric CO₂ average (Updated August 31, 2015, Mauna Loa Obs.):
377.82 ppm


signature.asc
Description: PGP signature


[O] activate new org-tree-to-indirect-buffer to rename to name of heading

2015-09-03 Thread Rainer M Krug
Hi

I am following an older discussion of mine (Subject:
org-tree-to-indirect-buffer - naming and prefix in define keyboard key).

I have

#+begin_src emacs-lisp
(define-key org-mode-map "\C-ci" (lambda ()
   (interactive)
   (org-tree-to-indirect-buffer '(4
#+end_src

to open the org-tree in a new indirect buffer. This works nice, but I
want to rename the buffer.

I know from Alan Schmitt that I can do this by using

#+begin_src emacs-lisp
 (rename-buffer (org-get-heading) t)
#+end_src

but I have to activate the new indirect buffer first.

How can I activate the new indirect buffer, so that I can rename it to
the name of the header?

Thanks,

Rainer
-- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, 
UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa

Tel :   +33 - (0)9 53 10 27 44
Cell:   +33 - (0)6 85 62 59 98
Fax :   +33 - (0)9 58 10 27 44

Fax (D):+49 - (0)3 21 21 25 22 44

email:  rai...@krugs.de

Skype:  RMkrug

PGP: 0x0F52F982


signature.asc
Description: PGP signature


[O] Templating with Org

2015-09-03 Thread Eric Abrahamsen
A while ago I asked about creating a system that repeats body text for
many Org headings -- essentially writing an export template that is
re-used for many headings. Search through Gmane is tedious and strangely
inaccurate, so I'm not bothering to find the original thread.

I've come up with a solution that others might find useful -- I'm also
hoping for some tips on improving it. I suppose I can add it to Worg
later.

I'll paste the function at the bottom, but what I'm talking about is
this:

#+BEGIN_SOURCE org
Templating Test
:PROPERTIES:
:EXPORT_BODY_TEMPLATE: template-heading
:END:
** Bob Jones
:PROPERTIES:
:SALUTATION: Dear Mr Jones
:MARMOTS:  390
:END:
** Janet Smith
:PROPERTIES:
:SALUTATION: Dear Prof. Smith
:MARMOTS:  9
:END:
** Unknown
:PROPERTIES:
:SALUTATION: Dear Sir/Madame
:MARMOTS:  42
:END:
Also, would you at your earliest convenience please remind us of your
name?
* Template body:noexport:
:PROPERTIES:
:ID:   template-heading
:END:
{{{property(SALUTATION)}}},

This is an automatically-generated form letter, informing you that you
have {{{property(MARMOTS)}}} marmots remaining in your account at the
United Bank of Marmots.

@@body@@

Yours truly,\\
Director of the United Bank of Marmots
#+END_SOURCE

When this is exported, the body of the "Template body" heading is
switched in for the bodies of each of the children of "Templating test".
That lets you use property macros to fill in the template context. As a
special case, the string "@@body@@" will be replaced with the original
body of the exported heading, if there is one.

The function below works fine, though I'd sure like to know if anyone
has any suggestions for cleaning it up, particular the bits about
finding and extracting heading bodies.

More unfortunately, it doesn't work if you restrict the export scope to
the "Templating Test" subtree, because the "EXPORT_BODY_TEMPLATE"
property isn't seen. I'd sure like to find a way to fix that.

I suppose one solution would be to explicitly add EXPORT_BODY_TEMPLATE
to the list of inherited properties, and then remove the inner
`org-map-entries'. But one of the things I like about the current
arrangement is that it is limited to direct children of the heading with
that property set.

Anyway, comments and improvements welcome!

Eric


#+BEGIN_SOURCE emacs-lisp
(defun org-template-replace (backend)
  "Do template body replacement in the exported region.

For any heading that has the EXPORT_BODY_TEMPLATE property set,
treat the value of that property as an org heading id, find that
heading, get its body text, and replace the body text of each of
this heading's children with that text.

This can be used to write a single export template which is then
used for many headings."
  (let ((org-use-property-inheritance nil))
(org-map-entries
 (lambda ()
   (let ((targ (org-entry-get (point) "EXPORT_BODY_TEMPLATE"))
 (level (org-current-level))
 original-body template-body)
 (when targ
   (setq template-body
 (save-excursion
   (org-id-goto targ)
   (org-end-of-meta-data t)
   (when (or (looking-at org-heading-regexp)
 (= (point) (point-max)))
 (user-error "Template heading has no body text."))
   (buffer-substring-no-properties
(point)
(progn (org-next-visible-heading 1)
   (point)
   (save-restriction
 (org-narrow-to-subtree)
 (org-map-entries
  (lambda ()
(org-end-of-meta-data t)
(cond
 ((looking-at org-heading-regexp)
  (open-line 1))
 ((= (point) (point-max))
  (newline))
 (t (setq original-body
  (delete-and-extract-region
   (point)
   (progn
 (save-excursion
   (org-next-visible-heading 1)
   (point)))

(insert
 (replace-regexp-in-string
  (if original-body
  "@@body@@"
"@@body@@\n\n") (or original-body "") template-body))
(setq org-map-continue-from (1- (point
  (format "LEVEL=%d" (1+ level)))
 "EXPORT_BODY_TEMPLATE<>\"\"")))

(add-hook 'org-export-before-processing-hook #'org-template-replace)

#+END_SOURCE