[O] #+INCLUDE: file in code block results does not work?

2014-03-26 Thread KDr2
I wrote a piece of code like below:

#+NAME: inc-file
#+BEGIN_SRC elisp :results value raw :exports results :var file=
common.inc.org
  (concat #+INCLUDE: /path/to/include-dir/ file) ;; path is cal-ed from
path of current-buffer file
#+END_SRC

#+CALL: inc-file(file=a.org) :results raw

but this does not work, anyone knows why?

By the way, #+HTML_HEAD in code block results works well:

#+NAME: d-header
#+BEGIN_SRC elisp :results value raw :exports results
  (concat #+HTML_HEAD: link rel=\stylesheet\ type=\text/css\ href=\
/style.css \ /)
#+END_SRC

#+CALL: d-header() :results raw


Thanks.

-- 
-- 

KDr2, http://kdr2.com


Re: [O] Tasks with lots of logbook entries are very slow

2014-03-26 Thread Pere Quintana Seguí
El 25/03/14 19:27, Marcin Borkowski ha escrit:
 Dnia 2014-03-25, o godz. 16:00:01
 Pere Quintana Seguí p...@quintanasegui.com napisał(a):
 
 I log most of my work with org-mode. Some of my tasks are repetitive,
 this is, I do them weekly or daily (i.e. empty mail inbox). After many
 years, the logs are very long. As a consequence, marking these tasks
 as done is *very* slow.

 Is there a workaround that does not involver deleting the logs?
 
 Archiving?
 

No, archiving would'nt work, as I need the task every day.

Thanks for the tip.

Pere




Re: [O] Tasks with lots of logbook entries are very slow

2014-03-26 Thread Pere Quintana Seguí
El 25/03/14 19:47, Achim Gratz ha escrit:
 I've long resorted to using two drawers back-to-back:

That seems to be the most straightforward solution. I'll do that.

Maybe org-mode could do this automatically. A variable would determine
when log entries should be archived in the second drawer.

I would write a patch if I could program in elisp, but I can't. :'(

Thanks,

Pere






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

2014-03-26 Thread Alan Schmitt
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
article, I added the following block in a section that is not exported:

--8---cut here---start-8---
#+begin_src emacs-lisp :results silent :exports results
  (add-to-list 'org-latex-classes
   '(llncs
 \\documentclass{llncs}
 (\\section{%s} . \\section*{%s})
 (\\subsection{%s} . \\subsection*{%s})
 (\\subsubsection{%s} . \\subsubsection*{%s})))
#+end_src
--8---cut here---end---8---

My questions are:
- is there a way to do this without an emacs-lisp block?
- is there a nicer way to make sure that an emacs-lisp block is
evaluated upon export than :exports results :results silent? (If
I don't put it there, the block is not evaluated.)
- is there a way to just say the name of the documentclass without all
the boilerplate code below? In other words, can I say this is a llncs
documentclass with the same sectioning as an article?

Thanks,

Alan



Re: [O] Tasks with lots of logbook entries are very slow

2014-03-26 Thread Peter Neilson
On Wed, 26 Mar 2014 04:10:02 -0400, Pere Quintana Seguí  
p...@quintanasegui.com wrote:



El 25/03/14 19:27, Marcin Borkowski ha escrit:

Dnia 2014-03-25, o godz. 16:00:01
Pere Quintana Seguí p...@quintanasegui.com napisał(a):


I log most of my work with org-mode. Some of my tasks are repetitive,
this is, I do them weekly or daily (i.e. empty mail inbox). After many
years, the logs are very long. As a consequence, marking these tasks
as done is *very* slow.

Is there a workaround that does not involver deleting the logs?


Archiving?



No, archiving would'nt work, as I need the task every day.

Thanks for the tip.

Pere


Perhaps this will help:

Standard method for log maintenance outside of org is to rotate logs into  
archive. The current log is only for the current day (or month, week, or  
year). Other criteria, such as log size, can be used to trigger rotation.  
Rotation cuts off the current log, archives it, possibly deletes truly  
ancient logs, and starts a new current log. Look up the Linux logrotate  
command for further info. Here's one description:  
http://www.thegeekstuff.com/2010/07/logrotate-examples/




Re: [O] #+INCLUDE: file in code block results does not work?

2014-03-26 Thread Nicolas Goaziou
Hello,

KDr2 killy.d...@gmail.com writes:

 I wrote a piece of code like below:

 #+NAME: inc-file
 #+BEGIN_SRC elisp :results value raw :exports results :var file=
 common.inc.org
   (concat #+INCLUDE: /path/to/include-dir/ file) ;; path is cal-ed from
 path of current-buffer file
 #+END_SRC

 #+CALL: inc-file(file=a.org) :results raw

 but this does not work, anyone knows why?

During export process, INCLUDE keywords are expanded before Babel code
is executed.

You can use a macro here:

  #+MACRO: inc-file #+INCLUDE: /path/to-include-dir/$1

  {{{inc-file(a.org)}}}


Regards,

-- 
Nicolas Goaziou



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

2014-03-26 Thread Feng Shu
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...
 article, I added the following block in a section that is not exported:
 --8---cut here---start-8---
 #+begin_src emacs-lisp :results silent :exports results
   (add-to-list 'org-latex-classes
'(llncs
  \\documentclass{llncs}
  (\\section{%s} . \\section*{%s})
  (\\subsection{%s} . \\subsection*{%s})
  (\\subsubsection{%s} . \\subsubsection*{%s})))
 #+end_src
 --8---cut here---end---8---

 My questions are:
 - is there a way to do this without an emacs-lisp block?
 - is there a nicer way to make sure that an emacs-lisp block is
 evaluated upon export than :exports results :results silent? (If
 I don't put it there, the block is not evaluated.)
 - is there a way to just say the name of the documentclass without all
 the boilerplate code below? In other words, can I say this is a llncs
 documentclass with the same sectioning as an article?

You should defun a classe for llncs.sty before use it. maybe
you can rename llncs.sty to article.sty, and put it to directory which contain
your org file.


 Thanks,

 Alan

-- 




Re: [O] #+INCLUDE: file in code block results does not work?

2014-03-26 Thread Nicolas Goaziou
Nicolas Goaziou n.goaz...@gmail.com writes:

 You can use a macro here:

   #+MACRO: inc-file #+INCLUDE: /path/to-include-dir/$1

   {{{inc-file(a.org)}}}

Err, no. Macros are also expanded after INCLUDE keywords. The only code
executed before these are handled is
`org-export-before-processing-hook'.



Re: [O] [PATCH] Source block fontification handling indentation

2014-03-26 Thread Bastien
Hi Michael,

Pontus Michael m.pon...@gmail.com writes:

 Source block fontification is achieved by copying source block
 contents into temporary buffer under appropriate major mode and
 mirroring face text-properties into original buffer.

thanks for the change and the detailed explanations.

Eric, I'm short of time this week, so if you have a chance to
review and perhaps apply this change, please go ahead.

Otherwise, I'll review this next week.

Thanks,

-- 
 Bastien



Re: [O] Tasks with lots of logbook entries are very slow

2014-03-26 Thread Eric S Fraga
Achim Gratz strom...@nexgo.de writes:

[...]

 I've long resorted to using two drawers back-to-back:

 :LOGBOOK:
  …stuff…
 :END:
 :CLOSED:
  …old stuff…
 :END:

Thanks for this.  Very simple yet elegant solution.
-- 
: Eric S Fraga (0xFFFCF67D), Emacs 24.3.50.2, Org release_8.2.5h-687-g9d39aa



[O] Bug: Error with org-bibtex export with tags when using custom bibtypes [8.2.5h (8.2.5h-82-gd91d4b-elpaplus @ /Users/leonardaveryrandall/.emacs.d/elpa/org-plus-contrib-20140324/)]

2014-03-26 Thread Leonard Randall
Hello,

When I attempt to run M-x org-bibtex on a .org file with non-standard
bibtex types that have a tag, they fail to export if
org-bibtex-tags-are-keywords is set to t. This persists even if I add the
bibtex type to org-bibtex-types.  I checked, and this problem persists with
a minimal init file, and a minimal org file. I have also checked, and I get
the same problem with Emacs 24.3.5 from emacsforosx.  I just started using
org-bibtex so I do not know how far the bug goes back.

Here is a minimal example that gets the bug.


** Critique of Practical Reason :ex:
:PROPERTIES:
:TITLE: Critique of Practical Reason
:BOOKTITLE: Practical Philosophy
:BTYPE: bookinbook
:CUSTOM_ID: Kant:1996a
:AUTHOR: Kant, Immanuel
:PAGES: 133--276
:TRANSLATOR: Gregor, Mary J
:EDITOR: Gregor, Mary J
:YEAR:  1996
:PUBLISHER: Cambridge University Press
:ADDRESS: Cambridge UK
:END:



I press ``M-x org-bibtex'' it returns ``Bibtex error on Critique of
Practical Reason. This error does not occur if I change ``BTYPE to
``book'' or if I remove the tag ``:ex:'' from the headline. As I noted
above, I added ``bookinbook'' to the org-bibtex-types and added the
appropriate fields there and in org-bibtex-fields.



Here is a minimal init:

(setq org-bibtex-types
  '((:article
 (:description . An article from a journal or magazine)
 (:required :author :title :journal :year)
 (:optional :volume :number :pages :month :note :annote :url :abstract
:keywords :file :uri))
(:book
 (:description . A book with an explicit publisher)
 (:required (:editor :author) :title :publisher :year)
 (:optional (:volume :number) :series (:address :location) :edition
:month :note :annote :url :abstract :keywords :file :uri))
(:bookinbook
 (:description . A part of a book, which could be, and once was, its
own book.)
 (:required :title (:chapter :pages) :publisher :year :booktitle)
 (:optional :crossref :author :editor :volume :translator :number
:series :type :address :location :edition :note :annote :url :abstract
:keywords :file :uri))
(:booklet
 (:description . A work that is printed and bound, but without a named
publisher or sponsoring institution.)
 (:required :title)
 (:optional :author :howpublished (:address :location) :month :year
:note :annote :url :abstract :keywords :file :uri))
(:conference
 (:description . )
 (:required :author :title :booktitle :year)
 (:optional :editor :pages :organization :publisher (:address
:location) :month :note :annote :url :abstract :keywords :file :uri))
(:inbook
 (:description . A part of a book, which may be a chapter (or section
or whatever) and/or a range of pages.)
 (:required (:author :editor) :title (:chapter :pages) :publisher :year)
 (:optional :crossref (:volume :number) :series :type (:address
:location) :edition :month :note :annote :url :abstract :keywords :file
:uri))
(:incollection
 (:description . A part of a book having its own title.)
 (:required :author :title :booktitle :publisher :year)
 (:optional :crossref :editor (:volume :number) :series :type :chapter
:pages (:address :location) :edition :month :note :annote :url :abstract
:keywords :file :uri))
(:inproceedings
 (:description . An article in a conference proceedings)
 (:required :author :title :booktitle :year)
 (:optional :crossref :editor (:volume :number) :series :pages
(:address :location) :month :organization :publisher :note :annote :url
:abstract :keywords :file :uri))
(:manual
 (:description . Technical documentation.)
 (:required :title)
 (:optional :author :organization (:address :location) :edition :month
:year :note :annote :url :abstract :keywords :file :uri))
(:mastersthesis
 (:description . A Masterâ EURO (tm)s thesis.)
 (:required :author :title :school :year)
 (:optional :type (:address :location) :month :note :annote :url
:abstract :keywords :file :uri))
(:misc
 (:description . Use this type when nothing else fits.)
 (:required)
 (:optional :author :crossref :booktitle :date :title :howpublished
:month :year :note :annote :location :url :abstract :keywords :file :uri))
(:phdthesis
 (:description . A PhD thesis.)
 (:required :author :title :school :year)
 (:optional :type (:address :location) :month :note :annote :url
:abstract :keywords :file :uri))
(:proceedings
 (:description . The proceedings of a conference.)
 (:required :title :year)
 (:optional :editor (:volume :number) :series (:address :location)
:month :organization :publisher :note :annote :url :abstract :keywords
:file :uri))
(:techreport
 (:description . A report published by a school or other institution.)
 (:required :author :title :institution :year)
 (:optional :type (:address :location) :month :note :annote :url
:abstract :keywords :file :uri))
(:unpublished
 (:description . A document having an author and title, but not
formally 

[O] Path of file to save code block results

2014-03-26 Thread Yi Zhang

Hi All,

The evaluation of code block

#+begin_src R :file img.pdf
hist(rnorm(100))
#+END_SRC

does not output img.pdf to the current folder. But if I use ~/img.pdf, 
file will be saved to ~/. Am I missing something here?


Thanks,

YZ

--
Yi Zhang, Ph.D.

School of Civil  Construction Engineering
Oregon State University
Corvallis, OR, 97331



Re: [O] #+INCLUDE: file in code block results does not work?

2014-03-26 Thread KDr2
Thanks very much.

I use dynamic block now, by adding `org-update-all-dblocks' to
`org-export-before-processing-hook'.


On Wed, Mar 26, 2014 at 5:42 PM, Nicolas Goaziou n.goaz...@gmail.comwrote:

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

  You can use a macro here:
 
#+MACRO: inc-file #+INCLUDE: /path/to-include-dir/$1
 
{{{inc-file(a.org)}}}

 Err, no. Macros are also expanded after INCLUDE keywords. The only code
 executed before these are handled is
 `org-export-before-processing-hook'.




-- 
-- 

KDr2, http://kdr2.com


Re: [O] Path of file to save code block results

2014-03-26 Thread Sebastien Vauban
Yi Zhang wrote:
 The evaluation of code block

 #+begin_src R :file img.pdf
 hist(rnorm(100))
 #+END_SRC

 does not output img.pdf to the current folder. But if I use ~/img.pdf, 
 file will be saved to ~/. Am I missing something here?

You miss :results graphics, for example:

  #+begin_src R :results graphics :file img.pdf
  hist(rnorm(100))
  #+END_SRC

Though, why is the behavior different whether you have ~/ or not in the
filename??

Best regards,
  Seb

-- 
Sebastien Vauban




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

2014-03-26 Thread Fabrice Niessen
Feng Shu wrote:
 Alan Schmitt alan.schm...@polytechnique.org writes:

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

You could have a look at Orgmk [1], a suite of shell scripts I wrote
with the following goals in mind:

- to be more productive, by running the export only when the source Org
  files are updated.

- *to share some common Emacs and Org configuration inside your team*,
  separately of what you have in your personal Emacs configuration file.

- to offload compilation into an external batch Emacs process, allowing
  you to go on editing or working while exporting the documents.

You just need to install it, and then using it is a simple as:

--8---cut here---start-8---
  org2html [OPTION] FILE
  org2latex [OPTION] FILE
  org2pdf [OPTION] FILE
  org2beamerpdf [OPTION] FILE
  org2odt [OPTION] FILE
  org2txt [OPTION] FILE
  orgmk [OPTION]
  orgmk [OPTION] [html | pdf]
  orgmk [OPTION] [FILE]
--8---cut here---end---8---

Best regards,
Fabrice

[1] https://github.com/fniessen/orgmk

-- 
Fabrice Niessen
Leuven, Belgium
http://www.pirilampo.org/




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

2014-03-26 Thread Alan Schmitt
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 ;-)

 My questions are:
 - is there a way to do this without an emacs-lisp block?
 - is there a nicer way to make sure that an emacs-lisp block is
 evaluated upon export than :exports results :results silent? (If
 I don't put it there, the block is not evaluated.)
 - is there a way to just say the name of the documentclass without all
 the boilerplate code below? In other words, can I say this is a llncs
 documentclass with the same sectioning as an article?

 You should defun a classe for llncs.sty before use it. maybe
 you can rename llncs.sty to article.sty, and put it to directory which contain
 your org file.

Yes, this could be a way to do it. The current approach works, I find it
a little bit too verbose, though.

Thank you for the suggestion,

Alan



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

2014-03-26 Thread Alan Schmitt
Hello Fabrice,

Fabrice Niessen fni-n...@pirilampo.org writes:

 You could have a look at Orgmk [1], a suite of shell scripts I wrote
 with the following goals in mind:

 - to be more productive, by running the export only when the source Org
   files are updated.

 - *to share some common Emacs and Org configuration inside your team*,
   separately of what you have in your personal Emacs configuration
   file.

This is very interesting ...

 - to offload compilation into an external batch Emacs process, allowing
   you to go on editing or working while exporting the documents.

I usually export in offline mode, so I can keep editing while the export
is going on.

 You just need to install it, and then using it is a simple as:

   org2html [OPTION] FILE
   org2latex [OPTION] FILE
   org2pdf [OPTION] FILE
   org2beamerpdf [OPTION] FILE
   org2odt [OPTION] FILE
   org2txt [OPTION] FILE
   orgmk [OPTION]
   orgmk [OPTION] [html | pdf]
   orgmk [OPTION] [FILE]

Thank you for the suggestion, I'll definitely have a look.

Alan



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

2014-03-26 Thread Nicolas Goaziou
Hello,

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

 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
 article, I added the following block in a section that is not exported:

 #+begin_src emacs-lisp :results silent :exports results
   (add-to-list 'org-latex-classes
'(llncs
  \\documentclass{llncs}
  (\\section{%s} . \\section*{%s})
  (\\subsection{%s} . \\subsection*{%s})
  (\\subsubsection{%s} . \\subsubsection*{%s})))
 #+end_src

 My questions are:
 - is there a way to do this without an emacs-lisp block?

Yes there is, with a BIND keyword, e.g.:

  #+BIND: org-latex-classes ((article \\documentclass{llncs} 
(\\section{%s} . \\section*{%s})))

