Re: [O] exporting zotxt or orgref links to HTML and ODF

2015-01-27 Thread Richard Lawrence
Rasmus ras...@gmx.us writes:

 BTW: Org has an almost-agnostic format for storing citation data via
 org-bibtex.el.  So perhaps it's easier to go from whatever to
 org-bibtex-format and from there to ox-backend-format.  I think that's how
 pandoc does it as well.

Well, that would certainly suit me, as I already store my citation data
in org-bibtex format, and generate a .bib file as needed from it.  I
think Pandoc does something similar with YAML, either in-file or in a
separate bibliography file.  I do not know if the org-bibtex format will
play nicely with non-BibTeX citation databases, though; can anyone speak
to that?

Best,
Richard




Re: [O] Is it possible to use org-babel to deal with bibtex?

2014-12-15 Thread Richard Lawrence
Hi Feng,

Feng Shu tuma...@gmail.com writes:

 I want to deal with my bibtex like this, is it possible?

I'm not entirely sure what you're asking to do here.  

Your example looks like you want to store bibliography information in
Org, and generate citations using Org syntax.  This is possible, and
plenty of people do it.  See the org-bibtex library (included in the
main Org distribution) for storing your bibliographic data in Org trees;
see the ox-bibtex library (in contrib) for one way of generating
citations using Org syntax.

Here's my setup (which uses org-bibtex but not ox-bibtex):
http://article.gmane.org/gmane.emacs.orgmode/86033/
 
You might also look into John Kitchin's org-ref library:
https://github.com/jkitchin/jmax/blob/master/org/org-ref.org

None of these options involve Babel, though; I'm not sure if you
specifically wanted a Babel-based solution.  Is there something more
specific you're trying to do?  

Best,
Richard




Re: [O] How do I set a class for a paragraph in HTML export?

2014-12-01 Thread Richard Lawrence
Hi Marcin,

Marcin Borkowski mb...@wmi.amu.edu.pl writes:

 I'd like to get something like this:

 p class=myclassHello world/p

 What should I write in the Org file?  Looking at org-html-paragraph, I'm
 afraid that it's currently impossible.

This works for me:

--
#+ATTR_HTML: :class myclass
This is a paragraph.
--

That produces
--
p class=myclass
This is a paragraph./p
--
in the exported HTML.

Best,
Richard

OpenPGP Key ID: CF6FA646
Fingerprint: 9969 43E1 CF6F A646