Though you need to activate it with `org-export-allow-bind-keywords', if
only as a file local variable:

  # Local Variables:
  # org-export-allow-bind-keywords: t
  # End:

 - is there a nicer way to make sure that an emacs-lisp block is
 evaluated upon export than :exports results :results silent? (If
 I don't put it there, the block is not evaluated.)

You can put the block in a :noexport: section. Then, I don't think that
you need to then :exports or :results parameters.

 - is there a way to just say the name of the documentclass without all
 the boilerplate code below? In other words, can I say this is a llncs
 documentclass with the same sectioning as an article?

You can use a final filter to replace article with llncs in the
document, but there is no straightforward way, e.g., a keyword, to do
so.

Regards,

-- 
Nicolas Goaziou



[O] How to write a org babel hook, which can manupulate result

2014-03-26 Thread Feng Shu
Hi:

I want to write a hook to menupulate org babel output,
The problem is: How can I get two points info: [pointA] and [pointB]
in my hook function?

#+begin_src R :results output raw drawer
tbl - data.frame(a=c(1,2,3),b=c(3,2,1))
print(ascii(tbl),type=org)
#+END_SRC

#+RESULTS:
:RESULTS:
[pointA]
|   |a |b |
|---+--+--|
| 1 | 1.00 | 3.00 |
| 2 | 2.00 | 2.00 |
| 3 | 3.00 | 1.00 |
[pointB]
:END:



-- 



Re: [O] A problem with publishing

2014-03-26 Thread Rick Frankel

On 2014-03-23 17:01, Marcin Borkowski wrote:

Hi list,

publishing doesn't work.  I guess that I broke something;).  May the
source and publishing directories be the same?  I have this in my
init.el:

(setq org-publish-project-alist
'((fnis2014
:base-directory ~/directory
:publishing-directory ~/directory
:base-extension org\\|css\\|jpg\\|png
:publishing-function org-reveal-export-to-html
:completion-function (lambda () (compile make install)

The make install means just rsync'ing to a remote server.

When I export (C-c C-e R R) and then publish (C-c C-e P x) (or
M-x compile), everything is ok.  When I just publish, changes seem
not to be pushed to the remote server, and I'm left with some *Org
export* process buffers.


My guess is that using *-export-to-html as the publishing function is
the culprit. There should/needs to be an org-reveal-publish-to-html
publishing function. I'm guessing the reason it works when you
manually export is that since the html file is up-to-date vis. the org
source, the code path bypasses that step (and just runs the completion
function).

If org-reveal doesn't have a publishing function, try (not tested):

(lambda (plist filename pubdir)
(org-publish-org-to 'reveal filename .html plist pubdir))

BTW, org-publish has built-in support for pushing to a remote server.
You can use a tramp url as the publishing-directory, bypassing the
completion function.

rick



Re: [O] How to write a org babel hook, which can manupulate result

2014-03-26 Thread Daimrod
Feng Shu tuma...@gmail.com writes:

 Hi:
Hi Feng,

Look at the :post header argument.
(info (org) post)

 I want to write a hook to menupulate org babel output,
 The problem is: How can I get two points info: [pointA] and [pointB]
 in my hook function?

 #+begin_src R :results output raw drawer
 tbl - data.frame(a=c(1,2,3),b=c(3,2,1))
 print(ascii(tbl),type=org)
 #+END_SRC

 #+RESULTS:
 :RESULTS:
 [pointA]
 |   |a |b |
 |---+--+--|
 | 1 | 1.00 | 3.00 |
 | 2 | 2.00 | 2.00 |
 | 3 | 3.00 | 1.00 |
 [pointB]
 :END:

-- 
Daimrod/Greg



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

2014-03-26 Thread Alan Schmitt
Hello Nicolas,

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

 My questions are:
 - is there a way to do this without an emacs-lisp block?

 Yes there is, with a BIND keyword, e.g.:

   #+BIND: org-latex-classes ((article \\documentclass{llncs} 
 (\\section{%s} . \\section*{%s})))

 Though you need to activate it with `org-export-allow-bind-keywords', if
 only as a file local variable:

   # Local Variables:
   # org-export-allow-bind-keywords: t
   # End:

Ah, yes, this is quite helpful. Thanks.

 - is there a nicer way to make sure that an emacs-lisp block is
 evaluated upon export than :exports results :results silent? (If
 I don't put it there, the block is not evaluated.)

 You can put the block in a :noexport: section. Then, I don't think that
 you need to then :exports or :results parameters.

It is in a :noexport: section already. Here is a quick test.

Exporting

--8---cut here---start-8---
* Test :noexport:

#+begin_src sh
echo date 1  ~/tmp/results
echo `date`  ~/tmp/results
#+end_src

#+begin_src sh :exports results :results silent
echo date 2  ~/tmp/results
echo `date`  ~/tmp/results
#+end_src
--8---cut here---end---8---

yields this ~/tmp/results file:

--8---cut here---start-8---
date 2
Wed Mar 26 14:46:08 CET 2014
--8---cut here---end---8---

The behavior is identical if the :noexport: tag is absent.

 - is there a way to just say the name of the documentclass without all
 the boilerplate code below? In other words, can I say this is a llncs
 documentclass with the same sectioning as an article?

 You can use a final filter to replace article with llncs in the
 document, but there is no straightforward way, e.g., a keyword, to do
 so.

Thanks,

Alan



Re: [O] #+INCLUDE: file in code block results does not work?

2014-03-26 Thread KDr2
I wrote a blog entry to describe all the dynamic tricks I used in the
exporting:

http://kdr2.com/tech/emacs/orgmode-export-process.html


On Wed, Mar 26, 2014 at 7:54 PM, KDr2 killy.d...@gmail.com wrote:

 Thanks very much.

 I use dynamic block now, by adding `org-update-all-dblocks' to
 `org-export-before-processing-hook'.


 On Wed, Mar 26, 2014 at 5:42 PM, Nicolas Goaziou n.goaz...@gmail.comwrote:

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

  You can use a macro here:
 
#+MACRO: inc-file #+INCLUDE: /path/to-include-dir/$1
 
{{{inc-file(a.org)}}}

 Err, no. Macros are also expanded after INCLUDE keywords. The only code
 executed before these are handled is
 `org-export-before-processing-hook'.




 --
 --

 KDr2, http://kdr2.com




-- 
-- 

KDr2, http://kdr2.com


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

2014-03-26 Thread Nicolas Goaziou
Alan Schmitt alan.schm...@polytechnique.org writes:

 It is in a :noexport: section already. Here is a quick test.

 Exporting

 * Test :noexport:

 #+begin_src sh
 echo date 1  ~/tmp/results
 echo `date`  ~/tmp/results
 #+end_src

 #+begin_src sh :exports results :results silent
 echo date 2  ~/tmp/results
 echo `date`  ~/tmp/results
 #+end_src

 yields this ~/tmp/results file:

 date 2 Wed Mar 26 14:46:08 CET 2014

 The behavior is identical if the :noexport: tag is absent.

Then I think you can at least remove the :results silent part, can't
you?


Regards,

-- 
Nicolas Goaziou



Re: [O] #+INCLUDE: file in code block results does not work?

2014-03-26 Thread Nicolas Goaziou
Hello,

KDr2 killy.d...@gmail.com writes:

 I wrote a blog entry to describe all the dynamic tricks I used in the
 exporting:

 http://kdr2.com/tech/emacs/orgmode-export-process.html

Thank you for sharing.

For completeness, there is another step involved in the process before
switching to back-ends: run functions in
`org-export-before-parsing-hook'.

 I use dynamic block now, by adding `org-update-all-dblocks' to
 `org-export-before-processing-hook'.

Also, you can also a function in the same hook that would update
a generic inc-file macro in the file:

  (lambda (backend)
(org-with-wide-buffer
 (goto-char (point-min))
 (let ((case-fold-search nil))
   (while (re-search-forward ^ *#\\+MACRO: +inc-file +\\\(PATH\\) nil t)
 (replace-match (get-path-dynamically) t nil nil 1)

with the following generic macro:

  #+MACRO: inc-file PATH$1


Regards,

-- 
Nicolas Goaziou



Re: [O] [PATCH] Add catch-up all LaTeX errors

2014-03-26 Thread Francesco Pizzolante
Hi,

May I bump up this thread?

Thanks for your help.

Regards,
 Francesco

Francesco Pizzolante wrote:
 Hi,

 This is not a definitive patch. It's just a first step in getting a better 
 one.

 The issue is the fact that, when exporting to PDF, in some cases, Org tells
 that the export has been done successfully while the PDF file has not been
 produced!

 As an example, if you open the target PDF file with Adobe Reader and, in the
 meantime, you export your Org file again to PDF, you'll see that Org will tell
 you it's OK (Process Completed) while, if you look at the *Org PDF LaTeX
 Output* buffer, you'll see an error such as:

 ! I can't write on file `toto.pdf'.
 [...]

 The problem comes from the fact that Org just checks for a couple of error
 messages (defined in org-latex-known-errors) and report it's OK if it doesn't
 find those messages:

 (defcustom org-latex-known-errors
   '((Reference.*?undefined .  [undefined reference])
 (Citation.*?undefined .  [undefined citation])
 (Undefined control sequence .  [undefined control sequence])
 (^! LaTeX.*?Error .  [LaTeX error])
 (^! Package.*?Error .  [package error])
 (Runaway argument .  Runaway argument))
 [...]

 In order to be sure to check for ALL errors, we should check for any line
 beginning with '!' (http://en.wikibooks.org/wiki/LaTeX/Errors_and_Warnings).
 That's the idea of this patch.

 Though, the issue with this patch is that some error can match 2 messages, and
 you get the following display:

 Process completed with errors: [LaTeX error] [Unknown error]

 To this issue, I see 2 solutions:

 1. Either catch all errors with a single regexp (and remove all other 
 regexps):

 (defcustom org-latex-known-errors
   '((^!.* .  LaTeX error))
 [...]

 2. Stop on the first error found and report it.

 In all cases, it would be much better to be able to report the error line such
 as:

 Process completed with errors: [! I can't write on file `toto.pdf'.]

 Can someone do this or help me to achieve it?

 Best regards,
  Francesco

 ---
  lisp/ox-latex.el |3 ++-
  1 files changed, 2 insertions(+), 1 deletions(-)

 diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
 index 9262ded..2cffe38 100644
 --- a/lisp/ox-latex.el
 +++ b/lisp/ox-latex.el
 @@ -862,7 +862,8 @@ logfiles to remove, set `org-latex-logfiles-extensions'.
  (Undefined control sequence .  [undefined control sequence])
  (^! LaTeX.*?Error .  [LaTeX error])
  (^! Package.*?Error .  [package error])
 -(Runaway argument .  Runaway argument))
 +(Runaway argument .  Runaway argument)
 +(^!.* . [Unknown error]))
Alist of regular expressions and associated messages for the user.
  The regular expressions are used to find possible errors in the
  log of a latex-run.
 --
 1.7.9





Re: [O] Bad footnotes when including org files

2014-03-26 Thread Nicolas Goaziou
Hello,

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

 Thanks for your answer. Maybe I will try your solution. Otherwise
 I will run a before-parse-hook to change fn:XX to something unique
 (by adding buffer name for example.

We could do it by default.

One problem is that INCLUDE keyword is a very simple feature. For
example, if you include two files in a row and the first one ends with
a footnote section, the other one will be included in that section and,
therefore, not exported. So if we start to make it smart, we could be
tempted to add too many other checks.

Anyway, here's a patch for that.

WDYT?


Regards,

-- 
Nicolas Goaziou
From 2a22d4dc3beb300094c9ee28158f227dbf467cda Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou n.goaz...@gmail.com
Date: Wed, 26 Mar 2014 15:34:59 +0100
Subject: [PATCH] ox: Make footnotes file specific when including Org files

* lisp/ox.el (org-export-expand-include-keyword,
  org-export--prepare-file-contents): Make footnotes file specific
  when including Org files.

http://permalink.gmane.org/gmane.emacs.orgmode/83606
---
 lisp/ox.el | 32 
 1 file changed, 28 insertions(+), 4 deletions(-)

diff --git a/lisp/ox.el b/lisp/ox.el
index 9f77af4..cf70643 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -3279,7 +3279,9 @@ with their line restriction, when appropriate.  It is used to
 avoid infinite recursion.  Optional argument DIR is the current
 working directory.  It is used to properly resolve relative
 paths.
-  (let ((case-fold-search t))
+  (let ((case-fold-search t)
+	(file-prefix (make-hash-table :test #'equal))
+	(current-prefix 0))
 (goto-char (point-min))
 (while (re-search-forward ^[ \t]*#\\+INCLUDE: nil t)
   (let ((element (save-match-data (org-element-at-point
@@ -3349,13 +3351,16 @@ paths.
 		 (with-temp-buffer
 		   (let ((org-inhibit-startup t)) (org-mode))
 		   (insert
-		(org-export--prepare-file-contents file lines ind minlevel))
+		(org-export--prepare-file-contents
+		 file lines ind minlevel
+		 (or (gethash file file-prefix)
+			 (puthash file (incf current-prefix) file-prefix
 		   (org-export-expand-include-keyword
 		(cons (list file lines) included)
 		(file-name-directory file))
 		   (buffer-string)
 
-(defun org-export--prepare-file-contents (file optional lines ind minlevel)
+(defun org-export--prepare-file-contents (file optional lines ind minlevel id)
   Prepare the contents of FILE for inclusion and return them as a string.
 
 When optional argument LINES is a string specifying a range of
@@ -3369,7 +3374,12 @@ headline encountered.
 
 Optional argument MINLEVEL, when non-nil, is an integer
 specifying the level that any top-level headline in the included
-file should have.
+file should have.
+
+Optional argument ID is an integer that will be inserted before
+each footnote definition and reference if FILE is an Org file.
+This is useful to avoid clashes when more than one Org file with
+footnotes is included in a document.
   (with-temp-buffer
 (insert-file-contents file)
 (when lines
@@ -3428,6 +3438,20 @@ file should have.
 	   (org-map-entries
 		(lambda () (if ( offset 0) (delete-char (abs offset))
 			(insert (make-string offset ?*)))
+;; Append ID to all footnote references and definitions, so they
+;; are file specific and cannot collide with other included files.
+(goto-char (point-min))
+(while (re-search-forward org-footnote-re nil t)
+  (let ((reference (org-element-context)))
+	(when (memq (org-element-type reference)
+		'(footnote-reference footnote-definition))
+	  (goto-char (org-element-property :begin reference))
+	  (forward-char)
+	  (let ((label (org-element-property :label reference)))
+	(cond ((not label))
+		  ((org-string-match-p \\`[0-9]+\\' label)
+		   (insert (format fn:%d- id)))
+		  (t (forward-char 3) (insert (format %d- id
 (org-element-normalize-string (buffer-string
 
 (defun org-export-execute-babel-code ()
-- 
1.9.1



Re: [O] [PATCH] Add catch-up all LaTeX errors

2014-03-26 Thread Nicolas Goaziou


Hello,

Francesco Pizzolante
fpz-djc/ipccudyqhejpep6iedvlejwur...@public.gmane.org writes:

 The issue is the fact that, when exporting to PDF, in some cases, Org tells
 that the export has been done successfully while the PDF file has not been
 produced!

 As an example, if you open the target PDF file with Adobe Reader and, in the
 meantime, you export your Org file again to PDF, you'll see that Org will 
 tell
 you it's OK (Process Completed) while, if you look at the *Org PDF LaTeX
 Output* buffer, you'll see an error such as:

 ! I can't write on file `toto.pdf'.
 [...]

 The problem comes from the fact that Org just checks for a couple of error
 messages (defined in org-latex-known-errors) and report it's OK if it doesn't
 find those messages:

Errors are not related to your problem. Actually, ox-latex.el uses
a rather weak check to know if process was successful or not:

  (if (not (file-exists-p pdffile))
  (error (concat (format PDF file %s wasn't produced pdffile)
 (when errors (concat :  errors
...
(message (concat Process completed
 (if (not errors) . (concat  with errors:  errors)

IOW, it cannot tell the difference between a successful export and an
export failure with an already existing PDFFILE.

This part needs to be improved.


Regards,

-- 
Nicolas Goaziou




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

2014-03-26 Thread Alan Schmitt
Nicolas Goaziou n.goaz...@gmail.com writes:

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

 It is in a :noexport: section already. Here is a quick test.

 Exporting

 * Test :noexport:

 #+begin_src sh
 echo date 1  ~/tmp/results
 echo `date`  ~/tmp/results
 #+end_src

 #+begin_src sh :exports results :results silent
 echo date 2  ~/tmp/results
 echo `date`  ~/tmp/results
 #+end_src

 yields this ~/tmp/results file:

 date 2 Wed Mar 26 14:46:08 CET 2014

 The behavior is identical if the :noexport: tag is absent.

 Then I think you can at least remove the :results silent part, can't
 you?

Yes, indeed. I'm too used to putting these blocks in parts that are
actually exported. Sorry for the confusion,

Alan



[O] Multiple agenda buffers

2014-03-26 Thread Robert P. Goldman
I find if I accidentally return over an item's date, I get a second
agenda buffer for that date.

That seems fine, but what I don't like is that from now on, any org
agenda commands go to THAT buffer, rather than going into the old agenda
buffer, which I keep around all the time.

So I have, for example *Org Agenda* and *Org Agenda(a:2014-03-25)

Is there some way to kill the latter so that it does not come back?

I did ^X-k in that buffer, and it disappeared, but my next org agenda
command went into a buffer like that, instead of going into the original
*Org Agenda* (and its frame).

Is this related to org-agenda-this-buffer-is-sticky?  I don't really
understand the description of stickiness in org-agenda.el and it's not
referenced in the index of the manual.

thanks,
r



Re: [O] #+INCLUDE: file in code block results does not work?

2014-03-26 Thread KDr2
Oh, I'll star this mail, and add it to my post later, thanks again :)


On Wed, Mar 26, 2014 at 10:31 PM, Nicolas Goaziou n.goaz...@gmail.comwrote:

 Hello,

 KDr2 killy.d...@gmail.com writes:

  I wrote a blog entry to describe all the dynamic tricks I used in the
  exporting:
 
  http://kdr2.com/tech/emacs/orgmode-export-process.html

 Thank you for sharing.

 For completeness, there is another step involved in the process before
 switching to back-ends: run functions in
 `org-export-before-parsing-hook'.

  I use dynamic block now, by adding `org-update-all-dblocks' to
  `org-export-before-processing-hook'.

 Also, you can also a function in the same hook that would update
 a generic inc-file macro in the file:

   (lambda (backend)
 (org-with-wide-buffer
  (goto-char (point-min))
  (let ((case-fold-search nil))
(while (re-search-forward ^ *#\\+MACRO: +inc-file +\\\(PATH\\)
 nil t)
  (replace-match (get-path-dynamically) t nil nil 1)

 with the following generic macro:

   #+MACRO: inc-file PATH$1


 Regards,

 --
 Nicolas Goaziou




-- 
-- 

KDr2, http://kdr2.com


Re: [O] Unconditionally turn off Flyspell mode during export

2014-03-26 Thread Sebastien Vauban
Hi Bastien,

Bastien wrote:
 Sebastien Vauban writes:

 (add-hook 'text-mode-hook
   (lambda ()
 (message Turning on Flyspell in buffer `%s' (buffer-name))
 (flyspell-mode 1)))

 Though, as you can see, that has the perverse impact that Flyspell
 gets called (even multiple times) during the export process, when
 creating copies of the source Org document:

 From master, you can check against `org-babel-exp-reference-buffer' to
 see if you are currently exporting, and then activate flyspell-mode
 only if you're not.

IIUC, I can't make use of it. Let me explain...

As that variable is only defined in Org mode, I must make such a check
in `org-mode-hook' only (not anymore in `text-mode-hook'):

--8---cut here---start-8---
  (add-hook 'org-mode-hook
(lambda ()
  (unless (and (boundp 'org-babel-exp-reference-buffer)
   org-babel-exp-reference-buffer)
(message Turning on Flyspell in buffer `%s' (buffer-name))
(turn-on-flyspell
--8---cut here---end---8---

Hence, if I don't enable Flyspell anymore in Text mode, I don't have
Flyspelling for common text files (not in Org mode). Not what I want.

If I do enable Flyspell in Text mode, I'm back on square one: my problem
is not solved.

Am I missing something?

Best regards,
  Seb

-- 
Sebastien Vauban




Re: [O] [PATCH] Add catch-up all LaTeX errors

2014-03-26 Thread Francesco Pizzolante


Hi Nicolas,

Thanks for your answer.

 As an example, if you open the target PDF file with Adobe Reader and, in the
 meantime, you export your Org file again to PDF, you'll see that Org will
 tell
 you it's OK (Process Completed) while, if you look at the *Org PDF LaTeX
 Output* buffer, you'll see an error such as:

 ! I can't write on file `toto.pdf'.
 [...]

 The problem comes from the fact that Org just checks for a couple of error
 messages (defined in org-latex-known-errors) and report it's OK if it
 doesn't find those messages:

 Errors are not related to your problem. Actually, ox-latex.el uses
 a rather weak check to know if process was successful or not:

   (if (not (file-exists-p pdffile))
   (error (concat (format PDF file %s wasn't produced pdffile)
  (when errors (concat :  errors
 ...
 (message (concat Process completed
  (if (not errors) . (concat  with errors:  errors)

 IOW, it cannot tell the difference between a successful export and an
 export failure with an already existing PDFFILE.

This is not true as this code checks for the `errors' variable in all
cases. With an already existing PDFFILE, you will end up with this
message: 'Process completed with errors: ...'.

From my point of view, the issue comes from the fact that the `errors'
variable is not correctly filled in with errors from the LaTeX log file.

As you can see in the following code, we do not catch error lines
starting with '!' but *only* those starting with '! LaTeX...' and '!
Package...':

--8---cut here---start-8---
(defcustom org-latex-known-errors
  '((Reference.*?undefined .  [undefined reference])
(Citation.*?undefined .  [undefined citation])
(Undefined control sequence .  [undefined control sequence])
(^! LaTeX.*?Error .  [LaTeX error])
(^! Package.*?Error .  [package error])
(Runaway argument .  Runaway argument))
[...]
--8---cut here---end---8---

While the wikibooks reference
(http://en.wikibooks.org/wiki/LaTeX/Errors_and_Warnings) tells that to
be sure to catch *all* errors, we have to check for any line beginning
with '!'.

Then, in the case where the `errors' variable would effectively contain
any error from the log file, the code you mention above would work in
any case.

That's why I started with this patch (*and it works*):

---
 lisp/ox-latex.el |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 9262ded..2cffe38 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -862,7 +862,8 @@ logfiles to remove, set `org-latex-logfiles-extensions'.
 (Undefined control sequence .  [undefined control sequence])
 (^! LaTeX.*?Error .  [LaTeX error])
 (^! Package.*?Error .  [package error])
-(Runaway argument .  Runaway argument))
+(Runaway argument .  Runaway argument)
+(^!.* . [Unknown error]))
   Alist of regular expressions and associated messages for the user.
 The regular expressions are used to find possible errors in the
 log of a latex-run.
--
1.7.9

The only issue is that the error reporting is not really helpfull (as my
current patch only reports 'Unknown error' for any other error).

Any suggestion is welcome.

Best regards,
 Francesco




Re: [O] [PATCH] Write org variables into own R environment

2014-03-26 Thread Rainer M Krug
Aaron Ecay aarone...@gmail.com writes:

 Hi Rainer,

 This patch looks very promising.  (I have not had a chance to test the
 implementation yet).  

Thanks - please let me know as soon as you tested it.

 One issue might be the name of the “org” variable
 – maybe this should instead be “.org” or “_org” to lessen the chance of
 stomping on pre-existing variables named “org” in people’s code.

Agreed here. .org would be a tricky solution, because it is hidden -
advantage or disadvantage? Probably a disadvantage. I will rename it to 
_org_variables_ which is likely to be unique.

Do you think it would be worth to have a check along the lines of 

if(class(_org_variables_)!=environment) {
  stop(_org_variables_ is already defined )
} else {
  ...
}

or to make the name user definable?

A different thing which I am using at the moment is to save the
environment so that it can be easily distributed along the tangled code
*if all variables are defined at the beginning and not per code block*.

Another option I am thinking about is to provide the possibility to
store not only variables, but also R function - useful? Effectively a
kind of R package light for org-mode?


 Thanks (also for your previous patch for handling in graphics blocks),

Pleasure - Thanks that they are useful.

Rainer

 --
 Aaron Ecay



-- 
Rainer M. Krug
email: Raineratkrugsdotde
PGP: 0x0F52F982


pgpuWbiisoAOa.pgp
Description: PGP signature


Re: [O] [PATCH] Add catch-up all LaTeX errors

2014-03-26 Thread Nicolas Goaziou


Francesco Pizzolante f...@missioncriticalit.com writes:

 IOW, it cannot tell the difference between a successful export and an
 export failure with an already existing PDFFILE.

 This is not true as this code checks for the `errors' variable in all
 cases. With an already existing PDFFILE, you will end up with this
 message: 'Process completed with errors: ...'.

If file.pdf exists before the export, you will always get Process
completed, even if the current export was a total failure (e.g., no
file produced).

IIUC, you're really looking after a way to know if a pdf file was really
produced. Reporting Process completed with errors : [unknown error]
will certainly not help on this you because some errors are not fatal
(i.e., they are skipped and the pdf file is still produced).

 From my point of view, the issue comes from the fact that the `errors'
 variable is not correctly filled in with errors from the LaTeX log file.

[...]

 While the wikibooks reference
 (http://en.wikibooks.org/wiki/LaTeX/Errors_and_Warnings) tells that to
 be sure to catch *all* errors, we have to check for any line beginning
 with '!'.

I agree, but this is not sufficient, see below.

 Then, in the case where the `errors' variable would effectively contain
 any error from the log file, the code you mention above would work in
 any case.

 That's why I started with this patch (*and it works*):

It depends on what you define as working. We're talking about two
different things. I think a better error system should report:

  1. a PDF file not produced (or updated),
  2. a PDF file produced with errors,
  3. a PDF file produced with warnings (maybe),
  4. a PDF file produced cleanly.

4 already works. Your patch improves 2, but 1 is still wrong.


Regards,

-- 
Nicolas Goaziou




Re: [O] Unconditionally turn off Flyspell mode during export

2014-03-26 Thread Nick Dokos
Sebastien Vauban sva-n...@mygooglest.com
writes:

 Hello,

 I use Flyspell in all my text-mode and prog-mode buffers, hence as well
 in my Org mode buffers -- as they ultimately derive from Text mode.

 I do that with:

 (add-hook 'text-mode-hook
   (lambda ()
 (message Turning on Flyspell in buffer `%s' (buffer-name))
 (flyspell-mode 1)))

 Though, as you can see, that has the perverse impact that Flyspell gets
 called (even multiple times) during the export process, when creating
 copies of the source Org document:

 Turning on Flyspell in buffer `ecm.txt2'
 Turning on Flyspell in buffer `ecm.txt22'
 Turning on Flyspell in buffer ` *temp*'
 Turning on Flyspell in buffer `ecm.html'
 Saving file d:/ecm.html...
 Wrote d:/ecm.html

 Is it possible to *automatically disable Flyspell during the export*
 *process*, as it's completely useless (the export buffers are killed when
 the export is done) and eats useful CPU cycles?


Advise org-export-as with an `around' piece of advice where you set the
text-mode-hook to nil (or just delete the flyspell part) perhaps?

Untested.
-- 
Nick




[O] No link found on links in drawers

2014-03-26 Thread Karl Voit
Hi!

I am using custom links like [[photo:FirstnameLastname.jpg]] in my
contacts.org.

Those links stopped working recently. Whenever I try to click or C-c
C-c the link, I get user-error: No link found.

Same happens with file: links.

Both links work outside of my PROPERTIES drawer.

-- 
mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML to Org-mode:
get Memacs from https://github.com/novoid/Memacs 

https://github.com/novoid/extract_pdf_annotations_to_orgmode + more on github




Re: [O] bug: org-shiftmetaright fails to shift the last child

2014-03-26 Thread Samuel Wales
seems to work.  thank you.

On 3/25/14, Bastien b...@gnu.org wrote:
 Fixed again, thanks and sorry for this regression.

-- 
The Kafka Pandemic: http://thekafkapandemic.blogspot.com

The disease DOES progress.  MANY people have died from it.  And
ANYBODY can get it.

Denmark: free Karina Hansen NOW.



[O] Space in Exported Text

2014-03-26 Thread Esben Stien
If I f.ex make a beautiful table in org-mode: 

|-+-+---++-|
| foo | bar | xyzzy | hukarz | |
| qux | | corge | grault | garply waldo fred plugh |
| baz | |   || |
|-+-+---++-|

 , it's not so beautiful anymore if I send it in an email.

Is it not possible to force these spacings as space?

I guess this is gnus fault, but I'm not really sure.

-- 
Esben Stien is b0ef@e s  a 
 http://www. s tn m
  irc://irc.  b  -  i  .   e/%23contact
   sip:b0ef@   e e 
   jid:b0ef@n n



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

2014-03-26 Thread Thomas S. Dye
Alan Schmitt alan.schm...@polytechnique.org writes:

 I usually export in offline mode, so I can keep editing while the export
 is going on.

If you and your colleagues export asynchronously, then the document
class (and other environment changes) can be placed in an initialization
file for the asynchronous process.

An approach that I'm exploring tangles this initialization file from
code that is kept in a noexport section of the document.  See
http://orgmode.org/worg/exporters/plos-one-template-worg.html for an
example that likely can be improved.

hth,
Tom

-- 
Thomas S. Dye
http://www.tsdye.com



Re: [O] [PATCH] Add catch-up all LaTeX errors

2014-03-26 Thread Sebastien Vauban
Nicolas Goaziou wrote:
 Francesco Pizzolante f...@missioncriticalit.com writes:

 IOW, it cannot tell the difference between a successful export and an
 export failure with an already existing PDFFILE.

 This is not true as this code checks for the `errors' variable in all
 cases. With an already existing PDFFILE, you will end up with this
 message: 'Process completed with errors: ...'.

 If file.pdf exists before the export, you will always get Process
 completed, even if the current export was a total failure (e.g., no
 file produced).

 IIUC, you're really looking after a way to know if a pdf file was really
 produced. Reporting Process completed with errors : [unknown error]
 will certainly not help on this you because some errors are not fatal
 (i.e., they are skipped and the pdf file is still produced).

 From my point of view, the issue comes from the fact that the `errors'
 variable is not correctly filled in with errors from the LaTeX log file.

 [...]

 While the wikibooks reference
 (http://en.wikibooks.org/wiki/LaTeX/Errors_and_Warnings) tells that to
 be sure to catch *all* errors, we have to check for any line beginning
 with '!'.

 I agree, but this is not sufficient, see below.

 Then, in the case where the `errors' variable would effectively contain
 any error from the log file, the code you mention above would work in
 any case.

 That's why I started with this patch (*and it works*):

 It depends on what you define as working. We're talking about two
 different things. I think a better error system should report:

   1. a PDF file not produced (or updated),
   2. a PDF file produced with errors,
   3. a PDF file produced with warnings (maybe),
   4. a PDF file produced cleanly.

 4 already works. Your patch improves 2, but 1 is still wrong.

FWIW, I'm using this in some export code I have:

--8---cut here---start-8---
  (let* ((orgfile (buffer-file-name))
 (base-name (file-name-base orgfile))
 (htmlfile (concat base-name .html))
 (pdffile (concat base-name .pdf)))
  ...
  (when (file-exists-p pdffile)
(if (file-newer-than-file-p orgfile pdffile)
  (org-latex-export-to-pdf)
  (message PDF is up to date with Org file
--8---cut here---end---8---

That way, we know if the PDF file has been (re-)produced: it must be
newer than the Org file...

Best regards,
  Seb

-- 
Sebastien Vauban




Re: [O] Space in Exported Text

2014-03-26 Thread Ken Mankoff

On 2014-03-26 at 14:32, Esben Stien wrote:
 If I f.ex make a beautiful table in org-mode: 

 |-+-+---++-|
 | foo | bar | xyzzy | hukarz | |
 | qux | | corge | grault | garply waldo fred plugh |
 | baz | |   || |
 |-+-+---++-|

  , it's not so beautiful anymore if I send it in an email.

 Is it not possible to force these spacings as space?

 I guess this is gnus fault, but I'm not really sure.

Looks perfect to me. I'm using fixed-width font in my email
client. Changing tabs to spaces won't solve bad looking tables because
most people use variable-width fonts. Nothing you can do about that.

You can also use mu4e and compose emails in an Org minor-mode
(includes babel and everything!) and convert emails to HTML when sent
(and include a plain-text copy too). I think that would be the best
bet of having a table look good to the recipient. See Org Mode
Example section at bottom of
http://www.brool.com/index.php/using-mu4e 

  -k.




Re: [O] Space in Exported Text

2014-03-26 Thread William Denton

On 26 March 2014, Esben Stien wrote:


|-+-+---++-|
| foo | bar | xyzzy | hukarz | |
| qux | | corge | grault | garply waldo fred plugh |
| baz | |   || |
|-+-+---++-|

, it's not so beautiful anymore if I send it in an email.


It looks fine in my monospaced font---isn't it just a matter of formatting when 
you paste it into your preferred email client?


Bill
--
▮ William Denton ▮ Toronto, Canada ▮ http://www.miskatonic.org/ ▮


Re: [O] Bad footnotes when including org files

2014-03-26 Thread Xavier Garrido

Hi Nicolas,

Le 26/03/2014 15:41, Nicolas Goaziou a écrit :

Hello,

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


Thanks for your answer. Maybe I will try your solution. Otherwise
I will run a before-parse-hook to change fn:XX to something unique
(by adding buffer name for example.


We could do it by default.

One problem is that INCLUDE keyword is a very simple feature. For
example, if you include two files in a row and the first one ends with
a footnote section, the other one will be included in that section and,
therefore, not exported. So if we start to make it smart, we could be
tempted to add too many other checks.

Anyway, here's a patch for that.

WDYT?



Applied, tested and it works like a charm. I still have some issues with 
a very big book I am writing but at least on the small example I sent 
it solves the issues.


Thanks a lot,
Xavier




Re: [O] I need help extending ob-ocaml to support :results output

2014-03-26 Thread Alan Schmitt
Hello,

Here is a patch that allows for the output of ocaml babel blocks to be
captured. It also makes the parsing of the resulting value more robust:
results of type string list are now converted to a table, for
instance.

At the moment I only check for results of the form verbatim or
output (before this patch, only verbatim was possible). Results of
kind value are parsed as before (converted to a string, a number,
a table, or left as-is).

Please don't hesitate to suggest improvements, to the code or to the
Changelog.

Thanks,

Alan

From bcc2fc7ae0e4d099481af229a79b06ae9a160f14 Mon Sep 17 00:00:00 2001
From: Alan Schmitt alan.schm...@polytechnique.org
Date: Wed, 26 Mar 2014 22:23:53 +0100
Subject: [PATCH] ob-ocaml.el: Clean up babel evaluation of ocaml blocks

* ob-ocaml.el (org-babel-execute:ocaml): Capture the output, type, and
value when evaluating ocaml blocks. Return the one requested by
`results'.

(org-babel-ocaml-parse-output): Change the signature to take a type
and a value. Make the parsing of the type more robust.
---
 lisp/ob-ocaml.el | 55 +++
 1 file changed, 31 insertions(+), 24 deletions(-)

diff --git a/lisp/ob-ocaml.el b/lisp/ob-ocaml.el
index 1f29a25..b7ef2d1 100644
--- a/lisp/ob-ocaml.el
+++ b/lisp/ob-ocaml.el
@@ -79,16 +79,24 @@
 	 (progn (setq out nil) line)
    (when (string-match re line)
 	 (progn (setq out t) nil
-   (mapcar #'org-babel-trim (reverse raw
+   (mapcar #'org-babel-trim (reverse raw)))
+	 (raw (org-babel-trim clean))
+	 (result-params (cdr (assoc :result-params params)))
+	 (parsed 
+	  (string-match 
+	   \\(\\(.*\n\\)*\\)[^:\n]+ : \\([^=\n]+\\) =\\(\n\\| \\)\\(.+\\)$ 
+	   raw))
+	 (output (match-string 1 raw))
+	 (type (match-string 3 raw))
+	 (value (match-string 5 raw))
+	 )
 (org-babel-reassemble-table
- (let ((raw (org-babel-trim clean))
-	   (result-params (cdr (assoc :result-params params
-   (org-babel-result-cond result-params
-	 ;; strip type information from output unless verbatim is specified
-	 (if (and (not (member verbatim result-params))
-		  (string-match = \\(.+\\)$ raw))
-	 (match-string 1 raw) raw)
-	 (org-babel-ocaml-parse-output raw)))
+ (org-babel-result-cond result-params
+   (cond
+	((member verbatim result-params) raw)
+	((member output result-params) output)
+	(t raw))
+   (org-babel-ocaml-parse-output value type))
  (org-babel-pick-name
   (cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
  (org-babel-pick-name
@@ -121,21 +129,20 @@
   (concat [| (mapconcat #'org-babel-ocaml-elisp-to-ocaml val ; ) |])
 (format %S val)))
 
-(defun org-babel-ocaml-parse-output (output)
-  Parse OUTPUT.
-OUTPUT is string output from an ocaml process.
-  (let ((regexp [^:]+ : %s = \\(.+\\)$))
-(cond
- ((string-match (format regexp string) output)
-  (org-babel-read (match-string 1 output)))
- ((or (string-match (format regexp int) output)
-  (string-match (format regexp float) output))
-  (string-to-number (match-string 1 output)))
- ((string-match (format regexp list) output)
-  (org-babel-ocaml-read-list (match-string 1 output)))
- ((string-match (format regexp array) output)
-  (org-babel-ocaml-read-array (match-string 1 output)))
- (t (message don't recognize type of %s output) output
+(defun org-babel-ocaml-parse-output (value type)
+  Parse VALUE of type TYPE.
+VALUE and TYPE are string output from an ocaml process.
+  (cond
+   ((string= string type)
+(org-babel-read value))
+   ((or (string= int type)
+	(string= float type))
+(string-to-number value))
+   ((string-match list type)
+(org-babel-ocaml-read-list value))
+   ((string-match array type)
+(org-babel-ocaml-read-array value))
+   (t (message don't recognize type %s type) value)))
 
 (defun org-babel-ocaml-read-list (results)
   Convert RESULTS into an elisp table or string.
-- 
1.8.5.3



[O] Org-default face?

2014-03-26 Thread Sebastien Vauban
Hello,

Some time ago, the flowing text inside Org buffers was rendered in the
`org-default' face.

It isn't the case anymore.  Is it a bug on my side?

Best regards,
  Seb

-- 
Sebastien Vauban




[O] Chaining strings between babel blocks: why so many '\'?

2014-03-26 Thread Alan Schmitt
Hello,

I've been playing with block chaining to generate some dot file then to
export then as images. I had a little trouble finding the number of '\'
I need to put in front of a quote if I want the quote to be quoted. Here
is a way to make it work:

--8---cut here---start-8---
#+name: foo
#+begin_src emacs-lisp :exports none
bar [label = \\test1\\]\nbaz [label = \\test2\\]
#+end_src

#+results: foo
: bar [label = \\test1\\]
: baz [label = \\test2\\]

#+begin_src dot :file ~/tmp/test-dot.png :var input=foo :exports results
graph {
  $input
}
#+end_src
--8---cut here---end---8---

My question is: why can't I simply use this:

--8---cut here---start-8---
#+name: foo
#+begin_src emacs-lisp :exports none
bar [label = test1]\nbaz [label = test2]
#+end_src

#+results: foo
: bar [label = \test1\]
: baz [label = \test2\]
--8---cut here---end---8---

(I guess the answer is in the error in replace-regexp-in-string:
(error Invalid use of `\\' in replacement text)
.)

Would it be problematic to first transform every \\ into a  in
org-babel-expand-body:dot, before the call to replace-regexp-in-string?

Thanks,

Alan



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

2014-03-26 Thread Alan Schmitt
Hello Tom,

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

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

 I usually export in offline mode, so I can keep editing while the export
 is going on.

 If you and your colleagues export asynchronously, then the document
 class (and other environment changes) can be placed in an initialization
 file for the asynchronous process.

 An approach that I'm exploring tangles this initialization file from
 code that is kept in a noexport section of the document.  See
 http://orgmode.org/worg/exporters/plos-one-template-worg.html for an
 example that likely can be improved.

This would clearly make our export process more robust and reproducible.
Thanks a lot for the link, I'll look into it.

Alan



Re: [O] Chaining strings between babel blocks: why so many '\'?

2014-03-26 Thread Nicolas Goaziou
Hello,

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

 I've been playing with block chaining to generate some dot file then to
 export then as images. I had a little trouble finding the number of '\'
 I need to put in front of a quote if I want the quote to be quoted. Here
 is a way to make it work:

 #+name: foo
 #+begin_src emacs-lisp :exports none
 bar [label = \\test1\\]\nbaz [label = \\test2\\]
 #+end_src

 #+results: foo
 : bar [label = \\test1\\]
 : baz [label = \\test2\\]

 #+begin_src dot :file ~/tmp/test-dot.png :var input=foo :exports results
 graph {
   $input
 }
 #+end_src

 My question is: why can't I simply use this:

 #+name: foo
 #+begin_src emacs-lisp :exports none
 bar [label = test1]\nbaz [label = test2]
 #+end_src

 #+results: foo
 : bar [label = \test1\]
 : baz [label = \test2\]

 (I guess the answer is in the error in replace-regexp-in-string:
 (error Invalid use of `\\' in replacement text)
 .)

Indeed. This function, unless told not to, treats backslashes characters
specially.

 Would it be problematic to first transform every \\ into a  in
 org-babel-expand-body:dot, before the call to
 replace-regexp-in-string?

I think `replace-regexp-in-string' should be called with a non-nil
LITERAL argument in this case.


Regards,

-- 
Nicolas Goaziou



Re: [O] [PATCH] Add catch-up all LaTeX errors

2014-03-26 Thread Charles Millar

Nicolas Goaziou wrote:



Hello,


Nicholas and Francesco,


Francesco Pizzolante
fpz-djc/ipccudyqhejpep6iedvlejwur...@public.gmane.org writes:


The issue is the fact that, when exporting to PDF, in some cases, Org tells
that the export has been done successfully while the PDF file has not been
produced!

As an example, if you open the target PDF file with Adobe Reader and, in the
meantime, you export your Org file again to PDF, you'll see that Org will tell
you it's OK (Process Completed) while, if you look at the *Org PDF LaTeX
Output* buffer, you'll see an error such as:

! I can't write on file `toto.pdf'.
[...]

The problem comes from the fact that Org just checks for a couple of error
messages (defined in org-latex-known-errors) and report it's OK if it doesn't
find those messages:


Errors are not related to your problem. Actually, ox-latex.el uses
a rather weak check to know if process was successful or not:

   (if (not (file-exists-p pdffile))
   (error (concat (format PDF file %s wasn't produced pdffile)
  (when errors (concat :  errors
 ...
 (message (concat Process completed
  (if (not errors) . (concat  with errors:  errors)


First, I have subsequent messages in this thread and the discussion.

Should Nick's observation, that


IOW, it cannot tell the difference between a successful export and an
export failure with an already existing PDF



also include the qualification that the existing PDF file is also opened 
at the time of the second export? I base this on Francesco's example 
above and the following.


I usually export a subtree to LaTeX as PDF file and open. If I make 
small corrections to the subtree and export again, AND forget to close 
the PDF file that is already opened from the earlier export, Org reports 
a successful export; however, the revised exported PDF does not exist. 
(Also I use EXPORT_FILE_NAME: in PROPERTIES as the top of the subtree.)


If I remember to close the first exported PDF, the revised subtree 
exports OK.


I'm just curious, does the problem exist iff the pdf, that is to be 
replaced, is opened?


Charlie Millar





Re: [O] How to write a org babel hook, which can manupulate result

2014-03-26 Thread Feng Shu
Daimrod daim...@gmail.com writes:

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

 Hi:
 Hi Feng,

 Look at the :post header argument.
 (info (org) post)

Thanks ...

 I want to write a hook to menupulate org babel output,
 The problem is: How can I get two points info: [pointA] and [pointB]
 in my hook function?

 #+begin_src R :results output raw drawer
 tbl - data.frame(a=c(1,2,3),b=c(3,2,1))
 print(ascii(tbl),type=org)
 #+END_SRC

 #+RESULTS:
 :RESULTS:
 [pointA]
 |   |a |b |
 |---+--+--|
 | 1 | 1.00 | 3.00 |
 | 2 | 2.00 | 2.00 |
 | 3 | 3.00 | 1.00 |
 [pointB]
 :END:

-- 




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] Chaining strings between babel blocks: why so many '\'?

2014-03-26 Thread Peter Neilson
On Wed, 26 Mar 2014 18:19:35 -0400, Nicolas Goaziou n.goaz...@gmail.com  
wrote:



Hello,

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


I've been playing with block chaining to generate some dot file then to
export then as images. I had a little trouble finding the number of '\'
I need to put in front of a quote if I want the quote to be quoted. Here
is a way to make it work:

#+name: foo
#+begin_src emacs-lisp :exports none
bar [label = \\test1\\]\nbaz [label =  
\\test2\\]

#+end_src

#+results: foo
: bar [label = \\test1\\]
: baz [label = \\test2\\]

#+begin_src dot :file ~/tmp/test-dot.png :var input=foo :exports results
graph {
  $input
}
#+end_src

My question is: why can't I simply use this:

#+name: foo
#+begin_src emacs-lisp :exports none
bar [label = test1]\nbaz [label = test2]
#+end_src

#+results: foo
: bar [label = \test1\]
: baz [label = \test2\]

(I guess the answer is in the error in replace-regexp-in-string:
(error Invalid use of `\\' in replacement text)
.)


Indeed. This function, unless told not to, treats backslashes characters
specially.


Would it be problematic to first transform every \\ into a  in
org-babel-expand-body:dot, before the call to
replace-regexp-in-string?


I think `replace-regexp-in-string' should be called with a non-nil
LITERAL argument in this case.


Maybe someone (neilson runs and hides!) should write a tool that allows  
construction of C++11-style raw string literals that would  
auto-transmogrify into the backslash mess that elisp requires.




Re: [O] How to write a org babel hook, which can manupulate result

2014-03-26 Thread Feng Shu
Daimrod daim...@gmail.com writes:

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

 Hi:
 Hi Feng,

 Look at the :post header argument.
 (info (org) post)

How to use elisp in :post directly,
for example:

#+begin_src R :results output raw drawer :post (align-multi-table)
  content
#+end_src

#+begin_comment
(defun align-multi-table (optional content)
  (interactive)
  (let ((content (or content *this*)))
(with-temp-buffer
  (insert content)
  (goto-char (point-min))
  (while (not (eobp))
(when (org-at-table-p)
  (org-table-align))
(forward-line))
  (buffer-string
#+end_comment


 I want to write a hook to menupulate org babel output,
 The problem is: How can I get two points info: [pointA] and [pointB]
 in my hook function?

 #+begin_src R :results output raw drawer
 tbl - data.frame(a=c(1,2,3),b=c(3,2,1))
 print(ascii(tbl),type=org)
 #+END_SRC

 #+RESULTS:
 :RESULTS:
 [pointA]
 |   |a |b |
 |---+--+--|
 | 1 | 1.00 | 3.00 |
 | 2 | 2.00 | 2.00 |
 | 3 | 3.00 | 1.00 |
 [pointB]
 :END:

-- 




Re: [O] Space in Exported Text

2014-03-26 Thread Esben Stien
Ken Mankoff mank...@gmail.com writes:

 Looks perfect to me. 

Yeah, it seems it's because of non mono font, but I didn't think it
would be that drastic difference. 

, but I confirmed it, by copying something I sent to a person with a
gmail account into my emacs and it was perfect again. 

I guess this issue doesn't really have a solution, other than sending it
as html. 

-- 
Esben Stien is b0ef@e s  a 
 http://www. s tn m
  irc://irc.  b  -  i  .   e/%23contact
   sip:b0ef@   e e 
   jid:b0ef@n n



[O] Export Org checkboxes in ox-html using UTF-8 symbols

2014-03-26 Thread Grant Rettke
Hi,

Sacha Chua made a nice hack to export checkboxes as unicode symbols to
HTML here:

http://sachachua.com/blog/2014/03/emacs-tweaks-export-org-checkboxes-using-utf-8-symbols/?shareadraft=baba27119_533313c944f64

(defun sacha/org-html-checkbox (checkbox)
  Format CHECKBOX into HTML.
  (case checkbox (on span class=\check\#x2611;/span) ;
checkbox (checked)
(off span class=\checkbox\#x2610;/span)
(trans code[-]/code)
(t )))
(defadvice org-html-checkbox (around sacha activate)
  (setq ad-return-value (sacha/org-html-checkbox (ad-get-arg 0

Thanks Sacha.

Regards,

Grant Rettke | AAAS, ACM, AMA, COG, IEEE, Sigma Xi
gret...@acm.org | http://www.wisdomandwonder.com/
“Wisdom begins in wonder.” --Socrates
((λ (x) (x x)) (λ (x) (x x)))
“Life has become immeasurably better since I have been forced to stop
taking it seriously.” --Thompson



Re: [O] How to write a org babel hook, which can manupulate result

2014-03-26 Thread Daimrod
Feng Shu tuma...@gmail.com writes:

 Daimrod daim...@gmail.com writes:

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

 Hi:
 Hi Feng,

 Look at the :post header argument.
 (info (org) post)

 How to use elisp in :post directly,

I don't think you can.

You have to use it this way (not tested):

#+NAME: align-multi-table
#+BEGIN_SRC emacs-lisp :var content=nil :results raw
  (align-multi-table content)
#+END_SRC
#+begin_src R :results output raw drawer :post align-multi-table(content=*this*)
  content
#+end_src

 for example:

 #+begin_src R :results output raw drawer :post (align-multi-table)
   content
 #+end_src
 #+begin_comment
 (defun align-multi-table (optional content)
   (interactive)
   (let ((content (or content *this*)))
 (with-temp-buffer
   (insert content)
   (goto-char (point-min))
   (while (not (eobp))
   (when (org-at-table-p)
 (org-table-align))
   (forward-line))
   (buffer-string
 #+end_comment


 I want to write a hook to menupulate org babel output,
 The problem is: How can I get two points info: [pointA] and [pointB]
 in my hook function?

 #+begin_src R :results output raw drawer
 tbl - data.frame(a=c(1,2,3),b=c(3,2,1))
 print(ascii(tbl),type=org)
 #+END_SRC

 #+RESULTS:
 :RESULTS:
 [pointA]
 |   |a |b |
 |---+--+--|
 | 1 | 1.00 | 3.00 |
 | 2 | 2.00 | 2.00 |
 | 3 | 3.00 | 1.00 |
 [pointB]
 :END:

-- 
Daimrod/Greg



Re: [O] org-babel R output table with plot

2014-03-26 Thread John Hendy
On Mon, Mar 24, 2014 at 7:00 PM, Feng Shu tuma...@gmail.com wrote:
 John Hendy jw.he...@gmail.com writes:

 On Mon, Mar 24, 2014 at 10:22 AM, Feng Shu tuma...@gmail.com wrote:
 Hi everyone

 I want to R output table with plot, I use a solution below,
 Who can tell me other solutions?


 I sort of follow the below, but I think it would be more helpful to
 describe what you *don't* like about the output below. In other words,
 what are you trying to achieve that is not working below?


 It just suit my need, but I want to know more simper solution, which let
 me type less code.

Hmmm. Not seeing a ton of ways to optimize, but it might depend on
your total usage scenario. How many of these types of table/plot
combinations are you creating? Just a couple sets, or a lot?

The plot command is the only one that looks inefficient since a babel
block with :file header would automate opening/closing a device... If
you defined your data.frame in another babel block and used the
:session argument, you could do something like this:

#+name: plot
#+header: :file /path/to/file.png :width 1600 :height 900 :res 200
#+begin_src R :session r :exports results :results output graphics

plot(data)

#+end_src

After that executes, you'll end up with a named results block which
you can manually add the #+caption to? I typically use something like
the above. Your solution is nice as one could add things like
#+attr_latex or #+begin/end_center code via the paste() function in
R... while mine saves having to manually do pnt(); plot(); dev.off().

Another option might be to generate all your plots in a loop, perhaps,
and then stick to just programmatically including them with Org
syntax? I essentially did that here:
- http://lists.gnu.org/archive/html/emacs-orgmode/2012-08/msg01167.html

Not really much different than what your'e doing, though, I suppose.
It would just scale nicely if you have various data sets and always
generate a table and plot from them all. Then you could create your
data.frames in a list and then lapply() through them with each of your
functions, printing the proper Org syntax as the result (with :results
drawer, as you're already using).

This thread also came to mind, as I was reusing lines like you are,
and keeping them in separate babel blocks. I got the suggestion to
call a named block, which might be of interest if you've not done that
before?
- General use: https://www.mail-archive.com/emacs-orgmode@gnu.org/msg56684.html
- Using a #+call line:
https://www.mail-archive.com/emacs-orgmode@gnu.org/msg56688.html


Sorry I can't be of more help!

John



Re: [O] Space in Exported Text

2014-03-26 Thread Samuel Wales
tell him or her to click on show original.

or export to tsv, which will sometimes work.



[O] if we operate on a subtree, perhaps we could adjust levels

2014-03-26 Thread Samuel Wales
in maint, if you encrypt with org-crypt on an entry with children, then
demote, then decrypt, the subtree levels do not match up.
for example, the children can end up as uncle/aunt nodes.

maybe something like these are possibilities:

  1) optionally adjust subtree levels to match the location
 of the header at time of decryption.  this is similar
 to how org-yank behaves.  it would have to re-encrypt
 if you encrypt, demote, decrypt, encrypt.

  2) optionally put the subtree in an org source block so
 that it is no longer an active subtree (can't search
 headlines in agenda, they are not where they belong, can't export
as part of parent, have to edit with c-c ')

  3) restrict the function to only operate on body text
 (can't do subtrees).

  4) status quo (allow outline corruption at user's risk).

  5) a combination.

maybe there are more possibilities.

comments?

samuel



Re: [O] org-babel R output table with plot

2014-03-26 Thread Feng Shu
John Hendy jw.he...@gmail.com writes:

 On Mon, Mar 24, 2014 at 7:00 PM, Feng Shu tuma...@gmail.com wrote:
 John Hendy jw.he...@gmail.com writes:

 On Mon, Mar 24, 2014 at 10:22 AM, Feng Shu tuma...@gmail.com wrote:
 Hi everyone

 I want to R output table with plot, I use a solution below,
 Who can tell me other solutions?


 I sort of follow the below, but I think it would be more helpful to
 describe what you *don't* like about the output below. In other words,
 what are you trying to achieve that is not working below?


 It just suit my need, but I want to know more simper solution, which let
 me type less code.

 Hmmm. Not seeing a ton of ways to optimize, but it might depend on
 your total usage scenario. How many of these types of table/plot
 combinations are you creating? Just a couple sets, or a lot?

 The plot command is the only one that looks inefficient since a babel
 block with :file header would automate opening/closing a device... If
 you defined your data.frame in another babel block and used the
 :session argument, you could do something like this:
 #+name: plot
 #+header: :file /path/to/file.png :width 1600 :height 900 :res 200
 #+begin_src R :session r :exports results :results output graphics

 plot(data)

 #+end_src

 After that executes, you'll end up with a named results block which
 you can manually add the #+caption to? I typically use something like
 the above. Your solution is nice as one could add things like
 #+attr_latex or #+begin/end_center code via the paste() function in
 R... while mine saves having to manually do pnt(); plot(); dev.off().


 Another option might be to generate all your plots in a loop, perhaps,
 and then stick to just programmatically including them with Org
 syntax? I essentially did that here:
 - http://lists.gnu.org/archive/html/emacs-orgmode/2012-08/msg01167.html

 Not really much different than what your'e doing, though, I suppose.

 It would just scale nicely if you have various data sets and always
 generate a table and plot from them all. Then you could create your
 data.frames in a list and then lapply() through them with each of your
 functions, printing the proper Org syntax as the result (with :results
 drawer, as you're already using).

I use loop to generate multi tables.

There is a problem:  only the first table generated from current R src.
can be aligned correctly, which sometime is very annoy.

The below hook can align all the tables generate from R code:

#+begin_src elisp
(add-hook 'org-babel-after-execute-hook 'eh-org-babel-align-tables)

(defun eh-org-babel-align-tables (optional info)
  Align all tables in the result of the current source
  (interactive)
  (let ((location (org-babel-where-is-src-block-result nil info)))
(when location
  (save-excursion
(goto-char location)
(when (looking-at (concat org-babel-result-regexp .*$))
  (while ( (point) (progn (forward-line 1) (org-babel-result-end)))
(when (org-at-table-p)
  (toggle-truncate-lines 1)
  (org-table-align)
  (goto-char (org-table-end)))
(forward-line)))
#+end_src



 This thread also came to mind, as I was reusing lines like you are,
 and keeping them in separate babel blocks. I got the suggestion to
 call a named block, which might be of interest if you've not done that
 before?
 - General use: 
 https://www.mail-archive.com/emacs-orgmode@gnu.org/msg56684.html- Using a 
 #+call line:
 https://www.mail-archive.com/emacs-orgmode@gnu.org/msg56688.html


 Sorry I can't be of more help!

 John

-- 



Re: [O] How to write a org babel hook, which can manupulate result

2014-03-26 Thread Feng Shu
Daimrod daim...@gmail.com writes:

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

 Daimrod daim...@gmail.com writes:

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

 Hi:
 Hi Feng,

 Look at the :post header argument.
 (info (org) post)

 How to use elisp in :post directly,

 I don't think you can.

 You have to use it this way (not tested):
 #+NAME: align-multi-table
 #+BEGIN_SRC emacs-lisp :var content=nil :results raw
   (align-multi-table content)
 #+END_SRC
 #+begin_src R :results output raw drawer :post 
 align-multi-table(content=*this*)
   content
 #+end_src

I prefer using a hook function to do this job, The below is my hook:

#+begin_src elisp
(add-hook 'org-babel-after-execute-hook 'eh-org-babel-align-tables)

(defun eh-org-babel-align-tables (optional info)
  Align all tables in the result of the current source
  (interactive)
  (let ((location (org-babel-where-is-src-block-result nil info)))
(when location
  (save-excursion
(goto-char location)
(when (looking-at (concat org-babel-result-regexp .*$))
  (while ( (point) (progn (forward-line 1) (org-babel-result-end)))
(when (org-at-table-p)
  (toggle-truncate-lines 1)
  (org-table-align)
  (goto-char (org-table-end)))
(forward-line)))
#+end_src



 for example:

 #+begin_src R :results output raw drawer :post (align-multi-table)
   content
 #+end_src
 #+begin_comment
 (defun align-multi-table (optional content)
   (interactive)
   (let ((content (or content *this*)))
 (with-temp-buffer
   (insert content)
   (goto-char (point-min))
   (while (not (eobp))
  (when (org-at-table-p)
(org-table-align))
  (forward-line))
   (buffer-string
 #+end_comment


 I want to write a hook to menupulate org babel output,
 The problem is: How can I get two points info: [pointA] and [pointB]
 in my hook function?

 #+begin_src R :results output raw drawer
 tbl - data.frame(a=c(1,2,3),b=c(3,2,1))
 print(ascii(tbl),type=org)
 #+END_SRC

 #+RESULTS:
 :RESULTS:
 [pointA]
 |   |a |b |
 |---+--+--|
 | 1 | 1.00 | 3.00 |
 | 2 | 2.00 | 2.00 |
 | 3 | 3.00 | 1.00 |
 [pointB]
 :END:

--