(See http://www.ocf.berkeley.edu/~rwl/encryption.html for more information.)




Re: [O] Wrapping sections in html not possible

2014-11-29 Thread Richard Lawrence
Hi Henry,

Henry Hirsch he...@w3-net.de writes:

 So how can org mode support wrapping sections in html?
 Especially for more complex cases where a section or
 multiple sections will be wrapped in multiple divs.

You can do this with an export filter or filters.  See the Advanced
Configuration section in the Exporting chapter of the manual.

Here is a simple example to get you started:
#+BEGIN_SRC elisp
(defun my-html-headline-wrap-filter (text backend info)
  Wrap headlines in div.jumbotron during export.
  (when (org-export-derived-backend-p backend 'html)
(concat div class=\jumbotron\ text /div)))

(add-to-list 'org-export-filter-headline-functions
 'my-html-headline-wrap-filter)
#+END_SRC

As written, this will wrap *all* sections (including their headline) in
divs with the jumbotron class during HTML export.  You probably want to
do this for just some headlines, in just some documents.  So, you'll
need to add a test in my-html-headline-wrap-filter so that it only wraps
the relevant headlines, and leaves others unchanged.  Perhaps you can do
this based on the title of the headline, or the presence of some tag or
property.  If you need help with this, just ask!
 
Best,
Richard




Re: [O] Large LaTeX project in single file or using publishing

2014-11-28 Thread Richard Lawrence
Hi Jake,

Jacob Gerlach jacobgerl...@gmail.com writes:

 I'm starting writing my thesis, for which I hope to remain in org-mode
 rather than regular LaTeX.

Others have already given you good advice, but since I am also writing
my thesis in Org, I thought I would chime in.  Like you, I felt a bit of
trepidation when I was deciding whether to write in Org or LaTeX; I
ultimately went with Org because (1) I find it much more pleasant to use
98% of the time; (2) I felt pretty confident I could plug the gaps in
the other 2% with help from Org's awesome community; and (3) I wanted
the option to export to other formats like HTML (though I haven't used
this much so far).

 I am working on adapting a thesis LaTeX template into org-mode. The
 template is set up with a main.tex having several individual files
 (chapters, appendices, etc) \include'd.

 I believe that I could parallel this using org's publishing mechanism. An
 alternate approach would be to use one single file, since I can simply fold
 chapters to focus my workflow.

Like others, I would recommend the one-file approach.  One advantage is
that it makes it easier to compile parts of your document by themselves,
since exporting a subtree from Org will inherit any #+LATEX_HEADER:
declarations that apply to the whole document (unless you override them
by setting the EXPORT_LATEX_HEADER property on the subtree).

 My first concern is losing the ability to use internal links if I use
 separate files. Another thought is compilation time if I use one file and
 must always run pdflatex over the entire document. I'm sure there are
 pitfalls either way that I'm not yet aware of.

If you decide you need to go the multiple-files route, you can probably
find a way to convert internal links into external ones.  I half-recall
someone posting code on this list to do this at some point...

Here are a couple of other things to think about.  When I decided to go
with Org, I took a few steps to ensure that if I ever need to switch to
pure LaTeX, I will be able to do so with minimal pain, just by exporting
my Org document to .tex and going from there.  (The big sticking point
here for me was making sure I could produce human-readable, stable
labels and refs for things like sections.  See the variable
org-latex-custom-id-as-label, which was introduced by a patch I wrote.)

If you're worried about ever having to make the switch, I would
recommend thinking ahead about each of the Org features you rely on and
seeing how they get exported to LaTeX.  If the default output is not
something you'd want to edit by hand, consider either limiting your use
of that feature, or customizing it so that it produces better output for
you.  Org provides a lot of ways to do the latter, from tweaking
variables to export filters to custom export backends.

Another thing to think ahead about is how you want to deal with your
bibliography.  People on this list use different approaches.  I
personally keep my reading tasks and notes in Org, then generate a .bib
file from this as needed during compilation of my thesis.  Others keep
bibliographic information directly in .bib.  I think you'll find there
are good tools for either approach, but one or the other will probably
fit better into your workflow, and may affect how easily you can export
to other formats.

Hope that's helpful!

Best,
Richard




Re: [O] Large LaTeX project in single file or using publishing

2014-11-28 Thread Richard Lawrence
Marcin Borkowski mb...@wmi.amu.edu.pl writes:

 Also, Richard's post made me realize why I prefer to stay with LaTeX: I
 know it way better than Elisp (even though I'm making progress), and in
 case of troubles, I can more easily deal with them in LaTeX (though
 vertical positioning of things on the page - especially trying to
 typeset on a grid - still beats me).

Yes, that's a good point: if you already know LaTeX well, but are less
comfortable hacking on Org, that would probably change my advice.

I have accumulated about 600 lines of custom Elisp that is required to
export my thesis from Org to LaTeX and PDF.  (The bulk of this, 471
lines, is a custom export backend derived from the latex backend.  It
deals with exporting certain Org lists as non-standard LaTeX
environments.  Most of the rest deals with exporting my reading list to
.bib and defining various custom link types, etc. to make the Org side
more pleasant.)

By contrast, I have only written about 100 lines in custom LaTeX style
files (so far -- I might need to do more of this when it comes time to
get the final styling right for filing my dissertation).  I also rely on
other packages from CTAN, but I don't have to maintain those myself.

I'm no Elisp wizard, but I am now pretty familiar with Org exporter and
I'm comfortable with Lisp in general.  On the other hand, I tend to shy
away from anything more complicated that \newcommand in the (La)TeX
world.

Best,
Richard




Re: [O] Large LaTeX project in single file or using publishing

2014-11-28 Thread Richard Lawrence
Jacob Gerlach jacobgerl...@gmail.com writes:

 On Fri, Nov 28, 2014 at 12:40 PM, Richard Lawrence
 richard.lawre...@berkeley.edu wrote:
 (The big sticking point here for me was making sure I could produce
 human-readable, stable labels and refs for things like sections.  See
 the variable org-latex-custom-id-as-label, which was introduced by a
 patch I wrote.)

 This sounds helpful. I'm using ELPA (tracking maint?) and don't see
 this variable. Was your patch applied to master?

It was.  I just checked -- sorry, I guess it's not in maint, even though
it was applied a while ago.  Looks like it will land in Org 8.3.

Best,
Richard

OpenPGP Key ID: CF6FA646
Fingerprint: 9969 43E1 CF6F A646

(See http://www.ocf.berkeley.edu/~rwl/encryption.html for more information.)




Re: [O] How to view everything DONE today?

2014-11-26 Thread Richard Lawrence
Hi Sascha,

Sascha Ziemann cev...@gmail.com writes:

 I tried to get a list of all items done today. I tried to open the agenda
 view but is does not show anything. What is the right command to see the
 items done today?

If you use logging, one way to do this is to press l in the agenda, to
turn on log mode.  This will show you all the tasks you worked on,
including the ones that you marked done.

I'm not sure if this is possible without logging, since your org files
won't record when tasks were marked done.  You can turn on logging with
a line like

#+STARTUP: logdone

in the preamble of an org file to turn logging on for that file, or

(setq org-log-done 'time) 

in your .emacs, to turn it on globally.

To keep things neat, you might also want to use

#+STARTUP: logdrawer

or 

(setq org-log-into-drawer t)

so your logs go in a LOGBOOK drawer.

Hope that helps!

Best,
Richard




Re: [O] Custom export backend based on HTML: how to implement own blocks?

2014-11-23 Thread Richard Lawrence
Hi Marcin,

Marcin Borkowski mb...@wmi.amu.edu.pl writes:

 1. How can I know (in org-html-underline, for instance) whether I am in
 a MYBLOCK or not?

I don't know whether this is the best approach, but given an element,
you can walk up its parents in the parse tree until you either reach a
MYBLOCK (in which case, you are in such a block) or the top of the tree
(in which case, you aren't).
 
Here's an approach I use in a custom backend[1] to do something similar.
The following function is used to identify paragraphs (or other
elements) that are within lists which have an #+ATTR_LINGUISTICS
declaration specifying a :package property.  (Because it recursively
walks up the parse tree, this works even for paragraphs in
arbitrarily-nested sublists.)

#+BEGIN_SRC emacs-lisp
(defun org-linguistics-find-enclosing-pkg (element)
  Find the enclosing linguistics package of a (list) element during export.
  (let ((pkg (org-export-read-attribute :attr_linguistics element
:package))
(parent (org-export-get-parent element)))
(cond
 ; return if we found a :package attribute on element
 (pkg pkg)
 ; recurse on the parent if element has a parent but we found no
 ; :package attribute
 (parent (org-linguistics-find-enclosing-pkg parent))
 ; otherwise, no :package attribute was found
 (t nil
#+END_SRC

(In your case, a similar function might only need to return a boolean
value that indicates whether an element is inside a MYBLOCK, rather than
returning a string, as this function does.)

Then, in other code, I can treat paragraphs differentially based on
whether they are in a list with this :package attribute set, e.g.

#+BEGIN_SRC emacs-lisp
(defun some-function-that-handles-paragraphs (paragraph)
  (let* ((enclosing-pkg (org-linguistics-find-enclosing-pkg paragraph))
 ; ...
 )
; 
(cond
 ((string= enclosing-pkg gb4e)
  ; do something for paragraphs in lists with :package gb4e ...
  )
 ((string= enclosing-pkg linguex)
  ; do something for paragraphs in lists with :package linguex ...
  )
 (t
  ; do a default thing for paragraphs that are not in such lists
  
#+END_SRC

Hope that's helpful!

Best,
Richard

[1] The backend is ox-linguistics, a package for writing
linguistics-style examples in Org:
https://github.com/wyleyr/ox-linguistics




Re: [O] Bug: Agenda filtering by DEADLINE, SCHEDULED broken [8.3beta (release_8.3beta-575-g1dfa77 @ /home/rwl/src/org-mode/lisp/)]

2014-11-18 Thread Richard Lawrence
Hi Nicolas, 

Nicolas Goaziou m...@nicolasgoaziou.fr writes:

 This should be fixed. Thank you for reporting it.

I confirm that it is fixed.  Thanks so much!

-- 
Best,
Richard

OpenPGP Key ID: CF6FA646
Fingerprint: 9969 43E1 CF6F A646

(See http://www.ocf.berkeley.edu/~rwl/encryption.html for more information.)



Re: [O] How to get remember working properly?

2014-11-18 Thread Richard Lawrence
Hi Sharon,

Sharon Kimble boudic...@skimble.plus.com writes:

 #+BEGIN_SRC emacs-lisp
 (setq org-remember-templates
 '((Todo ?t * TODO %^{Brief Description} %^g\n%?\nAdded: %U 
 ~/.emacs.d/org/remember.org Tasks)
  (Journal   ?j ** %^{Head Line} %U %^g\n%i%?  
 ~/.emacs.d/org/journal.org) 
   (Clipboard ?c ** %^{Head Line} %U %^g\n%c\n%?  
 ~/.emacs.d/org/remember.org)
   (Receipt   ?r ** %^{BriefDesc} %U %^g\n%?   
 ~/.emacs.d/org/finances.org)
   (Book ?b ** %^{Book Title} %t :BOOK: 
 \n%[~/.emacs.d/.book_template.txt]\n
  ~/org/journal.org)
   (Film ?f ** %^{Film Title} %t :FILM: 
 \n%[~/.emacs.d/.film_template.txt]\n
  ~/org/journal.org)
   (Someday   ?s ** %^{Someday Heading} %U\n%?\n  
 ~/.emacs.d/org/someday.org)
   (Private ?p \n* %^{topic} %T \n%i%?\n 
 ~/.emacs.d/org/privnotes.org)
   (Contact ?o \n* %^{Name} :CONTACT:\n% ~/.emacs.d/org/contact.txt]\n
~/org/privnotes.org)
  )
)
 #+END_SRC

 With everything that I remember it shows it as, example only -

 * peace [2014-11-18 Tue 11:30] 

 i.e. headline before the date. How do I get it the other way round
 please, meaning date - headline?

I think all you need to do here is move the %U in your templates
before the %^{ ... } that represents where you type in the headline.

For example, the Journal template becomes:

  (Journal   ?j ** %U %^{Head Line} %^g\n%i%?  
~/.emacs.d/org/journal.org) 
  
See the section on Template Expansion in the Capture section of the
manual for an explanation of what's going on here.

 Also you close the entry by C-c C-c which, in my case, calls
 Tags again. How can I get it working right in this case please?

Not sure about this -- I don't use remember -- but a good place to start
is to do C-h k C-c C-c in your capture buffer; this will tell you which
function is bound to C-c C-c.  If it's not what you expect, the next
step is to figure out what it should be bound to and set the appropriate
function in the relevant keymap.

Best,
Richard




[O] Bug: Agenda filtering by DEADLINE, SCHEDULED broken [8.3beta (release_8.3beta-575-g1dfa77 @ /home/rwl/src/org-mode/lisp/)]

2014-11-17 Thread Richard Lawrence
 (146syllabus-build 
146syllabus-attach))
 (161syllabus-build :base-directory
  ~/Documents/philosophy/teaching/161/syllabus
  :publishing-directory
  ~/Documents/philosophy/teaching/161/syllabus
  :publishing-function org-latex-publish-to-pdf 
:base-extension
   :include (section-syllabus.org))
 (161syllabus-attach :base-directory
  ~/Documents/philosophy/teaching/161/syllabus
  :publishing-directory
  
~/Documents/website/public_html/lib/attachments/teaching/161
  :publishing-function org-publish-attachment 
:base-extension pdf)
 (161pdfs :components (161syllabus-build 
161syllabus-attach))
 (website :components (orgfiles css images 
161pdfs)))
 org-agenda-span 1
 org-mode-hook '(#[nil \300\301\302\303\304$\207
   [org-add-hook change-major-mode-hook org-show-block-all 
append local] 5]
 #[nil \300\301\302\303\304$\207
   [org-add-hook change-major-mode-hook 
org-babel-show-result-all append local]
   5]
 org-babel-result-hide-spec org-babel-hide-all-hashes)
 org-refile-targets '((nil :maxlevel . 4))
 org-ctrl-c-ctrl-c-hook '(org-babel-hash-at-point 
org-babel-execute-safely-maybe)
 org-confirm-elisp-link-function 'yes-or-no-p
 org-refile-use-outline-path t
 org-html-format-headline-function 'org-html-format-headline-default-function
 org-log-into-drawer t
 org-export-with-archived-trees nil
 org-highlight-latex-and-related '(latex)
 org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
 org-occur-hook '(org-first-headline-recenter)
 org-from-is-user-regexp \\Richard Lawrence\\
 org-ascii-format-drawer-function '(lambda (name contents width) contents)
 org-mobile-directory /media/nexus/mobileorg
 org-latex-pdf-process '(pdflatex -interaction nonstopmode 
-output-directory=%o %f
 BIBINPUTS=%o:$BIBINPUTS bibtex %o/%b
 pdflatex -interaction nonstopmode 
-output-directory=%o %f
 pdflatex -interaction nonstopmode 
-output-directory=%o %f)
 org-latex-format-inlinetask-function 
'org-latex-format-inlinetask-default-function
 org-modules '(org-habit org-w3m org-bbdb org-bibtex org-docview org-gnus 
org-info org-irc
   org-mhe org-rmail)
 org-latex-format-headline-function 'org-latex-format-headline-default-function
 org-html-format-drawer-function '(lambda (name contents) contents)
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-html-format-inlinetask-function 
'org-html-format-inlinetask-default-function
 )



Re: [O] math in parentheses

2014-10-28 Thread Richard Lawrence
Hi Andreas,

Andreas Leha andreas.l...@med.uni-goettingen.de writes:

 I encounter a problem using $..$ expressions when they are enclosed
 in parentheses.

 This $T$ works, but ($T$) this does not.

 Is that expected behaviour?

 (Note that \(...\) expressions work.)

Yes, that is the expected behavior.  Org is much pickier about when $
can be a math delimiter than \( ... \).  The reason is that $ can
also be used as a regular symbol in Org documents; when it is, it should
be *not* be exported as a math delimiter to LaTeX, and distinguishing
non-math-delimiting from math-delimiting uses of $ is not a trivial
matter.

Thus, when in doubt, use \( ... \).

Best,
Richard




Re: [O] Help exporting to-do list as LaTeX/PDF

2014-10-04 Thread Richard Lawrence
Hi Andreas,

Andreas Yankopolus andr...@yank.to writes:
 ...
 kpathsea: Running mktexpk --mfmode / --bdpi 600 --mag 1+0/600 --dpi 600 
 ecbx1200

 kpathsea: Running mktexfmt mf.base
 mktexpk: Mismatched mode ljfour and resolution 600; ignoring mode.
 mktexpk: Running mf-nowin -progname=mf \mode:=ljfour; mag:=1+0/600; 
 nonstopmode; input ecbx1200
 This is METAFONT, Version 2.718281 (Web2C 2013)

 kpathsea: Running mktexfmt mf.base
 I can't find the base file `mf.base'!

 It took a while to get to this point, and I had to install a number of
 font packages from the pkgsrc tex-* collection. I do have tex-ec-1.0
 and tex-eco-1.3 installed. But it seems like the problem is more with
 metafont, which is completely beyond me.

Yeah, this looks to me like your setup is attempting to load (or build??) a
font as part of the compilation process.  As far as I know, that is not
something that should be required when compiling an Org document
exported to LaTeX with the default options.

What are the values of your

org-latex-default-packages-alist
org-latex-packages-alist
org-latex-pdf-process

variables?  And what does the header of the exported .tex file look
like?

I guess the way to debug this is to remove the packages that are loaded
in the exported .tex file, one at a time, until you discover the one
that is at fault here.  (If it's not some particular package, but
rather TeX/LaTeX itself that's trying to use METAFONT, I think you're in
deeper waters...)

Best,
Richard




Re: [O] Enforcing newlines in plain text export

2014-09-27 Thread Richard Lawrence
Hi Kaushal, 

Kaushal kaushal.m...@gmail.com writes:

 I am requesting a consistent solution.

 If // at the end of a line inserts newline when exporting in all formats,
 then it should do the same when used in between a line too for ALL export
 formats.

 Example: #+TITLE: Line one // Line two

 I am simply trying to explain why we need another solution for the sake of
 consistency across all org exported formats.

Like I said, I agree that something like this would be useful; I
occasionally would like \\ to have more general behavior, too.
Anyway, it seems worth discussing.

My point is that this would be a new feature, which is technically
*inconsistent* with the currently-documented behavior.  Implementing it
would take some work and would involve breaking backward
compatibility. (At least in theory -- I don't know if anyone out there
relies on \\ *not* being translated when it does not appear at the end
of a line, but someone might be.)  So it's not something to be taken
lightly.

Does anyone know why the behavior of \\ is presently restricted to
appearing at the end of the line in a paragraph?  Does anyone need it to
be exported literally when it appears elsewhere?

Best,
Richard




[O] Fwd: Enforcing newlines in plain text export

2014-09-26 Thread Richard Lawrence
Hi Kaushal,

I am forwarding your message to the Org mode list; you only sent it to
me and Nicolas...

Kaushal kaushal.m...@gmail.com writes:

 I came across
 https://lists.gnu.org/archive/html/emacs-orgmode/2014-09/msg00466.html
 through this emacs SE page:
 http://emacs.stackexchange.com/questions/255/new-line-in-title-of-an-org-mode-exported-html-document

 The question I had asked on stackexchange was: How to export a mid-line
 newline consistently in all formats.

In paragraphs, all you need to do is end a line with \\ to force a
line break.  This works for LaTeX, HTML, and plain text export, at least.

This doesn't work in other kinds of syntax, like headlines, but you may
not need it there.

 But I couldn't figure out how to convey a newline character when exporting
 to plain text (ascii).

 I tried,

 #+MACRO: NEWLINE @@latex:\\@@ @@html:br@@ @@ascii:\n@@

 But that simply puts out \n verbatim in the exported txt file.

I don't know the answer to this specific issue---you might need to
create a custom export filter---but hopefully you can just use \\
instead of a macro like this.

Do you need to enforce line breaks *outside of* a paragraph in plain
text export?  If so, what case are you worried about specifically?

Best,
Richard

OpenPGP Key ID: CF6FA646
Fingerprint: 9969 43E1 CF6F A646

(See http://www.ocf.berkeley.edu/~rwl/encryption.html for more information.)



Re: [O] Enforcing newlines in plain text export

2014-09-26 Thread Richard Lawrence
Kaushal kaushal.m...@gmail.com writes:

 Interesting thing is that `\\` work fine at the end of the lines.

Yes, this is the behavior documented in the manual.

 I need to force line breaks in cases like these

 -
 For example, to execute the =example_1= test and run in the {{{NEWLINE}}}

 =/some/long/path/that/wouldn't/fit/along/with/the/above/line/in/the/same/line=
 directory,
 do the following..
 -

 In the above example, org-export will not wrap the text between the
 verbatim formatting characters =.
 To ensure that the exported formats (html/pdf/ascii) look clean, I have to
 force a newline character just before that long string.

 Now using \\ here instead of {{{NEWLINE}}} works but then I have to
 ensure that I place the \\ character at the very end. If they are placed
 mid-line then they will be interpreted as newline by latex but simply \\
 character by html exporter.

As you say, \\ at the end of the line works fine in this case.  So it
seems you do not have a need for another solution.

 For consistency, the {{{NEWLINE}}} approach looks better; hoping that
 org-mode will support a special newline character for ascii exports at some
 time:

 -
 #+MACRO: NEWLINE @@latex:\\@@ @@html:br@@ @@ascii:NEWLINE_CHARACTERS_
 FOR_ASCII_EXPORT@@
 -

This would really not be a great solution, and I don't think you should
expect Org mode to support it.  If you really need something like this,
you could write an export filter for yourself (e.g., one that replaces
the string ASCII_NEWLINE_CHARACTER with \n in the exported buffer).
See the Advanced configuration section of the Exporting chapter in the
manual.

A better and more general solution, I think, would be to allow \\ to
be used in other contexts, such as in headlines, title/author/date
declarations, etc.  But that is a change to the currently documented
syntax, and it is probably a fair amount of work to implement, so it
probably isn't going to happen unless a variety of users really need it
and the maintainers think it would be an improvement to Org.
 
Best,
Richard



Re: [O] Changed behaviours of LaTeX exporter in version 8.0+

2014-09-19 Thread Richard Lawrence
Hi Joseph,

Kyeong Soo (Joseph) Kim kyeongsoo@gmail.com writes:

 Great thanks for your answering my two questions, especially sharing your
 experience for cross-referencing in LaTeX export.

 Though your suggestion for cross-referencing is an excellent workaround, I
 wonder whether there is any benefit using org-mode in writing papers in
 this case; for instance, manual setting of CUSTOM_ID would be a hassle,
 considering that it can be easily  automatically done in LaTeX with
 AUCTeX/RefTeX's label function.

Don't you need to make sure that your sections have a consistent label
in order to refer to them?

At any rate, one of the reasons I use this solution is that I want to be
able to easily use plain LaTeX at points where I discover that I can't
make Org do everything I want.  One of the cases I was worried about,
for example, is having a section reference inside an embedded LaTeX
block.  If you don't know the label ahead of time, you can't use a raw
\ref command inside #+BEGIN_LATEX...#+END_LATEX.  So I like being able
to set the labels via CUSTOM_ID on an as-needed basis. (I don't do it
for every section.)

You might be able to get away with less; it looks to me like the
[[*Foo][Section Foo]] still produces a link to a headline in LaTeX
output.  Does that not work for you?

 I still don't know why the new export engine has brought so many
 compatibility issues in its behavior.  It seems that I'd better go
 back to the prior version (7.X) in order to focus on my research.

The new export engine was a complete re-write, and came with an attempt
to define and standardize Org syntax.  Some of the incompatibilities are
due to that standardization: the old LaTeX and HTML exporters might
treat some text differently, for example, or not deal with some corner
case, so in writing a new export engine, it was necessary to define the
correct behavior.  Other incompatibilities are just bugs that come with
any new piece of software; the exporter is under heavy development and
those are constantly getting fixed.

The new exporter really is a *lot* better, and in my experience it is
worth the effort to upgrade.  I found myself bumping into the
limitations of the pre-8.0 exporter very frequently.  If you don't, you
can wait, but I think you'll find the new exporter a lot easier to work
with and to get help with.

Best,
Richard

OpenPGP Key ID: CF6FA646
Fingerprint: 9969 43E1 CF6F A646

(See http://www.ocf.berkeley.edu/~rwl/encryption.html for more information.)



Re: [O] Changed behaviours of LaTeX exporter in version 8.0+

2014-09-18 Thread Richard Lawrence
Hi Joseph,

Kyeong Soo (Joseph) Kim kyeongsoo@gmail.com writes:

 I just found out that, if I close Emacs and relaunch it, all variables for
 filter (i.e., 'org-export-filter-*') are not defined. As a result, the
 following elisp codes for the workaround based on both your suggestion and
 the filter example in the manual causes void variable error (i.e.,
 Symbol's value as variable is void:
 org-export-filter-special-block-function):

Try adding:

(require 'ox)

before your filter definition.

Best,
Richard




Re: [O] Changed behaviours of LaTeX exporter in version 8.0+

2014-09-18 Thread Richard Lawrence
Hi Joseph,

Kyeong Soo (Joseph) Kim kyeongsoo@gmail.com writes:

 Sorry for asking another question; this time it is for the
 cross-referencing in LaTeX export, which existed before (e.g., Sec. 16 of
 manual for 8.0) but is gone now.
 ...
 Now with 8.2.7c and the following org internal link to a section

 ... described in Sec. [[*SectionOne][SectionOne]] ...

 LaTeX export generates the following code:

 ... described in Sec. \texttt{SectionOne}, ...

I think the problem here is that you don't have a link type, and the new
LaTeX exporter doesn't convert links it doesn't understand into
references.

I use a series of custom link types to make references to document
parts in my dissertation.  Here's the code I use; you will probably want
to adapt it to your use case:

#+BEGIN_SRC elisp
;; use CUSTOM_ID properties to generate labels
(setq org-latex-custom-id-as-label t)

(defun org-find-headline-by-custom-id (prefix path)
  Find a headline in the current buffer by CUSTOM_ID value PREFIX:PATH.
  (save-excursion
(goto-char (point-min))
 (and
  ; borrowed from org.el; there doesn't seem to be a function that searches
  ; for a headline with a specific property value
  (re-search-forward
   (concat ^[ \t]*:CUSTOM_ID:[ \t]+ prefix : path [ \t]*$) nil t)
  (setq pos (match-beginning 0
   (if pos
   (progn
 (goto-char pos)
 (org-back-to-heading t))
 (message (format Headline with CUSTOM_ID %s:%s not found. prefix path

(defun org-export-dissertation-link (prefix path desc format)
  Export a link to a dissertation section, etc.

In LaTeX, the exported link will look like:
  DESC~\\ref{PREFIX:PATH}

(when (member format '(latex linguistics))
  (format %s~\\ref{%s:%s} desc prefix path)))

; Parts:
(org-add-link-type
 part
 (lambda (path)
   (org-find-headline-by-custom-id part path))
 (lambda (path desc format)
   (org-export-dissertation-link part path (or desc Part) format)))

; Chapters:
(org-add-link-type
 chap
 (lambda (path)
   (org-find-headline-by-custom-id chap path))
 (lambda (path desc format)
   (org-export-dissertation-link chap path (or desc Chapter) format)))

; Sections:
(org-add-link-type
 sec
 (lambda (path)
   (org-find-headline-by-custom-id sec path))
 (lambda (path desc format)
   (org-export-dissertation-link sec path (or desc Section) format)))

; Tables:
(org-add-link-type
 tab
 (lambda (path) (org-link-search (concat tab: path)))
 (lambda (path desc format)
   (org-export-dissertation-link tab path (or desc Table) format)))

#+END_SRC

So a link like [[sec:foo]] renders as Section~\ref{sec:foo},
[[chap:foo]] renders as Chapter~\ref{chap:foo}, etc. when exported
to LateX, and you can follow links to jump to the appropriate document
headline.

Note that this works by giving my document sections fixed labels by
setting the CUSTOM_ID property.  I give headlines a descriptive name in
this property, using the LaTeX convention of prefixing sec:, etc. to
keep my labels straight; Org then generates \label commands for document
parts using the CUSTOM_ID property.  This requires setting
org-latex-custom-id-as-label.  For example, a headline like

*** Another interesting section
:PROPERTIES:
:CUSTOM_ID: sec:interesting
:END:

is exported as

\section{Another interesting section}
\label{sec:interesting}

(The prefixes are important, since they function both as link types and
as parts of label/ref keys.  As you'll notice, the
org-export-dissertation-link function adds them back in to the key.)

I find this setup keeps things working well across revisions,
re-ordering and re-naming of sections, etc.

Hope that helps!

Best,
Richard




[O] Bug? Or new behavior? Paragraphs in HTML

2014-09-06 Thread Richard Lawrence
Hi everyone,

After updating this morning, I notice that when

#+BEGIN_SRC org
* My headline
Some text here.
#+END_SRC

is exported to HTML, the paragraph below the headline is no longer
wrapped in a paragraph tag:

#+BEGIN_SRC html
h2 id=sec-1span class=section-number-21/span My headline/h2
div class=outline-text-2 id=text-1
Some text here.
/div
#+END_SRC

Whereas if there is more than one paragraph below the headline, they
are:

#+BEGIN_SRC org
* My headline
Some text here.

What about here?

Or here?
#+END_SRC 

becomes

#+BEGIN_SRC html
h2 id=sec-1span class=section-number-21/span My headline/h2
div class=outline-text-2 id=text-1
p
Some text here.
/p

p
What about here?
/p

p
Or here?
/p
/div
#+END_SRC 

I am guessing this is the result of commit
9a34a13c077f592c5528d95c155ecdf2d655937e.

Is this now the expected behavior for paragraphs, even *outside* of
lists?  Personally I find this a bit unexpected.  It broke my CSS, and I
am not sure what the best way to fix it is.  What should I do if I want
to style all the blocks of text on a page, since some will be wrapped in
p tags and others won't be, depending on whether there are other
paragraphs in the same div?
 
Best,
Richard




Re: [O] capture template, filename

2014-09-05 Thread Richard Lawrence
Hi Michael,

Michael Welle mwe012...@gmx.net writes:

 I have a capture template like this:

  (j Journal plain 
(file (capture-report-data-file  ~/org))
%^{Heading}\n#tags %^{Tags}\nmeta-creation_date: %(format-time-string 
 \%m/%d/%Y %H:%M:%S\)\n\n%?)

 In capture-report-data-file I want to calculate the filename for the org
 file. The filename should be constructed with information from the
 heading's value.

If I understand correctly, you are trying to choose the file in which to
save the captured data dynamically, at capture time, based on the value
of the headline...right?

I think you will not be able to do this by setting a target in
org-capture-templates, as you are trying to do.  The reason is that the
target for the capture is expanded and determined before any data is
captured.  (If you can calculate the filename without using the heading
value, you could use (function ...) or (file+function ...) rather than
(file ...) in org-capture-templates to set the target location.)

I think what you probably want to do is *refile* the captured entry to
the desired location after the template is filled out.  I think you can
do this from one of the org-capture-{prepare,before,after}-finalize
hooks -- probably org-capture-prepare-finalize-hook.  You could there
add something like

(lambda ()
  (org-back-to-heading)
  (let ((target (get-target-from-heading)))
(org-refile nil nil target))

where get-target-from-heading should return a refile location based on
the heading.  I'm not sure about all the arguments to org-refile
(particularly the second, `default-buffer').  Also if you have other
capture templates where you don't want to dynamically refile based on
the heading, you need to insert a test in there to only do the refile in
the cases you want.

I should say this is not tested and you may need to play around with
some things to get it to work for you.  Someone else may have better
advice.  But I hope that points you in the right direction!

Best,
Richard




Re: [O] Custom formatting during export

2014-09-03 Thread Richard Lawrence
Hi Gabe,

Gabe Becker becker.g...@gene.com writes:

 * section title

 Here is some text, but I want [specialthing: this bit here] to be formatted
 differently than [newanddifferent: this other big over here].


 Where I would have defined specific custom formatting rules for
 specialthing and newanddifferent type entities.

 Is there a way to do this in orgmode? If not, it seems like it would be a
 very useful feature (at least to me:) ). Note: I don't care about the
 syntax as long as the result is the same.

Based on the syntax you chose for your example, you might be looking for
custom link types; see the documentation for the org-add-link-type
function:
--
(org-add-link-type TYPE optional FOLLOW EXPORT)

Add TYPE to the list of `org-link-types'.
Re-compute all regular expressions depending on `org-link-types'

FOLLOW and EXPORT are two functions.

FOLLOW should take the link path as the single argument and do whatever
is necessary to follow the link, for example find a file or display
a mail message.

EXPORT should format the link path for export to one of the export formats.
It should be a function accepting three arguments:

  paththe path of the link, the text after the prefix (like http:)
  descthe description of the link, if any, or a description added by
  org-export-normalize-links if there is none
  format  the export format, a symbol like `html' or `latex' or `ascii'..

The function may use the FORMAT information to return different values
depending on the format.  The return value will be put literally into
the exported file.  If the return value is nil, this means Org should
do what it normally does with links which do not have EXPORT defined.
--

You could define a custom link type for specialthing, and then use the
export parameter to provide a function that will export the path 
of the link in a backend-specific way.  Then you would write

blah blah [[specialthing:whatever-path]] blah blah 

I'm sure there are good examples of how to do this on Worg, but I cannot
seem to find them at the moment...

If you need to do something more complicated than what custom link types
allow, Thorsten's suggestions are the place to start: Org has a lot of
ways to customize export output.
 
Best,
Richard




Re: [O] Getting lots of Emacs crashes

2014-09-02 Thread Richard Lawrence
Hi Noah,

Noah Slater nsla...@apache.org writes:

 I'm getting a lot of Emacs crashes recently using Org. Is there any
 way I can help to debug why this is happening?

What version of Org are you using?  What happens when Emacs crashes?

Best,
Richard




[O] Bug?/performance issue in org-icalendar-export-current-agenda

2014-08-26 Thread Richard Lawrence
Hi all,

I pulled from master recently (for the first time since the spring), and
since the update, I have noticed a performance/lockup issue.  The
problem occurs when exporting an agenda view to iCalendar format.

My Emacs version is 23.4.1 and my Org version is 8.3beta (I am
currently on commit 767895...)
 
I have traced the problem down to a call to
`org-icalendar-export-current-agenda', though I don't know if the
problem is in this function or in another function called by it.
Somewhere during the execution of this function, Emacs goes to 100% CPU
usage (on one core) and memory usage starts growing until I kill the
process.
 
Here's what my setup looks like.  I have just one entry in
`org-agenda-custom-commands' that defines the files field.  It looks
like:

 (Z Export to iCalendar file tags +event|+appointment nil
  (~/Documents/website/public_html/lib/attachments/calendar.ics)

I normally only call this command via a cron job that exports my agenda
files to .ics, which until recently was working fine.  But I have
noticed I can reproduce the lockup interactively by building an agenda
view with this command, and then calling
`org-icalendar-export-current-agenda' on it (which is also what happens,
a few steps down the call chain, during the cron job).

I have run some tests by manually setting org-agenda-files, then
building this agenda and eval'ing

(org-icalendar-export-current-agenda /tmp/agenda.ics) 

in the agenda buffer.  The results:

1) Using just a simple three-entry test file, the export completes quickly
   and I don't see the lockup.  
2) Using an agenda file which contains plenty of real data
   (about 1000 lines) but no headlines tagged event or appointment
   (i.e., a file for which this agenda view is empty), the call to
   `org-icalendar-export-current-agenda' takes about 5 seconds to
   complete, even though there are no entries to export.  During those
   5 seconds, the Emacs process goes to 100% CPU usage.
3) Using a different agenda file (of about 4000 lines) which contains
   about 75 matching headlines, the call to
   `org-icalendar-export-current-agenda' does not complete within
   several minutes, during which time I see 100% CPU usage and rapid
   memory usage growth.  

So it looks to me like maybe some part of the export process uses
exponentially more time and memory, depending on the input, since a
minimal test case does not produce the problem.

What's the next step for debugging this?  Please let me know if I can
provide more information.  

Thanks! 

-- 
Best,
Richard




Re: [O] Bug?/performance issue in org-icalendar-export-current-agenda

2014-08-26 Thread Richard Lawrence
Nicolas Goaziou m...@nicolasgoaziou.fr writes:

 Interestingly, I introduced a patch that should speed up this function
 yesterday. You may want to update Org (the patch landed after 767895)
 and try again.

Indeed!  I just pulled again and the problem is gone.  The export runs
much more reasonably now, completing in a few seconds even with all my
agenda files in the mix.  Thanks!

Best,
Richard




[O] [PATCH] ox-latex: fix lost export option latex-custom-id-labels

2014-08-20 Thread Richard Lawrence
Hi everyone,

I recently pulled from master and noticed that an option in the LaTeX
export backend that I rely on had gotten lost in the shuffle.  (I didn't
check the history, but I believe it must have been removed accidentally,
since the code that checks this option is still there.)  Here is a patch
to re-introduce it.

Thanks!

Best,
Richard

From 0b351bfc2e494bb010a4c27768a5ccd2ae846367 Mon Sep 17 00:00:00 2001
From: Richard Lawrence richard.lawre...@berkeley.edu
Date: Wed, 20 Aug 2014 16:55:50 -0700
Subject: [PATCH] ox-latex: fix lost export option

* lisp/ox-latex.el (latex): reintroduce `latex-custom-id-labels' option in backend

TINYCHANGE
---
 lisp/ox-latex.el |1 +
 1 file changed, 1 insertion(+)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 6ea35c5..c14d6dc 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -110,6 +110,7 @@
 ;; Other variables.
 (:latex-active-timestamp-format nil nil org-latex-active-timestamp-format)
 (:latex-classes nil nil org-latex-classes)
+(:latex-custom-id-labels nil nil org-latex-custom-id-as-label)
 (:latex-default-figure-position nil nil org-latex-default-figure-position)
 (:latex-default-table-environment nil nil org-latex-default-table-environment)
 (:latex-default-table-mode nil nil org-latex-default-table-mode)
-- 
1.7.10.4



Re: [O] How to programmatically use/edit data provided on capture

2014-08-03 Thread Richard Lawrence
Hi Marcin,

Marcin Antczak marcin.antc...@neutrico-themes.pl writes:

 I got capture template with prompts to collect some properties:

 #+BEGIN_SRC
 * TODO %\1 / Some task description
:PROPERTIES:
:NAME: %^{NAME}
:END:
 #+END_SRC

 My question is: How to get information on user input data to transform
 this data before capture finalize.

I too have wanted to do something like this, but I am not sure that it
is possible without hacking org-capture, because I don't think you can
hook into the template processing at an arbitrary point.

Is it really important that you transform the data *before* capture
finalize?  If not, I think you could do this *during* capture finalize
by replacing, say, a pre-determined string PUT-NAME-HERE with the value of 

(custom-dashify-function (org-entry-get (point) NAME))

You could do that from org-capture-prepare-finalize-hook, maybe.  Would
that work for you?  It has some limitations:
  - it's only easy to recover data that was entered as properties or tags, not
arbitrary strings
  - you can't continue to edit the capture buffer after doing this
processing, since the hook will only be called after you start
finalization 
 
If you come up with a better solution, I'd like to hear about it!  I
have scratched my head about this several times before, but I've never
come up with a satisfactory solution.

Good luck!

Best,
Richard




Re: [O] Automatically Increasing Priority

2014-06-25 Thread Richard Lawrence
Hi Esben,

Esben Stien b...@esben-stien.name writes:

 Does there exist such a concept of automatically increasing priority
 after a while?

I'm not aware of any way of automatically changing the priority of a
headline, though if you really need this, it looks like it would be
fairly simple to do it in Elisp using the `org-map-entries' and
`org-priority' functions.  

I have the same problem you do: the priorities feature does not really
map well onto my work.  I used to capture a priority with every item,
but I've recently stopped doing that because I found it didn't make
sense for me.  I think it makes more sense to assign priorities
manually, when you're in a context of figuring out which tasks to work
on, rather than in a context of recording tasks to be done in the
future.

I suggest that, if you aren't doing this already, you put deadlines on
your TODO items, rather than priorities, and then sort the agenda by
deadline.  This has the advantage that it `prioritizes' all your tasks
in a natural way in the agenda: anything due soon (or past due) comes up
before things that are due later on.  So if you assign every task an
initial deadline, its `priority' will go up automatically, as time
passes.  When it comes due, you can always readjust the deadline if your
initial estimate didn't work out.

It's also useful, I think, to make one of your tasks a recurring weekly
review: go through all your other tasks, make sure you still want to do
them, adjust deadlines as necessary, etc.  If you find you still want
priority cookies in addition to deadlines, you could assign them during
this review for tasks due in the upcoming week.  At that point, you'll
be in a context where assigning priorities to these items makes more
sense, since you'll be looking at the other tasks each task competes
with.

Hope that helps!

Best,
Richard


(If possible, please encrypt your reply to me using my PGP key:
Key ID: CF6FA646
Fingerprint: 9969 43E1 CF6F A646.
See http://www.ocf.berkeley.edu/~rwl/encryption.html for more information.)




Re: [O] Advice needed: Cant find a decent way to autosync my work TODO org file between laptop and work pc

2014-05-24 Thread Richard Lawrence
Hi Xebar,

Xebar Saram zelt...@gmail.com writes:

 i mainly used git over the last 6 months but that forces me to
 pull/commit/push manually each time i add something to either machine and
 that is really annoying. plus i get merge conflicts all the time

 I have tried dropbox at the past but again this causes conflicts,
 isntreliable to me (on my
 linux laptop it doesn't always resume sync after sleep)

If neither git nor Dropbox works for you, I'm not sure this will be
helpful, but...

I personally use git for this.  To keep the effort of syncing and
merging low, I have a cron job set up to automatically commit in certain
repositories containing my Org files every hour.  It's just a
quick-and-dirty hack, but here it is:

#+BEGIN_SRC bash
#!/bin/bash
# Add org file changes to the repository
ROOT=$HOME
REPOS=org Documents/philosophy/dissertation Documents/philosophy/teaching 
Documents/philosophy/reading src/emacs

commit_and_push()
{
  for REPO in $REPOS
  do
  echo Repository: $ROOT/$REPO
  cd $ROOT/$REPO

  if [ ! -d .git ]; then
  echo Not a git repository; skipping
  continue
  fi
  if [ ! -r autocommits ]; then
  echo No autocommits file found; skipping
  continue
  fi

  # Remove deleted files
  git ls-files --deleted -z | xargs -0 git rm /dev/null 21

  # Add files on whitelist to commit for current branch
  while read FILE
  do
  git add $FILE
  done  autocommits

  git commit -m $(date) from $(hostname) by autocommit.sh
  STATUS=$?
  if [ $STATUS != 0 ]; then
  echo git commit failed with exit status $STATUS
  fi

  # Push the current branch
  # requires branch.name.remote to be specified in git config
  # and ideally push.default = tracking 
  git push --porcelain
  STATUS=$?
  if [ $STATUS != 0 ]; then
  echo git push failed with exit status $STATUS
  fi

  done
}

pull()
{
  for REPO in $REPOS
  do
  echo Repository: $REPO
  cd $ROOT/$REPO

  git status | grep 'modified:'
  if [ $? == 0 ]; then
  echo modified files present; fetching, but not pulling.
  CMD=fetch
  else
  CMD=pull
  fi

  git $CMD
  STATUS=$?
  if [ $STATUS != 0 ]; then
  echo git $CMD failed with exit status $STATUS
  fi
  done
}

case $1 in
  commit)
  commit_and_push
  ;;
  pull)
  pull
  ;;
  *)
  echo Usage: $0 {commit|pull}
  exit 1
  ;;
esac

exit 0
#+END_SRC

This script requires a file called autocommits in each repository in
$REPOS which is a whitelist of files to autocommit changes in.  Most of
my Org files are on such a list.

I run this from Cron like:
#+BEGIN_SRC cron
0 * * * * ~/bin/autocommits.sh commit /dev/null 21 
#+END_SRC

To make sure my changes are saved before this script runs, I have in my .emacs:
#+BEGIN_SRC elisp
(run-at-time 00:59 3600 'org-save-all-org-buffers) ; cron commits on the hour
(add-hook 'before-save-hook 'org-update-all-dblocks)
#+END_SRC

And finally, to pull the autocommitted changes on a new machine:
$ autocommits.sh pull

So you still have to manually pull and fix any merge conflicts, but I
find that committing often generally keeps the work involved here
minimal (because I can't usually work on two machines at once!).

Hope that helps!

Best,
Richard




Re: [O] Advice needed: Cant find a decent way to autosync my work TODO org file between laptop and work pc

2014-05-24 Thread Richard Lawrence
Martin Schöön martin.sch...@gmail.com writes:

 What if, as is the case for me, work computer runs Win7 and home computer
 runs Linux?
 Now I use a manual 'system' which shouldn't be necessary, I think.

Well, I don't run Windows on any of my systems, so someone else probably
has better advice here.

I'm pretty sure git runs on Windows, and in theory you should be able to
do something similar to the Bash script/cron job setup I described using
batch files.  But I'm no expert on that.

Another alternative would be to write a short ELisp program to do the
same thing, using `run-at-time' and `shell-command'...though I don't
know how shell-command works on Windows.

Also, Unison (http://www.cis.upenn.edu/~bcpierce/unison/) promises to do
two-way file sync between *nix and Windows.  I've never tried it; has
anyone else?

-- 
Best,
Richard


(If possible, please encrypt your reply to me using my PGP key:
Key ID: CF6FA646
Fingerprint: 9969 43E1 CF6F A646.
See http://www.ocf.berkeley.edu/~rwl/encryption.html for more information.)



Re: [O] Enumeration within environment block

2014-05-18 Thread Richard Lawrence
Hi Xavier,

Xavier Garrido xavier.garr...@gmail.com writes:

 The problem is that the enumeration number gets lost either in the
 =enumerate= env. in LaTeX or the =ol= tags in html and thus question
 restart to number 1 every time I have a BEGIN_QUESTION/END_QUESTION
 block. Is there a way to solve that issue or at least to force the
 item number ? (for instance, in LaTeX I can write \item[1],\item[2]
 and in html I can set the =ol= start value).

I don't have any real advice for HTML (CSS counters??) but there are
some solutions that exist in the LaTeX world for cumulative numbering
like this.

The solutions I am most familiar with are the linguex[1], gb4e[2], and
philex[3] packages.  (These are packages for linguists, who often need a
running set of examples with text in between -- though they also have
linguistics-specific stuff that you probably don't need.)

There is also the enumitem[4] package.  I don't have much experience
with this but it may work for you.

I wrote a custom exporter for Org that adds support for exporting Org
lists to the numbered example environments used by linguex and gb4e.  It
is called ox-linguistics[5] and is posted on Github.  If you like the
solution provided by linguex or gb4e at the LaTeX level, this would
allow you to access it from Org, without having to write embedded LaTeX.
It also lets you refer back to examples (questions, in your case) using
Org targets and links.

ox-linguistics is still alpha-quality and I may make some significant
changes to it soon, but I have been using it for a while now to compile
my dissertation, and it's been meeting my needs pretty well.  Let me
know what you think.

[1] http://www.ctan.org/pkg/linguex
[2] http://www.ctan.org/pkg/gb4e
[3] http://www.ctan.org/pkg/philex
[4] http://www.ctan.org/pkg/enumitem
[5] https://github.com/wyleyr/ox-linguistics

-- 
Best,
Richard




Re: [O] Managing bibtex database using org-mode?

2014-05-08 Thread Richard Lawrence
Hi Vikas and all,

Vikas Rawal vikasli...@agrarianresearch.org writes:

 I manage my whole bibtex database on org. It makes my workflow more
 integrated. It allows me to keep bib info, todo states and notes all
 in the same place, and it allows me to access it all through the
 agenda. I just periodically run org-bibtex to make sure that I have a
 updated bib file.

 This is exactly what I have in mind. Would you mind sharing an example
 file, and may be an outline of your work flow?

I also manage my whole bibtex database in Org.  Here is my setup:

1) I store new readings as I come across them using a capture template.
(See the attached reading.txt.)  This template is pretty basic, but I
think it could easily be adapted to store more data, such as links to
PDFs, or automatically import Bibtex entries (over org-protocol?) using
a function from org-bibtex.

The relevant stanza from my org-capture-templates is:
#+BEGIN_SRC elisp
(dr Reading entry
 (file+olp ,dissertation-agenda-file Reading list)
 (file ,(concat org-template-directory /reading.txt))
 :prepend t)
#+END_SRC

2) I use a post-capture hook to detect whether a captured entry is a
reading (it looks for the AUTHOR property) and optionally add
bibliographic data using org-bibtex-create-in-current-entry:

#+BEGIN_SRC elisp
(defun add-bibliographic-data ()
  ; this is a bit hacky: we detect the AUTHOR property, and create bibtex 
entries if
  ; it is present
  (message optionally adding bibliographic data)
  (if (and (org-entry-get (point) AUTHOR)
   (y-or-n-p Add bibliographic data? ))
  ; with prefix arg to get all fields:
  (org-bibtex-create-in-current-entry 1)
nil))

(add-hook 'org-capture-before-finalize-hook (lambda () 
(add-bibliographic-data)))
#+END_SRC

This completes the `front-end' portion of my setup, which gets data on
new readings into Org.

The `back-end' setup, which exports the captured entries to a .bib file,
involves a Makefile that calls wrappers around org-bibtex functions.

3) All the wrapper functions do is walk over the Org tree containing my
reading list, using org-map-entries, and export each entry with a
defined CUSTOM_ID value using org-bibtex-headline to a new buffer.  (It
skips those with no CUSTOM_ID, since these won't produce valid bibtex
entries.)  This buffer then gets saved as the new .bib file.  The code
is in bib-export.el, attached.

Note that this code makes some assumptions about my setup (mostly that
all reading entries are stored under a top-level Reading list heading
in a certain Org file); it is not suitable for general use without some
adaptation.

You can call the wrapper functions from within Emacs using
M-x reading-list-to-bibtex.

4) I also call the wrapper functions from a Makefile.  This allows me to
get a fresh copy of my .bib file whenever it's needed, just by typing
`make bib'.  Here's the relevant stanza from the Makefile, which lives
in the same directory as the file containing my reading list
(tasks.org):

#+BEGIN_SRC make
EMACS=emacs
BATCH_EMACS=$(EMACS) --batch -Q --load lib/el/org-dissertation.el

build/dissertation.bib: tasks.org lib/el/bib-export.el
$(BATCH_EMACS) --load lib/el/bib-export.el --file tasks.org \
   --funcall reading-list-to-bibtex

bib: build/dissertation.bib
#+END_SRC

That's it!  Hope you find that useful.

Best,
Richard

** %^{Todo state|FIND|PRINT|READ|NOTES} [#%^{Priority|A|B|C}] 
%^{Description|Reading} %^g
   %^{TITLE}p %^{AUTHOR}p %^{AREA}p %?
   :PROPERTIES:
   :Entered: %U
   :END:


bib-export.el
Description: application/emacs-lisp


Re: [O] State of the art in citations

2014-04-29 Thread Richard Lawrence
Hi Vikas,

Vikas Rawal Lists vikasli...@agrarianresearch.org writes:

 On 26-Apr-2014, at 6:56 pm, Clément B. clem...@inventati.org wrote:

 Hi all,
 
 - Should I use biblatex instead of bibtex?  
 
 You should. It is very powerful and straightforward. The manual
 is great.

 Is the choice so clearcut?

 A lot of bibliographic databases provide bibtex-compatible citation
 information. How do you deal with that, when you shift to biblatex?

As I recently learned (thanks to this list!), biblatex supports .bib
files.  So switching to biblatex is not an issue from this perspective:
you can continue to drop bibtex-compatible citation information into
your .bib file and use it with biblatex.

If ox-bibtex reads .bib files, that should continue to work, too.

Best,
Richard




Re: [O] minted in Org 8.6

2014-04-29 Thread Richard Lawrence
Hi Ken,

Ken Mankoff mank...@gmail.com writes:

 #+begin_src emacs-lisp
 ;; minted latex export
 (setq org-export-latex-listings 'minted
   org-export-latex-minted-options
   '((frame lines)
 (fontsize \\scriptsize)
 (linenos )))
 #+end_src

 If I test this with emacs -Q, it works. If I test it with my default,
 code is exported as verbatim. This suggests the bug is in an init file
 of mine.

 However, I have removed all Org sections of my init file. I am fairly
 confident this is not a setting of mine, since if I look at the current
 state included in a org-submit-bug-report, the state is almost the
 same between emacs and emacs -Q, the only difference being Org 7.9 v.
 Org 8.6, and a few default settings that have changed between the two.

The new exporter, which arrived in 8.0, renamed most variables related
to export.  I think the variables you are setting here are now named:

org-latex-listings
org-latex-minted-options

My guess is that renaming them in your init file will fix the problem.

-- 
Best,
Richard




Re: [O] Is OrgMode really GTD compliant?

2014-04-27 Thread Richard Lawrence
Hi Rene,

Rene jl...@yahoo.com writes:

 According to David Allen, whenever you define an action you need to
 assign three pieces of information that you will later use as criteria
 to decide what to do (in order of precedence):

  1. Context: Where should I be (@home, @work, etc.) and/or which tools
 should I have at my disposal (@computer, @internet, etc.) to do
 this action?
  2. Time needed: Which amount of time available must I have to do
 this action?
  3. Energy needed: How wasted/fresh can I be to do this action?

 Then, when you're up for executing an action, you use context, time
 available, and energy available as a sieve to sift out what can be
 done. Only after you've looked at these three can you determine what
 is the priority for right now, the present moment.
 ...
 Orgmode helps you capture
  - the context: by means of tags,
  - the time needed: by means of an effort property,
  - the ABC priorities: by means of cookies.
...
 Has anyone tried to customize orgmode so as to make it really GTD
 compliant?

I am not really familiar with the official GTD methodology, and I don't
know exactly how you would normally represent the energy needed
associated with a task, but here's a suggestion.

It occurs to me that you could just use the A/B/C priority cookies to
represent energy levels, since you don't want to use them to encode
priorities.  Something like:
  #A: need to be fresh
  #C: can be wasted
  #B: everything else
or whatever would work for you.  If that's granular enough to represent
your energy-needed levels, then it's a neat hack that requires zero
customization.  Sorting and filtering by energy needed is then already
built into the agenda functions, etc.  Just think energy needed
whenever Org says priority (which isn't very often), and you're good
to go.

-- 
Best,
Richard





Re: [O] using org-refile to sort research notes?

2014-04-27 Thread Richard Lawrence
Hi Jay,

Jay Dixit di...@aya.yale.edu writes:

 Hello friendly org-mode community,

 I'm using org-mode to research and write a nonfiction book. I have a large
 amount of notes and quotes that I now need to sort into separate files.

 I am creating separate org files, one for each chapter of my book—
 chapter-1.org, chapter-2.org, etc.—with org headings in each one for every
 topic/subsection.

 I now want to categorize my notes, moving them from where they are—i.e. in
 a set of long, unorganized org files with names like new-research.org and
 more-research-and-notes.org—into the the chapter files.

 1. Am I right in thinking that org-refile is the most efficient way to do
 this?

That sounds right to me.

 2. What's the best way to do this? Should I add all of my chapter.org files
 to the agenda using org-agenda-file-to-front? I ask because these are not
 TODO headings, just headings with notes and quotes, so I'm not sure if
 using org-agenda functionality is appropriate.

Rather than adding these files to the agenda, I would have a look at the
`org-refile-targets' variable.  This variable tells Org where to look
for entries to refile under.

If this is a one-time operation, you may be able to just set the
variable a few times: adjust the variable to point to your chapter-1.org
notes heading, then refile all those notes; then point it to your
chapter-2.org notes heading, then refile all those notes...; etc.  This
will make it super easy to get the right refile target.

 Thanks in advance for any advice.

I don't know what led you to choose the new file layout that you're
moving to, but here is an alternative that you might also consider.

Make your project into just two files, say book.org and notes.org; the
first contains the text of the book, while the second contains the notes
and tasks for each chapter.  One advantage of this setup is that it
would allow you to organize your notes in whatever way is most natural
to them, rather than by chapter.  You can then use tags to associate
notes with chapters.  If for example you have some quotes that belong
together but are relevant to both chapters 1 and 2, you can have them in
a single entry in notes.org, tagged with :ch1:ch2:.  Likewise for tasks:
if some tasks require you to modify multiple chapters, you just tag them
multiple times.  (Links may also be helpful in this setup.)

I used to have a setup a lot like the one you described, but I found
that tags allowed me to organize my notes and tasks with much more
flexibility than using a tree-like hierarchy.  There's always the
question of where some note belongs when you can only file it in one
place.

I now use the two-file setup for writing my dissertation.  I keep tasks
and notes about readings I do in one file, with tags to associate them
with chapters and so on, and do my actual writing in another file.  This
keeps both types of information clean and organized, but I can move
easily between them.

--
Best,
Richard




Re: [O] State of the art in citations

2014-04-27 Thread Richard Lawrence
Hi Clément and all,

Clément B. clem...@autistici.org writes:

 As for citations, I find that the most flexible way is to define
 my own link types, that allows control on both org formatting and
 export...

Replacing my inline \cite commands with custom link types is something
I've been meaning to do for a while.  Thanks for the implementation
ideas!  

I have a setup that for some people may complement the one Clément
describes.  Rather than dealing with .bib files and RefTeX, I represent
my bibliography in Org, and use org-bibtex to (re-)generate a .bib file
as needed.  Here's how it works, in brief; I described it more fully at:
http://article.gmane.org/gmane.emacs.orgmode/79016/

1) I store each reading as a TODO headline using a capture template.  I
use the post-capture hook to call org-bibtex-create-in-current-entry as
appropriate.  This allows me to keep notes, links, deadlines
etc. associated with each reading in Org, as well as the bibliographic
data.

2) I have a function that uses org-map-entries to walk over the
headlines for my readings and export them to a .bib file.  This
regenerates my .bib file on an as-needed basis; the real bibliographic
database is stored in Org.  (I call this function from a Makefile, but
it could just as easily be used from within the Org export process.)

The next step, which I haven't yet implemented but which would connect
this setup to one like Clément described, would be to add behavior to
the custom link types so that *following* the link would jump to the
associated TODO entry for the reading, rather than the entry in the .bib
file.  This should be straightforward, since org-bibtex uses the
CUSTOM_ID property to store the cite key.  And jumping to my own notes
about a reference (which might further link to the original text),
rather than to a .bib file, is usually what I want.

-- 
Best,
Richard




Re: [O] latex export of \ce question

2014-04-21 Thread Richard Lawrence
Hi John,

John Kitchin jkitc...@andrew.cmu.edu writes:

 If I have this in an org file:

 \ce{ABO_3}
 \ce{ABO_{3-\delta}}

 this exports as
 \ce{ABO_3}
 \ce\{ABO$_{\text{3-}\delta}$\}

 The first one is fine, but the second one is not.  The nested {} seems to
 mess it up. Is there a way to get this to export correctly?

Hmm.  I've played around with this a little, and the best solution I've
got is to use an explicit fallback to LaTeX, like:

#+LATEX: \ce{ABO_{3-\delta}}

...or whatever literal LaTeX is the right output for your situation.
(What is the correct export output in this case?  In particular, should
the contents of the subscript be in math mode?)

The problem does indeed seem to be the embedded braces...I'm guessing
this is an inherent limitation, resulting form the fact that Org uses
regular expressions to recognize LaTeX expressions.

If this is something you need to do all the time, and the #+LATEX syntax
doesn't work for you (e.g. if you also need HTML export), you could look
into an Org macro or an export filter. 

Best,
Richard


(If possible, please encrypt your reply to me using my PGP key:
Key ID: CF6FA646
Fingerprint: 9969 43E1 CF6F A646.
See http://www.ocf.berkeley.edu/~rwl/encryption.html for more information.)




Re: [O] [RFC] Org Minor Mode?

2014-04-11 Thread Richard Lawrence
Hi Thorsten,

Bastien b...@gnu.org writes:

 Nicolas Goaziou n.goaz...@gmail.com writes:

 Thorsten Jolitz tjol...@gmail.com writes:

 What do you think - is there any chance that Org-mode switches from
 static hardcoded regexp strings (all over the place) to dynamic
 regexps calculated at runtime (using libraries like drx.el or rx.el)?

 I hope not. The syntax should stabilize, not drift away.

 Agreed.  Maybe there are some hardcoded regexps that we can factor
 out, but dynamically building those fundamental regexp is a deadend.

I agree with what Nicolas and Bastien have said, but I wanted to say
that I think there is an interesting idea in Thorsten's post that
shouldn't be dismissed out of hand.

Org provides a set of UI concepts (tree-like structure, visibility
cycling, tree filtering, task state tracking, building an agenda from
multiple sources, ...)  that map nicely onto a lot of other situations,
and would be really handy to have access to even when the syntax of the
underlying file is incompatible with Org's syntax.

There are two ways to think about Org syntax, which I think should be
distinguished here.  One is as the grammar of a .org file: basically, a
set of rules that allow a sequence of characters to be parsed into an
AST.  The other way to think about Org syntax is the way Lisp
programmers sometimes talk about syntax: as the AST itself, the
collection of Lisp data types and their interrelationships that define a
valid Org document.

If Org were to evolve to the point where the UI concepts were
implemented purely as transformations on an AST -- on Org syntax in the
second sense -- then the way would be clear for making those concepts
available in editing modes where the grammar of the underlying file is
incompatible with Org syntax in the first sense.  A programming mode
could, say, parse comments into an Org AST, then expose that AST to the
functions implementing Org's UI concepts.  Et voila: you get visibility
cycling, task state tracking, agendas...in your source code comments.

One sort of use case where I think this idea could really shine is in
dealing with email.  Obviously, the grammar of the underlying mail files
(say, in a Maildir) will never be compatible with Org syntax in the
first sense.  But Org handles so many of the concepts that apply to
email (threading messages into hierarchies, visibility cycling, tagging,
sorting by date or priority, thinking of messages as tasks to be dealt
with, dealing with attachments) in such a nice way that I find myself
sorely missing Org whenever I read mail in a client that doesn't
implement them as nicely -- which is all of them.  If it were possible
to build a parser for message files that transformed them into an Org
AST, the mail client of my dreams would be in reach.

I have no idea if evolving Org in this direction is feasible or even
really desireable.  It may be that the two notions of Org syntax are
tightly coupled in principle, so that the idea of producing an Org AST
from an alternative underlying file format will never make sense.  But I
think that would be surprising.  

This evolution would clearly require more work than just abstracting out
the regular expressions that implement much of Org's syntax in the first
sense, and I think Bastien and Nicolas are right that we don't want
either notion of Org syntax to become less stable.  Still, I think
there's a lot of interesting possibilities we could explore if Org's
implementations of the two notions of syntax were to become less tightly
coupled.

Best,
Richard




Re: [O] Biblatex and Org

2014-04-07 Thread Richard Lawrence
Hi Tom,

t...@tsdye.com (Thomas S. Dye) writes:

 I think you'll be fine with org-bibtex and biblatex.

 Richard Lawrence richard.lawre...@berkeley.edu writes:

 So it looks like switching to biblatex is just a matter of changing my
 compilation process and the bibliography commands in my documents.  Does
 that sound right?

 Here is a description of using bibtex and biblatex with the old
 exporter that should still be useful:

 http://orgmode.org/worg/org-tutorials/org-latex-export.html#sec-17

 It is easy to switch from one to the other.
 ...

This was very helpful.  Many thanks!

Best,
Richard




Re: [O] [OT] Don't use BibTeX!

2014-04-06 Thread Richard Lawrence
Marcin Borkowski mb...@wmi.amu.edu.pl writes:

 Dnia 2014-04-05, o godz. 09:46:39
 Richard Lawrence richard.lawre...@berkeley.edu napisał(a):

 I have sometimes run into problems (mostly with BibTeX) when the

 Sorry for being off-topic, but I can't resist: *please* *don't* *use*
 *BibTeX*.  On the scale of tools that solve problems vs. tools that
 create problems (cf. http://xkcd.com/1343/ ;)), it is located on the
 far right.

Now now, the first sentence on http://www.bibtex.org/Using/ says that to
use Bibtex, Just create a plain text file and apply what has been
explained in section BibTeX File Format.!  It doesn't say anything
about how to use the manual. ;)

 (For instance, to be able to customize its bibliography style, you
 could (a) give up, (b) use some user-friendly (or not) front-end,
 having less power than BibTeX itself (obviously!), or (c) learn
 BibTeX's own, very peculiar, stack-based ad-hoc language grown to
 describe bibliography styles.  Not good.  Also, if you're unlucky and
 you write in some non-English language, well, you're unlucky with
 BibTeX, especially if e.g. your name starts with a non-Latin letter.
 Etc.)

I mostly use bibtex because that's what I learned, and none of these
issues apply to me at this (early) stage in my career.  I have no need
for customizing my bibliography style.  I suppose this will matter more
to me when I start sending things out for publication, but at this point
I'm still just trying to write the damn dissertation...

 Use biblatex instead.  It's more modern, it's being supported, it
 knowns that there exist things like UTF-8 and non-English languages,
 it supports more citation styles etc.

I have heard this, but haven't investigated biblatex because I haven't
yet really felt the need.

I keep my reading list and notes in Org, then export them to a .bib file
using org-bibtex.  Does biblatex support .bib files?  If not, what would
be required to support a biblatex-based workflow in Org?

Thanks for keeping me honest!

Best,
Richard




Re: [O] Kill ring contains non-killed output after an export

2014-04-06 Thread Richard Lawrence

Konstantin Kliakhandler ko...@slumpy.org writes:

 Richard Lawrence richard.lawre...@berkeley.edu writes:
 The behavior you are seeing is as expected, though I agree that this
 behavior is usually not all that useful.  See the variable
 org-export-copy-to-kill-ring if you want to turn it off.

 Thanks! Now the export is much more usable for me. Out of curiousity,
 what is the use case of the default behavior?

I have no idea...if I had to take a guess, it would be that when
exporting a region as a LaTeX *snippet*, such as a table, it could be
useful to yank the resulting code into another buffer.  But I really
can't think of a situation where yanking a whole .tex document from the
kill ring is preferable to just visiting the exported file/buffer.  So
I'm all for changing the default behavior.

Best,
Richard




[O] Biblatex and Org [was: [OT] Don't use BibTeX!]

2014-04-06 Thread Richard Lawrence
Hi Thomas,

Thomas S. Dye t...@tsdye.com writes:

 If you're just starting out, I encourage you to use biblatex.  It will
 take a few minutes to make the switch and then you won't have to think
 about it.  A biblatex site you find googling should tell you what you
 need to know.

Well, that's the trouble...although I'm still probably a couple of years
from wanting to publish anything, I'm not just starting out.  I use Org
to keep track of my readings and citation information, and then export
this data to .bib on the fly using functions from org-bibtex.  I have
quite a few readings recorded this way.  I described my setup a while
ago here:

http://thread.gmane.org/gmane.emacs.orgmode/78983/focus=79016

So I'm not really tied to BibTeX, but I *am* relying on org-bibtex.  I'm
certainly willing to switch to biblatex if that's going to save me a lot
of time or headache in the future.  What I need to know is what's
required to switch over the parts of my setup that originate in Org.  

Correct me if I'm wrong, but it looks like I can keep using this part of
my setup, because biblatex supports the .bib format:
#+BEGIN_QUOTE
biblatex can be used with or without BibTeX the program
since its default backend Biber uses fully supports the BibTeX file
format (bib) and users should be able to move to biblatex will little or
no changes to their BibTeX data files when using Biber as a backend.

(from section 2 of the biblatex manual at
http://mirror.hmc.edu/ctan/macros/latex/contrib/biblatex/doc/biblatex.pdf)
#+END_QUOTE

So it looks like switching to biblatex is just a matter of changing my
compilation process and the bibliography commands in my documents.  Does
that sound right?

Thanks for your advice!

Best,
Richard



Re: [O] Images not showing up in PDF output

2014-04-05 Thread Richard Lawrence
Hi Mark,

 On Saturday,  5 Apr 2014 at 05:59, Mark S. wrote:
 Hello,

 I was able to export a subtree as PDF, but the images don't show
 up. The images do export in HTML, and I can see that there is LaTeX
 code for it. It looks like this:

   \includegraphics[width=10em]{./Periodicals.org_20140402_202538_4928DjL.png}

 Are there settings or additional add-ons that I need to produce the images?

In addition to Eric's advice, I would recommend that you check that this
image is in the right directory, relative to where the .tex file lives,
and relative to where LaTeX is being run.  (Check the compile log to see
if there are errors about not finding the image, or try to compile the
exported .tex by hand, without the -interaction nonstopmode option which
I believe is Org's default.)

I have sometimes run into problems (mostly with BibTeX) when the
exported .tex file doesn't exist in the directory where
org-latex-pdf-process is run: even though the paths may look right in
the .tex file, if the other files used in the compilation (.aux, etc.)
don't end up in the right place, relative paths can break.
 
Best,
Richard


(If possible, please encrypt your reply to me using my PGP key:
Key ID: CF6FA646
Fingerprint: 9969 43E1 CF6F A646.
See http://www.ocf.berkeley.edu/~rwl/encryption.html for more information.)




Re: [O] How to simply move footnotes from one org document to another?

2014-04-05 Thread Richard Lawrence
Hi Grant,

Grant Rettke g...@wisdomandwonder.com writes:

 Goal: Easily copy and paste sections of text along with footnote
 references into the new document,
 and in doing so, add the contents of the previous document to the new
 document, and let org
 deal with the new footnote names.

 As I write this, I realize that it isn't so simple. I'm just looking
 for a place to start in terms of what
 is already present and how you deal with it currently.

I use the inline footnote syntax [fn:: ...] for just this reason.  I
think easy migration of non-inline footnotes would be a nice feature to
add to Org, though doing it right would be non-trivial.

A strategy that another user once described to me for dealing with this
problem is the following:

1) Use a regexp search and replace to re-number the footnotes
   in the region of the text you want to move, giving them high numbers
   (e.g., prefixing each with ).
2) Use Org to re-sort the footnotes in the original file, so that the
   newly-renumbered footnotes all appear at the end.
3) Move the text and the footnotes to the new file, which should now be
   easy, since the footnotes are all grouped together.
4) In the new file, use Org to re-number the footnotes back to something 
normal.  
   
This sounded like a pretty good idea to me, though I haven't had a need
to try it myself.

Hope that helps!

Best,
Richard


(If possible, please encrypt your reply to me using my PGP key:
Key ID: CF6FA646
Fingerprint: 9969 43E1 CF6F A646.
See http://www.ocf.berkeley.edu/~rwl/encryption.html for more information.)




Re: [O] Kill ring contains non-killed output after an export

2014-04-05 Thread Richard Lawrence
Hi Konstantin,

Konstantin Kliakhandler ko...@slumpy.org writes:

 Whenever I export an org file to pdf, subsequently my kill-ring contains
 the tex code of the intermediate latex stage.
 ...
 What I would expect to get: the last thing I killed.

The behavior you are seeing is as expected, though I agree that this
behavior is usually not all that useful.  See the variable
org-export-copy-to-kill-ring if you want to turn it off.

Changing the default value of this variable was recently discussed on
this list:

http://thread.gmane.org/gmane.emacs.orgmode/84048/focus=84055

Looks like there haven't been any strong objections to changing it, but
maybe the subject of this thread will grab some more attention for the
issue.

Best,
Richard


(If possible, please encrypt your reply to me using my PGP key:
Key ID: CF6FA646
Fingerprint: 9969 43E1 CF6F A646.
See http://www.ocf.berkeley.edu/~rwl/encryption.html for more information.)




Re: [O] Get counting of items

2014-04-03 Thread Richard Lawrence
Thorsten Jolitz tjol...@gmail.com writes:

 #+begin_src emacs-lisp
   (with-current-buffer my.org
 (eval (append (list '+)
   (org-map-entries
(lambda () (if (eq (org-outline-level) 1) 1 0))
 #+end_src

Or, slightly more simply:

#+begin_src emacs-lisp
(with-current-buffer my.org
(apply '+ (org-map-entries
   (lambda () (if (eq (org-outline-level) 1) 1 0)
#+end_src

which you could wrap into a function like:

#+begin_src emacs-lisp
(defun count-toplevel-headlines ()
  Count the top level headlines in the current buffer
  (interactive)
  (message
(format Number of first level headlines: %s 
  (save-excursion
(apply '+ (org-map-entries
   (lambda () (if (eq (org-outline-level) 1) 1 0
#+end_src

Best,
Richard


(If possible, please encrypt your reply to me using my PGP key:
Key ID: CF6FA646
Fingerprint: 9969 43E1 CF6F A646.
See http://www.ocf.berkeley.edu/~rwl/encryption.html for more information.)




Re: [O] Creating changelog with magit

2014-04-03 Thread Richard Lawrence
Hi Thorsten,

Thorsten Jolitz tjol...@gmail.com writes:

 i.e. magit does not detect which files/definitions have changed and already
 offers the template for all changes of the current diff to HEAD.

 Am I doing something wrong or is this all there is?

As far as I am aware, this is all there is...at least on the version of
magit I'm running (1.1.1, which is old, but it's the current version in
Debian stable).  Maybe newer magit does something more useful?  Or maybe
there is some configuration incantation to make the default behavior of
C more useful for elisp files?  If someone knows, I would also like to
hear...

Best,
Richard




Re: [O] Better way to specify the latex documentclass of an exported file without changing my configuration?

2014-03-26 Thread Richard Lawrence
Hi Alan,

Alan Schmitt alan.schm...@polytechnique.org writes:

 Feng Shu tuma...@gmail.com writes:

 Alan Schmitt alan.schm...@polytechnique.org writes:

 Hello,

 I'm collaborating on a paper with some colleagues, and I convinced them
 to use org-mode. I'm trying to make sure the paper is as self-contained
 as possible (I don't want them to have to change their emacs
 configuration file).To change the documentclass name of the exported

 Maybe you can write a Makefile to change their emacs configure...

 I don't want to push my luck ;-)

I wouldn't have a Makefile change their .emacs, but this does seem like
a good application for a Makefile or similar.

You can put code that configures Emacs/Org in the way you need for
compiling your document in a separate file in the repository, then load
that file using Emacs' --load flag in the command that runs the
export/compilation.

For example, here's a snippet of the Makefile I use for my
dissertation.  This compiles the bibliography from my Org-based reading
list:

#+BEGIN_EXAMPLE
BATCH_EMACS=$(EMACS) --batch -Q 

bib: tasks.org lib/el/bib-export.el
$(BATCH_EMACS) --load lib/el/bib-export.el --file tasks.org --funcall 
reading-list-to-bibtex
#+END_EXAMPLE

(The code that lives in bib-export.el takes care of walking over the
reading entries in tasks.org and exporting them to Bibtex.  It is where
reading-list-to-bibtex is defined.  I'm happy to share if you want to
see it.)

This allows me to just type `make bib' to get a fresh copy of my .bib file.

Another nice thing about this approach is that you can use the -Q flag,
as I've done here, to make sure that Emacs' configuration is clean
before the export begins, which should make compilation more reliable.

-- 
Best,
Richard





Re: [O] Org release 8.2.5g (minor release from maint)

2014-03-13 Thread Richard Lawrence
Hi Bastien,

Bastien b...@gnu.org writes:

 Any reason why Debian developers are not using 24.3 as the stable
 version of Emacs?  It has been out for now one year.

Well, the way that the Debian stable release works is that they ship the
latest stable version of a package which is available at the time of
their pre-release freeze.  After the freeze, packages only receive
updates for critical bugs and security fixes for the lifetime of the
release.

The current release (Debian Wheezy) was frozen on 2012-06-30 and
released 2013-05-04. I think Emacs 24 probably just barely missed the
Wheezy release, as 24.1 was released 2012-06-10.  My guess is that the
Debian maintainers either didn't consider 24.1 stable enough yet for
Wheezy, or they just weren't sure and didn't want to take the chance.

The next release (Jessie) is not yet frozen, and some post-24 Emacs will
certainly be included when it is.

Anyway, I don't think Org should be beholden to distributions' release
cycles in general.  Users like me who are happy with an older Emacs but
want a newer Org are probably a very small minority (but speak up if
you're out there!).  And for these users, it is probably only a minor
inconvenience to have to install cl-lib or a newer Emacs.  That is at
least true in my case.  If introducing a dependency on cl-lib right now
will be the best thing for Org, I have no real objections; if it can be
put off for a while without significant cost, that would be great, but
it isn't necessary.

Best,
Richard



Re: [O] Exporting to multiple files

2014-03-13 Thread Richard Lawrence
Hi Marcin,

Marcin Borkowski mb...@wmi.amu.edu.pl writes:

 I'd like to export an Org-mode file to /multiple/ HTML files.  For
 instance, I might want to convert all first and second level headings
 to files, and third-level headings to h1, fourth-level ones to h2
 inside these files etc.  Is that possible?  I looked into the docs, but
 didn't find anything like this.

I once wrote a function that does something like this.  (I haven't used
it since the pre-8.0 days, though, so it probably needs updating.)  It
creates individual PDFs from the subtrees under a headline, then
concatenates them into one PDF using an external program (pdftk).
Naming is done based on the EXPORT_FILE_NAME property as usual.  Maybe
you can use it as a skeleton:

#+BEGIN_SRC elisp
;; utilities for exporting the subtrees of a tree as individual PDFS
;; and as a single, concatenated PDF
(defun org-export-individual-pdfs-and-concat ()
  (interactive)
  (setq export-files nil
pdf-files nil
; point must be in main tree to be exported (not a subtree)
concat-pdf-name (get-property-or-fail (point) CONCATENATED_PDF_NAME))
  (progn
(org-map-entries
 (lambda ()
   (setq org-map-continue-from (outline-next-heading))
   (org-mark-subtree)
   ; org-map-entries positions point at the beginning of each subtree
   (if org-map-continue-from ; non-nil if outline-next-heading found a 
heading
   (let ((org-trust-scanner-tags t))
 (push (get-property-or-fail (point) EXPORT_FILE_NAME) 
export-files)))
   (mapcar 'message (org-get-tags))
   (org-export-as-pdf nil)) ; TODO: why doesn't this respect noexport tag?
 nil 'tree)
(concat-pdfs (nreverse (mapcar 'tex-name-to-pdf-name export-files))
 concat-pdf-name)))

(defun get-property-or-fail (pom property)
  (or
   ; probably some opportunity for optimization here...see function
   ; documentation for org-map-entries
   (org-entry-get pom property)
   (error (format Entry at %s does not define property %s 
(org-heading-components) property

(defun tex-name-to-pdf-name (filename)
  (concat (file-name-sans-extension filename) .pdf))

(defun concat-pdfs (in-files out-file)
  (shell-command
   (format pdftk %s cat output %s
   (mapconcat (lambda (s) s) in-files  ) ; join pdf names with spaces
   out-file)))

#+END_SRC

Another option that occurs to me -- though it may not serve your needs
-- is to export your Org file to texinfo format.  I believe the texinfo
compiler can then generate separate separate HTML files for the
different sections in your .texi file.  Might be worth a try.
 
-- 
Best,
Richard




Re: [O] Org release 8.2.5g (minor release from maint)

2014-03-07 Thread Richard Lawrence
Bastien b...@gnu.org writes:

 Eric Schulte schulte.e...@gmail.com writes:

 Great, so should Org-mode require cl-lib and stop supporting the
 following functions?

 I guess so.  But I'm unclear yet whether this removes compatibility
 with older Emacsen.  I'll check this.

I believe it does remove compatibility with anything pre-24.0.  At
least, there is no cl-lib in GNU Emacs 23.4.1, which is the version
currently in Debian stable.

I am one small voice, but as a user who prefers Debian stable but also
the maint branch of Org, I'd request that you avoid a hard dependency on
cl-lib for a while longer, maybe at least until Emacs 24 is the default
in major distro's package systems?

Best,
Richard



Re: [O] Org release 8.2.5g (minor release from maint)

2014-03-07 Thread Richard Lawrence
Eric Schulte schulte.e...@gmail.com writes:

 With cl-lib installable as a library through ELPA, would requiring it as
 a dependency be acceptable?  I suppose Org-mode doesn't currently have
 any dependencies, so it might not be worth adding one just to remove
 some redundant functions.

Well, there's no ELPA in Emacs pre-24.0 either, at least not built-in.
So a dependency on ELPA/package.el is not really any better than a
dependency on cl-lib for folks like me. 

Best,
Richard



Re: [O] Publish project alist in org-mode 8 - confusing documentation

2014-03-06 Thread Richard Lawrence
Hi Gez,

Gez sule...@gmail.com writes:

 but I don't know where to begin adapting it to the new export framework.

 For example, I'd be very grateful if someone could translate the
 following (or something more simple) into org-mode 8 version, so I can
 start evaluating and playing with it.

 (require 'org-publish)
 (setq org-publish-project-alist
   '(
 (org-notes
  :base-directory ~/org/
  :base-extension org
  :publishing-directory ~/public_html/
  :recursive t
  :publishing-function org-publish-org-to-html

It's been a while since I converted my publishing setup to the new
exporter, but I *think* the only change you need to make here is to the
:publishing-function option.  

The function you want here is now called org-html-publish-to-html.
There are other similar functions in the other export backends -- e.g.,
the function to publish to PDF is org-latex-publish-to-pdf.

Thus, if you need to find an appropriate publishing function, start by
looking for a function named like: org-BACKEND-publish-to-FORMAT.  I
don't remember how I figured this out, but hopefully it is documented in
the manual...

(I am not sure about the :recursive or :auto-preamble options, which
don't appear in the variable documentation for
org-publish-project-alist; if changing :publishing-function on its own
does not get this setup working, try removing those options.)

  :headline-levels 7
  :auto-preamble t
  )
 (org-static
  :base-directory ~/org/
  :base-extension css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf
  :publishing-directory ~/public_html/
  :recursive t
  :publishing-function org-publish-attachment
  )
 (org :components (org-notes org-static))
   ))

Again, I think this should work as-is, with the possible exception of
the :recursive option.  org-publish-attachment is still around.

Hope that helps!

Best,
Richard




Re: [O] Exporting LaTeX source blocks with HTML backend

2014-03-03 Thread Richard Lawrence
Hi Xavier,

Xavier Garrido xavier.garr...@gmail.com writes:

 I am facing one issue when I am exporting from orgmode to html. I like 
 to write LaTeX code within #+BEGIN_SRC latex ... #+END_SRC block mainly 
 to take benefit/advantage of the syntax highlighting (debugging long 
 LaTeX equations is simpler). The problem is that these code blocks are 
 not exported at all by the html export backend whereas the LaTeX backend 
 does. Of course, an easy solution will be to remove the 
 #+BEGIN_SRC/#+END_SRC lines and both latex and html exporters will just 
 do it right. But, as I said, syntax highlighting is really useful and I 
 can't imagine living without it.

I don't quite understand what you're looking for here.  Are you wanting
these blocks to be exported as source code?  Or do you want them to be
interpreted somehow?

Removing the BEGIN_SRC/END_SRC lines will just result in raw LaTeX code
getting dumped into your HTML, and a browser won't know what to do with
that (at least not without help...are you wanting MathJax to interpret
it?).

 As a summary I would like to do the following

 #+BEGIN_SRC org
 * Test LaTeX block
Syntax highlighting is always nice but the following block is not 
 exported in html. An option will be to remove the #+BEGIN_SRC 
 latex/#+END_SRC lines

#+BEGIN_SRC latex
  \begin{align*}
  x=x\\
  y=y
  \end{align*}
#+END_SRC

When I export this using the HTML exporter, the LaTeX code is wrapped in
a div with class=org-src-container, and the actual code appears
inside a pre tag.  Is this the behavior you see?  Is that not what you
want?

If you are instead looking to get something in your HTML output that
looks like the result of compiling the LaTeX code, I am not exactly sure
how to accomplish this, but it looks like there is some useful
information in the section Math formatting in HTML export in the Org
manual about either using MathJax or preprocessing LaTeX code into
images with dvipng.

Hope that helps,
Richard


(If possible, please encrypt your reply to me using my PGP key:
Key ID: CF6FA646
Fingerprint: 9969 43E1 CF6F A646.
See http://www.ocf.berkeley.edu/~rwl/encryption.html for more information.)




Re: [O] Exporting LaTeX source blocks with HTML backend

2014-03-03 Thread Richard Lawrence
Xavier Garrido xavier.garr...@gmail.com writes:

 #+BEGIN_SRC latex
   \begin{align*}
   x=x\\
   y=y
   \end{align*}
 #+END_SRC

 When I export this using the HTML exporter, the LaTeX code is wrapped in
 a div with class=org-src-container, and the actual code appears
 inside a pre tag.  Is this the behavior you see?  Is that not what you
 want?

 In my case, the code is not even wrapped into org-src-container class, 
 it just does not appear at all.

Hmm.  If Ista's solution doesn't work for you, you may want to look into
why this is happening.  Maybe you have a variable or option set
somewhere that is suppressing export of these blocks for some reason.  I
am using the maint version of the exporter (8.2.5h) and I don't use
HTML export much, so I am pretty sure what I see is the current default
behavior.

Best,
Richard


(If possible, please encrypt your reply to me using my PGP key:
Key ID: CF6FA646
Fingerprint: 9969 43E1 CF6F A646.
See http://www.ocf.berkeley.edu/~rwl/encryption.html for more information.)



Re: [O] trunc fill modes?

2014-02-28 Thread Richard Lawrence
Peter Davis p...@pfdstudio.com writes:

 On my MacBook Pro at work, running Aquamacs 3.0a, in Org mode the mode
 line shows

 ... Fill

I think you want auto-fill-mode.  See: 
https://www.gnu.org/software/emacs/manual/html_node/emacs/Auto-Fill.html

Auto-fill-mode is an Emacs minor mode.  You can make sure it's turned on
in Org (which is a major mode) by adding it to Org's mode hook:

(add-hook 'org-mode-hook   ; add a function to the Org mode 
hook...
  (lambda () (auto-fill-mode 1)))  ; that ensures auto-fill-mode is on

Put that somewhere in your ~/.emacs, restart Emacs (to reload your
~/.emacs), and you should see Fill in the mode line when you're in Org
mode.

You can do the same for other modes by swapping out the org-mode-hook
symbol for the appropriate hook variable for another mode (usually
called MODE-NAME-hook).

Best,
Richard


(If possible, please encrypt your reply to me using my PGP key:
Key ID: CF6FA646
Fingerprint: 9969 43E1 CF6F A646.
See http://www.ocf.berkeley.edu/~rwl/encryption.html for more information.)




Re: [O] Any linguists (or other gb4e/linguex users) on this list?

2014-02-24 Thread Richard Lawrence
Aaron Ecay aarone...@gmail.com writes:

 This looks very interesting.  I have created some code that uses tables
 for glossed examples.  So it turns this:

 #+name: ex:ilurdotz
 #+header: :gloss yes
 #+header: :trans You carried me in the car.
 #+header: :cite /MVAV/ Southern High Navarre, p.\space{}160
 | zuek| ekarri | n-ai-zue| neri| kotxe-an |
 | 2PL.ERG | bring  | 1SG-AUX-2PL.ERG | 1SG.DAT | car-LOC  |

 into:

 \ex
 \begingl
 \gla[] zuek ekarri n-ai-zue neri kotxe-an//
 \glb[] \textsc{2pl.erg} bring \textsc{1sg-aux-2pl.erg} \textsc{1sg.dat} 
 car-\textsc{loc}//
 \glft ‘You carried me in the car.’ \trailingcitation{\emph{MVAV} Southern 
 High Navarre, p.\ 160}//
 \endgl
 \label{ex:ilurdotz}
 \xe

Hmm, cool!  I don't actually have much use for glosses myself, but this
seems like a nice way to do this.  Did you have to define a derived
export backend to make this work?  Or are you able to do this using
filters?

 I also have some code for embedding syntax trees, which basically just
 passes them through to LaTeX (with some niceties such as translating
 #+caption to \caption{}).  I’ve been meaning to rewrite this for some
 time so that it compiles the trees to SVG to enable embedding into html.

That would also be nice.  If you feel like this code would be worth
packaging up, maybe we could put it together with mine in an
org-linguistics contrib package or some such.

 \begin{exe}
 \ex[ ]{This is an example sentence.} \label{s:example}
 \ex[*]{This ungrammatical sentence!} \label{s:ungrammatical}
 \end{exe}

 Does this work correctly when the \label is outside the brackets of the
 \ex?  I guess it must, but I was surprised...

Indeed it does.  Actually I assumed it /had/ to be outside, probably
because I misinterpreted a comment in the documentation that when you
have judgment brackets, ``in this case you have to indicate the scope of
the example itself with {...}'s''.  (This probably reveals my ignorance
about how LaTeX magically associates labels with what they label.) But
looking again, the gb4e documentation doesn't really make it clear
either way.  If it should go on the inside, that would actually simplify
my code a little bit.

I think it would be straightforward to extend what I've got to exporting
linguex examples, and possibly even expex examples (though I haven't
used that package myself).  Would that be useful to you?

Best,
Richard




Re: [O] [patch] Support CUSTOM_ID property in latex export

2014-02-22 Thread Richard Lawrence
Hi Nicolas and all,

Thanks for your feedback.  I have a couple of questions about your
comments:

Nicolas Goaziou n.goaz...@gmail.com writes:

 I think you can remove that it is unique throughout the generated
 document, as it is already explained in the manual, and not specific to
 this variable.

True, it is explained that CUSTOM_ID must be unique, but not that the
generated label must be.  I have changed this to:

You are responsible for ensuring that the value is a valid LaTeX
\\label key, and that no other \\label commands with the same key appear
elsewhere in your document.

That seems clearer to me; it forbids e.g. introducing labels with the
same key on a #+LATEX: line.  Sound good?

 OTOH, it would be nice to specify what is a valid \label key (e.g.,
 forbidden characters) and that the default value doesn't have this
 limitation (otherwise, that wouldn't be much of a trade-off).

 +(let ((custom-label (and org-latex-custom-id-as-label
 + (org-element-property :CUSTOM_ID 
 headline


I can't actually find a clear explanation anywhere of exactly what is
and isn't allowed in a label key.  All the LaTeX documentation seems to
just say:

A key can consist of any sequence of letters, digits, or punctuation
characters. Upper and lowercase letters are different.

But clearly, the issue is what sort of punctuation is allowed.  :
and _ are OK, but % and $ aren't...is there a definitive list
somewhere I should refer to?  Maybe I should just say the user should
have a look at the regexp in org-export-solidify-link-text?

 There is one thing to consider here. We can define the new variable as
 a back-end options, i.e., add

   (:latex-manual-id nil nil org-latex-custom-id-as-label)


 in the back-end definition (the name of the property doesn't matter
 much, you can change it).


 This is not strictly necessary, but it allows, for example, to change
 its value for specific projects (in the publishing sense) without
 setting the variable globally.

 If you think it is useful to do so,

   (and org-latex-custom-id-as-label

 should become

   (and (plist-get info :latex-manual-id)

 +   (let* ((custom-label (and org-latex-custom-id-as-label
 +(org-element-property :CUSTOM_ID 
 destination)))

 Ditto.


OK, that sounds like a good idea, but are these the only changes that
would be necessary?  Where should the name of the back-end option and
its relationship to this variable be documented?

Best,
Richard


(If possible, please encrypt your reply to me using my PGP key:
Key ID: CF6FA646
Fingerprint: 9969 43E1 CF6F A646.
See http://www.ocf.berkeley.edu/~rwl/encryption.html for more information.)



Re: [O] Tables with line wrapping?

2014-02-22 Thread Richard Lawrence
Hi Peter,

Peter Davis p...@pfdstudio.com writes:

 I'm using org-mode to prepare a document that will ultimately be
 exported to PDF. Unfortunately, I need to include a table whose contents
 will wrap as needed.

I've run into this problem before too, but I haven't found a good
solution. (Though I haven't looked that hard.)  Maybe someone else will
have a better suggestion than the workaround I've used (see below).

 The options I can see are:

 1) Do everything I can in org-mode, then export and edit the
 intermediate .tex file, or

 2) Create the table with some other tool, and include it as an image
 into the org document

 Am I missing anything? Are there other (better?) ways? As I expect to be
 revising both the table and the rest of the document for a while, the
 uni-directional workflow in #1 above would be difficult.

What about just maintaining the table as an embedded LaTeX block? e.g.

... your Org text here ...
#+BEGIN_LATEX
\begin{tabular} % or wrap with \begin{table} if you need, etc.
% ...
\end{tabular}
#+END_LATEX

That way, at least, you can edit your document and the table at the same
time and in the same file, though it means giving up Org's nice table
editing features.
 
Best,
Richard





Re: [O] [patch] Support CUSTOM_ID property in latex export

2014-02-22 Thread Richard Lawrence
Hi Nicolas and all,

OK, I think I've got a patch now that addresses everything you asked
for.  It is attached.  This has been quite a learning experience!  Let
me know if other changes are necessary.  

From 07bfc34a48858aa386c0416e592082610c913ef3 Mon Sep 17 00:00:00 2001
From: Richard Lawrence richard.lawre...@berkeley.edu
Date: Fri, 21 Feb 2014 11:22:08 -0800
Subject: [PATCH] Support using CUSTOM_ID property to generate section labels
 during LaTeX export
To: emacs-orgmode@gnu.org
Cc: n.goaz...@gmail.com

This allows the user to control how Org generates label keys for
headlines during LaTeX export, and thus to know their keys in advance.
This is useful for e.g. using \ref commands inside of embedded LaTeX
blocks.

* lisp/ox-latex.el:
  (defcustom org-latex-custom-id-as-label): Variable to control using
CUSTOM_ID values as labels during export

  Backend definition: Add :latex-custom-id-labels option to backend's
:options-alist, using value of org-latex-custom-id-as-label to
define its behavior

  (org-latex-headline): Optionally generate label keys based on CUSTOM_ID,
depending on value of :latex-custom-id-labels option

  (org-latex-link): Optionally generate refs based on CUSTOM_ID,
depending on value of :latex-custom-id-labels option

This change was discussed in the following thread:
http://thread.gmane.org/gmane.emacs.orgmode/82392
---
 lisp/ox-latex.el |   84 +++---
 1 file changed, 73 insertions(+), 11 deletions(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 5815874..4ae4bf4 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -106,7 +106,8 @@
 		   (:latex-class-options LATEX_CLASS_OPTIONS nil nil t)
 		   (:latex-header LATEX_HEADER nil nil newline)
 		   (:latex-header-extra LATEX_HEADER_EXTRA nil nil newline)
-		   (:latex-hyperref-p nil texht org-latex-with-hyperref t))
+		   (:latex-hyperref-p nil texht org-latex-with-hyperref t)
+		   (:latex-custom-id-labels nil nil org-latex-custom-id-as-label))
   :filters-alist '((:filter-options . org-latex-math-block-options-filter)
 		   (:filter-parse-tree . org-latex-math-block-tree-filter)))
 
@@ -375,6 +376,59 @@ which format headlines like for Org version prior to 8.0.
   :package-version '(Org . 8.0)
   :type 'function)
 
+(defcustom org-latex-custom-id-as-label nil
+   Toggle use of CUSTOM_ID properties for generating section labels.
+
+When this variable is non-nil, Org will use the value of a
+headline's CUSTOM_ID property as the key for the \\label command
+for the LaTeX section corresponding to the headline.
+
+By default, Org generates its own internal section labels for all
+headlines during LaTeX export.  This process ensures that the
+\\label keys are unique and valid, but it means the keys are not
+available in advance of the export process.
+
+Setting this variable gives you control over how Org generates
+labels for sections during LaTeX export, so that you may know
+their keys in advance.  One reason to do this is that it allows
+you to refer to headlines using a single label both in Org's link
+syntax and in embedded LaTeX code.
+
+For example, when this variable is non-nil, a headline like this:
+
+  ** Some section
+ :PROPERTIES:
+ :CUSTOM_ID: sec:foo
+ :END:
+  This is section [[#sec:foo]].
+  #+BEGIN_LATEX
+  And this is still section \\ref{sec:foo}.
+  #+END_LATEX
+
+will be exported to LaTeX as:
+
+  \\subsection{Some section}
+  \\label{sec:foo}
+  This is section \\ref{sec:foo}.
+  And this is still section \\ref{sec:foo}.
+
+Note, however, that setting this variable introduces a limitation
+on the possible values for CUSTOM_ID.  When this variable is
+non-nil and a headline defines a CUSTOM_ID value, Org simply
+passes this value to \\label unchanged.  You are responsible for
+ensuring that the value is a valid LaTeX \\label key, and that no
+other \\label commands with the same key appear elsewhere in your
+document.  (Keys may contain letters, numbers, and the following
+punctuation: '_' '.' '-' ':'.)  There are no such limitations on
+CUSTOM_ID when this variable is nil.
+ 
+For headlines that do not define the CUSTOM_ID property, Org will
+continue to use its default labeling scheme to generate labels
+and resolve links into section references.
+  :group 'org-export-latex
+  :type 'boolean
+  :version 24.5
+  :package-version '(Org . 8.3))
 
  Footnotes
 
@@ -1373,10 +1427,14 @@ holding contextual information.
 			   todo todo-type priority text tags))
 	   ;; Associate \label to the headline for internal links.
 	   (headline-label
-	(format \\label{sec-%s}\n
-		(mapconcat 'number-to-string
-			   (org-export-get-headline-number headline info)
-			   -)))
+	(let ((custom-label (and (plist-get info :latex-custom-id-labels)
+ (org-element-property :CUSTOM_ID headline
+	  (if custom-label
+		  (format \\label{%s}\n custom-label)
+		(format \\label{sec-%s}\n
+			(mapconcat 'number

Re: [O] [patch] Support CUSTOM_ID property in latex export

2014-02-21 Thread Richard Lawrence
Hi Nicolas and all,

Here's a new patch that adds a variable org-latex-custom-id-as-label to
control whether CUSTOM_ID should be used to generate labels during LaTeX
export.

Let me know what you think.  In particular, I wasn't sure if I should
provide more information in the defcustom statement beyond :group and
:type (like :package-version?).  Also, does the docstring represent the
trade-offs of using this variable well enough?

I wasn't sure how to get git format-patch to generate a single patch for
the changes between my branch and master (since there are now two
commits on my branch), so this was generated with git diff --patch.  If
you want me to send the commit message, etc. can you let me know how to
do this in whatever way is most convenient for you?  

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 5815874..df22768 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -375,6 +375,47 @@ which format headlines like for Org version prior to 8.0.
   :package-version '(Org . 8.0)
   :type 'function)
 
+(defcustom org-latex-custom-id-as-label nil
+   Toggle use of CUSTOM_ID properties for generating section labels.
+
+If non-nil, Org will use the value of a headline's CUSTOM_ID
+property as the argument to the \label command for the LaTeX
+section corresponding to the headline.
+
+Setting this variable gives you control over how Org generates
+labels for sections during LaTeX export.  One reason to do this
+is that it allows you to refer to headlines using a single label
+both in Org's link syntax and in embedded LaTeX code.
+
+For example, when this variable is non-nil, a headline like this:
+
+  ** Some section
+ :PROPERTIES:
+ :CUSTOM_ID: sec:foo
+ :END:
+  This is section [[#sec:foo]].
+  #+BEGIN_LATEX
+  And this is still section \ref{sec:foo}.
+  #+END_LATEX
+
+will be exported to LaTeX as:
+
+  \subsection{Some section}
+  \label{sec:foo}
+  This is section \ref{sec:foo}.
+  And this is still section \ref{sec:foo}.
+
+Note, however, that when a headline defines a value for
+CUSTOM_ID, Org simply passes this value to \label unchanged.  You
+are responsible for ensuring that the value is a valid LaTeX
+\label key, that it is unique throughout the generated document,
+etc.
+ 
+For headlines that do not define the CUSTOM_ID property, Org will
+continue to use its default labeling scheme to generate labels
+and resolve links into section references.
+  :group 'org-export-latex
+  :type 'boolean)
 
  Footnotes
 
@@ -1373,10 +1414,14 @@ holding contextual information.
 			   todo todo-type priority text tags))
 	   ;; Associate \label to the headline for internal links.
 	   (headline-label
-	(format \\label{sec-%s}\n
-		(mapconcat 'number-to-string
-			   (org-export-get-headline-number headline info)
-			   -)))
+	(let ((custom-label (and org-latex-custom-id-as-label
+ (org-element-property :CUSTOM_ID headline
+	  (if custom-label
+		  (format \\label{%s}\n custom-label)
+		(format \\label{sec-%s}\n
+			(mapconcat 'number-to-string
+   (org-export-get-headline-number headline info)
+   -)
 	   (pre-blanks
 	(make-string (org-element-property :pre-blank headline) 10)))
   (if (or (not section-fmt) (org-export-low-level-p headline info))
@@ -1845,12 +1890,16 @@ INFO is a plist holding contextual information.  See
 	  ;; number.  Otherwise, display description or headline's
 	  ;; title.
 	  (headline
-	   (let ((label
-		  (format sec-%s
-			  (mapconcat
-			   'number-to-string
-			   (org-export-get-headline-number destination info)
-			   -
+	   (let* ((custom-label (and org-latex-custom-id-as-label
+(org-element-property :CUSTOM_ID destination)))
+		  (label
+		   (or
+		custom-label
+		(format sec-%s
+			(mapconcat
+			 'number-to-string
+			 (org-export-get-headline-number destination info)
+			 -)
 	 (if (and (plist-get info :section-numbers) (not desc))
 		 (format \\ref{%s} label)
 	   (format \\hyperref[%s]{%s} label


Best,
Richard


(If possible, please encrypt your reply to me using my PGP key:
Key ID: CF6FA646
Fingerprint: 9969 43E1 CF6F A646.
See http://www.ocf.berkeley.edu/~rwl/encryption.html for more information.)


[O] Any linguists (or other gb4e/linguex users) on this list?

2014-02-21 Thread Richard Lawrence
Hi Org folks,

I am wondering if anyone on this list uses the gb4e or linguex packages
in LaTeX documents that they export from Org.

I have been working on an export backend derived from the LaTeX exporter
to allow exporting ordinary Org lists as linguistics examples formatted
by one of these two packages.  For example, a list like:

#+ATTR_LATEX: :environment gb4e-exe
1) This is an example sentence. s:example
2) * This ungrammatical sentence! s:ungrammatical

would be exported as:

\begin{exe}
\ex[ ]{This is an example sentence.} \label{s:example}
\ex[*]{This ungrammatical sentence!} \label{s:ungrammatical}
\end{exe}

This allows typing your examples using Org's nicer syntax, and referring
to them using Org links.

The backend is still in very early stages (it doesn't support linguex
yet, for example, nor have I tested it with glosses), but it supports
simple gb4e examples, including nested lists.  If anyone else is
interested in this, I can try to package it up in a form that could be
shared or put in org-contrib.  Let me know!

-- 
Best,
Richard


(If possible, please encrypt your reply to me using my PGP key:
Key ID: CF6FA646
Fingerprint: 9969 43E1 CF6F A646.
See http://www.ocf.berkeley.edu/~rwl/encryption.html for more information.)



Re: [O] [patch] Support CUSTOM_ID property in latex export

2014-02-19 Thread Richard Lawrence
Nicolas Goaziou n.goaz...@gmail.com writes:

 Richard Lawrence richard.lawre...@berkeley.edu writes:

 Would using a different property---say, LATEX_LABEL---resolve your
 concerns?  This property could be explicitly documented as overriding
 Org's default labeling, with the value passed down directly to LaTeX.

 I'd rather have a variable, e.g., `org-latex-custom-id-as-label'. When
 this variable is non-nil, Org uses raw custom ID value instead of
 auto-generated value for labels.

 Its docstring should explain the limitations that are introduced when
 using this variable, and in which cases it is interesting to enable it
 (i.e, your use-case). IOW the docstring should be informative about the
 trade-off.

Ah, yes, that is more elegant.

 So, it's basically your patch with an additional variable and its
 docstring. Do you want to take care of it?

Sure, I can do this in the next couple of days.

Best,
Richard


(If possible, please encrypt your reply to me using my PGP key:
Key ID: CF6FA646
Fingerprint: 9969 43E1 CF6F A646.
See http://www.ocf.berkeley.edu/~rwl/encryption.html for more information.)



Re: [O] [patch] Support CUSTOM_ID property in latex export

2014-02-18 Thread Richard Lawrence
Nicolas Goaziou n.goaz...@gmail.com writes:

 Hello,

 Richard Lawrence richard.lawre...@berkeley.edu writes:

 It seems to me that if you explicitly specify CUSTOM_ID with the intent
 of overriding Org's default labeling, you ought to have some idea what
 can go in a \label, and be prepared to debug your LaTeX compilation if
 there's an error.  If you're not prepared to do that, you should limit
 yourself to the default behavior.  But if you *are* prepared to do that,
 why should Org prevent you?

 This is the problem. At the moment, CUSTOM_ID has no limitation about
 the characters it can use. As long as the value is unique, Org will
 create a valid label for it.

 OTOH, you patch introduces a limitation and could force users to debug
 LaTeX compilation, even if they didn't want to mess with Org's default
 labeling in the first place. If you are *not* prepared, why Org should
 force you?

 So, this is not a net benefit in the general case.

OK, I can understand this.  There are people who are using CUSTOM_ID
already, and they shouldn't have to worry about debugging LaTeX if they
weren't counting on it.  (In my case, I'm not using this property for
anything else, so this wasn't an issue, and using CUSTOM_ID provided a
handy way to use the [[#link]] syntax to introduce \refs with the label
I intended.)

Would using a different property---say, LATEX_LABEL---resolve your
concerns?  This property could be explicitly documented as overriding
Org's default labeling, with the value passed down directly to LaTeX.
During link resolution, a headline would export with a \label{VAL},
and a link to a headline with this property would export to \ref{VAL},
where VAL is the value of this property.

Thus, e.g.,

** A headline
   :PROPERTIES:
   :CUSTOM_ID: foo
   :LATEX_LABEL: bar
   :END:
Some text ... this is section [[#foo]].

would become:

\subsection{A headline}
\label{bar}
Some text \ldots this is section \ref{bar}.
 
That would meet all my needs, I think.

In my case it would also be handy to have some way to link to headlines
based on the LATEX_LABEL property directly (say, like [[label:bar]]).
But that's easy enough to add.

 The strategy you suggest would result in multiple labels in the same
 location in the exported document.  This is bad because it introduces
 ambiguity and is thus fragile.  The exported document could have two sets
 of \refs which point to two different \labels.  Initially, LaTeX
 would compile them to the same thing, but if one of the labels got moved
 or deleted, one set of refs would break.

 Sorry for being dense, but I fail to see where is the ambiguity. Org
 will not get confused with its own internal labels, neither will you
 with yours. Do you have a real worrisome situation in mind?

The worrisome situation I have in mind is if I find that I eventually
need to move away from Org to straight LaTeX.  I would want to start
with an Org export to LaTeX, and then continue from that point by
editing the exported .tex file.  In that case, one label could
eventually get deleted, or they could drift apart, and then one set of
\refs could subtly break (say, if I put a new \subsection in between
them).  To avoid this, I want the exported .tex file to just use one set
of labels.

Best,
Richard


(If possible, please encrypt your reply to me using my PGP key:
Key ID: CF6FA646
Fingerprint: 9969 43E1 CF6F A646.
See http://www.ocf.berkeley.edu/~rwl/encryption.html for more information.)



Re: [O] [patch] Support CUSTOM_ID property in latex export

2014-02-16 Thread Richard Lawrence
Hi Nicolas,

Nicolas Goaziou n.goaz...@gmail.com writes:

 Richard Lawrence richard.lawre...@berkeley.edu writes:

 1) Sometimes I need to refer to a section from within an embedded LaTeX
 block.  In that case, I need to know the appropriate label to use at the
 LaTeX level, not just in Org.  For example:

 * A headline
   :PROPERTIES:
   :CUSTOM_ID: sec:a-headline
   :END:

 # ... stuff ...

 #+BEGIN_LATEX
 % ... more stuff ...
 (see section~\ref{sec:a-headline})
 #+END_LATEX

 I don't think this is a good idea, as the character set allowed in
 \label{...} macros is only a subset of the character set allowed in
 custom id value. Hence the `org-export-solidify-link-text' function.

 If you are cautious, this will not be a problem, but it could bite users
 with little LaTeX knowledge.

Well, I don't quite see the force of this.  After all, isn't there a
general rule to the effect that if you override Org's default behavior,
you're on your own, so be careful?  Users are expected to make sure
that CUSTOM_ID is unique, for example.

It seems to me that if you explicitly specify CUSTOM_ID with the intent
of overriding Org's default labeling, you ought to have some idea what
can go in a \label, and be prepared to debug your LaTeX compilation if
there's an error.  If you're not prepared to do that, you should limit
yourself to the default behavior.  But if you *are* prepared to do that,
why should Org prevent you? 

 This is not possible with the present section labeling in LaTeX export,
 because I have no way of forcing Org to use a particular label for a
 section.

   * A headline
 #+latex: \label{my-section}

 #+BEGIN_LATEX
 % ... more stuff ...
 (see section~\ref{my-section})
 #+END_LATEX

 It also seems more consistent to me: since you want to explicitly write
 the \ref{...}, you are also expected to explicitly write the \label{...}
 part.

But then I would not be able to take advantage of referring to that
label from within plain Org text (i.e., outside an embedded LaTeX block)
using links.  The whole point of this is that I want to be able to refer
to a *single*, unambiguous label from within both contexts.

The strategy you suggest would result in multiple labels in the same
location in the exported document.  This is bad because it introduces
ambiguity and is thus fragile.  The exported document could have two sets
of \refs which point to two different \labels.  Initially, LaTeX
would compile them to the same thing, but if one of the labels got moved
or deleted, one set of refs would break.  

 2) I hope this doesn't happen, but there may come a time when I need to
 move away from Org and just use straight LaTeX.  Having control over the
 labeling will make this transition much easier, because it means I won't
 have to worry about manually changing the labels in a long document from
 Org's default sec-... numbering to my own semantic labels.

 See above. You can even automate that with a hook (i.e., get the custom
 id value and add a corresponding label at the beginning of the
 headline).

I realize that I could automate this if necessary.  That in fact is why
I wrote the patch: I'm trying to do the work of automating it now,
rather than waiting until a moment when I realize in desperation that I
have to convert to LaTeX. :)

For the reasons I cited above, I wouldn't want to use multiple labels,
which is why I prefer to implement my automation this way.  Is it
possible to use a hook to do what this patch does? i.e., to *replace*
Org's default labeling with labels generated from CUSTOM_ID, and have
links exported to \refs using that value instead of the default
labeling?

I sent the patch because I saw on the list that at least one other
person wanted a feature like this.  If it is not accepted, that's OK; I
will work around it, probably using a derived export backend.  But I
have to imagine that other people are doing something similar. I know
there are other people on this list using Org to write long documents
that they compile with LaTeX, and they are probably facing a similar
problem.

 3) This will make the LaTeX exporter's behavior more consistent with the
 HTML exporter's behavior.  The HTML exporter will use CUSTOM_ID if it is
 supplied to construct the id attributes of headlines and divs.  If
 someone is relying on this behavior of the HTML exporter, they might be
 unpleasantly surprised by the LaTeX exporter's behavior.

 One relying on an implementation detail instead of the actual
 specifications has to be prepared for surprises.

Maybe so, but that's actually sort of my point.  At the moment, my
options are:
  1) Use multiple labeling schemes, one accessible to Org, one
 accessible to LaTeX, and use the former in Org text and the latter
 in embedded LaTeX
  2) Avoid using Org's labeling/linking entirely, and just explicitly specify
 all my \labels and \refs
  3) Rely on my understanding of how Org will produce section labels
 when I \ref sections inside

[O] [patch] Support CUSTOM_ID property in latex export

2014-02-15 Thread Richard Lawrence
From 81115d0884c165778520aa1b4d4fa83580417e1c Mon Sep 17 00:00:00 2001
From: Richard Lawrence richard.lawre...@berkeley.edu
Date: Sat, 15 Feb 2014 11:59:44 -0800
Subject: [PATCH] LaTeX export: support CUSTOM_ID property in section labels
 and link refs

* lisp/ox-latex.el (org-latex-headline): when exporting a headline, if
  it has a CUSTOM_ID property, use that value as the associated
  label for a section (or whatever)
(org-latex-link): when exporting a link, if the
  destination is a headline with a CUSTOM_ID property, use that value
  in the referencing command

Fixes an issue raised at: http://thread.gmane.org/gmane.emacs.orgmode/54039

TINYCHANGE
---
 lisp/ox-latex.el |   25 -
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 5815874..cbca0a5 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -1372,11 +1372,14 @@ holding contextual information.
 	   (full-text (funcall org-latex-format-headline-function
 			   todo todo-type priority text tags))
 	   ;; Associate \label to the headline for internal links.
+	   ;; Use the value of :CUSTOM_ID: property as label if it is defined.
 	   (headline-label
-	(format \\label{sec-%s}\n
-		(mapconcat 'number-to-string
-			   (org-export-get-headline-number headline info)
-			   -)))
+	(let ((custom-label (org-element-property :CUSTOM_ID headline)))
+	  (if custom-label (format \\label{%s}\n custom-label)
+		(format \\label{sec-%s}\n
+			(mapconcat 'number-to-string
+   (org-export-get-headline-number headline info)
+   -)
 	   (pre-blanks
 	(make-string (org-element-property :pre-blank headline) 10)))
   (if (or (not section-fmt) (org-export-low-level-p headline info))
@@ -1846,11 +1849,15 @@ INFO is a plist holding contextual information.  See
 	  ;; title.
 	  (headline
 	   (let ((label
-		  (format sec-%s
-			  (mapconcat
-			   'number-to-string
-			   (org-export-get-headline-number destination info)
-			   -
+		  (or
+		   ;; Case 1: headline has a CUSTOM_ID property; use that as label
+		   (org-element-property :CUSTOM_ID destination)
+		   ;; Case 2: headline has no CUSTOM_ID; use default numbering 
+		   (format sec-%s
+			   (mapconcat
+			'number-to-string
+			(org-export-get-headline-number destination info)
+			-)
 	 (if (and (plist-get info :section-numbers) (not desc))
 		 (format \\ref{%s} label)
 	   (format \\hyperref[%s]{%s} label
-- 
1.7.10.4


Hi Orgsters,

Here is a patch to add support for using CUSTOM_ID properties for labels
and refs in the LaTeX exporter.

The patch uses the value of CUSTOM_ID when exporting a headline for the
associated \label, and when exporting a link for the associated \ref
command (or whatever).

For example, from this Org file:

===
* Headline 1
  :PROPERTIES:
  :CUSTOM_ID: sec:headline1
  :END:
  Links to headlines which have no CUSTOM_ID still work normally, like
  this one: [[Headline 2]].

* Headline 2
  Links to headlines which have a CUSTOM_ID property will use this
  value to refer to them:

  This link refers to Headline 1 using the builtin syntax for
  CUSTOM_ID: [[#sec:headline1]].

  This one uses the fuzzy search on the headline text: [[Headline 1]].
===

the relevant section is now exported as:

===
\section{Headline 1}
\label{sec:headline1}
Links to headlines which have no CUSTOM\(_{\text{ID}}\) still work normally, 
like
this one: \ref{sec-2}.
\section{Headline 2}
\label{sec-2}
Links to headlines which have a CUSTOM\(_{\text{ID}}\) property will use this
value to refer to them:

This link refers to Headline 1 using the builtin syntax for
CUSTOM\(_{\text{ID}}\): \ref{sec:headline1}.

This one uses the fuzzy search on the headline text: \ref{sec:headline1}.
===

Previously, the label for Headline 1 would have been \label{sec-1}, and
the links under Headline 2 would have been exported as \ref{sec-1}. 

This addresses an issue that was raised here, but got no response:
http://thread.gmane.org/gmane.emacs.orgmode/54039

I also need this behavior, which is why I wrote this.

Hope that's helpful!

Best,
Richard



Re: [O] [patch] Support CUSTOM_ID property in latex export

2014-02-15 Thread Richard Lawrence
Nicolas Goaziou n.goaz...@gmail.com writes:

 Richard Lawrence richard.lawre...@berkeley.edu writes:

 Here is a patch to add support for using CUSTOM_ID properties for labels
 and refs in the LaTeX exporter.

 Thank you for the patch. Though, I don't understand why it is needed.

 I also need this behavior, which is why I wrote this.

 Would you mind explaining your use case?

 From a user's perspective, CUSTOM_ID allows an user to refer to
 a particular headline with a specific internal link type. How this is
 done internally is something different, which belong to the
 implementation level.

Sure.  I apologize -- I should have said more about this in my previous
email than just referring to that old post.

I am presently using Org to write my dissertation, which I compile using
the LaTeX exporter.  This means I am writing long documents with
embedded LaTeX blocks.  (Maybe this is ill-advised, but it has worked
great so far!)

Basically, I want control over how the labeling is done in the exported
document for two reasons:

1) Sometimes I need to refer to a section from within an embedded LaTeX
block.  In that case, I need to know the appropriate label to use at the
LaTeX level, not just in Org.  For example:

* A headline
  :PROPERTIES:
  :CUSTOM_ID: sec:a-headline
  :END:

# ... stuff ...

#+BEGIN_LATEX
% ... more stuff ...
(see section~\ref{sec:a-headline})
#+END_LATEX

This is not possible with the present section labeling in LaTeX export,
because I have no way of forcing Org to use a particular label for a
section.

2) I hope this doesn't happen, but there may come a time when I need to
move away from Org and just use straight LaTeX.  Having control over the
labeling will make this transition much easier, because it means I won't
have to worry about manually changing the labels in a long document from
Org's default sec-... numbering to my own semantic labels.

Right now, I am at a risk of losing a lot of information if I have to
make this transition, because my CUSTOM_ID values don't have any effect
on the generated LaTeX.  Being able to set section labels as needed from
within Org would reduce this risk and therefore allow me to put this
transition off longer.

Another reason (not mine, but someone else might care) is:

3) This will make the LaTeX exporter's behavior more consistent with the
HTML exporter's behavior.  The HTML exporter will use CUSTOM_ID if it is
supplied to construct the id attributes of headlines and divs.  If
someone is relying on this behavior of the HTML exporter, they might be
unpleasantly surprised by the LaTeX exporter's behavior.

Does all that seem reasonable?
  
Best,
Richard



Re: [O] managing articles in my personal library, and their citational material, using org mode instead of bibtex

2013-11-22 Thread Richard Lawrence
Hi Eric,

On Thu, Nov 21, 2013 at 03:00:00PM -0700, Eric Schulte wrote:
 Very cool,
 
 I think some of these functions could be merged into
 contrib/lisp/org-bibtex-extras.el to very good effect.

Sure!  I'd be happy to help out with this.  I see you are the author
of org-bibtex-extras; feel free to grab/borrow/adapt any code from my
post, or let me know if there are changes I could work on and send
you.

Best,
Richard


(If possible, please encrypt your reply to me using my PGP key:
Key ID: CF6FA646
Fingerprint: 9969 43E1 CF6F A646.
See http://www.ocf.berkeley.edu/~rwl/encryption.html for more information.)



Re: [O] managing articles in my personal library, and their citational material, using org mode instead of bibtex

2013-11-20 Thread Richard Lawrence
Eric Schulte schulte.e...@gmail.com writes:

 Ian Barton li...@wilkesley.net writes:

 On 19/11/13 01:40, Christopher W. Ryan wrote:
 Not sure citational is even a word, but hopefully it conveys my meaning!

 I've been using LaTeX for academic writing and reading for quite some
 time, with emacs as my editor. I'm pretty familiar with managing a .bib
 file containing all the references I've collected, and using it in LaTeX
 \cite commands.

 I've come to org-mode more recently. I'm trying to imagine how I might
 use it to manage my personal library. I have a directory full of pdf
 files, each a downloaded article. Some articles I reference in papers I
 write; others I just read and want to keep.  I also have a .bib file
 where I put the citational material for all those articles. Whenever I
 download an article, I add its entry to my .bib file. I tend to manage
 this with JabRef because it searches Medline so easily, but I also will
 edit the .bib file directly when necessary.

 I like the idea of an org file containing the citational information
 (authors, title, journal, etc)  *plus* links to the pdfs on my hard
 drive, or on the internet. I could also include my notes about the
 articles. But what would that org file look like? How do I insert a
 reference to an article into the org file which contains the article I
 am writing?

 I'd be grateful for any explanations, or links to tutorials.


I am also a grad student, and I use a setup which is similar to Eric's,
but rather than importing from bibtex, I use Org's capture features to
directly input the bibliographic data when I come across something I
want to add to my reading list.  I don't maintain a separate .bib file
at all; rather I generate it as needed from the Org file containing my
reading list.

This setup allows me to think of readings as TODO items included in my
agenda, take notes and make links in the entry, and also keep
bibliographic data in Org (which I export via org-bibtex).

Here's what my setup looks like:

1)  A capture template for new readings.  My template looks like this:

** %^{Todo state|FIND|PRINT|READ|NOTES} [#%^{Priority|A|B|C}] 
%^{Description|Reading} %^g
   %^{TITLE}p %^{AUTHOR}p %^{AREA}p %?
   :PROPERTIES:
   :Entered: %U
   :END:

This template does not have a field for adding links to PDFs, but you
could easily add that.

2) A hook to add bibliographic data to reading entries when finalizing a
capture.  I put this in my Org setup:

;; post-processing in capture templates
(defun add-bibliographic-data ()
  ; this is a bit hacky: we detect the AUTHOR property, and create bibtex 
entries if
  ; it is present
  (message optionally adding bibliographic data)
  (if (and (org-entry-get (point) AUTHOR)
   (y-or-n-p Add bibliographic data? ))
  ; with prefix arg to get all fields:
  (org-bibtex-create-in-current-entry 1)
nil))

(add-hook 'org-capture-before-finalize-hook (lambda () 
(add-bibliographic-data)))

There may be a better way to do this, but it works for me!

3) Elisp functions to export my entire reading list to .bib (these
assume that your readings are not in a separate file, but under a top-level
entry called Reading list in some other file):

;; lib/el/bib-export.el in my dissertation tree:
(setq dissertation-bib-file 
~/Documents/philosophy/dissertation/build/dissertation.bib)

(defun add-headline-to-bib-buffer (bib-buffer)
  Export headline at point to Bibtex into the given buffer
  (let ((bib-entry (org-bibtex-headline))
(custom-id (org-entry-get (point) CUSTOM_ID)))
(if (and custom-id bib-entry)
(with-current-buffer bib-buffer
  (insert bib-entry)

(defun export-subtree-to-bib-buffer (headline bib-buffer)
  Export the entries in the subtree at point to Bibtex into the given buffer.
  (save-excursion
  (goto-char (org-find-exact-headline-in-buffer headline))
  (org-map-entries
   (lambda () (add-headline-to-bib-buffer bib-buffer))
   t ; match: all entries below this one
   'tree ; scope: just this subtree
   )))

(defun reading-list-to-bibtex ()
  Export 'Reading list' headline in current buffer to dissertation.bib
  (interactive)
  (let ((org-buffer (current-buffer))
(bib-buffer (create-file-buffer dissertation.bib)))
(export-subtree-to-bib-buffer Reading list bib-buffer)
(with-current-buffer bib-buffer
  (write-file dissertation-bib-file
   
4) A Makefile entry to call the export functions:

BATCH_EMACS=$(EMACS) --batch -Q 

bib: tasks.org lib/el/bib-export.el
$(BATCH_EMACS) --load lib/el/bib-export.el --file tasks.org --funcall 
reading-list-to-bibtex


Thus, I can run make bib in my dissertation tree and get a fresh
export of all my readings to a .bib file.

Hope that helps!

Best,
Richard




Re: [O] heading numbering in LaTeX export?

2013-09-07 Thread Richard Lawrence
Hi Peter,

Peter Salazar cycleofs...@gmail.com writes:

 I have a LaTeX template I created for use with org-mode, to export to PDF
 via LaTeX using xelatex.

 I don't edit LaTeX directly, I just generate from org-mode. This works
 perfectly for me except for one thing: it only works when I have heading
 numbering turned on.

 When I turn numbering off in org-mode, by adding this line to my org-mode
 file...

 #+OPTIONS:   num:nil

 ...LaTeX no longer recognizes my headings as headings. This creates two
 problems:

 1. The Table of Contents is blank.

This is because, when you set num:nil, Org exports headings to LaTeX
using the \section*{} command, not the usual \section{}.  LaTeX does not
put sections defined with \section* (or \chapter*, \part*, etc.) in the
table of contents. 

Thus, if you still want all sections to show up in your table of
contents, you probably don't want to set num:nil.  If you just want
section numbers not to show up in section titles, there's probably a
simple way to do this in LaTeX by redefining a command, but I can't find
it right now; maybe someone else here knows.  Once you know the LaTeX
command, you can set it on Org via

#+LATEX_HEADER: \renewcommand{...}

or whatever.

See also: 
https://en.wikibooks.org/wiki/LaTeX/Document_Structure#Sectioning_commands

 2. The \leftmark in the heading shows up as Contents instead of showing
 up as the title of the section.

I'm not sure about this issue.  I would guess that it's also caused
by using \section* rather than \section, but there's no \leftmark
command in the test document I created. 

-- 
Best,
Richard





Re: [O] Simplifying the weekly agenda a tiny bit, howto?

2013-07-18 Thread Richard Lawrence
François Pinard pin...@iro.umontreal.ca writes:

 Eric Abrahamsen e...@ericabrahamsen.net writes:

 First of all, if your event is a meeting, it should only be
 timestamped, not deadlined or scheduled.  Then it will just show up
 where it's supposed to, and not before (or after).

 How do I get it quickly rescheduled then, when it is a regular activity?
 I find fairly convenient using t d to push an activity at its next
 slot in the future.  Could I do something equivalent with mere time
 stamps?

If it's a regular activity, you can use a repeater in the timestamp, like:

* Weekly meeting
  2013-07-18 Thu 15:00 +1w

or if you need something more complicated, you can use the diary sexp
functions, like:

* 22:00-23:00 The nerd meeting on every 2nd Thursday of the month
  %%(diary-float t 4 2)

* Class every Tuesday and Thursday in the Spring 2013 semester 12:30PM-2PM
  %%(org-class 2013 1 22 2013 5 10 2)
  %%(org-class 2013 1 22 2013 5 10 4)

For non-regular meetings, I have a capture template that allows me to
easily enter them; maybe this is a good option for you if you regularly
need to schedule meetings, but at times that you can't predict before
you actually enter them.

 It probably shouldn't even be a TODO.  Otherwise, scheduled TODOs show
 up on their schedule, and deadlined TODOs show up on their deadline,
 and also today's agenda, if you're coming up on the deadline.

 There are many Org commands able to find, display and otherwise handle
 TODOs.  If I stop using such keywords, wouldn't I give up the tools?

Maybe.  Which tools do you use for TODOs that you also apply to
meetings?

Apart from the schedule-based agenda view, if you find it convenient to
e.g. create a list of all your upcoming meetings, you can do things like
tag all your meetings with a :meeting: or :appointment: tag, and then
use tag searches and/or custom agenda views to identify them, sort them
by timestamp, etc.

Hope that's helpful!

Best,
Richar




Re: [O] One more question on bibliographies in Org

2013-06-22 Thread Richard Lawrence
Vincent Beffara vbeff...@ens-lyon.fr writes:


 The main question is: what would be a convenient way to store the
 references in the .org file, to allow for easy editing and exporting ?

Have you looked at org-bibtex?  It stores bibliographic data as
properties.

I keep a separate Org headline for each reading I do, under which I
write notes, etc.  I use org-bibtex to store the bibliographic data for
each of these entries, and a custom elisp function (which basically just
maps org-bibtex-headline over these entries) to generate a .bib file on
demand.

I imagine it would be easy enough to modify org-bibtex to also provide
an export bibliographic data to some HTML-friendly format.

-- 
Best,
Richard






Re: [O] One more question on bibliographies in Org

2013-06-22 Thread Richard Lawrence
Richard Lawrence richard.lawre...@berkeley.edu writes:

 I imagine it would be easy enough to modify org-bibtex to also provide
 an export bibliographic data to some HTML-friendly format.

Actually, it looks like the (relatively new) contrib/lisp/ox-bibtex.el
does basically this, by running a .bib file through bibtex2html.

Best,
Richard




Re: [O] Avoid escaping braces in LaTeX export?

2013-06-08 Thread Richard Lawrence
Eric S Fraga e.fr...@ucl.ac.uk writes:

 Richard Lawrence richard.lawre...@berkeley.edu writes:
 Org is not latex, for better or for worse.  However, it does allow you
 to mix the two in various ways.  The inline approach is limited to
 {text} that is on the same line.  You could try using visual-line-mode
 and have all paragraphs be single lines.

 Alternative, you could try (untested):

 blah blah blah
 #+LATEX: \ic{
 some text for the inline comment
 #+LATEX: }
 more blah

Thanks, Eric; that works, too.

I think for now the best thing is for me to put longer comments in a
custom environment.  Then I can use Org's block syntax, and have other
export backends do the right thing, if I ever use them instead of LaTeX.

I did dig into the exporter code a bit, so in case anyone is bitten by a
similar issue that doesn't have a ready workaround, the places to look
seem to be:
  - org-element.el:org-element-latex-or-entity-successor.  This is where
LaTeX fragments are identified.  (As Eric notes, multi-line commands
will not have their arguments parsed as part of a latex-fragment;
instead, the argument and surrounding braces are parsed as text in
the surrounding paragraph.) 
  - ox-latex.el:org-latex-plain-text.  This is where special characters
that don't get parsed as part of a LaTeX fragment are
protected/escaped.

I still think it might be nice if each of the protections in
org-latex-plain-text could be toggled via an #+OPTIONS keyword, since
more often than not, I find that characters are escaped in LaTeX export
when I would prefer they weren't.  But that might be a peculiar fact
about how I use Org.  Since for now I don't require this behavior, I'm
not going to try to implement it myself, but if anyone else would also
find it useful, let me know and I will take a stab at writing a patch.

Thanks, all, for the help!

-- 
Best,
Richard




[O] Avoid escaping braces in LaTeX export?

2013-06-07 Thread Richard Lawrence
Hi all,

I'm wondering if there is a way to prevent the LaTeX exporter from
escaping { and } characters.  There are export options to control
the behavior of a number of other special characters, but I don't see
any way to control export of braces in the documentation.  Am I just
missing it?  If not, I'd like to request this as a feature.

Here's my use case.  I often create new commands in LaTeX to abstract
over some common pattern so I can easily type it and change it later if
necessary.  For example, when taking notes on readings, I have a command
that makes its argument into an `inline comment' (basically an aside to
myself) defined as follows:

#+LATEX_HEADER: \newcommand{\ic}[1]{{\footnotesize [~#1~]}}

Then in my notes I have things like:

 Marcus' point is more subtle, though, than that the substitutional
 reading validates these inferences or theorems while the objectual
 reading does not.  \ic{This would not persuade Quine, for example: the
 failure of existential generalization in modal contexts is for Quine a
 reason to reject quantified modal logic, rather than give the
 existential quantifier a different reading.}  

The new exporter exports this as:

 Marcus' point is more subtle, though, than that the substitutional
 reading validates these inferences or theorems while the objectual
 reading does not.  \ic\{This would not persuade Quine, for example: the
 failure of existential generalization in modal contexts is for Quine a
 reason to reject quantified modal logic, rather than give the
 existential quantifier a different reading.\} 

with the braces wrapping the argument for my custom command escaped.
This breaks the custom command in the export.

I can't test it at the moment, but I believe the old exporter did not
escape these braces, as I used this command regularly and it compiled
correctly.

I would like to be able to get the old behavior back.  I don't mind
manually escaping braces when necessary, because I almost always do not
want them escaped.  I understand if this is not a reasonable default,
but it would be nice for me if it were something I could set on an
#+OPTIONS line.  If others are interested in this, I can look into
creating a patch.

(By the way, it looks like there was a patch for a similar issue in
commit c6fd49726f2eaf417361b190b37e2d8ffb5864fc, but that is from April
2009 and therefore would apply to the old exporter.)

Thanks for your insights!

-- 
Best,
Richard




Re: [O] Avoid escaping braces in LaTeX export?

2013-06-07 Thread Richard Lawrence
Marcin Borkowski mb...@wmi.amu.edu.pl writes:

 Dnia 2013-06-07, o godz. 10:26:31
 Richard Lawrence richard.lawre...@berkeley.edu napisał(a):

 Here's my use case.  I often create new commands in LaTeX to abstract
 over some common pattern so I can easily type it and change it later
 if necessary.  For example, when taking notes on readings, I have a
 command that makes its argument into an `inline comment' (basically
 an aside to myself) defined as follows:
 
 #+LATEX_HEADER: \newcommand{\ic}[1]{{\footnotesize [~#1~]}}
 

 Quick and dirty workaround (untested):

 #+LATEX_HEADER: \def\ic!#1!{{\footnotesize [~#1~]}}

 Of course, you may do \def\ic(#1){...}, \def\ic~#1~{...} etc.  The
 delimiter characters may not appear in the argument, though (nesting
 is not supported!).

 This is very un-LaTeX-y (it is much lower-level TeX syntax), but it is
 occasionaly useful (and heavily used by LaTeX itself, btw - this is
 used among others for delimiting optional arguments).

Hmm, that does work for this case, thanks!  

Still, this won't work directly for cases where I have loaded a LaTeX
package that provides a command which uses curly braces.  (I could
redefine such commands, as above, but that could get real ugly, real
fast...).  It seems like this a general problem that the exporter should
have a way to handle.

-- 
Best,
Richard




Re: [O] A simple way to search only headlines

2013-06-07 Thread Richard Lawrence
Xebar Saram zelt...@gmail.com writes:

 Thank you both Thorsten and Seb, i really appreciate the help!

 Seb, you wrote: The programming equivalent to C-c a s is:

 (org-agenda nil s)

 That's what you'd have to bind to a key (using a lambda function).

 im a complete neewb and dont really have any idea on how to do the above,
 can you show me an example?

I think you're looking for something like:

(define-key org-mode-map (kbd C-M-h) (lambda () (org-agenda nil s )))

You could put a line like that in your .emacs.  Here's what it does:
#+BEGIN_SRC emacs-lisp
(define-key;; insert a new keybinding
  org-mode-map ;; into the Org mode map (so this won't affect bindings in 
non-Org buffers)

  ;; This is the key we're binding: C-M-h, for headline search
  ;; You can use whatever key you like, but you might want to check first that 
it isn't
  ;; already bound to something else (e.g., via C-h k from an Org buffer).
  ;; The kbd macro converts a string representation to the appropriate key code.
  (kbd C-M-h)
  
  ;; This is the function to run when the key is pressed.  The lambda
  ;; form creates an anonymous function which calls org-agenda with
  ;; the s argument and a restriction to current buffer.
  (lambda () (org-agenda nil s )))
#+END_SRC

Best,
Richard




Re: [O] A simple way to search only headlines

2013-06-07 Thread Richard Lawrence
Xebar Saram zelt...@gmail.com writes:

 Hi Richard

 Fantastic, thx alot for the code snippet and detailed explanation, it
 really helps to understand what goes on. unfortunately i get an error:

 Wrong type argument: commandp, (lambda nil (org-agenda nil s ))

Ah, sorry about that, should have tested my code before I sent it!

The problem is that you have to give a /command/ to define-key (i.e., a
function with a call to `interactive' in its definition).

This should do it:

(define-key org-mode-map (kbd C-M-h) (lambda () (interactive) (org-agenda nil 
s )))

Best,
Richard




Re: [O] [OT] Gnus mail tutorial?

2013-05-25 Thread Richard Lawrence
Jacek Generowicz jacek.generow...@cern.ch writes:

 Marcin Borkowski writes:

 I'm thinking about using Emacs as my email client, and I'm considering
 using Gnus for that.

 If it is Emacs rather than Gnus itself that attracts you, then you might
 consider notmuch or mu4e. Both have a Xapian-based core, and include an
 Emacs interface.

+1.

I used Gnus with an IMAP account for a while, but found that (in
addition to being intimidating and complicated) it was annoyingly slow.
I did write a brief tutorial about getting it set up, which you may or
may not find useful; it's at [1].  

I still use Gnus to read news (e.g., this list, via Gmane), which is
much simpler to set up, and pretty handy.

After abandoning Gnus for mail, but wishing to remain in Emacs, I tried
nmh with MH-E as a front end.  I liked MH-E well enough, but the big
problem was that I couldn't find any program to sync mail in both
directions from MH directories, and I want a local copy of my mail on
multiple machines which reflects the state on the IMAP server.

So, long story short, I have now switched to using offlineimap to sync
over IMAP with a Maildir.  This keeps my mail locally available but also
in sync across multiple machines.  I read this Maildir in mutt, not
Gnus, because I read nasty things on the Internet about how Gnus'
Maildir implementation really stinks (e.g., it uses its own tagging
system instead of the standard Maildir flags, and it eats up inodes on
your filesystem like crazy).  I use notmuch to index it, and
notmuch-mode in Emacs to search it.  I have my mutt editor set to
emacsclient.

It ain't perfect, by any means (and if anyone has suggestions on a
better setup, I'd love to hear them), but it works for me. 

[1] 
http://whereofwecannotspeak.wordpress.com/2009/07/15/getting-gnus-to-read-mail-over-imap/

-- 
Best,
Richard




Re: [O] Collaborating with TODO lists and clocks.

2013-04-29 Thread Richard Lawrence
Hi Gareth,

Gareth Smith g...@doc.ic.ac.uk writes:

 I hadn't thought of using :tags on a clock table. I still worry if we'll
 find ourselves in a situation where more than one of us has clocked in
 some time on the same task.

Yes, I agree this might not be optimal, for that case in particular.
One nice thing about this use of tags is that you have a representation
of when more than one person is working on a task, but that makes the
clock less useful, as it can no longer represent an individual's working
time without some effort to separate the clocks of the different owners.

 For example, often I clock into a task while I do the work of
 sub-dividing it into smaller tasks. And often when I'm actively working
 on a task, I'll create a sub-task of my current-clocked-task on the
 fly. It seems to me that if I continue with this sort of working
 practice, and attempt to collaborate with others who work similarly,
 then we might quickly find that it's not easy to describe a given task
 (or even subtask) as being owned by a single person.

So one problem case is where you own a task, but someone else owns one
of its subtasks, e.g.:

==
* Clock tables
#+BEGIN: clocktable :maxlevel 2 :scope file :tags +gareth
#+CAPTION: Clock summary at [2013-04-29 Mon 18:25]
| Headline   | Time   |  |
|++--|
| *Total time*   | *3:05* |  |
|++--|
| TODO Task 1| 3:05   |  |
| \__ TODO Subtask 1 || 1:05 |
| \__ TODO Subtask 2 || 1:00 |
#+END:
#+BEGIN: clocktable :maxlevel 2 :scope file :tags +john
#+CAPTION: Clock summary at [2013-04-29 Mon 18:17]
| Headline   | Time   |  |
|++--|
| *Total time*   | *1:05* |  |
|++--|
| TODO Task 1| 1:05   |  |
| \__ TODO Subtask 1 || 1:05 |
#+END:

* TODO Task 1:gareth:
  CLOCK: [2013-04-29 Mon 18:15]--[2013-04-29 Mon 19:15] =  1:00
** TODO Subtask 1  :john:
   CLOCK: [2013-04-29 Mon 18:15]--[2013-04-29 Mon 19:20] =  1:05
** TODO Subtask 2:gareth:
   CLOCK: [2013-04-29 Mon 16:16]--[2013-04-29 Mon 17:16] =  1:00
==

Notice that Gareth gets credit for John's time on Subtask 1, because
Gareth owns Task 1.

You can avoid this particular gotcha in (at least) two ways:

1) Remove the :gareth: tag on task 1 and move the clock time to subtask
2 (more generally, ownership tags and clock times should only appear
at the lowest level of the task tree).  Maybe this makes the most sense,
but it slows down the worflow a bit and is hard to enforce, etc.

2) Use a tag filter like +gareth-john to build the clock table (more
generally, the clock table for each person should exclude tags for all
the others).  This prevents double counting and is easy to enforce, but
if any tasks have more than one owner, no one will get credit for their
clock times.

 Again, perhaps my workflow is at fault, and I should be organising
 myself in a more principled way. And perhaps in practice I'll find that
 tasks do tend to be owned by just one person anyway. 

Yeah, it's a hard problem with no general solution that I can see.  The
best thing is just to figure out what constraints you're willing to put
on your workflow, given what Org allows you to do.

Hope that's helpful!

Best,
Richard





Re: [O] Collaborating with TODO lists and clocks.

2013-04-28 Thread Richard Lawrence
Hi Gareth,

Gareth Smith gar...@totherme.org writes:

 Does anyone use org to collaborate on task lists? It seems to me that it
 would be very natural to put a tasks.org file into a VCS repo, claim a
 task by changing its status from TODO to IN_PROGRESS (and committing
 that change), work, then mark as DONE at the end.

 That's all awesome - but what if you're also using org to clock your
 working time?
 ...
 Alternatively, am I wrong about what I think I want? Is there a better
 workflow I should be thinking about adopting?

Is there a reason you don't want any clock data to end up in the shared
tasks.org?

If not, one thing you could do is:

1) When claiming a task, each person uses a tag for their name (in
addition to, or instead of, just changing the TODO state).  Then that
person owns the clock data for that task.

2) Then use the :tags option on a clock table to filter the clock data
for just the tasks you personally have worked on; each person can have
their own table (in tasks.org).

For example, suppose you have a task like:

* TODO Frobnicate something

You claim it by changing that to:

* IN_PROGRESS Frobnicate something  :gareth:

Check that in, then start your clock in this tree.

Somewhere else in the file, you have a clock table like:

#+BEGIN: clocktable :maxlevel 3 :scope file :tags +gareth
#+CAPTION: Gareth's working time on all tasks
# ...
#+END:

which will show you the clock data for just the tasks you've worked on
(i.e., are tagged in).

-- 
Best,
Richard




Re: [O] How to analyze clocking reports (e. g. with spreadsheet application)?

2013-04-27 Thread Richard Lawrence
Hi Martin,

Martin elwood...@web.de writes:

 I'm using the org-mode clocking features (in org-mode 7.9.4) extensively 
 to document how much time I spent with which task and when.

 I wonder how I can export the data (e. g. to MS Excel) for further analysis;
 * time consumed by different projects
 * interruptions and jumping from task to task
 * time consumed by tasks with a special tag
 etc.

Have you looked at this section in the manual?  I don't use many of
these features myself, but I think Org itself can tell you many of these
things without exporting the data to a separate tool:

http://orgmode.org/org.html#The-clock-table

-- 
Best,
Richard




Re: [O] Bug: Footnotes break iCalendar export [8.0.1 (release_8.0.1 @ /home/rwl/src/org-mode/lisp/)]

2013-04-21 Thread Richard Lawrence
Hi Bastien,

Bastien b...@gnu.org writes:

 Richard Lawrence richard.lawre...@berkeley.edu writes:

 I've been trying to get iCalendar export working with my agenda files
 again since upgrading to 8.0, and I've found that footnotes break the
 agenda export to .ics.  The problem is that a plain text version of the
 footnotes in the file ends up in the output floating loose---not
 wrapped by VEVENT tags or any other tags---resulting in an unparseable
 .ics file (at least according to Google Calendar).

 I tried this patch but for some reason it does not work.

This patch does not work for me, either, but thanks for trying!

 I did not look further, surely Nicolas has something that
 works.  I agree footnotes should be turned off by default
 for the .ics export.

I also tried the following modifications in the definition of the
icalendar backend, without much effect:

1) Adding (footnote-definition . ignore) and
(footnote-reference . ignore) to the :translate-alist

2) Adding (:filter-footnote-definition . ignore) and
(:filter-footnote-reference . ignore) to the :filters-alist

Both of these looked like they might work based on the
org-export-define-backend documentation, but the footnotes still show up
in the output.

[...further tinkering...]

It looks like the problem is this: the icalendar backend does not
specify a transcoder for the inner-template element.  Thus it falls
back to the org-ascii-inner-template transcoder, which appends footnotes
to the end of the exported content.

Thus, one solution is to define an org-icalendar-inner-template
transcoder which does nothing to modify the content (but overrides the
fallback); that is the solution I've used in the attached patch.

Best,
Richard

diff --git a/lisp/ox-icalendar.el b/lisp/ox-icalendar.el
index 49299b0..39ba383 100644
--- a/lisp/ox-icalendar.el
+++ b/lisp/ox-icalendar.el
@@ -261,6 +261,7 @@ re-read the iCalendar file.)
 		 (inlinetask . ignore)
 		 (planning . ignore)
 		 (section . ignore)
+		 (inner-template . org-icalendar-inner-template)
 		 (template . org-icalendar-template))
   :options-alist
   '((:exclude-tags
@@ -747,7 +748,18 @@ END:VALARM\n
 		 (if (zerop alarm-time) org-icalendar-alarm-time alarm-time)
 
 
- Template
+ Templates
+
+(defun org-icalendar-inner-template (contents info)
+  Return inner contents string after iCalendar conversion.
+CONTENTS is the transcoded contents string. INFO is a plist used
+as a communication channel.
+
+This function just returns CONTENTS unchanged.  Its purpose is to
+override the inner-template transcoder of the ascii
+backend (`org-ascii-inner-template'), which appends footnotes
+that break the iCalendar format.
+  contents)
 
 (defun org-icalendar-template (contents info)
   Return complete document string after iCalendar conversion.


[O] [PATCH] tiny fixes in ox-ascii.el [was: Re: Bug: Footnotes break iCalendar export]

2013-04-21 Thread Richard Lawrence

Here is a patch for a couple of tiny issues I encountered in ox-ascii.el
while debugging ox-icalendar.el.  Explanation:

1) There is no function called `org-ascii-footnote-definition' (though
it looks like maybe there once was?), so I changed a reference to it to
`ignore' to be more explicit.

I'm not sure if this is the right thing to do -- maybe the point was to
let the user define such a function if she wishes?  That however would
be inconsistent with the comment that such definitions are ignored (see
below).

2) A tiny change to the comment explaining why there is no such
function: footnote definitions are ignored because they are compiled by
`org-ascii-inner-template', not `org-ascii-template'.

Best,
Richard

diff --git a/lisp/ox-ascii.el b/lisp/ox-ascii.el
index 2191539..4543c34 100644
--- a/lisp/ox-ascii.el
+++ b/lisp/ox-ascii.el
@@ -68,7 +68,7 @@
 (export-block . org-ascii-export-block)
 (export-snippet . org-ascii-export-snippet)
 (fixed-width . org-ascii-fixed-width)
-(footnote-definition . org-ascii-footnote-definition)
+(footnote-definition . ignore)
 (footnote-reference . org-ascii-footnote-reference)
 (headline . org-ascii-headline)
 (horizontal-rule . org-ascii-horizontal-rule)
@@ -1147,7 +1147,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information.
  Footnote Definition
 
 ;; Footnote Definitions are ignored.  They are compiled at the end of
-;; the document, by `org-ascii-template'.
+;; the document, by `org-ascii-inner-template'.
 
 
  Footnote Reference


[O] Bug: Footnotes break iCalendar export [8.0.1 (release_8.0.1 @ /home/rwl/src/org-mode/lisp/)]

2013-04-20 Thread Richard Lawrence

Hi Org maintainers,

I've been trying to get iCalendar export working with my agenda files
again since upgrading to 8.0, and I've found that footnotes break the
agenda export to .ics.  The problem is that a plain text version of the
footnotes in the file ends up in the output floating loose---not
wrapped by VEVENT tags or any other tags---resulting in an unparseable
.ics file (at least according to Google Calendar).

Here's a sample Org file to illustrate:

* Entry 1
  This entry has some text with an inline footnote[fn:: which isn't
  very interesting]
* Entry 2
  This entry has some text with an external footnote[fn:1]
* Appointment with Someone
  2013-04-20 Sat 15:00
* Footnotes
[fn:1] which still isn't very interesting

And here's the output I get when I export this
(via C-c a  a C-x C-w /tmp/test.ics):

BEGIN:VCALENDAR
VERSION:2.0
X-WR-CALNAME:OrgMode
PRODID:-//Richard Lawrence//Emacs with Org mode//EN
X-WR-TIMEZONE:America/Los_Angeles
X-WR-CALDESC:
CALSCALE:GREGORIAN
BEGIN:VEVENT
DTSTAMP:20130420T211153Z
UID:TS1-5b8f14ac-d380-437f-88dd-4ed0a4ebacb9
DTSTART:20130420T15
DTEND:20130420T17
SUMMARY:Appointment with Someone
DESCRIPTION:2013-04-20 Sat 15:00
CATEGORIES:test
END:VEVENT



Footnotes
─

[1] which isn't very interesting

[2] which still isn't very interesting
END:VCALENDAR

Note that I still seem to get the behavior when I restrict the export to
headlines matching certain tags.  In that case, even footnotes from
entries which should not be exported end up in the output, which seems
pretty strange.

It doesn't make much sense to me to have footnotes when exporting to a
calendar format, so is there any way to suppress exporting footnotes in
this case?

Thanks!

Best,
Richard



Emacs  : GNU Emacs 23.2.1 (i486-pc-linux-gnu, GTK+ Version 2.20.1)
 of 2013-01-08 on murphy, modified by Debian
Package: Org-mode version 8.0.1 (release_8.0.1 @ /home/rwl/src/org-mode/lisp/)

current state:
==
(setq
 org-todo-keyword-faces '((WAITING . orange))
 org-speed-command-hook '(org-speed-command-default-hook 
org-babel-speed-command-hook)
 org-agenda-custom-commands '((r Reading list tags-todo +reading) (S . 
STUDY context searches) (Sf todo FIND) (Sp todo PRINT)
  (Sr todo READ) (Sn todo NOTES) (St 
tags-todo +STUDY) (P tags-todo +CAMPUS) (D tags-todo +COMPUTER)
  (H tags-todo +HOME) (E tags-todo 
ERRAND|BUY) (F tags +FREETIME) (X tags-todo +EXERCISE)
  (Z Export to iCalendar file tags 
event|appointment nil 
(~/Documents/website/public_html/lib/attachments/calendar.ics))
  )
 org-agenda-files '(~/Documents/philosophy/dissertation/tasks.org 
~/org/school.org ~/org/life.org ~/org/beer.org ~/org/food.org)
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-capture-templates '((s School)
 (st Todo entry (file+olp ~/org/school.org 
Tasks Spring 2013) (file ~/org/templates/todo.txt) :prepend t)
 (sy Todo (from active region or kill ring) entry 
(file+olp ~/org/school.org Tasks Spring 2013)
  (file ~/org/templates/todo-with-yank.txt) :prepend 
t)
 (sl Todo (with link) entry (file+olp 
~/org/school.org Tasks Spring 2013) (file 
~/org/templates/todo-with-link.txt)
  :prepend t)
 (se Event entry (file+headline ~/org/school.org 
Events) (file ~/org/templates/event.txt) :prepend t)
 (sr Reading entry (file+olp ~/org/school.org 
Reading list) (file ~/org/templates/reading.txt) :prepend t)
 (sa Appointment entry (file+olp ~/org/school.org 
Tasks Spring 2013) (file ~/org/templates/appointment.txt) :prepend t)
 (sb Bookmark entry (file+olp ~/org/school.org 
Bookmarks) (file ~/org/templates/bookmark-school.txt))
 (sc Class entry (file+olp ~/org/school.org 
Semester Schedule Spring 2013 Classes) (file ~/org/templates/class.txt))
 (ss Semester entry (file+olp ~/org/school.org 
Semester Schedule) (file ~/org/templates/semester.txt) :prepend t)
 (d Dissertation)
 (dt Todo entry (file+olp 
~/Documents/philosophy/dissertation/tasks.org Tasks) (file 
~/org/templates/todo.txt) :prepend t)
 (de Event entry (file+headline 
~/Documents/philosophy/dissertation/tasks.org Events) (file 
~/org/templates/event.txt)
  :prepend t)
 (dr Reading entry (file+olp 
~/Documents/philosophy/dissertation/tasks.org Reading list)
  (file ~/org/templates/reading.txt) :prepend t)
 (da Appointment entry (file+olp 
~/Documents/philosophy/dissertation/tasks.org Tasks)
  (file ~/org/templates/appointment.txt) :prepend t)
 (db Bookmark entry (file

[O] Bug: New keywords for org-agenda-sorting-strategy give wrong type argument error [8.0 (release_8.0-1-g5ef07d @ /home/rwl/src/org-mode/lisp/)]

2013-04-19 Thread Richard Lawrence

Dear Org team,

I think I have found a bug related to the new agenda sorting strategies.
When I set:

(setq org-agenda-sorting-strategy '(deadline-up))
; or deadline-down, or timestamp-up/down, or scheduled-up/down, etc.
; the same problem occurs using the '((agenda deadline-up) ...) form

it results in the following error:

org-entries-lessp: Wrong type argument: stringp, nil

and no entries are displayed in the agenda.

Some crude debugging on my part suggests that this error is triggered
when org-entries-lessp tries to compare the now line (i.e., the agenda
item generated from org-agenda-current-time-string) against another
item.

I think the problem is actually in org-cmp-ts: string-match doesn't like
getting nil as an argument.  So maybe the problem is that the now line
doesn't have the text properties corresponding to deadlines, timestamps,
etc., such that get-text-property is returning nil?

Hope that's helpful!  Please let me know if I can help with further
debugging.

Best,
Richard


Emacs  : GNU Emacs 23.2.1 (i486-pc-linux-gnu, GTK+ Version 2.20.1)
 of 2013-01-08 on murphy, modified by Debian
Package: Org-mode version 8.0 (release_8.0-1-g5ef07d @ 
/home/rwl/src/org-mode/lisp/)

current state:
==
(setq
 org-todo-keyword-faces '((WAITING . orange))
 org-speed-command-hook '(org-speed-command-default-hook 
org-babel-speed-command-hook)
 org-agenda-custom-commands '((r Reading list tags-todo +reading) (S . 
STUDY context searches) (Sf todo FIND) (Sp todo PRINT)
  (Sr todo READ) (Sn todo NOTES) (St 
tags-todo +STUDY) (P tags-todo +CAMPUS) (D tags-todo +COMPUTER)
  (H tags-todo +HOME) (E tags-todo 
ERRAND|BUY) (F tags +FREETIME) (X tags-todo +EXERCISE))
 org-agenda-files '(~/Documents/philosophy/dissertation/tasks.org 
~/org/school.org ~/org/life.org ~/org/beer.org ~/org/food.org)
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-after-todo-state-change-hook '(org-clock-out-if-current)
 org-footnote-auto-label 'confirm
 org-list-empty-line-terminates-plain-lists t
 org-agenda-sorting-strategy '(deadline-up)  ;; and others
 org-capture-before-finalize-hook '((lambda nil (add-bibliographic-data)))
 org-export-preprocess-hook '(ignoreheading-org-export-preprocess-hook)
 org-tab-first-hook '(org-hide-block-toggle-maybe 
org-src-native-tab-command-maybe org-babel-hide-result-toggle-maybe 
org-babel-header-arg-expand)
 org-src-mode-hook '(org-src-babel-configure-edit-buffer 
org-src-mode-configure-edit-buffer)
 org-confirm-shell-link-function 'yes-or-no-p
 org-todo-keywords '((sequence TODO INPROGRESS WAITING | DONE 
CANCELED) (sequence FIND PRINT READ NOTES | DONE CANCELED)
 (sequence PRIMARY SECONDARY | BOTTLED))
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-babel-pre-tangle-hook '(save-buffer)
 org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-drawers 
org-cycle-hide-inline-tasks org-cycle-show-empty-lines
  org-optimize-window-after-visibility-change)
 org-agenda-span 1
 org-mode-hook '(#[nil \300\301\302\303\304$\207 [org-add-hook 
change-major-mode-hook org-show-block-all append local] 5]
 #[nil \300\301\302\303\304$\207 [org-add-hook 
change-major-mode-hook org-babel-show-result-all append local] 5]
 org-babel-result-hide-spec org-babel-hide-all-hashes)
 org-refile-targets '((nil :maxlevel . 4))
 org-ctrl-c-ctrl-c-hook '(org-babel-hash-at-point 
org-babel-execute-safely-maybe)
 org-confirm-elisp-link-function 'yes-or-no-p
 org-refile-use-outline-path t
 org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
 org-occur-hook '(org-first-headline-recenter)
 org-from-is-user-regexp \\Richard Lawrence\\
 org-mobile-directory /media/nexus/mobileorg
 org-agenda-cmp-user-defined 'org-agenda-cmp-by-deadline
 org-modules '(org-habit org-w3m org-bbdb org-bibtex org-docview org-gnus 
org-info org-irc org-mhe org-rmail)
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 )



Re: [O] Bug: New keywords for org-agenda-sorting-strategy give wrong type argument error [8.0 (release_8.0-1-g5ef07d @ /home/rwl/src/org-mode/lisp/)]

2013-04-19 Thread Richard Lawrence
Indeed, the following patch seems to fix the issue for me, though I
don't know enough about the code to know if this is
clean/elegant/general enough:

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 631c6d0..c53c8c8 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -6989,9 +6989,9 @@ or \timestamp_ia\, compare within each of these type.
 When TYPE is the empty string, compare all timestamps
 without respect of their type.
   (let* ((def (if org-sort-agenda-notime-is-late 9901 -1))
-(ta (or (and (string-match type (get-text-property 1 'type a))
+(ta (or (and (string-match type (or (get-text-property 1 'type a) ))
  (get-text-property 1 'ts-date a)) def))
-(tb (or (and (string-match type (get-text-property 1 'type b))
+(tb (or (and (string-match type (or (get-text-property 1 'type b) ))
  (get-text-property 1 'ts-date b)) def)))
 (cond (( ta tb) -1)
  (( tb ta) +1

-- 
Best,
Richard




Re: [O] Can't Sort with New, 8.0 Sort Methods

2013-04-19 Thread Richard Lawrence
Hi Nick,

I filed a bug report for this issue here:
http://article.gmane.org/gmane.emacs.orgmode/70890

And mentioned a fix that works for me here:
http://article.gmane.org/gmane.emacs.orgmode/70893

You could try my fix in the meantime, and let the list know if it helps.

Best,
Richard




Re: [O] Using Org for a dissertation

2012-05-15 Thread Richard Lawrence
Tom and Nicolas,

Thanks!  I will give the new exporter a shot when I have a chance and
let you know how it goes.

Best,
Richard




Re: [O] Using Org for a dissertation

2012-05-15 Thread Richard Lawrence
Hi Suvayu,

suvayu ali fatkasuvayu+li...@gmail.com wrote:

 In case you are interested, I'm attaching some relevant bits. It has
 examples on how to put in tables (with short and long captions),
 figures, latex snippets and finally how I included a bibliography and
 appendices.
 
 Hope this will help.

Thanks!  This is definitely helpful.  The ignoreheading tag is a nice
hack -- fixes one of those niggling issues I've had with LaTeX export.

Best,
Richard



Re: [O] Using Org for a dissertation

2012-05-15 Thread Richard Lawrence
Hi Markus,

Thanks for your advice.  I figure that, like you, I may eventually need
to switch to LaTeX, but will stick with Org for now, at least until my
document structure is quite settled.

Can you elaborate a bit on the following?

Markus Grebenstein p...@mgrebenstein.de wrote:

 What I disliked/ preferred in auctex:
 - missing footnote folding in stable version

Stable version of Org, or Auctex?  What exactly is missing?

 - footnotes frequently lead to trouble with overlapping latex groups.

What is a Latex group? How they could overlap?  (I would especially like
to be aware of potential footnote problems ahead of time.)

 - reference handling in especial w.r.t headings (if you change the
 heading you use the reference)

Do you mean you prefer \label and \ref in Latex over Org's abstraction?

Thanks!

Best,
Richard







Re: [O] Using Org for a dissertation

2012-05-14 Thread Richard Lawrence
Hi Eric,

Eric Schulte eric.schu...@gmx.com wrote:

 I am currently writing my dissertation (proposal) in Org-mode.  So far
 it is working very well for me, I can export to both PDF for more formal
 submissions to my adviser and to HTML for less formal posting to a web
 page.  I keep *all* of my reading notes as Org-bibtex headlines in a
 single large reading.org file.  I have a (somewhat complex) system
 whereby I am able to reference these bibtex entries from the
 dissertation and automatically generate the required .bib file as part
 of my document export process.  One nice side effect of this setup has
 been the ability to do a fun graphical export of my references [1].
 
 My entire dissertation directory is in a public git repository [2], you
 may find my Makefile [3] useful (although again I should warn you that
 my particular setup may be needlessly complex).

Thanks for your helpful advice!  Your org-bibtex setup in particular
looks like exactly what I need.  (Your dissertation proposal looks very
interesting, too!)

I think what I will do is stick with Org for now, and try to be smarter
about a few things (like the #+LABEL command...which I must have read
about at some point but forgotten) so that, if I ever need to drop down
to straight LaTeX, it will be easy to make the switch.  You've given me
a helpful example to follow.

Best,
Richard




Re: [O] Using Org for a dissertation

2012-05-14 Thread Richard Lawrence
Thomas S. Dye t...@tsdye.com wrote:

 The current Org-mode LaTeX exporter is nifty, but it was designed to
 export notes and not dissertations.  It can be configured to do that,
 but the extra translation step adds some complexity and potentially
 introduces problems.  In my work this potential downside is more than
 made up for by the reproducible research facilities of Org-mode.  When I
 don't need these, I typically write in LaTeX.  The AucTeX environment is
 a terrific help to the author of a LaTeX document and in many ways it is
 ideal for a dissertation writer.

Thanks for your advice.  This has been my experience so far as well.

 That said, the new LaTeX exporter in Org-mode is being designed to
 overcome some of the limitations of the old exporter, so it will
 probably be the case that the translation step from Org-mode to LaTeX
 will get easier.  It would be good to have someone write a dissertation
 using the new exporter because it might stretch the exporter in ways
 that smaller, simpler documents do not.  But I doubt if this will be the
 path of least resistance to the finished dissertation.  

I have seen mention of the new exporter on this list a bit, but I don't
read the list enough to know where to find it.  How can I try it, if I
want to see how it compares to the current exporter?  Is it in a public
branch somewhere?  Would feedback from me be helpful?

 I'm using ebib to manage BibTeX data now and I really like it.  It works
 well with both LaTeX and Org-mode, so I don't have to switch gears
 completely to move from one authoring environment to the other.

Hmm, I hadn't heard of ebib, but I will have a look at it.  Thanks for
the tip!

Best,
Richard




[O] Using Org for a dissertation

2012-05-12 Thread Richard Lawrence
Hi all,

I am a graduate student in philosophy, and I am about to begin writing
my dissertation.  I am wondering about whether I should write it in Org,
or stick to plain LaTeX.

This question has been asked before:
http://article.gmane.org/gmane.emacs.orgmode/22756

But that was two years ago; Org has changed a fair bit, and I'm
wondering if there are any updates to the advice given there.  Moreover,
I'm wondering if anyone has written a dissertation or other long
documents in Org in the meantime, and what their experiences have been.
(Henri-Paul, do you still read this list?)

I have used Org to write most of the shorter papers I have so far
written as a graduate student, and been very happy with the results.  I
prefer most of Org's editing features and conventions to bare LaTeX.  I
haven't previously had much of a need to mix TODO items and writing, but
imagine I will with a dissertation.  I *have* been relying on Org's
to-do list features for my reading: I enter new readings as TODO items
via capture, and include the bibliographic fields that make them
suitable to export via org-bibtex when it comes time to reference them.
None of the writing I've done so far has had strict formatting
requirements, however, and I have run into enough small formatting
issues in the past that I want to avoid having them grow into large
issues in the context of a dissertation.

Since I am not in the sciences, I doubt that I will have many figures or
complex tables, which I know can lead to headaches.  Here are a few of
the things I *am* worried about.  I'm sure most of them can be dealt
with; I am guessing that most of these issues reflect my ignorance or
outdated knowledge of Org features.  I'd be grateful for pointers or
workarounds for them:

1) Section labels and other in-document references.  It's nice that Org
generates these on export, but I need to be able to assign and use
labels that will not change if the document is reordered.  I know I can
simply add such labels via a \label command, but I am worried that using
them in addition to Org's autogenerated labels might cause numbering
problems in LaTeX.

2) Escaping/unrecognized commands.  I have occassionally run into
annoyances where Org escapes characters or commands that I intend to be
exported literally (~ and $ are perennial offenders).  Export also
tends to break when fill-paragraph breaks a LaTeX command across a line,
like:

some preceding text up to the end of the line \cite{SomeAuthorReference,
AnotherReference}.

3) Indentation around #+BEGIN_*/#+END_* environments. (I most often use
QUOTE.)  I usually have to explicitly control indentation in a way that
I wouldn't have to in LaTeX, because Org inserts blank lines around them
during export.

4) Inline footnotes.  I usually prefer to use inline footnotes, but I
think I have found in the past that Org's syntax for inline footnotes
([fn:: ...]) interacts badly with LaTeX commands, especially anything
requiring a ] in the footnote text.

5) Bibtex and bibliographies.  I love keeping my reading list as Org
TODO entries, but would like a more automated way to export (just) the
entries I need for a particular document to a .bib file.  I would also
like to have more control over the bibliography as a section of my
document.  The \bibliography command must live under some Org heading or
other, and as far I as know it can't live under its own without
generating an extraneous heading, so I have to be careful that it ends
up at the end of the last section.

Are there other issues that people have run into when using Org to write
a longer document with strict formatting requirements?  Again, any and
all advice is greatly appreciated!

Thanks,
Richard




Re: [O] can I force all-caps in part of a headline in a capture template?

2012-05-06 Thread Richard Lawrence
Hi Chris,

Try this: in your .emacs, add the following code:

(defun prompt-for-lastname-and-upcase ()
  (upcase (read-string Last name: )))

This defines a function that will prompt the user to type a last name
into the minibuffer, converts the result into uppercase, and returns it
as a string.

Then, in your capture template, change %^{LASTNAME} to
%(prompt-for-lastname-and-upcase).

Best,
Richard






Re: [O] can I force all-caps in part of a headline in a capture template?

2012-05-06 Thread Richard Lawrence
Richard Lawrence richard.lawre...@berkeley.edu writes:

 Try this: in your .emacs, add the following code:

 (defun prompt-for-lastname-and-upcase ()
   (upcase (read-string Last name: )))

 This defines a function that will prompt the user to type a last name
 into the minibuffer, converts the result into uppercase, and returns it
 as a string.

 Then, in your capture template, change %^{LASTNAME} to
 %(prompt-for-lastname-and-upcase).


By the way, if you need to do the same thing for other fields, you can
do something like this instead:

(defun prompt-and-upcase (prompt-str)
  (upcase (read-string prompt-str)))

This generalizes the original function I gave you; you can pass in a
prompt string.

Then, in your capture template, wherever you need an uppercase field:

%(prompt-and-upcase Whatever prompt you need: )

e.g.,

%(prompt-and-upcase Last name: )

Best,
Richard




[O] time-up/down in org-agenda-sorting-strategy seems to have no effect?

2011-08-28 Thread Richard Lawrence
Hi everyone,

I've just started using custom agenda views in earnest, and I would like
to be able to control how several custom views are sorted.  I have tried
to set org-agenda-sorting-strategy to reflect what I want, but it seems
to have no effect on how items are sorted.  I'm wondering if I'm missing
something.

Specifically, I see no difference in how the items in todo, tags, and
tags-todo agenda views are sorted when I set time-down or time-up as the
first (or only) sorting criterion.  (tag-up/down and category-up/down
seem to work alright; I haven't tested the other sorting criteria.)

Here's how I'm expressing the setup I want:

#+BEGIN_SRC emacs-lisp
(setq org-agenda-sorting-strategy 
   '((agenda habit-down time-up priority-down category-keep)
 (todo time-down priority-down category-keep)
 (tags time-down priority-down category-keep)
 (search time-up priority-down todo-state-up)))
 
(setq org-agenda-custom-commands
  '((r Reading list tags-todo +reading)
(S . STUDY context searches)
(Sf todo FIND)
(Sp todo PRINT)
(Sr todo READ)
(Sn todo NOTES)
(St tags-todo +STUDY)
(D tags-todo +COMPUTER)
(H tags-todo +HOME)
(E tags-todo +ERRAND)
(F tags +FREETIME)))
#+END_SRC

Any insight you can provide will be very much appreciated.  Thanks!

Best,
Richard Lawrence




Re: [O] Email - Org-mode: charset problem

2011-06-27 Thread Richard Lawrence

 At Mon, 27 Jun 2011 10:30:06 +0200,
 Karl Voit wrote:
 Is there somebody who managed to develop an email to Org-mode bridge
 without having charset problems? (No, I do not use Emacs as a
 MUA[4])

David Maus dm...@ictsoc.de writes:
 I do use an Emacs base mua (Wanderlust) and recently started to file
 reference notes for certain messages. Because in cases I want to keept
 the message (e.g. an interesting usenet post) I save the raw message
 to a temporary file and add it as an attachment. This works nice,
 although I'd really like to have an automated way of save+attache when
 capturing.

 So, what about org-capture? You could use a script that serializes the
 raw message to disk and -- somehow -- calls capture with a reference
 to this file. Emacs opens the mail file and extracts information
 required for the template using the build-in MIME libaries (mml-*
 IIRC) which are capable of correctly parsing and if necessary decoding
 (e.g. quoted printable encoded letters in the subject). After
 extracting the information Emacs creates the appropriate capture
 entry, somehow adds the message file as attachment and finishes the
 capture process.

I do something like this, though I also use Emacs as an MUA (Gnus).  

My approach was to write a little parser that binds the various parts of
a message in a pre-determined format to variables that I grab in an Org
capture template, and dynamically scope those variables into a call to
org-capture.  I have included my code below.

But to address your original question:  unfortunately, I do not have a
solution to the encoding problem.  Despite my pre-determined format,
the emails I got (student paper submissions) were often in strange
encodings that I ended up fixing by hand during the capture process.

However, as David points out, I believe that it would be possible to use
Emacs' MIME libraries to do the dirty work.  I just haven't had time (or
desire, honestly) to figure out how.  If you figure it out, though, I'd
love to hear about it!

My (quite simplistic) code is below.  I hope you find it useful if you
decide to go this route!

Best,
Richard


 simple working example: Gnus side
; handling paper submissions
(defun capture-paper-part ()
  Call parse-paper and capture the result using org-capture
  (interactive)
  (let ((paper (parse-paper *phil100-paper-header-re*)))
(if paper
  (org-capture nil ap) ; ap is Org-capture key combo for template 
shown below
  (message No paper found in this part

(if (not (boundp 'gnus-mime-action-alist))
(setq gnus-mime-action-alist '())) 
(add-to-list 'gnus-mime-action-alist '(capture paper . capture-paper-part))

(defconst *phil100-paper-header-re*
  ^\\(?1:.*\\)\n\\(?2:.*\\)\n\\(?3:[Pp]aper *\\(?31:[0-9]+\\).*\\))

(defun parse-paper (header-re)
  Return an alist representing a paper, by parsing the buffer using header-re
  (save-excursion
(goto-char (point-min))
(if (re-search-forward header-re nil t)
(list `(header . ,(or (match-string 0) ))
  `(author . ,(or (match-string 2) ))
  `(title . ,(or (match-string 1) ))
  `(date . ,(or (match-string 3) ))
  `(num . ,(or (match-string 31) ))
  `(body . ,(buffer-substring (match-end 0) (point-max
  nil)))

(defun paper-property (key)
  ; paper is dynamically scoped in by capture-paper-part
  (or (cdr (assoc key paper)) ))
  
(defun string-replace-downcase (from to in)
  Replace FROM with TO in string IN, and also downcase the result
  (with-temp-buffer
(insert in)
(goto-char (point-min))
(while (search-forward from nil t)
  (replace-match to nil t))
(downcase-region (point-min) (point-max))
(buffer-substring (point-min) (point-max

 simple working example: Org capture template
** %(paper-property 'author)
   :PROPERTIES:
   :EXPORT_TITLE: %(paper-property 'title)
   :EXPORT_AUTHOR: %(paper-property 'author)
   :EXPORT_DATE: Paper %(paper-property 'num)
   :EXPORT_FILE_NAME: %(concat (paper-property 'num) - 
(string-replace-downcase   - (paper-property 'author)) .tex)
   :END:

%(paper-property 'body)




<    1   2   3   4   >