Re: [O] babel: ob-C with Visual C++ and compilation-mode

2014-08-28 Thread Eric Schulte
Ernesto Durante stobos...@gmail.com writes:

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

 Ernesto Durante stobos...@gmail.com writes:

 Perhaps a new header argument should be added for C-Family languages
 which will inhibit this main wrapping behavior?

 -- Eric

 Hi Eric,

 According to me, we can already inhibit the wrapping with the following
 header :main no. Maybe, it should be the default behavior ?


Oh, great.  I don't think we should change the default.  It is easy to
customize the value of this header argument, and the default should be
targeted at ease of use for first timers, which I believe means doing
something useful even for code blocks without an explicit main.

Best,
Eric



 Best
 Ernesto

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] [PATCH] babel: ob-C with Visual C++ and compilation-mode

2014-08-28 Thread Eric Schulte
Ernesto Durante stobos...@gmail.com writes:

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

 Hi Eric,

 You will find in attachment three patches


Hi Ernesto,

Thank you for sending these along, they look great.


 + First patch, modify org-babel-eval to load compilation-mode in case
of errors


Applied.


 + Second patch, modify org-babel-eval to deal with Microsoft visual
 C++ errors by concatenating the standard output with the standard error


Not applied.  I believe that concatenating STDOUT to STDERR for *every*
language simply because Microsoft Visual Studio does not correctly use
STDERR is not the correct approach here.  Perhaps a more tailored
solution may be possible for this problem which will not have global
effects.


 + Third patch, add to ob-C the missing function
org-babel-expand-body:cpp


Applied.

Thanks!
Eric


 Best
 Ernesto

 From 3e4f163a2b357c58a52b7811539ff4032d432aaf Mon Sep 17 00:00:00 2001
 From: Ernesto Durante edurante@localhost.localdomain
 Date: Mon, 25 Aug 2014 17:27:24 +0200
 Subject: [PATCH 1/3] org-babel-eval: compilation-mode to deal with errors in
  (C/C++/D)

 ---
  lisp/ob-eval.el | 6 ++
  1 file changed, 6 insertions(+)

 diff --git a/lisp/ob-eval.el b/lisp/ob-eval.el
 index 057590f..9fbbb42 100644
 --- a/lisp/ob-eval.el
 +++ b/lisp/ob-eval.el
 @@ -57,6 +57,12 @@ STDERR with `org-babel-eval-error-notify'.
 (progn
   (with-current-buffer err-buff
 (org-babel-eval-error-notify exit-code (buffer-string)))
 + (save-excursion
 +   (when (get-buffer org-babel-error-buffer-name)
 + (with-current-buffer org-babel-error-buffer-name
 +   (compilation-mode)
 +   ;;compilation-mode enforces read-only
 +   (read-only-mode 0
   nil)
   (buffer-string)
  
 -- 
 1.8.3.1

 From 9e306dbb39325998a5149840b229ffa802ec40e9 Mon Sep 17 00:00:00 2001
 From: Ernesto Durante edurante@localhost.localdomain
 Date: Mon, 25 Aug 2014 17:54:51 +0200
 Subject: [PATCH 2/3] org-babel-eval: showing Microsoft Visual C++ errors

 ---
  lisp/ob-eval.el | 27 +++
  1 file changed, 15 insertions(+), 12 deletions(-)

 diff --git a/lisp/ob-eval.el b/lisp/ob-eval.el
 index 9fbbb42..0e69583 100644
 --- a/lisp/ob-eval.el
 +++ b/lisp/ob-eval.el
 @@ -53,18 +53,21 @@ STDERR with `org-babel-eval-error-notify'.
(setq exit-code
   (org-babel--shell-command-on-region
(point-min) (point-max) cmd err-buff))
 -  (if (or (not (numberp exit-code)) ( exit-code 0))
 -   (progn
 - (with-current-buffer err-buff
 -   (org-babel-eval-error-notify exit-code (buffer-string)))
 - (save-excursion
 -   (when (get-buffer org-babel-error-buffer-name)
 - (with-current-buffer org-babel-error-buffer-name
 -   (compilation-mode)
 -   ;;compilation-mode enforces read-only
 -   (read-only-mode 0
 - nil)
 - (buffer-string)
 +  (let ((outb-str (buffer-string)))
 + ;;outb-str holds standard output + body
 + (if (or (not (numberp exit-code)) ( exit-code 0))
 + (progn
 +   (with-current-buffer err-buff
 + (org-babel-eval-error-notify exit-code
 +  (concat outb-str (buffer-string
 +   (save-excursion
 + (when (get-buffer org-babel-error-buffer-name)
 +   (with-current-buffer org-babel-error-buffer-name
 + (compilation-mode)
 + ;;compilation-mode enforces read-only
 + (read-only-mode 0
 +   nil)
 +   outb-str)
  
  (defun org-babel-eval-read-file (file)
Return the contents of FILE as a string.
 -- 
 1.8.3.1

 From c93e02a52d57a5eeb7b9b8aba04c6764f8122d5c Mon Sep 17 00:00:00 2001
 From: Ernesto Durante edurante@localhost.localdomain
 Date: Mon, 25 Aug 2014 18:16:01 +0200
 Subject: [PATCH 3/3] ob-C: fix missing function org-babel-expand-body:cpp

 ---
  lisp/ob-C.el | 5 +
  1 file changed, 5 insertions(+)

 diff --git a/lisp/ob-C.el b/lisp/ob-C.el
 index 2e146d4..076276e 100644
 --- a/lisp/ob-C.el
 +++ b/lisp/ob-C.el
 @@ -82,6 +82,11 @@ is currently being evaluated.)
  This function calls `org-babel-execute:C++'.
(org-babel-execute:C++ body params))
  
 +(defun org-babel-expand-body:cpp (body params)
 +  Expand a block of C++ code with org-babel according to it's
 +header arguments.
 +  (org-babel-expand-body:C++ body params))
 +
  (defun org-babel-execute:C++ (body params)
Execute a block of C++ code with org-babel.
  This function is called by `org-babel-execute-src-block'.

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] Running Node.js and exporting css.

2014-08-23 Thread Eric Schulte
Josh Berry tae...@gmail.com writes:

 Couple of weeks ago, I accidentally spammed the message board with several
 attempts to send up a couple of patches for some problems I was seeing.
  So, firstly, apologies for the spam.

 The two problems I was seeing were related to executing js using node.js,
 and exporting css with vendor properties.

 The node.js problem is that it will start putting in newlines if a
 structure is past some size.  I think this may be fixable by changing
 some settings in node.js, but it was also easy enough to change the regex
 to look past newlines in org.  An example of the problem can be seen by
 running the following

   #+BEGIN_SRC js
 return [[1, 2],[1, 2],[1, 2],[1, 2],[1, 2],[1, 2],[1,2]]
   #+END_SRC


 If you remove just one of the inner arrays, it will work as desired.


Thanks for the report Josh, I just pushed up an improved regexp for the
parsing of multi-line js results.

Best -- Eric


 The other problem is just as short.  Simply export the following when
 you have org-src-fontify-natively set.

   #+BEGIN_SRC css
 foo {
   -webkit-appearance: none;
 }
   #+END_SRC

 I cobbled a small change that seemed to fix that.

 At any rate, again apologies for the previous spam.  I didn't want to just
 respam immediately with an apology.

 Thanks!

 --
 josh


-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] babel: ob-C with Visual C++ and compilation-mode

2014-08-21 Thread Eric Schulte
Hi Ernesto,

This looks like a good change and I'd like to apply it.  Could you
re-submit this commit after doing the following.

1. ensure no lines go beyond 80 characters in length
2. remove all lines which include only closing parens
   (such lines are generally considered bad lisp style)
3. commit to your local git repository with git commit
4. format the patch with git format-patch

Thanks,
Eric

Ernesto Durante stobos...@gmail.com writes:

 Hi,

 I am using ob-C with gcc and Microsoft Visual C++. These two compilers
 have two different behaviours for outputting  errors. Gcc uses the
 standard error output and Visual C++ uses the regular output. 
 Under Windows, errors are not displayed because of the way
 org-babel-eval is coded. To work on both platforms, the standard
 output must be concatenated with the standard error.

 I modified the org-babel-eval in the following way.


 diff --git a/lisp/ob-eval.el b/lisp/ob-eval.el
 index 057590f..1a93460 100644
 --- a/lisp/ob-eval.el
 +++ b/lisp/ob-eval.el
 @@ -53,12 +53,20 @@ STDERR with `org-babel-eval-error-notify'.
(setq exit-code
   (org-babel--shell-command-on-region
(point-min) (point-max) cmd err-buff))
 -  (if (or (not (numberp exit-code)) ( exit-code 0))
 -   (progn
 - (with-current-buffer err-buff
 -   (org-babel-eval-error-notify exit-code (buffer-string)))
 - nil)
 - (buffer-string)
 + (let ((temp-buffer-str (buffer-string))) ;;temp-buffer-str holds 
 standard output + body
 +   (if (or (not (numberp exit-code)) ( exit-code 0))
 +   (progn
 + (with-current-buffer err-buff
 +   (org-babel-eval-error-notify exit-code (format %s%s 
 temp-buffer-str (buffer-string)))
 +   )
 + (save-excursion
 +   (when (get-buffer org-babel-error-buffer-name)
 + (with-current-buffer org-babel-error-buffer-name
 +   (compilation-mode)
 +   (read-only-mode 0)
 +   )))
 + nil)
 + temp-buffer-str)


 One suggestion. It will be nice to put the error buffer in
 compilation-mode, this way errors are highlighted and we can jump
 directly into the source code. I modified org-babel-eval to launch the
 compilation mode in case of errors. I also removed the read-only
 attribute, else the buffer content of org-babel-error-buffer-name cannot
 be erased.

 Clearly, it's not a good patch because org-babel-eval seems to be
 a core function in babel. Maybe for ob-C, this function should be
 replaced by a new function. 

 Thanks to everyone for orgmode and babel to exist. 

 Best
 Ernesto


-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] babel: ob-C with Visual C++ and compilation-mode

2014-08-21 Thread Eric Schulte
Ernesto Durante stobos...@gmail.com writes:

 Thierry Banel tbanelweb...@free.fr writes:

 I have identified a minor bug. When a source code block has the mode
 cpp, we cannot expand the code or more precisely the code is not
 expanded in the correct way because the following function is missing  

 (defun org-babel-expand-body:cpp (body params)
   Execute BODY according to PARAMS.This function calls 
 `org-babel-expand-body:C++'.
   (org-babel-expand-body:C++ body params))
 Thanks for reporting this ! You may consider submitting a patch for this
 bug. The comment Execute BODY ... should be changed to Expand BODY 


 Ok I will change the comment


I'd be happy to commit this patch after you make this change and
re-format with git format-patch.  Also, please consider filling out
the FSF copyright assignment paperwork, so that we may accept larger
patches from you in the future.

Thanks for you contributions!
Eric


 Best
 Ernesto
 You are very welcome
 Thierry

 Thank you Thierry for your answer and all the details. I really want to be a 
 contributor
 and help ob-C to improve (as well as can do a modest lisper).

 I tried to find a way to master Cx11 and babel is helping me a lot.
 I think babel can really accelerate learning and dissimation of C++.

 In this perspective, I have another very simple idea that I want to share
 with you. I find C++ too noisy. In the following piece of code
 I really find the presence of the main call and the return statement really 
 annoying and useless.

 #+begin_src C++ :includes '(iostream cassert) :results silent
 template typename T1, typename T2
 auto compose(T1 t1, T2 t2) - decltype(t1 + t2) { return t1+t2; }

 int main() {
  auto d=compose(std::string(ola),std::string(ciao)); //d's type is 
 std::string
  auto i=compose(4,2);
  assert(d== std::string(olaciao)  i==6);
 return 0
 }
 #+end_src


 We can remove it by letting ob-C do the work by modifying the function
 org-babel-C-ensure-main-wrap. Now the code looks (according to me) easier to 
 read

 #+begin_src C++ :includes '(iostream cassert) :results silent
 template typename T1, typename T2
 auto compose(T1 t1, T2 t2) - decltype(t1 + t2) { return t1+t2; }

 template 
 int compose(int t1,int t2) { return t1+t2; }

 main
 auto d=compose(std::string(ola),std::string(ciao)); //d's type is 
 std::string
 auto i=compose(4,2);
 assert(d== std::string(olaciao)  i==6);
 #+end_src

 What do you think ?

 Best
 Ernesto




-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] babel: ob-C with Visual C++ and compilation-mode

2014-08-21 Thread Eric Schulte
Ernesto Durante stobos...@gmail.com writes:

 Thierry Banel tbanelweb...@free.fr writes:

 Le 15/08/2014 19:22, Ernesto Durante a écrit :

 True.
 And to achieve that the :includes header tag was added:
 #+BEGIN_SRC C++ :includes stdio.h

 (Because otherwise a #include statement would end up in the main() function)

 For me this is already a questionable distortion of C++.

 The Emacs C++-mode does no attempt at hiding parts of a C++ file.
 It just display the file as it is, and that is good.

 Yes, you are right.


 This is far too complex for me.
 I will just write down the main() function rather than learning this
 extension.

 But of course, I am just one user among others.
 You are another user and you feel the need for this extension,
 and this should be taken into account.
 Try the extension for yourself, then share it, and see if others like it.

 Yes, you are right.


Perhaps a new header argument should be added for C-Family languages
which will inhibit this main wrapping behavior?

-- Eric


-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] R code block produces only partial output

2014-08-06 Thread Eric Schulte
Aaron Ecay aarone...@gmail.com writes:

 Hi Eric,

 2014ko abuztuak 5an, Eric Schulte-ek idatzi zuen:
 

 [...]

 I don't know.
 
 The Babel R support needs a dedicated maintainer.  This was a role Dan
 Davison originally filled.  I've partially filled in since, but as a
 *very* light R user I'm not the best person.

 I use babel’s R support (almost) every day for my work, and I know
 enough elisp to be getting along.  I’ve not had tons of time for
 org/emacs development lately, but I think I can make enough time to
 maintain ob-R.el.


That would be great, and a personal relief.  Perhaps you could begin
with a patch for the regexp issue in this thread?


 There are others who could probably do just as good (if not indeed
 better) a job.  Rainer’s name springs to mind as someone who has
 submitted several patches for ob-R lately, but there are probably
 others who I’m not calling to mind immediately.  I’d be happy to
 share with other willing volunteers, either as a joint maintainership
 or (perhaps preferably) alternating the position in a 3- to 6-month
 rota.

Yes, and some form of sharing would of course be great.  Multiple active
maintainers is better than just one.  I think the main thing is to have
someone who, in threads like this one with many good suggestions, will
take the initiative to move from discussion to a proposed patch, and
then to apply that patch down the line.

Thanks!
Eric

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] Org-mode extensions used to publish a dissertation

2014-08-06 Thread Eric Schulte
Rasmus ras...@gmx.us writes:

 Hi Eric,

 Thank you for sharing this.  I have hacks for many of the same things,
 but I'm sure I will find inspiration in your implementations as well
 when I read them more carefully.

 In particular the filters that operate directly on the tree seems
 interesting!  I have never really gotten into tree-manipulation.


With help on list I wrote one, and every subsequent filter has been a
simple extension from the first.  Hopefully those included herein will
be good models for future filters.

[...]

  8. TIKZ figure links

 Am I right to understand that the main use of this is automatically
 translating tikz figures into a format suitable for HTML?  The
 function is a bit long and I couldn't entirely grasp the functionality
 without reading the function in details.


See my reply to Joseph in this thread, hopefully it will clear this up.
This point is probably the most heavily influenced by personal
preference of all these points.


  9. Tie certain latex commands to the preceding word.

 Cool idea with the refs!

 I use something similar where I escape single space after points so
 that e.g. x becomes e.g.\ x.

 10. Fix emphasis in text export

 Good idea.

 Cheers,
 Rasmus

Best,
Eric

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] Org-mode extensions used to publish a dissertation

2014-08-06 Thread Eric Schulte
Joseph Vidal-Rosset joseph.vidal.ros...@gmail.com writes:

 Many thanks Eric for this email and the attachment.

 Of course it is very useful.

 2014-08-05 2:23 GMT+02:00 Eric Schulte schulte.e...@gmail.com:

 Hi List,

 I thoroughly enjoyed using Org-mode to write my dissertation.  I was
 happy to be able to export (mostly) equivalent versions of the document
 to HTML and PDF.  I'd recommend using Org-mode for such a complex
 writing task to those who are either willing to hack the exporter, or
 are willing to accept an Org-mode document with inline LaTeX which only
 /really/ works with the LaTeX backend.

 As I fall in the former category, here are the small extensions to the
 Org-mode exporter which I found necessary.  Thanks to the new exporting
 backend they were uniformly easy to implement.  They are included in the
 attached elisp file.  Each pagefeed (^L) in the file marks a new section
 of functionality, the sections are as follows...

  1. Ignore Headlines and keep content (discussed here recently)
  2. Multi-column Table Cells
  3. Wide tables extend into the margins.
  4. Wide tables squeezed within the margins
  5. sc links for the \sc{} latex command
  6. gls links for the \gls{} family of Glossary commands
  7. color links
  8. TIKZ figure links
  9. Tie certain latex commands to the preceding word.
 10. Fix emphasis in text export

 A simplified version of my Makefile is also attached.  I hope someone
 finds this useful.

 Best,
 Eric


 Can you tell us how using the Makefile in order to test all these functions
 for a dissertation?

The Makefile and the code do not need to be used together.

 I am especially interested by points 2 and 8.


For point 2 try adding the following above a wide table in an Org-mode
document (after evaluating the code).

  #+ATTR_LaTeX: :environment wide

On export this should allow your table to cut into the page margins
(note: for my school I later had to undo this as there were strict rules
about margins in dissertations).

Point 8 is a little more involved.  I prefer to convert my TIKZ figures
to svg for HTML export, and keep them as raw tikz for LaTeX export.  I
found that the easiest way to do this (for me at least), was to keep the
figures in external .tex files.  I would then manually generate an svg
version of these files using the tex2svg script (attached).  With these
files on hand, the code in Point 8 will export Org-mode text like the
following.

  #+name: llvm-mutation
  #+Caption[LLVM Transformations]: Illustration of transformations over LLVM 
IR.  These transformations require that the SSA data dependency graph be 
repaired after each mutation.
  #+TIKZ_Figure: llvm-mutation

so that the file llvm-mutation.tex is included in LaTeX export wrapped
in a figure, and the file llvm-mutation.svg is included as an image in
HTML export.

Best,
Eric

#!/bin/bash
#
# Usage: tex2svg [source.tex]
#
#Generate an SVG file from a snippet of LaTeX source code.
#The tex source should not be wrapped in begin/end{document}.
#
# Example Usage:
#
# $ cat tree.tex
# \usetikzlibrary{trees}
# \begin{tikzpicture}
#   \node [circle, draw, fill=red!20] at (0,0) {1}
#   child { node [circle, draw, fill=blue!30] {2}
# child { node [circle, draw, fill=green!30] {3} }
# child { node [circle, draw, fill=yellow!30] {4} }};
# \end{tikzpicture}
#
# $ ./tex2svg tree.tex
#
# $ file tree.svg
# tree.svg: SVG Scalable Vector Graphics image
#
PACKAGES=('[usenames]{color}' '{tikz}' '{color}' '{listings}' '{amsmath}' '{fancyvrb}' '{soul}')

PREAMBLE=$(cat EOF
\documentclass[preview]{standalone}
\def\pgfsysdriver{pgfsys-tex4ht.def}
$(for pack in ${PACKAGES[@]};do echo \\usepackage$pack; done)
\usepackage{algorithmic}
\usepackage{amsmath}
\usepackage{adjustbox}
\usepackage{fancyvrb}
\usepackage{booktabs}
\usepackage{xcolor}
\usepackage{hyperref}
\usepackage{changepage}
\usepackage{graphicx}
\DeclareGraphicsExtensions{.pdf,.png,.jpg,.JPG}
\begin{document}
EOF
)
POSTAMBLE=$(cat EOF
\end{document}
EOF
)

FIG=$1; shift;
BASE=$(basename $FIG .tex)
TMPFILE=$(mktemp).tex
TMPBASE=`basename $TMPFILE .tex`
TMPDIR=`dirname $TMPFILE`
cp $@ $TMPDIR

function exit_hook (){ rm -f $TMPBASE* $TMPFILE*; exit 0; }
trap exit_hook EXIT

cat EOF  $TMPFILE
$PREAMBLE
$(cat $FIG|sed 's/\\subcaption{.*}//')
$POSTAMBLE
EOF
htlatex $TMPFILE  rm $TMPFILE
if [ -f $TMPBASE-1.svg ];then
# scour -i $TMPBASE-1.svg -o $BASE.svg \
# || cp $TMPBASE-1.svg $BASE.svg
cp $TMPBASE-1.svg $BASE.svg
echo $BASE.svg
else
cp $TMPBASE.html $BASE.html
echo $BASE.html
fi

 Best wishes ,

 Jo.

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)


Re: [O] HTML lists are including paragraphs (lip…/p/li)

2014-08-05 Thread Eric Schulte
The code which checks to ensure that paragraph wrappers are only
inhibited if they are inhibited for the whole list mistakenly keeps
paragraph wrappers if one item of the list is itself a list

The location of this bug is the (cdr contents) in line 2899 of
ox-html.el.  I'd be inclined to remove this form, but I'm not sure what
valid case it checks for.

Best,
Eric

Daniel Clemente n142...@gmail.com writes:

 Hi. With latest org I'm getting lip…/p/li, which makes no
 sense; it should be li…/li
 Aren't there tests to find this type of breakages in export?


 Example:

 - hola
 - uno
   - dos
 - tres


 Is exported to:


 ul class=org-ul
 lip
 hola
 /p
 /li
 lip
 uno
 /p
 ul class=org-ul
 lidos
 /li
 /ul
 /li
 lip
 tres
 /p
 /li
 /ul


-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] R code block produces only partial output

2014-08-05 Thread Eric Schulte
Charles Berry ccbe...@ucsd.edu writes:

 Eric Schulte schulte.eric at gmail.com writes:

 
 Andreas Kiermeier andreas.kiermeier at gmail.com writes:
 
  On 4 August 2014 21:23, Eric Schulte schulte.eric at gmail.com wrote:
  Why are you setting the output type to graphics when you are trying to

 
 Hi Andreas,
 
 I can't reproduce your problem.  I get the following from your minimal
 example when run in an Org-mode file, and from the command line.  They
 are identical.  Are you using the latest version of Org-mode?
 
 Best,
 Eric
 
 [snip]
 
 [Previously saved workspace restored]
 
  x - rnorm(100)
  y - quantile(x, probs=seq(0,1,0.1))
  names(y) - 
 as.character(c(0,.1,.2,.3,.4,.5,.6,.7,.8,.9,1))
  y
   0  .1  .2  .3  .4  .5 
 -2.53624773 -1.30846042 -0.70659822 -0.43565010 -0.24318346 -0.01034625 
  .6  .7  .8  .9   1 
  0.24125644  0.49945059  0.92032314  1.36423669  2.83357915 
 
 
 
 


 Eric,

 As noted by Andreas and John this is a problem for session output.

 org-babel-R-evaluate-session uses 

  (string-match ^\\([ ]*[+\\.][ ]?\\)+\\([[0-9]+\\|[ ]\\) line)

 to find the start of R output in the session.

 This does not match the `  0', but matches the ` .6' 
 in the output you show above, so if that had been in a session, all the 
 output up to and including the '.' before the '6' would be clipped
 by the following

   (substring line (match-end 1))


 as Andreas output showed. 

 Deleting the \\. fixes Andreas case, but what are the circumstances 
 requiring the  \\. ?


I don't know.

The Babel R support needs a dedicated maintainer.  This was a role Dan
Davison originally filled.  I've partially filled in since, but as a
*very* light R user I'm not the best person.


 HTH,

 Chuck



-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] R code block produces only partial output

2014-08-04 Thread Eric Schulte
-paste-rectangle))
  (local-set-key \214 (quote org-table-sort-lines))
  (local-set-key \311 (quote org-toggle-iimage-in-org)))
 )
  org-shiftup-final-hook '(windmove-up)
  org-ascii-format-drawer-function '(lambda (name contents width) contents)
  org-directory ~/.org/
  org-html-format-drawer-function '(lambda (name contents) contents)
  org-shiftleft-final-hook '(windmove-left)
  org-metadown-hook '(org-babel-pop-to-session-maybe)
  org-agenda-files '(~/.org/agenda.org)
  org-src-mode-hook '(org-src-babel-configure-edit-buffer
 org-src-mode-configure-edit-buffer)
  org-after-todo-state-change-hook '(org-clock-out-if-current)
  org-todo-keyword-faces '((WAITING . ak-org-todo-warning-face))
  org-shiftright-final-hook '(windmove-right)
  org-babel-load-languages '((emacs-lisp) (R . t))
  org-babel-R-command C:/Progra~1/R/R-3.1.1/bin/x64/R --slave --no-save
  org-latex-format-inlinetask-function 'ignore
  org-confirm-shell-link-function 'yes-or-no-p
  )


-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] [PATCH] ob-shell

2014-08-04 Thread Eric Schulte
Alan Schmitt alan.schm...@polytechnique.org writes:

 Hello,

 On 2014-06-22 14:50, Eric Schulte schulte.e...@gmail.com writes:

 If this maintains existing functionality, please go ahead and apply it.

 Has this been applied? I'm still seeing a failing test for ob-shell.

 1 unexpected results:
FAILED  ob-shell/bash-uses-assoc-arrays

 Best,

 Alan

It looks like Achim is part way through making the required changes.

Achim Gratz strom...@nexgo.de writes:

 Eric Schulte writes:
  If this maintains existing functionality, please go ahead and apply it.
 
 Done on master.  The tests are left untouched, I will not have time to
 do anything there for the next few days.  Any helping hand is welcome.
 
 
 Regards,
 Achim.

Best,
Eric

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] R code block produces only partial output

2014-08-04 Thread Eric Schulte
Andreas Kiermeier andreas.kierme...@gmail.com writes:

 On 4 August 2014 21:23, Eric Schulte schulte.e...@gmail.com wrote:
 Why are you setting the output type to graphics when you are trying to
 return text?  I think that may be the source of your problem.

 Hi Eric,
 thanks for the quick response.
 I've had 'graphics' from my main data analysis file ... I think I got
 that from WORG.
 I've removed it, reloaded the file, but same outcome.
 Any other thoughts?
 Cheers,
 Andreas

Hi Andreas,

I can't reproduce your problem.  I get the following from your minimal
example when run in an Org-mode file, and from the command line.  They
are identical.  Are you using the latest version of Org-mode?

Best,
Eric

#+BEGIN_SRC R :results output
  x - rnorm(100)
  y - quantile(x, probs=seq(0,1,0.1))
  names(y) - as.character(c(0,.1,.2,.3,.4,.5,.6,.7,.8,.9,1))
  y
#+END_SRC

#+RESULTS:
:  0 .1 .2 .3 .4 .5 .6 
: -2.5388527 -1.7039145 -1.0586655 -0.4892375 -0.2083433  0.0669765  0.2674644 
: .7 .8 .9  1 
:  0.6065544  1.0985117  1.5376634  3.2423323 

$ R

R version 3.1.0 (2014-04-10) -- Spring Dance
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-unknown-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

[Previously saved workspace restored]

 x - rnorm(100)
 y - quantile(x, probs=seq(0,1,0.1))
 names(y) - 
 as.character(c(0,.1,.2,.3,.4,.5,.6,.7,.8,.9,1))
 y
  0  .1  .2  .3  .4  .5 
-2.53624773 -1.30846042 -0.70659822 -0.43565010 -0.24318346 -0.01034625 
 .6  .7  .8  .9   1 
 0.24125644  0.49945059  0.92032314  1.36423669  2.83357915 


-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)


[O] Org-mode extensions used to publish a dissertation

2014-08-04 Thread Eric Schulte
Hi List,

I thoroughly enjoyed using Org-mode to write my dissertation.  I was
happy to be able to export (mostly) equivalent versions of the document
to HTML and PDF.  I'd recommend using Org-mode for such a complex
writing task to those who are either willing to hack the exporter, or
are willing to accept an Org-mode document with inline LaTeX which only
/really/ works with the LaTeX backend.

As I fall in the former category, here are the small extensions to the
Org-mode exporter which I found necessary.  Thanks to the new exporting
backend they were uniformly easy to implement.  They are included in the
attached elisp file.  Each pagefeed (^L) in the file marks a new section
of functionality, the sections are as follows...

 1. Ignore Headlines and keep content (discussed here recently)
 2. Multi-column Table Cells
 3. Wide tables extend into the margins.
 4. Wide tables squeezed within the margins
 5. sc links for the \sc{} latex command
 6. gls links for the \gls{} family of Glossary commands
 7. color links
 8. TIKZ figure links
 9. Tie certain latex commands to the preceding word.
10. Fix emphasis in text export

A simplified version of my Makefile is also attached.  I hope someone
finds this useful.

Best,
Eric



init.el
Description: application/emacs-lisp


Makefile
Description: Binary data

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)


Re: [O] What is the best in-Emacs presentation mode for org-files today?

2014-08-03 Thread Eric Schulte
Bastien b...@gnu.org writes:

 Hi Grant,

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

 What are you opinions on the best mode for doing:
 1. Presentations inside of Emacs
 2. Using all the options available for org mode while in the presentation

 ... org-mode.

 I've found out that tweaking the font size and navigating through
 an Emacs buffer is often good enough for presentations.

I agree, full screen and large font is often sufficient.

However... When I want more I use the following.

  https://github.com/eschulte/epresent

Best,
Eric

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] [BABEL] Can all languages deal with multi-line headers?

2014-08-03 Thread Eric Schulte
Thorsten Jolitz tjol...@gmail.com writes:

 Hi List, 

 I wonder if I can assume that all ob-xxx.el languages, even those
 written before the new parser/exporter framework existed, know how to
 deal with multi-line headers like:

 ,
 | #+name: foo
 | #+header_args: :var x=bar
 | #+begin_src lang
 | ...
 | #+end_src
 `

 (I would think that argument parsing is done by the framework-core and
 was thus updated once and for all languages with Org 8+, but want to be
 sure). 

Yes, this is true of all languages however you have the syntax wrong in
your example.  See the manual.

  (info (org)Code block specific header arguments)

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] [BUG] src_blocks - :results raw and replace don't work together

2014-08-03 Thread Eric Schulte
Nick Dokos ndo...@gmail.com writes:

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

 Hi List,

 evaluating this 3 times does not work as expected:

 ,
 | * A
 | 
 | #+header: :results raw replace
 | #+begin_src emacs-lisp 
 |   (+ 2 2)
 | #+end_src
 | 
 | #+results:
 | 4
 | 4
 | 4
 `

 Independent from argument order, 'replace' (which should be default
 anyway) is ignored.

 Right - `raw' inserts results without delimiters so org has no idea
 where they end and cannot delete them (try org-babel-remove-result)
 or replace them.

Well said Nick, this is a natural limitation.  See the drawer portion
of the following page of the manual.

  (info (org)Results)

In general checking the manual before posting to the ML is a good idea.

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] How does org-babel-post-tangle-hook work?

2014-08-03 Thread Eric Schulte
This says that when the hook is executed, the current buffer (as
identified by the `current-buffer' function) will be a buffer visiting
the file of the tangled code.

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

 Hi,

 In this document

 http://orgmode.org/manual/Extracting-source-code.html#Extracting-source-code

 the hook 'org-babel-post-tangle-hook is explained as

 ,
 | This hook is run from within code files tangled by org-babel-tangle.
 Example applications could include post-processing, compilation or
 evaluation of tangled code files.
 `

 I know what a hook is and how to use them and where they run.

 My trouble is that I don't understand what this documentation is saying.

 Is it saying that if this hook exists in a file that was tangled by
 org that it will be executed? If so does it only work for elisp files
 or any kind of file?

 Kind regards,

 Grant Rettke | ACM, ASA, FSF, IEEE, SIAM
 g...@wisdomandwonder.com | 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


-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] bug in lisp code blocks

2014-08-03 Thread Eric Schulte
Hi Mark,

Thanks for the example, I've just pushed up a fix.

Best,
Eric

Mark Scala marksc...@gmail.com writes:

 Thanks, Bastien, for helping me report this bug more effectively.
 This email summarizes all the information I have about this bug and
 how to reproduce it. The problem is that a comment which appears as
 the _last_ line of a (common) lisp code block causes an error when
 that block is evaluated with C-c C-c. Here's how to reproduce it:

 1. You will need to have SBCL and Slime
installed. Your distribution of linux probably has a good enough
SBCL (I'm using 1.2.0 in Arch linux). The easiest way to get the
latest version of Slime is with Quicklisp, which you can find here
(together with instructions to install):
http://www.quicklisp.org/beta/.

Once you have Quicklisp installed and loaded, installing Slime is a
matter of calling (ql:quickload swank) at the sbcl repl.

   Note: I am also able to reproduce the bug using clisp:
 -  GNU CLISP 2.49 (2010-07-07) (built on
 var-lib-archbuild-extra-x86_64-barthalion)

 2. Start emacs with the following as the entire init.el (of course,
you'll probably have to modify the paths).

 #+BEGIN_SRC emacs-lisp

 (add-to-list 'load-path (expand-file-name ~/opt/org-mode/lisp))
 (require
 'org)

 (org-babel-do-load-languages

   'org-babel-load-languages

   '((lisp . t)))

   (setq inferior-lisp-program /usr/bin/sbcl)

 (add-to-list 'load-path
 ~/quicklisp/dists/quicklisp/software/slime-2.8)
   (require 'slime)
 #+END_SRC

 Note: I've also just reproduced the bug using the version of org-mode
 that ships with Emacs 24:

- Org-mode version 7.9.3f (release_7.9.3f-17-g7524ef @
 /usr/share/emacs/24.3/lisp/org/)

 3. Finally, create a new org file and insert this block:

 #+BEGIN_SRC lisp :results output

 (format t Hello world.)
   ;; comment after, causes crash when block is evaluated with C-c C-c
 #+END_SRC


 If you now evaluate the block with C-c C-c, you should get an EOF
 error. Here is a piece of the debugger report:

 #+BEGIN_QUOTE
 end of file on #SB-IMPL::STRING-INPUT-STREAM {1003F862D3}
[Condition of type END-OF-FILE]
 #+END_QUOTE

 It appears that the bug is caused by a comment string that is the last
 element of the block. Comments elsewhere do not cause this error.

 Here are the versions strings of the software I'm running:

   - GNU Emacs 24.3.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.12.2)
 of 2014-06-11 on var-lib-archbuild-staging-x86_64-jgc
   - Org-mode version 8.3beta (release_8.3beta-51-g02f2d5 @
 /home/mark/opt/org-mode/lisp/)
   - SBCL 1.2.0

 On Tue, Jul 29, 2014 at 9:13 AM, Bastien b...@gnu.org wrote:
 Hi Mark,

 you forgot to CC the list -- please do so, so that anyone can help
 fixing the problem.

 All this new information is important.  A complete recipe would take
 the user from a bare emacs -Q to an emacs with a sbcl connection and
 slime, and explain the steps for launching sbcl, connecting via slime,
 etc.

 Assume the ones who may fix the problem (like me and other maintainers)
 are not 100% familiar with Emacs/slime/sbcl, even though they can follow
 good recipes easily.

 Thanks for your efforts!

 PS: The hint about the last commented line triggered the bug is
 important and will certainly lead to a quick fix.

 --
  Bastien


-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] org-ref in action

2014-06-30 Thread Eric Schulte
Joseph Vidal-Rosset joseph.vidal.ros...@gmail.com writes:

 2014-06-29 20:19 GMT+02:00 Eric Schulte schulte.e...@gmail.com:


 With ox-bibtex.el [[cite:(page n)one-reference-paper-year]] will export as

   \cite[page n]{one-reference-paper-year}



 I am sorry Eric but [[cite:(page n)one-reference-paper-year]]  breaks the
 bibliography reference for me with ox-bibtex.el ... it is too bad because
 it was a convenient solution to get  \cite[page
 n]{one-reference-paper-year} .

 I am lost.


Could you be more specific?  Does org-mode generate any latex at all,
and how does it differ from what you'd expect?  If no LaTeX is
generated, and Org-mode actually throws an error then please provide a
backtrace.  I should be able to help but I'll need more information.

One thing I noticed is that I got better behavior if I didn't allow line
breaks in the link, which was easily accomplished by replacing
[[cite:(page n)one-reference-paper-year]] with
[[cite:(page~n)one-reference-paper-year]].  In general the later is
actually /preferable/ than the former, as you don't want LaTeX breaking
lines in the middle of a citation either.

Best,


 Regards

 Jo.

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] org-ref in action

2014-06-30 Thread Eric Schulte
 Thanns to the default cite action, I get for example in my org file:

  [[cite:(119–136)johansson36:_minim_formal]]

 and it creates no reference at al, because via the export I get:

 \cite{(119–136)johansson36:_minim_formal}


Using the latest version of Org-mode from the git repository, this is a
very new feature and requires usage of the git version of Org-mode, I am
seeing the desired behavior.  After simply requiring ox-bibtex, the
following

* H1
[[cite:(119–136)johansson36:_minim_formal]]

exports to

\begin{document}

\maketitle
\tableofcontents

\section{H1}
\label{sec-1}~\cite[119–136]{johansson36:_minim_formal}
% Emacs 24.4.50.2 (Org mode beta_8.3)
\end{document}

As expected.

I hope this helps,
Eric

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] html-encode in mathjax latex fragments

2014-06-30 Thread Eric Schulte
Nick Dokos ndo...@gmail.com writes:

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

 Hello,

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

 I noticed equations with 's weren't displaying correctly in HTML
 export using mathjax.  The attached patch fixes this by html-encoding
 latex fragments for mathjax HTML export.  I imagine this change would be
 generally useful and could be applied to master.

 I am a bit puzzled. I just tried exporting the following buffer:

   \(1  2\)

 and the result looked good. Could you provide an example of a failed
 export?



 See 

http://docs.mathjax.org/en/latest/tex.html#tex-and-latex-in-html-documents

 for some gotchas.

Thanks, the link does describe the problem well.  My particular problem
formula included id in part of a larger equation.

From the link above it sounds like replacing just ,  and 
should be sufficient, if the full html encoding in my previous patch was
too heavy weight.

Best,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



[O] numbered equations in html export

2014-06-30 Thread Eric Schulte
Hi,

All equations are numbered 1 when the attached example file is
exported to HTML.

#+Title: Example

* H1
See Equation [[the-first]],

#+name: the-first
\begin{equation}
n_{i+1} = \frac{n_{i} (d-i) (e-1)}{(i+1)}
\end{equation}

and also Equation [[the-second]].

#+name: the-second
\begin{equation}
n_{0} = 1
\end{equation}


Thanks,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)


Re: [O] how to handle backend-specific types as fuzzy link targets during export

2014-06-30 Thread Eric Schulte
Nicolas Goaziou m...@nicolasgoaziou.fr writes:

 Hello,

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

 Attached

 OK, now I get it.

 You're working at the wrong level. `latex-fragment' is an object
 (inline) type, but you're inserting it at the element's level. The
 equivalent (non inline) element is `latex-environment', which is, for
 example:

   \begin{equation}
   1+1=2
   \end{equation}

 So you could simply replace `latex-fragment' type with
 `latex-environment', and your example should work properly.


Confirmed, using `latex-environment' does give the desired behavior.

A related question.  Is there a command to re-number figures in export?
After adding latex-environments in a function added to the
`org-export-filter-parse-tree-functions' hook, all figures are numbered
1.

Thanks,


 HTH,


 Regards,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] numbered equations in html export

2014-06-30 Thread Eric Schulte
Nicolas Goaziou m...@nicolasgoaziou.fr writes:

 Hello,

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

 All equations are numbered 1 when the attached example file is
 exported to HTML.

 #+Title: Example

 * H1
 See Equation [[the-first]],

 #+name: the-first
 \begin{equation}
 n_{i+1} = \frac{n_{i} (d-i) (e-1)}{(i+1)}
 \end{equation}

 and also Equation [[the-second]].

 #+name: the-second
 \begin{equation}
 n_{0} = 1
 \end{equation}

 Only captioned equations are numbered. Behaviour is undefined for other
 equations.


Why is this the default behavior?  It looks to me like even when they're
present captions on equations aren't displayed for HTML or LaTeX export.
Additionally I don't see why captions should be related to, or required
for, the numbering of equations.

In a related issue which I believe is more convincingly a bug; links to
equations (whether numbered or not, with or without captions) don't
actually point anywhere.  A link to the name is constructed, but no
anchor with the name is inserted into the page.

Would it make sense to change the current behavior as follows?

1. On HTML export all named equations are made into targets for a link
   based on their name.

2. All named and referenced equations are numbered.

Thanks,



 Regards,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] org-ref in action

2014-06-29 Thread Eric Schulte
Joseph Vidal-Rosset joseph.vidal.ros...@gmail.com writes:

 Hi John, hello the list,

 My question is very simple and it is not unrevelevant vis-à-vis this
 thread, therefore I keep  the same thread.

 What  need is to get either  the usual citation format  (often in plain
 style) \cite{one-reference-paper-year} or this one with a mentioned page:
 \cite[page n]{one-reference-paper-year}.


With ox-bibtex.el [[cite:(page n)one-reference-paper-year]] will export as

  \cite[page n]{one-reference-paper-year}


 My problem with cite: org-mode format is that I am not able to get the
 second format. Ideally , I want to click on the reference and just to add
 the quoted page.

 I do not doubt that this is easy to get in org-mode, but I'm wasting my
 time to find how... if it is possible to get it with org-ref  or via
 another tool, many thanks in advance.

 Best regards

 Jo.
 ​

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



[O] html-encode in mathjax latex fragments

2014-06-29 Thread Eric Schulte
I noticed equations with 's weren't displaying correctly in HTML
export using mathjax.  The attached patch fixes this by html-encoding
latex fragments for mathjax HTML export.  I imagine this change would be
generally useful and could be applied to master.

Best,
Eric

From 8c4efca17f2a6fbc836c5a8b6b0f628b6c9fff33 Mon Sep 17 00:00:00 2001
From: Eric Schulte schulte.e...@gmail.com
Date: Sun, 29 Jun 2014 14:38:03 -0400
Subject: [PATCH] html-encode text in mathjax latex fragments

* lisp/ox-html.el (org-html-format-latex): Html-encode text in mathjax
  latex fragments.
---
 lisp/ox-html.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index df392a9..03037f5 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -2610,7 +2610,8 @@ a symbol among `mathjax', `dvipng', `imagemagick', `verbatim' nil
 and t.  See `org-html-with-latex' for more information.  INFO is
 a plist containing export properties.
   (let ((cache-relpath ) (cache-dir ))
-(unless (eq processing-type 'mathjax)
+(if (eq processing-type 'mathjax)
+	(setq latex-frag (org-html-encode-plain-text latex-frag))
   (let ((bfn (or (buffer-file-name)
 		 (make-temp-name
 		  (expand-file-name latex temporary-file-directory
-- 
2.0.0


-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)


Re: [O] org-ref in action

2014-06-26 Thread Eric Schulte
John Kitchin jkitc...@andrew.cmu.edu writes:

 Some features could be merged, but there is an important difference in that
 org-ref uses bibtex as the backend database, and reftex for searching, and
 org-bibtex uses org-mode headings as the backend database, and tag/property
 searches (I think).  It is like the difference between org-contacts and
 bbdb. They both serve similar needs, but with different data sources, and
 different ways to think about it.

 We might be able to figure out a way to specify a backend that would
 allow the independent features to work in both though.


I wonder what the API would look like.  The following functions comes to
my mind.  I'm not sure if there would be much more for org-ref...
- jump location for citation by ID
- return bibtex information for citation by ID
- validate citation

With those functions I imagine that a good deal of higher-level code
could be shared in a backend agnostic way.  Including,
- jump to citations
- provide information on citations
- collect citations during publishing (possibly automatically create the bib 
file)

If merging makes sense that's great, but if not then there's certainly
no harm in a diverse ecosystem of org tools supporting different work
flows and backend tools.

Best,
Eric


 John

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



 On Thu, Jun 26, 2014 at 8:21 AM, Fabrice Popineau 
 fabrice.popin...@supelec.fr wrote:


 +1 for org-bibtex (and ox-bibtex) that I'm using for a couple of years.

 But org-ref seems to go further (video is convincing).
 It would be really nice to merge org-ref and org-bibtex before they split
 too far apart.
 Wishful thinking from me because I don't see that I'm in position to do it.

 Fabrice


 2014-06-26 3:10 GMT+02:00 Matt Lundin m...@imapmail.org:

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

 
  This is a lot of useful functionality, and very nicely presented.
 
  Did you happen to try the built in bibtex support in Org-mode core and
  contrib?  And if so, is there a reason that you implemented this all
  independently?
 
  I think part of the problem with existing Org-mode bibtex support is
  that no-one knows it exists.

 Well, you can count on one big fan of org-bibtex.el here! (Though I must
 admit that I have not used ox-bibtex.el.)

  To help address this I threw up a very quick-and-dirty screen cast
  demonstrating some of Org's existing bibtex functionality.
 
  https://vimeo.com/99167082

 Thanks! Over the years, I've particularly appreciated the way
 org-bibtex.el makes it easy to keep bib data together with notes/todos.
 Both org-bibtex-read and org-bibtex-yank have become indispensable to my
 own workflow.

 Best,
 Matt




 --
 Fabrice Popineau
 -
 SUPELEC
 Département Informatique
 3, rue Joliot Curie
 91192 Gif/Yvette Cedex
 Tel direct : +33 (0) 169851950
 Standard : +33 (0) 169851212
 --



-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] results from Python block not visible

2014-06-26 Thread Eric Schulte
Daniel Clemente n142...@gmail.com writes:

 Hi, this babel code recently stopped working on my system:

 #+BEGIN_SRC python :results output
 print x
 #+END_SRC

 It prints:

 #+RESULTS:
 : None

 I expected to see x. This worked some days ago.


This works for me using the latest version of Org-mode with an Emacs
launched by running make vanilla from the base of the Org-mode repo.

Maybe the problem is in your configuration?


 If I use a command like os.system(xeyes), I see it running.

 In addition I don't see the Python block highlighted


 GNU Emacs 24.4.50.1 (x86_64-unknown-linux-gnu, X toolkit, Xaw scroll bars) of 
 2014-06-20 on la4
 org-mode from today
 Debian. Python 2.7 (same with Python 3).
 It also happens under emacs -Q

 Of course I loaded Python support:

 (org-babel-do-load-languages
  'org-babel-load-languages
  '((R . t)
(C . t)
 ; …
(python . t)
(ruby . t)
(sql . t)
(sqlite . t)))


 Greetings, Daniel


-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] org-ref in action

2014-06-25 Thread Eric Schulte
John Kitchin jkitc...@andrew.cmu.edu writes:

 Hello everyone,

 org-ref has basically stabilized. You can get the latest code at
 https://github.com/jkitchin/jmax/blob/master/org-ref.org.

 I made a little screen capture video here to show you what it does:
 https://www.youtube.com/watch?v=JyvpSVl4_dg

 Try it out, if it looks interesting, and let me know if you find any
 bugs!

 Thanks,

Great,

This is a lot of useful functionality, and very nicely presented.

Did you happen to try the built in bibtex support in Org-mode core and
contrib?  And if so, is there a reason that you implemented this all
independently?

I think part of the problem with existing Org-mode bibtex support is
that no-one knows it exists.  To help address this I threw up a very
quick-and-dirty screen cast demonstrating some of Org's existing bibtex
functionality.

https://vimeo.com/99167082

Best,
Eric

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



[O] how to handle backend-specific types as fuzzy link targets during export

2014-06-24 Thread Eric Schulte
Hello,

In the function `org-export-resolve-fuzzy-link' at line 4078 of ox.el
the `org-element-all-elements' variable is used to map over all elements
in the parse tree when looking for a possible link target.  However some
trees hold valid backend-specific types which are not members of the
`org-element-all-elements' variable (e.g., `latex-fragment').  This
results in named targets not being resolved during export.

I'm currently working around this locally by let-binding
`org-element-all-elements' in line 1967 of ox-latex.el, but I imagine
there should be a more general solution.

Thoughts?

Thanks,
Eric

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] Enabling another language in org-babel

2014-06-24 Thread Eric Schulte
Brendan Halpin brendan.hal...@ul.ie writes:

 Does there exist any documentation on extending org-babel to another
 language?


Hi Brendan,

There is a template [1] which may be filled out to add support for a new
language.  More generally simply defining a function named
`org-babel-execute:foo' will cause babel to try to execute foo code
blocks using that function.  See the template for existing
`org-babel-execute:*' functions.


 Relatedly, is anyone working on adding Stata coverage to org-babel?


I'm not but who knows.  If you do add support for Stata please consider
contributing it to Org-mode (see [2]).

Best,
Eric



 Regards,

 Brendan


Footnotes: 
[1]  http://orgmode.org/w/worg.git/blob/HEAD:/org-contrib/babel/ob-template.el

[2]  http://orgmode.org/worg/org-contribute.html

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] how to handle backend-specific types as fuzzy link targets during export

2014-06-24 Thread Eric Schulte
Nicolas Goaziou m...@nicolasgoaziou.fr writes:

 Hello,

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

 In the function `org-export-resolve-fuzzy-link' at line 4078 of ox.el
 the `org-element-all-elements' variable is used to map over all elements
 in the parse tree when looking for a possible link target.  However some
 trees hold valid backend-specific types which are not members of the
 `org-element-all-elements' variable (e.g., `latex-fragment').  This
 results in named targets not being resolved during export.

 I do not understand what you are trying to achieve. Line 4078 tries to
 find elements with a #+NAME affiliated keyword in the parse tree. LaTeX
 fragments cannot have such keywords.

 Maybe an example would help.


Sure.  I have added a function to org-export-filter-parse-tree-functions
which replaces a custom keyword with either a latex-fragment or an HTML
link wrapped in a paragraph depending on the export backend.  The latex
fragment basically has the following content,

\\begin{figure}
  \\centering
  \\input{%s}
  \\caption[%s]{\\label{%s}%s}
\\end{figure}\n\n

and I assign it a :name property to match the label in the above.  I
then have links elsewhere in the file which reference this label.

Is there a better way to achieve output like the above?  If not I think
an argument can be made that either (1) after filters have run
assumptions about which types can support which properties are moot, or
(2) there should be a way to have a filter insert a named chunk of
backend-specific code.

Thanks,
Eric



 Regards,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] how to handle backend-specific types as fuzzy link targets during export

2014-06-24 Thread Eric Schulte
Nicolas Goaziou m...@nicolasgoaziou.fr writes:

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

 Sure.  I have added a function to org-export-filter-parse-tree-functions
 which replaces a custom keyword with either a latex-fragment or an HTML
 link wrapped in a paragraph depending on the export backend.  The latex
 fragment basically has the following content,

 \\begin{figure}
   \\centering
   \\input{%s}
   \\caption[%s]{\\label{%s}%s}
 \\end{figure}\n\n

 and I assign it a :name property to match the label in the above.  I
 then have links elsewhere in the file which reference this label.

 I still do not get it. Could you show your (possibly simplified) filter
 function?


Attached



tikz-figure-keywords.el
Description: application/emacs-lisp


 Also, what code do you want ox-latex to generate?


So something like the following

#+name: technique-overview
#+Caption[Overview of Technique]: Text.
#+TIKZ_FIGURE: technique-overview

Lorem ipsum dolor sit amet Figure [[technique-overview]] posuere.

results in something like the following for latex export

\begin{figure}
  \centering
  \input{technique-overview}
  \caption[Overview of Technique]{\label{technique-overview}Text.}
\end{figure}

 Lorem ipsum dolor sit amet Figure \ref{technique-overview} posuere.

Thanks,
Eric


 Note that #+NAME is internal Org syntax. It cannot possibly be
 compatible with random raw LaTeX code. IOW, even if you can write raw
 LaTeX in an Org buffer, it doesn't mean that Org will understand the
 LaTeX code you wrote.


 Regards,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)


Re: [O] unattractive list spacing in ox-html export

2014-06-24 Thread Eric Schulte
Achim Gratz strom...@nexgo.de writes:

 Eric Schulte schulte.eric at gmail.com writes:
 I disagree, editing CSS shouldn't be required for reasonable default
 list spacing on HTML export.

 You can disagree all you want, that doesn't make the underlying problem go
 away.  The reason for the unattractive spacing is that list items, while
 conceptually paragraphs, do not have additional spacing after them so the
 list becomes more compact.  The W3C doesn't really encourage to use lists
 with paragraphs, but if you do (like Org), an explicit paragraph inside a
 list environment either should also not have that spacing or should have it
 at the beginning (in which case the first paragraph must be implicit).

My browser (recent Firefox) *does* place extra spacing around list
elements with paragraphs (with no CSS).  I assume this is standard.  So
regardless of what browsers should do, Org-mode should handle what they
actually do.

 So you'll have to modify the CSS anyway or the lists are still having
 ugly spacing. Your patch only makes it consistently ugly as soon as
 there is a single explicit paragraph needed.


I think consistency here is a win.  Maybe adding another rule to the
Org-mode default CSS would make the situation even better, but
personally I'm happy with the current look.

Thanks,
Eric


 Regards,
 Achim.




-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] Passing values by reference to src-blocks

2014-06-24 Thread Eric Schulte
Thorsten Jolitz tjol...@gmail.com writes:

 Hi List, 

 this does not work, although I would think it should (at least if there
 is no typo or so):


I think everything is doing what it is supposed to from an Org-mode
perspective, see below (with different functions).

#+name: plus-foo
#+header: :var buf-file=(buffer-file-name)
#+begin_src emacs-lisp
(concat buf-file +foo)
#+end_src

#+RESULTS: plus-foo
: /tmp/example.org+foo

#+name: project-name
#+header: :exports none
#+header: :var root-dir=plus-foo(buf-file=(buffer-file-name))
#+begin_src emacs-lisp
(concat root-dir +bar)
#+end_src

#+RESULTS: project-name
: /tmp/example.org+foo+bar


 ,
 | #+name: project-root
 | #+header: :var buf-file=(buffer-file-name)
 | #+begin_src emacs-lisp
 | (file-name-directory
 |  (directory-file-name
 |   (file-name-directory buf-file)))
 | #+end_src
 `

 #+results: project-root
 : /home/tj/News/drafts/

 ,
 | #+name: project-name
 | #+header: :exports none
 | #+header: :var root-dir=project-root(buf-file=(buffer-file-name))
 | #+begin_src emacs-lisp
 |   (mapconcat
 |'capitalize
 |(split-string
 | (file-name-nondirectory root-dir)
 | - 'OMIT-NULLS)
 | )
 | #+end_src
 `

 #+results: project-name

 Wrong usage of :var or limitations of header arguments?

This is to be expected.  The two blocks above compose to something like

#+begin_src emacs-lisp
  (file-name-nondirectory
   (file-name-directory
(directory-file-name
 (file-name-directory
  (buffer-file-name)
#+end_src

Calling `file-name-nondirectory' on the results of `file-name-directory'
seems like it should give you an empty string.

Best,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)


[O] impossible to have footnote touching verbatim

2014-06-23 Thread Eric Schulte
Hi,

I'm writing a document in which I use footnotes to hold references to
many tools.  One often wants the tool name in tt font, and the footnote
to be touching the tool name (i.e. =tool=[fn:1] ).  Unfortunately
currently Org-mode doesn't fontify or export tool in the above as tt.

Is there a way around this?

Thanks,
Eric

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



[O] unattractive list spacing in ox-html export

2014-06-23 Thread Eric Schulte
Hi,

When the lists with spaces in some (but not all) elements are exported
to HTML, they result in unattractive spacing.  This is due to the use of
paragraph tags in some list elements, which cause large spaces between
some list elements but no spaces between others.

I believe something should be done to ensure consistent spacing in the
HTML export of list elements.  I'd suggest that every list element
should be wrapped in a paragraph tag, but maybe a different solution is
more appropriate.

For example, the following Org-mode.

1. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec
   hendrerit tempor tellus. Donec pretium posuere tellus. Proin quam
   nisl, tincidunt et, mattis eget, convallis nec, purus
   
   Cum sociis natoque penatibus et magnis dis parturient montes,
   nascetur ridiculus mus. Nulla posuere. Donec vitae dolor. Nullam
   tristique diam non turpis. Cras placerat accumsan nulla. Nullam
   rutrum. Nam vestibulum accumsan nisl.

2. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec
   hendrerit tempor tellus. Donec pretium posuere tellus. Proin quam
   nisl, tincidunt et, mattis eget, convallis nec, purus. Cum sociis
   natoque penatibus et magnis dis parturient montes, nascetur
   ridiculus mus. Nulla posuere. Donec vitae dolor. Nullam tristique
   diam non turpis. Cras placerat accumsan nulla. Nullam rutrum. Nam
   vestibulum accumsan nisl.

3. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec
   hendrerit tempor tellus. Donec pretium posuere tellus. Proin quam
   nisl, tincidunt et, mattis eget, convallis nec, purus. Cum sociis
   natoque penatibus et magnis dis parturient montes, nascetur
   ridiculus mus. Nulla posuere. Donec vitae dolor. Nullam tristique
   diam non turpis. Cras placerat accumsan nulla. Nullam rutrum. Nam
   vestibulum accumsan nisl.


exports to the following html

ol class=org-ol
liLorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec
hendrerit tempor tellus. Donec pretium posuere tellus. Proin quam
nisl, tincidunt et, mattis eget, convallis nec, purus

p
Cum sociis natoque penatibus et magnis dis parturient montes,
nascetur ridiculus mus. Nulla posuere. Donec vitae dolor. Nullam
tristique diam non turpis. Cras placerat accumsan nulla. Nullam
rutrum. Nam vestibulum accumsan nisl.
/p
/li

liLorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec
hendrerit tempor tellus. Donec pretium posuere tellus. Proin quam
nisl, tincidunt et, mattis eget, convallis nec, purus. Cum sociis
natoque penatibus et magnis dis parturient montes, nascetur
ridiculus mus. Nulla posuere. Donec vitae dolor. Nullam tristique
diam non turpis. Cras placerat accumsan nulla. Nullam rutrum. Nam
vestibulum accumsan nisl.
/li

liLorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec
hendrerit tempor tellus. Donec pretium posuere tellus. Proin quam
nisl, tincidunt et, mattis eget, convallis nec, purus. Cum sociis
natoque penatibus et magnis dis parturient montes, nascetur
ridiculus mus. Nulla posuere. Donec vitae dolor. Nullam tristique
diam non turpis. Cras placerat accumsan nulla. Nullam rutrum. Nam
vestibulum accumsan nisl.
/li
/ol

Thanks,
Eric

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)


Re: [O] impossible to have footnote touching verbatim

2014-06-23 Thread Eric Schulte
Nicolas Goaziou m...@nicolasgoaziou.fr writes:

 Hello,

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

 I'm writing a document in which I use footnotes to hold references to
 many tools.  One often wants the tool name in tt font, and the footnote
 to be touching the tool name (i.e. =tool=[fn:1] ).  Unfortunately
 currently Org-mode doesn't fontify or export tool in the above as tt.

 Is there a way around this?

 You could probably tweak `org-emphasis-regexp-components' in order to
 allow square brackets as postmatch.


Should this be done personally or in master?

Thanks,



 Regards,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] unattractive list spacing in ox-html export

2014-06-23 Thread Eric Schulte
Nicolas Goaziou m...@nicolasgoaziou.fr writes:

 Hello,

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

 When the lists with spaces in some (but not all) elements are exported
 to HTML, they result in unattractive spacing.  This is due to the use of
 paragraph tags in some list elements, which cause large spaces between
 some list elements but no spaces between others.

 I believe something should be done to ensure consistent spacing in the
 HTML export of list elements.  I'd suggest that every list element
 should be wrapped in a paragraph tag, but maybe a different solution is
 more appropriate.

 Actually, there's a special case in ox-html.el (see line 2960) that
 prevents the first paragraph in an item to get p tag. I guess that
 this rule is meant for short lists, e.g.,

  - item 1
  - item 2

 where you do not want a new paragraph for each item. So, the special
 case could be extended to also check if there's another element in the
 item before ignoring the tags.


This sounds like the best approach.  The attached patch implements this
change, if it looks good I'll go ahead and apply it to master.

Thanks,
Eric

From 9af2b1c96e2062b1501cb930a1e1f95ab8c0882e Mon Sep 17 00:00:00 2001
From: Eric Schulte schulte.e...@gmail.com
Date: Mon, 23 Jun 2014 17:33:18 -0400
Subject: [PATCH 1/2] inhibit p wraps in list for all or none

* lisp/ox-html.el (org-html-paragraph): Extend the special case of
  inhibiting p wrappers to only perform such inhibition when *every*
  element of the list is a single element long.  Otherwise unsightly
  spacing results.
---
 lisp/ox-html.el | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 762e1dc..d95ce79 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -2956,7 +2956,17 @@ the plist used as a communication channel.
 (cond
  ((and (eq (org-element-type parent) 'item)
 	   (= (org-element-property :begin paragraph)
-	  (org-element-property :contents-begin parent)))
+	  (org-element-property :contents-begin parent))
+	   ;; every subsequent list element is a single element long
+	   (let ((gp (org-export-get-parent parent))
+		 (all-singles t))
+	 (org-element-map gp 'item
+	   (lambda (object)
+		 (let ((num-children (length (org-element-contents object
+		   (unless (= 1 num-children)
+		 (setq all-singles nil
+	   info nil 'item)
+	 all-singles))
   ;; Leading paragraph in a list item have no tags.
   contents)
  ((org-html-standalone-image-p paragraph info)
-- 
2.0.0


-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)


Re: [O] unattractive list spacing in ox-html export

2014-06-23 Thread Eric Schulte
Achim Gratz strom...@nexgo.de writes:

 Eric Schulte writes:
 I believe something should be done to ensure consistent spacing in the
 HTML export of list elements.  I'd suggest that every list element
 should be wrapped in a paragraph tag, but maybe a different solution is
 more appropriate.

 Setting the spacing for paragraphs within a list in the CSS seems much
 easier.

I disagree, editing CSS shouldn't be required for reasonable default
list spacing on HTML export.

Best,
Eric

 Besides, the content of a list item is conceptually a paragraph (the
 first one if there are more), so it shouldn't need to be wrapped
 anyway.


 Regards,
 Achim.

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] impossible to have footnote touching verbatim

2014-06-23 Thread Eric Schulte
Nicolas Goaziou m...@nicolasgoaziou.fr writes:

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

 Should this be done personally or in master?

 I can't think of a case where it could lead to confusion, so I'd say it
 can go in master, at least until someone complains, if ever.


Done. Thanks -- Eric

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] unattractive list spacing in ox-html export

2014-06-23 Thread Eric Schulte
Nicolas Goaziou m...@nicolasgoaziou.fr writes:

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

 +   ;; every subsequent list element is a single element long

 You need to start with a capital and a final period.

 Also, it could be merged with the comment below. E.g., Paragraphs have
 no tag when any item in current list is either empty or consist of
 a single paragraph.

 +   (let ((gp (org-export-get-parent parent))

 Since you only use it once, you don't need to bind it. Just use it in
 `org-element-map':

   (org-element-map (org-export-get-parent parent) 'item ...)

 + (all-singles t))
 + (org-element-map gp 'item
 +   (lambda (object)
 + (let ((num-children (length (org-element-contents object
 +   (unless (= 1 num-children)
 + (setq all-singles nil
 +   info nil 'item)

 This is not sufficient, as an item could contain a single center block
 with many paragraphs within. IOW you also need to check the type of the
 single element. We also need to accept empty items.

 Moreover, the item could contain another element not exported (i.e.
 a comment), but I guess that would go a bit too far.

 Also, note that `org-element-map' has a mechanism to exit early
 (argument FIRST-MATCH), so you can avoid mapping over all items if you
 already know that one of them doesn't contain a single paragraph.

 I think the following should do the job:

   (not (org-element-map (org-export-get-parent parent) 'item
  (lambda (item)
(let ((contents (org-element-contents item)))
  (and contents
   (or (cdr contents)
   (not (eq (org-element-type (car contents)) 
 'paragraph))
  info 'first-match 'item))

;; Leading paragraph in a list item have no tags.

 See above.


Applied with your changes.  Thanks for initial pointer and the code
review.

Best,
Eric



 Regards,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] [PATCH] ob-shell

2014-06-22 Thread Eric Schulte
If this maintains existing functionality, please go ahead and apply it.

Thanks,

Achim Gratz strom...@nexgo.de writes:

 Achim Gratz writes:
 Sebastien Vauban writes:
 I just ran `make test' and got the same error for
 `ob-shell/bash-uses-assoc-arrays'.

 Yes, that's because not all versions of bash that have associative
 arrays can parse the bizarre quoting style that goes through a
 sub-process and here-document that is used to fill in the parameters.

 Here's a patch that implements the suggestion and tested to work
 correctly with Cygwin and Linux.

 From a79aff65d562e59ed4e01e550224eb96a665c1ae Mon Sep 17 00:00:00 2001
 From: Achim Gratz strom...@stromeko.de
 Date: Thu, 19 Jun 2014 21:23:28 +0200
 Subject: [PATCH] ob-shell: stratify shell variable quoting

 * lisp/ob-shell.el: Remove unused defcustom
   `org-babel-sh-var-quote-fmt'.
   (org-babel-variable-assignments:bash_array):
   (org-babel-variable-assignments:bash_assoc): Remove superfluous
   `mapcar' and double quotes around parameters.
   (org-babel-sh-var-to-sh): Single-quote the whole string and escape
   all single quotes in the original string.
 ---
  lisp/ob-shell.el | 42 ++
  1 file changed, 18 insertions(+), 24 deletions(-)

 diff --git a/lisp/ob-shell.el b/lisp/ob-shell.el
 index 474a8f2..7d87026 100644
 --- a/lisp/ob-shell.el
 +++ b/lisp/ob-shell.el
 @@ -45,12 +45,6 @@ (defcustom org-babel-sh-command shell-file-name
:group 'org-babel
:type 'string)
  
 -(defcustom org-babel-sh-var-quote-fmt
 -  $(cat 'BABEL_TABLE'\n%s\nBABEL_TABLE\n)
 -  Format string used to escape variables when passed to shell scripts.
 -  :group 'org-babel
 -  :type 'string)
 -
  (defcustom org-babel-shell-names
'(sh bash csh ash dash ksh mksh posh)
List of names of shell supported by babel shell code blocks.
 @@ -113,28 +107,26 @@ (defun org-babel-variable-assignments:sh-generic
  (defun org-babel-variable-assignments:bash_array
  (varname values optional sep hline)
Returns a list of statements declaring the values as a bash array.
 -  (format unset %s\ndeclare -a %s=( \%s\ )
 - varname varname
 - (mapconcat 'identity
 -   (mapcar
 - (lambda (value) (org-babel-sh-var-to-sh value sep hline))
 - values)
 -   \ \)))
 +  (format unset %s\ndeclare -a %s=( %s )
 +   varname varname
 +   (mapconcat
 +(lambda (value) (org-babel-sh-var-to-sh value sep hline))
 +values
 + )))
  
  (defun org-babel-variable-assignments:bash_assoc
  (varname values optional sep hline)
Returns a list of statements declaring the values as bash associative 
 array.
(format unset %s\ndeclare -A %s\n%s
  varname varname
 -(mapconcat 'identity
 -  (mapcar
 -(lambda (items)
 -  (format %s[\%s\]=%s
 -varname
 -(org-babel-sh-var-to-sh (car items) sep hline)
 -(org-babel-sh-var-to-sh (cdr items) sep hline)))
 -values)
 -  \n)))
 +(mapconcat
 + (lambda (items)
 +   (format %s[%s]=%s
 +varname
 +(org-babel-sh-var-to-sh (car items) sep hline)
 +(org-babel-sh-var-to-sh (cdr items) sep hline)))
 + values
 + \n)))
  
  (defun org-babel-variable-assignments:bash (varname values optional sep 
 hline)
Represents the parameters as useful Bash shell variables.
 @@ -163,8 +155,10 @@ (defun org-babel-sh-var-to-sh (var optional sep hline)
Convert an elisp value to a shell variable.
  Convert an elisp var into a string of shell commands specifying a
  var of the same value.
 -  (format org-babel-sh-var-quote-fmt
 -   (org-babel-sh-var-to-string var sep hline)))
 +  (concat ' (replace-regexp-in-string
 +' '\'\'
 +(org-babel-sh-var-to-string var sep hline))
 +   '))
  
  (defun org-babel-sh-var-to-string (var optional sep hline)
Convert an elisp value to a string.
 -- 
 2.0.0



 Regards,
 Achim.

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] [PATCH] ob-shell: honor the specified shell for :session

2014-06-22 Thread Eric Schulte
I thought that `org-babel-sh-command' was still used if code blocks used
the keyword shell as the language.  If that's not the case and there
really is no more use for `org-babel-sh-command', then please go ahead
and apply this patch.

Thanks,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] proposal to have ignoreheading tags/properties

2014-06-22 Thread Eric Schulte
Aaron Ecay aarone...@gmail.com writes:

 Hi Eric,

 Thanks for your work on this code.  Partially inspired by this discussion,
 I’ve just created contrib/lisp/ox-extras.el, which I hope will become a
 home for useful export hook functions like this one.  Would you like to
 add your code there (or would you mind if I did so)?


Please feel free to add this to ox-extras.  Thanks -- Eric


 Thanks,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] babel python example not reproducible

2014-06-19 Thread Eric Schulte
Andreas Röhler andreas.roeh...@easy-emacs.de writes:

 On 18.06.2014 15:59, Eric Schulte wrote:
 Shiyuan gshy2...@gmail.com writes:

 Hi all,
I found a solution to fix the echo problem of the emacs python shell:
 http://stackoverflow.com/questions/8060609/python-interpreter-in-emacs-repeats-lines

 That is, in the Interior Python buffer, do
 M-: (setq comint-process-echoes t) ;; or nil

 Now, if I enter command directly in the interior python buffer, the command
 is not echoed and this is what I want.

 However, When I evaluate the python src code block in org-mode(by `C-c
 C-c`), the problem persists. I notice every time I evaluate the block, I
 see 'org_babel_python_eoe' in the interior python buffer.

 I  stumbled on a very strange emacs behavior. When I fiddled around, at
 some point, I produced the correct answer as the manual. I thought I got
 the right setup, but when I saved everything and restarted emacs, problem
 persists. Will it be a sign of anything wrong?

 What's even stranger is that: the evaluation for the first time gives
 different results from the evaluation for the second time,  on exactly the
 same src_block:

 This is what I got when I evaluation the code block for the first time:
 -
 #+BEGIN_SRC python :results output :session foo
 x=100
 print hello
 2
 print bye
 #+END_SRC

 #+RESULTS:
 #+begin_example

 x=100
 print hello
 hello
 2
 2
 print bye
 bye


 #+end_example
 ---
 ---

 The following is what I got when I evaluate the same block again:
 #+BEGIN_SRC python :results output :session foo
 x=100
 print hello
 2
 print bye
 #+END_SRC

 #+RESULTS:
 : x=100
 : print hello
 : hello
 : 2
 : 2
 : print bye
 : bye
 :
 :

 Notice that the prompt symbol  is in the result for the first
 evaluation but not in the second evaluation.

 This issue has been raised before, it is a quirk of how the python
 session starts up.  I think we've done what we can to handle this on the
 Org-mode side, I'd ask for a fix on the python.el maintainers.


 The prompts appear as respond from Python-process when setup-code is sent at 
 the beginning.
 org-babel already knows how to fetch only the results from last prompt.
 Probably separating a first run-python/py-shell from execute-process would do 
 it.


I don't follow the above with sufficient clarity to implement your
suggestion.  Could you provide a patch to the
`org-babel-python-initiate-session-by-key' function?

Thanks,
Eric


 Best,

 Andreas

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] Discussion request: 15m tangle time, details follow

2014-06-19 Thread Eric Schulte
Grant Rettke g...@wisdomandwonder.com writes:

 I still want to be using org,, so my plan for now then is to write a
 pre-processing script for before org-babel-tangle is run that:

 1. Checks each headline
 2. Checks if there is a source block
 3. If that source block doesn't have a noweb-ref name, and there is
 another source block under that
 headline, then merge it with the next source block of the same
 nature in that heading.

 That is off the top of my head, and I will try it by hand, first and
 see if it tangles the same result.

 Thoughts?

Perhaps an easier workaround would be to customize the value of
`org-babel-common-header-args-w-values'.  This variable determines which
header arguments are checked for in properties.  If you remove all
header arguments from this variable which you know are not used in a
property, it may dramatically speed up tangle time.

This may reduce the utility of some convenience functions, but should
not have too large of an impact on overall functionality.

Best,
Eric

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] babel python example not reproducible

2014-06-18 Thread Eric Schulte
Shiyuan gshy2...@gmail.com writes:

 Hi all,
   I found a solution to fix the echo problem of the emacs python shell:
 http://stackoverflow.com/questions/8060609/python-interpreter-in-emacs-repeats-lines

 That is, in the Interior Python buffer, do
 M-: (setq comint-process-echoes t) ;; or nil

 Now, if I enter command directly in the interior python buffer, the command
 is not echoed and this is what I want.

 However, When I evaluate the python src code block in org-mode(by `C-c
 C-c`), the problem persists. I notice every time I evaluate the block, I
 see 'org_babel_python_eoe' in the interior python buffer.

 I  stumbled on a very strange emacs behavior. When I fiddled around, at
 some point, I produced the correct answer as the manual. I thought I got
 the right setup, but when I saved everything and restarted emacs, problem
 persists. Will it be a sign of anything wrong?

 What's even stranger is that: the evaluation for the first time gives
 different results from the evaluation for the second time,  on exactly the
 same src_block:

 This is what I got when I evaluation the code block for the first time:
 -
 #+BEGIN_SRC python :results output :session foo
 x=100
 print hello
 2
 print bye
 #+END_SRC

 #+RESULTS:
 #+begin_example

 x=100
 print hello
 hello
 2
 2
 print bye
 bye


 #+end_example
 ---
 ---

 The following is what I got when I evaluate the same block again:
 #+BEGIN_SRC python :results output :session foo
 x=100
 print hello
 2
 print bye
 #+END_SRC

 #+RESULTS:
 : x=100
 : print hello
 : hello
 : 2
 : 2
 : print bye
 : bye
 :
 :

 Notice that the prompt symbol  is in the result for the first
 evaluation but not in the second evaluation.

This issue has been raised before, it is a quirk of how the python
session starts up.  I think we've done what we can to handle this on the
Org-mode side, I'd ask for a fix on the python.el maintainers.

 Also the result is not embedded in the #+being_example/#+end_example
 for the second evaluation.


Yes, short examples are examplized with : instead of the heavier
weight example blocks.  The results are functionally equivalent, but you
can customize the size at which different methods are used by changing
the `org-babel-min-lines-for-block-output' variable.


 I want to hunt down the problem. Any hints/helps is greatly appreciated.


Hope this helps.  Sadly Emacs python support is sub-par and as a
consumer, Org-mode python code blocks suffer.

Best,


 Shiyuan




 On Mon, Jun 16, 2014 at 9:12 AM, Doyley, Marvin mdoy...@ur.rochester.edu
 wrote:

 Hi Eric,

 Thanks for showing me the smart way of doing this.

 cheers,
 M
 --





-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] babel python example not reproducible

2014-06-18 Thread Eric Schulte
 Hi Guys,

 please permit a comment after some times - it's just not to create
 heroes :)

 IMHO the complexity orb-babel took by creating its own slots for
 symbols like function names, variables etc.  is not to handle reliably
 across the languages.


I don't understand what you mean by the above.


 A net and simple way out would be just to employ commands delivered by
 existing Emacs modes on org-source sections.  Inserting the results
 might be provided by a hook.


This is what Org-mode does when possible, and this is why some language
modes are both much simpler and much more reliable than others, e.g.,
because of Emacs' excellent support for common lisp ob-lisp.el is both
shorter and provides higher quality support than ob-python.el.

$ wc -l lisp/ob-{lisp,python}.el
  111 lisp/ob-lisp.el
  346 lisp/ob-python.el

If I've miss-understood the above please clarify.

Thanks,
Eric


 Cheers,

 Andreas






-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] proposal to have ignoreheading tags/properties

2014-06-16 Thread Eric Schulte
Nicolas Goaziou m...@nicolasgoaziou.fr writes:

 Hello,

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

 In my opinion the manual interleaving of noexport and export tags is
 overly cumbersome and is non-obvious.

 It is as non-obvious as the task it achieves.

 The obscure nature of this solution is evidenced by multiple
 discussions and implementations of filter functions to handle
 situations which could be covered by this noexport/export pattern.

 I don't know what you are referring to, since this noexport/export
 pattern isn't implemented yet. Do you have an example of such
 a discussion that dismissed said pattern?

 I think the attached patch should be applied to the core.  It includes
 the following.

 - a single new export function which removes the headlines and contents
   (the section element) of headlines tagged ignoreexport, then
   retains and promotes all sub-headlines contained therein.

 - a single new export tag named ignoreexport (ignore seems to be the
   crowd favorite, and adding export reduces possible conflicts with
   existing personal tags)

 Thank you for the patch.

 Again, my concern is that it introduces another tag for a task that
 could be possible without it. export, noexport, ignoreexport: this
 all gets confusing. Furthermore, this tag should, at the bare minimum,
 be configurable so it also introduces another keyword on par with
 SELECT_TAGS and EXCLUDE_TAGS.

 Moreover, that task is highly specific; I'm not convinced we should have
 a dedicated keyword for each of them. I'd rather have a simple solution
 for selective export problems, even if, as a generic solution, it may
 look clumsier.

 From the included tests, the effect of this patch is to convert a tree
 like the following,

 ,
 | * H1
 | Text1
 | ** H2  
 :ignoreexport:
 | Text2
 | *** H3
 | Text3
 |  H4
 | Text4
 | *** H5
 | Text5
 |  H6
 :ignoreexport:
 | Text6
 | * H7
 | Text7
 | * H8
 | Text8
 `

 Note that my suggestion is

   ,
   | * H1
   | Text1
   | ** H2  :noexport:
   | Text2
   | *** H3   :export:
   | Text3
   |  H4
   | Text4
   | *** H5   :export:
   | Text5
   |  H6:noexport:
   | Text6
   | * H7 :export:
   | Text7
   | * H8 :export:
   | Text8
   `

 In this case, it is more verbose. But the opposite would happen if you
 needed to also ignore children within the ignoreexport headlines.
 In order to get

   * H1
   ** H4

 compare


   * H1
   ** H2   :ignoreexport:
   *** H3  :noexport:
   *** H4

 with

   * H1
   ** H2   :noexport:
   *** H3
   *** H4:export:

 This time, the brevity of :ignoreexport: is not so clear. Also, it will
 not prevent the need to nest tags at some points. IOW, it is only
 efficient for one very specific use case. Outside of this case, the new
 tag would just be an annoyance and you would fallback
 to :noexport:/:export: nesting, if implemented. And if we cannot avoid
 tags nesting, I'd take 2 nesteable tags over 3 any day.

 Another point to consider is that :noexport:/:export has the advantage
 to mark explicitly what will be included in the export process. As such,
 I don't find less obvious than your proposal: in both cases, you have to
 understand the rules applied behind the keywords anyway. And these rules
 are well-known for export and noexport tags.


This is a specific tag for a specific but common use case.  I'll defer
to your judgment on the exporting code and instead share a filter
function which may be added to personal configurations (I've added this
to the FAQ as well [1]).

Having looked more closely at my use cases (documented in the attached
implementation), including the contents of ignored headlines is required
for most practical applications (which may make the parse tree invalid,
but which works well for every export backend I've used thus far).



ignore-headline.el
Description: application/emacs-lisp


 I'm sympathetic to arguments about maintaining simplicity of the core,
 and even more so to arguments about maintaining structural validity of
 trees during export.  I believe that this revised patch fully maintains
 valid tree structures, and I'd suggest that the increase in complexity
 of a single keyword is justified by the demonstrated user demand for
 this functionality.

 It mostly preserves tree structure, indeed. More comments about this
 below.

 Just to be clear: I'm not against implementing the functionality. We can
 implement it without increasing complexity, so the demand is hardly
 a justification for this added complexity

Re: [O] babel python example not reproducible

2014-06-16 Thread Eric Schulte
mdoy...@ur.rochester.edu (Doyley, Marvin) writes:

 Hi Shiyuan,

 I think the problem is that Emacs or babel is using python located in
 /usr/bin or /usr/local/sbin  rather than default python or ipython. The way I 
 got
 around this is rename python in these locations to python_old and then did
 a soft link to ipython (i.e., ln -s /anaconda/bin/ipython python). 

 I am sure there is a smarter way of telling babel to use ipython, but
 this was my work around.


See the `org-babel-python-command' variable.


 Hope this help
 cheers,
 M





-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] customizable C, C++, D, Java, Groovy compilers

2014-06-16 Thread Eric Schulte
Applied, Thanks!

Thierry Banel tbanelweb...@free.fr writes:

 Hi all

 Here is a patch to make compilers customizable
   (by typing M-x customize-group org-babel).
 It applies to C, C++, D, Java, Groovy.
 This is consistent with customizations for R, Python, Ditaa and others
 languages.

 Have fun
 Thierry



 From 933f50c3fbebefec14b5df8ebff0cebaf3e45922 Mon Sep 17 00:00:00 2001
 From: Thierry Banel tbanelweb...@free.fr
 Date: Sun, 15 Jun 2014 14:53:34 +0200
 Subject: [PATCH]  Make C, C++, D, Java, Groovy compilers customizable

   * ob-C.el (org-babel-C-compiler):
   (org-babel-C++-compiler):
   (org-babel-D-compiler): changed defvar to defcustom
   * ob-java.el (org-babel-java-command):
   (org-babel-java-compiler): changed defvar to defcustom
   * ob-groovy.el (org-babel-groovy-command):
   changed defvar to defcustom
 ---
  lisp/ob-C.el  |   36 ++--
  lisp/ob-groovy.el |   10 --
  lisp/ob-java.el   |   22 +-
  3 files changed, 51 insertions(+), 17 deletions(-)

 diff --git a/lisp/ob-C.el b/lisp/ob-C.el
 index 505b290..2e146d4 100644
 --- a/lisp/ob-C.el
 +++ b/lisp/ob-C.el
 @@ -46,16 +46,32 @@
  
  (defvar org-babel-default-header-args:C '())
  
 -(defvar org-babel-C-compiler gcc
 -  Command used to compile a C source code file into an
 -executable.)
 -
 -(defvar org-babel-C++-compiler g++
 -  Command used to compile a C++ source code file into an
 -executable.)
 -
 -(defvar org-babel-D-compiler rdmd
 -  Command used to compile and execute a D source code file.)
 +(defcustom org-babel-C-compiler gcc
 +  Command used to compile a C source code file into an executable.
 +May be either a command in the path, like gcc
 +or an absolute path name, like /usr/local/bin/gcc
 +parameter may be used, like gcc -v
 +  :group 'org-babel
 +  :version 24.3
 +  :type 'string)
 +
 +(defcustom org-babel-C++-compiler g++
 +  Command used to compile a C++ source code file into an executable.
 +May be either a command in the path, like g++
 +or an absolute path name, like /usr/local/bin/g++
 +parameter may be used, like g++ -v
 +  :group 'org-babel
 +  :version 24.3
 +  :type 'string)
 +
 +(defcustom org-babel-D-compiler rdmd
 +  Command used to compile and execute a D source code file.
 +May be either a command in the path, like rdmd
 +or an absolute path name, like /usr/local/bin/rdmd
 +parameter may be used, like rdmd --chatty
 +  :group 'org-babel
 +  :version 24.3
 +  :type 'string)
  
  (defvar org-babel-c-variant nil
Internal variable used to hold which type of C (e.g. C or C++ or D)
 diff --git a/lisp/ob-groovy.el b/lisp/ob-groovy.el
 index 9bb17e6..0068df9 100644
 --- a/lisp/ob-groovy.el
 +++ b/lisp/ob-groovy.el
 @@ -36,8 +36,14 @@
  (defvar org-babel-tangle-lang-exts) ;; Autoloaded
  (add-to-list 'org-babel-tangle-lang-exts '(groovy . groovy))
  (defvar org-babel-default-header-args:groovy '())
 -(defvar org-babel-groovy-command groovy
 -  Name of the command to use for executing Groovy code.)
 +(defcustom org-babel-groovy-command groovy
 +  Name of the command to use for executing Groovy code.
 +May be either a command in the path, like groovy
 +or an absolute path name, like /usr/local/bin/groovy
 +parameters may be used, like groovy -v
 +  :group 'org-babel
 +  :version 24.3
 +  :type 'string)
  
  (defun org-babel-execute:groovy (body params)
Execute a block of Groovy code with org-babel.  This function is
 diff --git a/lisp/ob-java.el b/lisp/ob-java.el
 index 22f8785..8c64171 100644
 --- a/lisp/ob-java.el
 +++ b/lisp/ob-java.el
 @@ -32,11 +32,23 @@
  (defvar org-babel-tangle-lang-exts)
  (add-to-list 'org-babel-tangle-lang-exts '(java . java))
  
 -(defvar org-babel-java-command java
 -  Name of the java command.)
 -
 -(defvar org-babel-java-compiler javac
 -  Name of the java compiler.)
 +(defcustom org-babel-java-command java
 +  Name of the java command.
 +May be either a command in the path, like java
 +or an absolute path name, like /usr/local/bin/java
 +parameters may be used, like java -verbose
 +  :group 'org-babel
 +  :version 24.3
 +  :type 'string)
 +
 +(defcustom org-babel-java-compiler javac
 +  Name of the java compiler.
 +May be either a command in the path, like javac
 +or an absolute path name, like /usr/local/bin/javac
 +parameters may be used, like javac -verbose
 +  :group 'org-babel
 +  :version 24.3
 +  :type 'string)
  
  (defun org-babel-execute:java (body params)
(let* ((classname (or (cdr (assoc :classname params))

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] proposal to have ignoreheading tags/properties

2014-06-15 Thread Eric Schulte
Hi,

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

 Hello,

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

 Why TODO types rather than a tag?  IMO using a TODO type would conflate
 task management and document structuring.  What do you think about the
 attached patch which should add this functionality to the core.

 Thank you. Unfortunately, in many cases this code will make the parse
 tree invalid. Consider the example below:

   * H1
 Text1
   ** H2 :inline:
 Text2

 A simplified version of the parse tree is:

   (headline
(section
 (paragraph Text1))
(headline
 (section
  (paragraph Text2

 With your function, it becomes

   (headline
(section
 (paragraph Text1))
(section
 (paragraph Text2)))

 which is invalid, as a given headline is not expected to have more than
 one section.

 Of course, it is possible to add code in order to merge both sections
 and get

   (headline
(section
 (paragraph Text1)
 (paragraph Text2)))

 which is exactly what you obtain in the first answer of the FAQ, along
 with its limitations (see the :noexport: example in the same question).

 Actually, the problem is deeper than that. This :inline: tag is just
 a convoluted way to ask for a positive answer to another FAQ: « Can
 I close an outline section without starting a new section? »
 (http://orgmode.org/worg/org-faq.html#closing-outline-sections). Indeed,
 allowing :include: tags is equivalent to allowing to close sections
 before the next one, at least at the export level:

   * Section one

   Some text

   ** Subsection one

   Some text

   ** Subsection two

   Some text

   ** end Subsection Two 
 :inline:

   Continue text in section one.

 This is not possible and goes against so many assumptions in Org that it
 will always introduce problems, as your function does.


Thanks Nicolas.  Point clearly stated.  All of the structural issues
hinge upon the inclusion of the contents of an inlined (ignored)
headline, so the solution is to change the behavior s.t. the non-subtree
contents of ignored headlines are also removed from export.  This is
implemented below.


 Since it cannot work in the general case, I do not think it should go in
 core. Fortunately, a simple function in `org-export-before-parsing-hook'
 provides a decent solution already. Users requiring more sophistication
 can always implement their own function and add it to that hook.

 OTOH, the situation could be improved wrt :export: and :noexport: tags.
 We could allow nesting :export: tags within :noexport: tags with the
 following rule: the :export: headline with the lowest level within
 the :noexport: tree gets promoted to the root of the tree.
 Other :export: headlines have their level set relatively to this one.
 Thus:

   Text before first headline
   * H1
   Body1
   ** H2 :noexport:
   Body2
   *** H3
   Body3
   *** H4 :export:
   Body4
    H5
   Body5

 will be seen as

   Text before first headline
   * H1
   Body1
   ** H4
   Body4
   *** H5
   Body5


In my opinion the manual interleaving of noexport and export tags is
overly cumbersome and is non-obvious.  The obscure nature of this
solution is evidenced by multiple discussions and implementations of
filter functions to handle situations which could be covered by this
noexport/export pattern.

I think the attached patch should be applied to the core.  It includes
the following.

- a single new export function which removes the headlines and contents
  (the section element) of headlines tagged ignoreexport, then
  retains and promotes all sub-headlines contained therein.

- a single new export tag named ignoreexport (ignore seems to be the
  crowd favorite, and adding export reduces possible conflicts with
  existing personal tags)

- some tests protecting this new functionality

- I'd like to add documentation of this tag to the manual to improve
  visibility beyond the existing FAQ entries (which have failed to
  prevent multiple on list discussions and re-implementations of this
  feature).  It is not clear where to document such a tag.  The export
  and noexport tags are only documented as a side effect of
  documentation for the SELECT_TAGS keyword.  I think it would be
  beneficial to add a selective export section or paragraph (which
  existed in the old manual) to the new manual.

From the included tests, the effect of this patch is to convert a tree
like the following,

,
| * H1
| Text1
| ** H2  :ignoreexport:
| Text2
| *** H3
| Text3
|  H4
| Text4
| *** H5
| Text5
|  H6:ignoreexport:
| Text6
| * H7
| Text7
| * H8
| Text8
`

on export to a tree like the following.

,
| 1 H1
| 
| 
|   Text1
| 
| 1.1 H3
| ~~
| 
|   Text3
| 
| 1.1.1 H4
| 
| 
|   Text4
| 
| 1.2 H5
| ~~
| 
|   Text5
| 
| 1.2.1 H7

Re: [O] patch: Oracle engine for SQL blocks

2014-06-13 Thread Eric Schulte
John Dell'Aquila del...@ml1.net writes:

 Thanks, Eric. I've started the FSF assignment process.

 I have a question about the header row delimiter in the results table. I
 didn't set the header-delim variable in the code, becasue the user can
 change the Oracle underline character, possibly multiple times, so it is
 difficult to work out a proper setting.

 The results appeared OK with header-delim left at . I now realize that
 this causes the table to be mis-parsed when the first column is blank,
 even though it has a proper header.

 I put in a fix to scan for the first set underline command and use
 that character, otherwise set header-delim to -. In the process of
 testing I found I could always set header-delim to '-' and the table
 parsed correctly even when the actual Oracle delimiter was set
 differently.

 I'm wondering how this is supposed to work. I'd rather not add
 unecessary complexity, but I don't want on rely on a bug or misfeature
 either.


I'm not familiar with this portion of ob-sql, so I'll defer to your best
judgment.

Best,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] conforming commit messages Was: babel C, C++, D enhancement

2014-06-13 Thread Eric Schulte
Bastien b...@gnu.org writes:

 Hi Eric and Thierry,

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

 This new patch looks great, and the test suite passes locally.  I've
 just applied it.

 Thanks for applying this -- let me just be boring again and insist on
 properly rewrite the Changelog when applying patches... in this case,
 there are a lot of tiny formatting issues I will need to fix myself
 when merging into Emacs :/

 Thanks to both of you!

Mea culpa!

I glanced at it and it looked good, but I'll be more careful moving
forward.  Does anyone on the list happen to have or know of a script
which could be used to automatically check for conforming commit
messages?  If so I'm sure git provides a hook to make passing such a
script part of the git commit process.  That's the only way I'll really
be consistent about this.

Thanks,
Eric

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] proposal to have ignoreheading tags/properties

2014-06-13 Thread Eric Schulte
Ken Mankoff mank...@gmail.com writes:

 Hi Eric,  On 2014-06-12 at 20:46, Eric Schulte wrote: 
 Can you suggest a more intuitive/appropriate tag name?  I'm not
 personally partial to inline, it was just the first thing that
 occurred to me.  Previous implementations of similar behavior used
 the tag prelim. 

 I posted the following before. I think you might not be getting all
 the emails I post to the list. For example, I commented that INLINE as
 a TODO keyword didn't make sense to me using a similar explanation to
 your reply to that same email.   I have used your implementation from
 last week using prelim but changed the word, because as with
 inline, I don't associate the word prelim with the behavior being
 implemented. 


Sounds like I'm missing something.


  -k.

 I vote for the following tags:

 + :noexport: Does not export item, content, and children.
 + :ignoreheading: Does not export heading. Exports content and
 children.
 + :ignorecontent: Does not export heading or content. Does export
 children.
 + :ignorebranch: Does not export heading, content, or children.
 + :promotesubheadings: Promotes children headings, regardless of
  exporting this heading or not

 Note that :ignorebranch: is the same as :noexport but is a more
 consistent naming scheme. Ignoring and promotion are two separate
 items
 and can be used together or exclusively for maximum number of export
 behaviors.

This feels excessive to me.  ignorecontent could more easily be
implemented with a leading ignored heading, and the common use case of
promoting a heading's children while ignoring the heading itself now
requires two tags with long names.

Best,
Eric

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] babel C, C++, D enhancement

2014-06-13 Thread Eric Schulte
Achim Gratz strom...@nexgo.de writes:

 Eric Schulte writes:
 This new patch looks great, and the test suite passes locally.  I've
 just applied it.

 You also get a warning from the byte-compiler on something that is
 clearly a bug.  I think the fix should be:

 --8---cut here---start-8---
 diff --git a/lisp/ob-C.el b/lisp/ob-C.el
 index dd03fa7..a794e2a 100644
 --- a/lisp/ob-C.el
 +++ b/lisp/ob-C.el
 @@ -264,7 +264,7 @@ (defun org-babel-C-val-to-C-type (val)
(list
 (if (equal org-babel-c-variant 'd) string const char*)
 \%s\))
 - (t (error unknown type %S type)
 + (t (error unknown type %S basetype)
  (cond
   ((integerp val) type) ;; an integer declared in the #+begin_src line
   ((floatp val) type) ;; a numeric declared in the #+begin_src line
 --8---cut here---end---8---


Agreed, I've just pushed up a fix.  Please feel free to push these sorts
of obvious bug fixes yourself in the future.


 The type determination is a tad optimistic, too.  An Emacs integer may
 or may not fit into C type int depending on how Emacs is compiled and
 which compiler you are using.


Certainly, more refinement wouldn't hurt.

Best,
Eric



 Regards,
 Achim.

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] Org 8.2.7

2014-06-13 Thread Eric Schulte
Bastien b...@gnu.org writes:

 Hi all,

 I released Org 8.2.7, a bugfix release.

 This comes with some important changes under the wood,

Much classier than making changes under the hood.

Thanks for the your constant support!
Eric

 
 though, so careful tests and bug reports are welcome!

 Thanks,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] proposal to have ignoreheading tags/properties

2014-06-12 Thread Eric Schulte
Mark Edgington edgi...@gmail.com writes:

 In using org-mode, there is one problem that has always irked me (and
 is apparently also closely related to the FAQ How do I ignore a
 headline?).  When I am writing something, I sometimes want to group
 things by concept or by work to be done, or any other number of
 groupings.  BUT I do not want these groupings to be part of the
 exported document itself.  In fact, I would like it to be as if the
 grouping did not exist at all (i.e. a headline that is ignored).

 The problem with using an ignored headline for grouping things is that
 it still does have an effect on exported document structure, in that
 all of the elements contained inside / in the scope of the ignored
 headline still keep their depth (one level deeper than the level of
 the ignored headline).

 What I want is for the nested items to have their levels all promoted
 by one, so that it's truly as if the ignored headline wasn't there at
 all, and that it invisibly wrapped around a group of items without
 requiring them to have a deeper level.  Perhaps this could be done by
 use of an ignoreheading and an ignoreheadingpromote tag (one
 promotes the level of contained items, another doesn't), or some
 equivalent set of properties that could be set on a headline.

 Would there be any chance that something like this could be built in
 to org-mode?  I think it would make it far more flexible in terms of
 organizing things, making this organization process orthogonal to the
 selection of sections/subsections of a document.


I just ran across this need myself, and updated an old solution to work
with the new exporter.  See the thread and my solution at the following.

http://lists.gnu.org/archive/html/emacs-orgmode/2014-06/msg00238.html

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] org-mime spurious alternative

2014-06-12 Thread Eric Schulte
Sébastien Delafond sdelaf...@gmail.com writes:

 Hello,

 from Debian bug #751014 (http://bugs.debian.org/751014):

   When org-mime-library is set to semi, org-mime generates a spurious
   alternative section around the HTML part.  This is due to two bugs in
   the function org-mime-multipart:

   1. it attempts to put a multipart/alternative section around the HTML,
  where it should be putting a multipart/related part;

   2. it tests for the presence of images by doing (when images ...),
  which triggers when images is the empty string (somebody has been
  programming in Python or Javascript?).

   To repeat:

 M-x load-library org-mime RET
 M-: (setq org-mime-library 'semi) RET
 M-x wl RET
 w

   Then insert some text below the separator line, and do

 M-x org-mime-htmlize

   and see the breakage.

 Cheers,

 --Seb



Does the attached patch fix these problems?

Thanks,
Eric

From 9af18107bd82fb9778b87b5891b1772fb847cc74 Mon Sep 17 00:00:00 2001
From: Eric Schulte schulte.e...@gmail.com
Date: Thu, 12 Jun 2014 14:40:32 -0400
Subject: [PATCH] fix semi-backend bug in org-mime

* contrib/lisp/org-mime.el (org-mime-multipart): Fix bug in use of the
  semi org-mime-library when converting emails to HTML.
---
 contrib/lisp/org-mime.el | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/contrib/lisp/org-mime.el b/contrib/lisp/org-mime.el
index 5f874d9..44bf91b 100644
--- a/contrib/lisp/org-mime.el
+++ b/contrib/lisp/org-mime.el
@@ -163,10 +163,13 @@ and images in a multipart/related part.
 ('semi (concat
 -- alternative-{\n
 -- [[text/plain]]\n plain
-	(when images (concat -- alternative-{\n))
--- [[text/html]]\n  html
-	images
-	(when images (concat -- }-alternative\n))
+	(if (and images ( (length images) 0))
+		(concat -- related-{\n
+			-- [[text/html]]\n  html
+			images
+			-- }-related\n)
+	  (concat -- [[text/html]]\n  html
+		  images))
 -- }-alternative\n))
 ('vm ?)))
 
-- 
2.0.0


-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)


Re: [O] How to specify the tangled comment to be the location of the noweb ref definition instead of where it was tangled?

2014-06-12 Thread Eric Schulte

 How do I make the code comment specify the actual location of the source block
 ref, not just where it was expanded and tangled?


Currently inserting comments around snippets of code expanded with noweb
is not supported.  You may be able to fake this through the clever use
of variables along the lines of the following,

#+begin_src sh :var start=(line-number-at-pos (point)) :results scalar
  cat EOF
  # started at $start
  foo bar baz
  EOF
#+end_src

or an implementation of optional wrappers for noweb-expanded snippets
would probably start with the `org-babel-expand-noweb-references'
function.

Best,
Eric

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] [bug][babel] noweb gotcha

2014-06-12 Thread Eric Schulte
Charles Berry ccbe...@ucsd.edu writes:

 The following 

 ,
 | #+PROPERTY: tangle yes
 | 
 | #+NAME: print-abc
 | #+BEGIN_SRC emacs-lisp
 | (format 
 | %s abc)
 | #+END_SRC
 | 
 | #+NAME: print-def
 | #+BEGIN_SRC emacs-lisp
 | (concat
 |  def )
 | #+END_SRC
 | 
 | #+BEGIN_SRC emacs-lisp :noweb yes
 | print-abc
 | print-def
 | #+END_SRC
 `



 tangles as 

 ,
 | (format 
 | %s abc)
 | 
 | (concat
 |  def )
 | 
 | (format 
 | %s abc)
 | (concat
 | )
 `


 Note that  def  disappeared from (concat ...).

 FWIW, adding quotes inside the constant string in org-babel-noweb-wrap:


 \\([^ \\t\n][^\]+?[^ \\t]\\|[^ \\t\n]\\)

 fixes this instance.


Does this raise any error, or fail silently?

Thanks,
Eric



 HTH,

 Chuck




-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] A simple org tangle and weave makefile

2014-06-12 Thread Eric Schulte
Grant Rettke g...@wisdomandwonder.com writes:

 Hi,

 My goals was to have a simple makefile to tangle and weave a document;
 so org-mk was out of scope.

 Just wondering; how could I have done it better?

 ##
 INIT=.emacs.el

 $(INIT): TC3F.org
 time emacs --batch --no-init-file --load .org-mode.emacs.el
 --find-file TC3F.org --funcall org-babel-tangle --kill

 TC3F.html: $(INIT)
 time emacs --batch --no-init-file --load .org-mode.emacs.el
 --find-file TC3F.org --funcall org-html-export-to-html --kill

 clean:
 rm $(INIT)
 rm TC3F.html
 ##

 Kind regards,


I don't know if this is better, but its closer to what I use locally.

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

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

%.tex: %.org init.el
	$(BATCH_EMACS) $*.org -f org-latex-export-to-latex

%.el: %.org init.el
	$(BATCH_EMACS) $*.org -f org-babel-tangle

# two fancier alternatives to the above which provide a default file
# name and encode language information

%.el: %.org init.el
	$(BATCH_EMACS) $*.org \
	--eval '(org-babel-tangle nil $@ (quote emacs-lisp))'

%.sh: %.org init.el
	$(BATCH_EMACS) $*.org \
	--eval '(org-babel-tangle nil $@ (quote bash))'


 Grant Rettke | AAAS, ACM, ASA, FSF, IEEE, SIAM, Sigma Xi
 g...@wisdomandwonder.com | 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.” --ThompsonH


-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)


Re: [O] proposal to have ignoreheading tags/properties

2014-06-12 Thread Eric Schulte

 I also ran across this need. What I had in mind was that certain todo
 types would be treated as inline.
 For instance, if P was a member of this hypothetical
 org-inline-todo-keywords, then

 * P a paragraph
   some contents

 would be rendered as

 some contents

 by the exporter, no matter the backend.

 Such a feature is more generic and would be useful in other contexts ;
 and the LaTeX-related issues discussed in this thread would be solved
 using something like

 * INLINE appendix
   \appendix
 * Appendix 1


Why TODO types rather than a tag?  IMO using a TODO type would conflate
task management and document structuring.  What do you think about the
attached patch which should add this functionality to the core.

From 5a41eae2af24097ec9c1507926af6f6fab8f2628 Mon Sep 17 00:00:00 2001
From: Eric Schulte schulte.e...@gmail.com
Date: Thu, 12 Jun 2014 16:11:04 -0400
Subject: [PATCH] export removes INLINE heading and promotes subtree

* lisp/ox.el (org-export-remove-and-promote-children-of-inline-headlines):
  A new function.
  (org-export-as): Include
  `org-export-remove-and-promote-children-of-inline-headlines' in the
  export process.
---
 lisp/ox.el | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/lisp/ox.el b/lisp/ox.el
index 4bfef52..961d795 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -2320,6 +2320,29 @@ tree is modified by side effect and returned by the function.
 		(plist-get info prop)
 		info
 
+(defun org-export-remove-and-promote-children-of-inline-headlines (data info)
+  Remove inline headlines and promote their children.
+DATA is the parse tree.  INFO is a plist containing export
+options.  Each headline tagged as INLINE will be removed
+retaining its contents, and promoting any children headlines by a
+single level.
+  (org-element-map data org-element-all-elements
+(lambda (object)
+  (when (and (equal 'headline (org-element-type object))
+ (or (member inline (org-element-property :tags object))
+		 (member INLINE (org-element-property :tags object
+(mapc (lambda (el)
+;; recursively promote all nested headlines
+(org-element-map el 'headline
+  (lambda (el)
+(when (equal 'headline (org-element-type el))
+  (org-element-put-property el
+:level (1- (org-element-property :level el))
+(org-element-insert-before el object))
+  (cddr object))
+(org-element-extract-element object)))
+info nil org-element-all-elements))
+
 (defun org-export--remove-uninterpreted-data-1 (data info)
   Change uninterpreted elements back into Org syntax.
 DATA is a parse tree or a secondary string.  INFO is a plist
@@ -3124,6 +3147,9 @@ Return code as a string.
 	 ;; Handle left-over uninterpreted elements or objects in
 	 ;; parse tree and communication channel.
 	 (org-export-remove-uninterpreted-data tree info)
+	 ;; Remove headlines tagged as inline and promote their
+	 ;; children.
+	 (org-export-remove-and-promote-children-of-inline-headlines tree info)
 	 ;; Call options filters and update export options.  We do not
 	 ;; use `org-export-filter-apply-functions' here since the
 	 ;; arity of such filters is different.
-- 
2.0.0




 Cheers,

 Nicolas

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)


Re: [O] patch: Oracle engine for SQL blocks

2014-06-12 Thread Eric Schulte
Hi John,

This patch looks great.  Given it's length FSF copyright assignment will
be required so please begin that process and when it is complete I'll be
very happy to apply this patch.

Thanks,
Eric

John Dell'Aquila del...@ml1.net writes:

 Hi,

 This patch makes Oracle a supported database for SQL source code
 blocks:

   - separate or unified logins, take your pick of:
 :dbuser user :dbpassword password :dbhost connect_id
 :dbuser user/password@connect_id
 :cmdline user/password@connect_id

   - support for :colnames on/off

   - helpful error messages in minibuffer if execution fails

   - good looking result block (most of the time)

 I've tested this extensively on Windows 7. It only needs the sqlplus
 executable and   file redirection, so it should work everywhere.

 I am willing to execute an FSF copyright assignment.

 Regards,
 John

 From 08e01124a7f65fbdeec8d14f0e7b555bb1565ad9 Mon Sep 17 00:00:00 2001
 From: John Dell'Aquila del...@ml1.net
 Date: Tue, 10 Jun 2014 20:33:31 -0500
 Subject: [PATCH] ob-sql.el: Implement Oracle engine

 * lisp/ob-sql.el (org-babel-execute:sql): Add Oracle support with
 proper error handling.
 ---
  lisp/ob-sql.el | 41 +
  1 file changed, 41 insertions(+)

 diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el
 index 7b85df8..42a03a1 100644
 --- a/lisp/ob-sql.el
 +++ b/lisp/ob-sql.el
 @@ -128,11 +128,31 @@ This function is called by 
 `org-babel-execute-src-block'.
 (org-babel-process-file-name in-file)
 (org-babel-process-file-name out-file)
 (or cmdline )))
 + ('oracle (format
 +   sqlplus -S -L %s %s %s %s
 +   (if (and dbuser dbpassword dbhost)  ; build login
 +   (format %s/%s@%s dbuser dbpassword dbhost)
 + (or dbuser ))  ; or just pass dbuser
 +   (or cmdline )
 +   (org-babel-process-file-name in-file)
 +   (org-babel-process-file-name out-file)))
  (t (error No support for the %s SQL engine engine)
  (with-temp-file in-file
(insert
 (case (intern engine)
('dbi /format partbox\n)
 +  ('oracle
 +   ;; Inject suitable SQL*Plus settings
 +   (concat
 +(if colnames-p
 +set heading on underline '-'\n  ; column headings
 +  set heading off\n)  ; no headings
 +set colsep '|' tab off\n  ; | between columns, no tabs
 +set linesize 150\n; Oracle default width
 +set newpage none\n; no page breaks
 +set feedback off\n; no informational messages
 +prompt ~_SentineL~!\n ; marker for post-processing
 +))
(t ))
 (org-babel-expand-body:sql body params)))
  (message command)
 @@ -155,6 +175,27 @@ This function is called by 
 `org-babel-execute-src-block'.
  (insert -\n)
  (setq header-delim -)
  (write-file out-file)
 +   ((eq (intern engine) 'oracle)
 +(with-temp-buffer
 +  (insert-file-contents out-file)
 +  ;; Delete up to and including sentinel (anything before
 +  ;; sentinel is garbage from user's login.sql script)
 +  (goto-char (point-min))
 +  (if (re-search-forward ~_SentineL~!\n nil t)
 +  (delete-region (point-min) (point)))
 +  ;; Anything left?
 +  (if (eq (buffer-size) 0)
 +  (if (string-match ; body)
 +  (error No rows selected) 
 +(error No rows selected (need final ; perhaps?
 +  ;; Scan for *last* Oracle or SQL*Plus error, include up
 +  ;; to 5 preceding lines in error message
 +  (goto-char (point-max))
 +  (if (re-search-backward ^\\(ORA\\|SP2\\)-[0-9]+:  nil t)
 +  (let ((p (line-end-position)))
 +(forward-line -5)
 +(error (buffer-substring-no-properties (point) p
 +  (write-file out-file)))
 (t
  ;; Need to figure out the delimiter for the header row
  (with-temp-buffer

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] [bug][babel] noweb gotcha

2014-06-12 Thread Eric Schulte
Charles C. Berry ccbe...@ucsd.edu writes:

 On Thu, 12 Jun 2014, Eric Schulte wrote:

 Charles Berry ccbe...@ucsd.edu writes:

 The following

 ,
 | #+PROPERTY: tangle yes
 |
 | #+NAME: print-abc
 | #+BEGIN_SRC emacs-lisp
 | (format
 | %s abc)
 | #+END_SRC
 |
 | #+NAME: print-def
 | #+BEGIN_SRC emacs-lisp
 | (concat
 |  def )
 | #+END_SRC
 |
 | #+BEGIN_SRC emacs-lisp :noweb yes
 | print-abc
 | print-def
 | #+END_SRC
 `



 tangles as

 ,
 | (format
 | %s abc)
 |
 | (concat
 |  def )
 |
 | (format
 | %s abc)
 | (concat
 | )
 `


 Note that  def  disappeared from (concat ...).

 FWIW, adding quotes inside the constant string in org-babel-noweb-wrap:


 \\([^ \\t\n][^\]+?[^ \\t]\\|[^ \\t\n]\\)

 fixes this instance.


 Does this raise any error, or fail silently?

 Thanks,
 Eric


 Alas, it fails silently -- producing the erroneous output.

 I guess the issue is that

   `(re-search-forward (org-babel-noweb-wrap) nil t)'

 finds quoted expressions like

 1. abc
 2. (concat  abc )

 FWIW,

 (re-search-forward
  (org-babel-noweb-wrap
   \\([^ \\t\n][^\]+?[^ \\t]\\|[^ \\t\n]\\)
   ) nil t)

 (adding quotes to the [^...] bits) takes care of example 2. Not sure
 if example 1 is a feature or a bug - I sometimes use things like

   text-I-want

 so maybe modifying the regex is good enough?

 OTOH, no-such-chunk has no effect. Maybe checking that the
 reference actually resolves is better than tweaking the regexes.


So it is currently possible to raise errors when noweb references don't
resolve through the use of the `org-babel-noweb-error-all-langs'
variable.  I just added `org-babel-noweb-error-all-langs' which may be
set to raise such errors regardless of the language of the code block.

Best,
Eric



 HTH,

 Chuck



-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] proposal to have ignoreheading tags/properties

2014-06-12 Thread Eric Schulte
Nicolas Girard girard.nico...@gmail.com writes:

 2014-06-12 22:13 GMT+02:00 Eric Schulte schulte.e...@gmail.com:


 Why TODO types rather than a tag?  IMO using a TODO type would conflate
 task management and document structuring.

 Agreed.

 What do you think about the
 attached patch which should add this functionality to the core.


 Seems fine to me !


Great, I'll leave actual application and possible adjustment to Nicolas
Goaziou as he knows best how the exporter should grow.


 I created a public repository containing a Makefile and a bunch of
 unit tests here: https://github.com/ngirard/org-inline-headings-tests.


This looks great, perhaps you could fold the unit tests into the testing
directory Org-mode repository and then share them as a patch?

Best,
Eric



 Cheers,

 Nicolas

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] proposal to have ignoreheading tags/properties

2014-06-12 Thread Eric Schulte
Ken Mankoff mank...@gmail.com writes:

 On 2014-06-12 at 16:13, Eric Schulte wrote:
 What do you think about the attached patch which should add this
 functionality to the core.

 Why inline? 

 Org already has inline TODO items which is a different thing. 

 I don't think the word inline signifies that a heading will or won't
 be exported and/or its children promoted.


Can you suggest a more intuitive/appropriate tag name?  I'm not
personally partial to inline, it was just the first thing that
occurred to me.  Previous implementations of similar behavior used the
tag prelim.

Thanks,
Eric

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] Can this table formula be done more efficient

2014-06-08 Thread Eric Schulte
Nick Dokos ndo...@gmail.com writes:

 Cecil Westerhof cldwester...@gmail.com writes:

 At the moment I am using the following formula:
     #+TBLFM: @$4..@$4 = $2 - $3 :: @$2=vsum(@$2..@$2) ::
 @$3=vsum(@$3..@$3) :: @$4=vsum(@$4..@$4)

 This does what I want, but there are two things that could be improved.

 - The second, third and fourth formula do exactly the same, only on
 different columns. Could this be rewritten to one formula?


 --8---cut here---start-8---
 #+TBLFM: @$4..@$4 = $2 - $3 :: @$2..$4=vsum(@$0..@$0)
 --8---cut here---end---8---

 See (info (org) References)

 - The line becomes long and hard to evaluate for a person. Is there
 a possibility to put the formulas below each-other?


 I don't believe so but my belief may be out of date. It has been
 discussed before: check the list archives.

Sort of but not really.  See Using multiple #+TBLFM lines in the
manual.

,
| Using multiple #+TBLFM lines
| 
| 
| You may apply the formula temporarily.  This is useful when you switch
| the formula.  Place multiple ‘#+TBLFM’ lines right after the table, and
| then press ‘C-c C-c’ on the formula to apply.  Here is an example:
| 
|  | x | y |
|  |---+---|
|  | 1 |   |
|  | 2 |   |
|  #+TBLFM: $2=$1*1
|  #+TBLFM: $2=$1*2
| 
| Pressing ‘C-c C-c’ in the line of ‘#+TBLFM: $2=$1*2’ yields:
| 
|  | x | y |
|  |---+---|
|  | 1 | 2 |
|  | 2 | 4 |
|  #+TBLFM: $2=$1*1
|  #+TBLFM: $2=$1*2
| 
| Note: If you recalculate this table (with ‘C-u C-c *’, for example), you
| will get the following result of applying only the first ‘#+TBLFM’ line.
| 
|  | x | y |
|  |---+---|
|  | 1 | 1 |
|  | 2 | 2 |
|  #+TBLFM: $2=$1*1
|  #+TBLFM: $2=$1*2
`


-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] babel C, C++, D enhancement

2014-06-08 Thread Eric Schulte
Thierry Banel tbanelweb...@free.fr writes:

 Hi Eric, hi All

 Here is a new patch (do not apply the previous).
 I added a check in the test suite for the D compiler availability
 (and for the C++ compiler as well).
 It silently returns true when the compiler is not found.

 To run the test suite I did that:
 - start from an up-to-date org-mode/ GIT directory
 - create a GIT branch, checkout there
 - apply the patch : git am patch-file
 - make clean
 - make autoloads
 - make test-dirty

 Eric, this result you were getting is strange:
   FAILED ob-C/inhomogeneous_table
 It is as though the NEW test suite was run against the OLD ob-C.el
 Maybe there was an old .elc compiled file hanging around ?
  
 Anyway, it works fine for me.
 Could someone check and tell me if something goes wrong ?

 Have fun
 Thierry


Hi Theirry,

This new patch looks great, and the test suite passes locally.  I've
just applied it.

Thanks!
Eric

also, thanks for taking the time to flesh out the commit message



 Le 06/06/2014 18:31, Eric Schulte a écrit :
 Hi Thierry,

 This looks wonderful, however after applying this patch I get the
 following errors when running make test-dirty.

 10 unexpected results:
FAILED  ob-C/inhomogeneous_table
FAILED  ob-D/inhomogeneous_table
FAILED  ob-D/integer-var
FAILED  ob-D/list-list-var
FAILED  ob-D/list-var
FAILED  ob-D/simple-program
FAILED  ob-D/string-var
FAILED  ob-D/table
FAILED  ob-D/two-integer-var
FAILED  ob-D/vector-var
 Could you update the test suite so that the C tests pass, and the D
 tests are not executed when D is not available?

 Also, could you flesh out the commit message so that it meets the Emacs
 commit message guidelines (http://orgmode.org/worg/org-contribute.html)?

 Many Thanks,
 Eric





-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] a minor patch to awk invocation

2014-06-07 Thread Eric Schulte
Greg Minshall minsh...@acm.org writes:

 though, in the spirit of no good deed goes unpunished:
 
 #+name: foo
 | a | b | c |
 #+begin_src awk :var a=foo
 BEGIN{ print a; }
 #+end_src
 
 gives an error (and, ':var a=this is a test' doesn't behave as one
 might expect).  i haven't looked at ob-*.el enough to know the patterns
 used to wrap up various forms of variables into different languages.

Ah, thanks for pointing this out.  I just pushed up a simple fix along
with a unit test for tabular input to awk blocks.

Best,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] a minor patch to awk invocation

2014-06-07 Thread Eric Schulte
Achim Gratz strom...@nexgo.de writes:

 Eric Schulte writes:
 Thanks for pointing out this shortcoming and for suggesting the
 command-line variable assignment option.  I've just pushed up a patch
 which changes the behavior of awk code blocks to assign variables on the
 command line, so the following now work.

 For whatever reason I now get errors from an awk invocation using
 standard input:

 --8---cut here---start-8---
 tset: standard error: Inappropriate ioctl for device
   
 /bin/stty: standard input: Inappropriate ioctl for device
 /usr/bin/stty: standard input: Inappropriate ioctl for device
 --8---cut here---end---8---

 Additionally, C-c C-v C-v doesn't work correctly on many blocks and
 gives

 --8---cut here---start-8---
 org-babel-expand-src-block: Wrong type argument: number-or-marker-p, nil
 --8---cut here---end---8---


I can't reproduce these problems.  Could you provide examples, and maybe
a stack traces?

Thanks,



 Regards,
 Achim.

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] Adding source location information when tangling

2014-06-07 Thread Eric Schulte
 Hi Thomas,

 I believe the `org-babel-tangle-comment-format-beg' and
 `org-babel-tangle-comment-format-end' variable should provide the
 functionality you desire.

 Hi, Eric,

 Thank you, though I'm afraid I'm still having trouble getting
 the right result.  The closest I've come is with this setting:

   (setq org-babel-tangle-comment-format-beg
 \\sourcefilename \%file\\n\\sourcefileline %start-line)

 But this adds comment characters before the commands.

 It also adds a blank line after the comment, throwing line numbers
 off by one.  (Actually they are off by two; maybe LilyPond needs
 \sourcefileline to be on the same line as the beginning of the code.)


Yes, these will be inserted as comments, not directly into the file.
I've just added a new customization variable which will allow you turn
off the automated commenting and trailing newline insertion.  Set
`org-babel-tangle-uncomment-comments' to a non-nil value.

Best,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] a minor patch to awk invocation

2014-06-07 Thread Eric Schulte
Achim Gratz strom...@nexgo.de writes:

 Eric Schulte writes:
 I can't reproduce these problems.  Could you provide examples, and maybe
 a stack traces?

 The tests have all been done with make vanilla and
 testing/examples/ob-awk-test.org.  The test failure is:

[...]

 I've no idea how to get at the command line.  It is clear that awk gets
 invoked and even delivers the right result, but somehow it is doing this
 differently than before in the case where it uses STDIN.  I can't
 reproduce with my own awk program on the command line.


Thanks for the additional information.

The only thing I can think of is that the ordering of the arguments on
the command line is somehow responsible for this error.  Here's the
command line executed by the ob-awk/input-src-block-1 awk test,

$ awk -f /tmp/babel-66681az/awk-6668uW2

where /tmp/babel-66681az/awk-6668uW2 has the following content.

,
| {
| print 42+$1
| }
`

The command is invoked with `call-process-shell-command'.

Are these failures only present *after* these recent changes to ob-awk?
I can't think of how these changes could be related to this STDIN error.


 The problem with C-c C-v C-v happens when invoking it on the
 #+BEGIN_SRC line only (which interestingly enough works without error
 once you've done it inside the source block first).


I would be surprised if this C-c C-v C-v is caused by my recent
changes to awk's variable handling.  Can you find the offend commit here
(or at least check if the problem is new)?

Thanks,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] Collapse LaTeX source before start of main document?

2014-06-07 Thread Eric Schulte
Eric Schulte schulte.e...@gmail.com writes:

 Matt Lundin m...@imapmail.org writes:

 Chris Malone chris.m.mal...@gmail.com writes:

 (Note: When using gmail, please adjust the settings to send your
 messages as plain text only instead of multipart/alternative.)

 When I include the actual contents of my abstract, this preliminary material
 section (the #+begin ... #+end block) is rather large.  I'd like to be able
 to put this material into a headline so that I could collapse it - but I
 don't want this headline exported as content of the main document.

 In other words, is there a property or tag that I can add to a headline that
 causes LaTeX export to ignore the fact that it is a headline (i.e. \chapter,
 \section, \subsection, etc.), but still export its contents?  Something
 like:

 You could add a hook to remove headlines with a prelim tag:

 --8---cut here---start-8---
 (defun my-org-export-remove-tagged-headlines (tag)
   (save-excursion
 (goto-char (point-min))
 (while (re-search-forward (concat : tag :) nil t)
   (delete-region (point-at-bol) (point-at-eol)

 (add-hook 'org-export-preprocess-hook (lambda () 
 (my-org-export-remove-tagged-headlines prelim)))
 --8---cut here---end---8---


 I found the very useful but sadly outdated snippet from 2011.  If anyone
 is interested, the following snippet implements the same functionality
 within the new export framework.

 --8---cut here---start-8---
 (defun org-export-remove-prelim-headlines (tree backend info)
   Remove headlines tagged \prelim\ while retaining their
 contents before any export processing.
   (org-element-map tree org-element-all-elements
 (lambda (object)
   (when (and (equal 'headline (org-element-type object))
  (member prelim (org-element-property :tags object)))
 (mapc (lambda (el)
 (let ((new-object
(if (equal 'headline (org-element-type el))
(org-element-put-property el
  :level (1- (org-element-property :level el)))
  el)))
   (message %s level %s
(org-element-property :raw-value new-object)
(org-element-property :level new-object))
   (org-element-insert-before new-object object)))
   (cddr object))
 (org-element-extract-element object)))
 info nil org-element-all-elements)
   tree)

 (add-hook 'org-export-filter-parse-tree-functions
   'org-export-remove-prelim-headlines)
 --8---cut here---end---8---


The following is a slightly improved implementation of the above.
--8---cut here---start-8---
(defun org-export-remove-prelim-headlines (tree backend info)
  Remove headlines tagged \prelim\ while retaining their
contents before any export processing.
  (org-element-map tree org-element-all-elements
(lambda (object)
  (when (and (equal 'headline (org-element-type object))
 (member prelim (org-element-property :tags object)))
(mapc (lambda (el)
;; recursively promote all nested headlines
(org-element-map el 'headline
  (lambda (el)
(when (equal 'headline (org-element-type el))
  (org-element-put-property el
:level (1- (org-element-property :level el))
(org-element-insert-before el object))
  (cddr object))
(org-element-extract-element object)))
info nil org-element-all-elements)
  tree)
--8---cut here---end---8---

Best,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] Adding source location information when tangling

2014-06-06 Thread Eric Schulte
Thomas Morgan t...@ziiuu.com writes:

 Hi, Rainer, 

 Rainer M Krug r.m.k...@gmail.com writes:

 Envoyé de mon iPhone

 Le 25 mai 2014 à 18:28, Thomas Morgan t...@ziiuu.com a écrit :
 
 Dear Org hackers,
 
 I have a question about tangling LilyPond code blocks.
 
 Is there a way to put the commands `\sourcefilename' and
 `\sourcefileline' in the tangled file before each block,
 perhaps in place of the comment that includes the same information?

 Yes - Check out the header option concerning tangling with comment. So
 links are inserted as comments which contain information about the
 filename And the header from which it was tangled.

 Thank you; that option is certainly useful.  What I was looking for,
 though, is a way to replace or supplement the comments with commands
 that indicate the same information directly to the compiler or
 interpreter (`\sourcefilename' and `\sourcefileline' for LilyPond,
 `#line' for C, etc.).


Hi Thomas,

I believe the `org-babel-tangle-comment-format-beg' and
`org-babel-tangle-comment-format-end' variable should provide the
functionality you desire.

Best,


 Best,

 Thomas


-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] Bug: ob-ditaa fails in generating pdf correctly

2014-06-06 Thread Eric Schulte
Anders Johansson mejlaande...@gmail.com writes:

 Hi,
 Example input:
 #+header: :eps t
 #+header: :file hello.pdf
 #+BEGIN_SRC ditaa
 +--+
 |  |
 |Hello |
 |  |
 +--+
 #+END_SRC


 When using the above code (which I guessed should be the correct way) 
 with ob-ditaa to produce a pdf (through  DitaaEps - epstopdf) it fails 
 in producing the pdf correctly and instead writes an eps to hello.pdf. 
 This isn't surprising, looking at the code where cmd should be 
 constructed to produce the eps as an intermediary file in /tmp (which is 
 expected in the construction of pdf-cmd) but doesn't.

 An ugly patch to fix it is attached

Applied.

 (this is ugly because it repeats the line:
 (org-babel-process-file-name (concat in-file .eps)) )


I un-duplicated this line.

Thanks,


 Cheers,
 Anders Johansson

 --- /home/aj/H\303\244mtningar/ob-ditaa.el  2014-05-22 17:15:35.489071991 
 +0200
 +++ ob-ditaa.el   2014-05-22 17:08:46.617089186 +0200
 @@ -90,6 +90,12 @@
(java (cdr (assoc :java params)))
(in-file (org-babel-temp-file ditaa-))
(eps (cdr (assoc :eps params)))
 +  (pdf-cmd (when (and (or (string= (file-name-extension out-file) pdf)
 +  (cdr (assoc :pdf params
 + (concat
 +  epstopdf
 +(org-babel-process-file-name (concat in-file .eps))
 +   -o= (org-babel-process-file-name out-file
(cmd (concat org-babel-ditaa-java-cmd
   java   org-ditaa-jar-option  
 (shell-quote-argument
 @@ -97,13 +103,10 @@
   (if eps org-ditaa-eps-jar-path org-ditaa-jar-path)))
   cmdline
   (org-babel-process-file-name in-file)
 - (org-babel-process-file-name out-file)))
 -  (pdf-cmd (when (and (or (string= (file-name-extension out-file) pdf)
 -  (cdr (assoc :pdf params
 - (concat
 -  epstopdf
 -(org-babel-process-file-name (concat in-file .eps))
 -   -o= (org-babel-process-file-name out-file)
 + (if pdf-cmd
 +   (org-babel-process-file-name (concat 
 in-file .eps))
 +   (org-babel-process-file-name 
 out-file
 +  )
  (unless (file-exists-p org-ditaa-jar-path)
(error Could not find ditaa.jar at %s org-ditaa-jar-path))
  (with-temp-file in-file (insert body))

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] [BUG] [babel] in :eval never with :session

2014-06-06 Thread Eric Schulte
Rainer M Krug rai...@krugs.de writes:

 Charles Berry ccbe...@ucsd.edu writes:

 Eric Schulte schulte.eric at gmail.com writes:

 
 Rainer M Krug Rainer at krugs.de writes:
 
  The error is back:
 
 
 You say back, was this error not present recently?  If so could you
 isolate the commit at which this error appeared?
 

 The bug seems to be in the use of

 (org-link-search heading) 

 in org-babel-exp-in-export-file which is called in 
 org-babel-exp-process-buffer. 

 That search will find the first heading that is a match after 
 (point-min). So it will mess up other header args, too.

 It was there back in 8.0.7 and recent commits did not touch it AFAICS.

 Org-mode version 7.9.3f (release_7.9.3f-17-g7524ef @
 /usr/local/Cellar/emacs-mac/emacs-24.3-mac-4.6/share/emacs/24.3/lisp/org/)

 as well. I don't think it makes sense to go further back. 

 So no regression, but bug.


Thanks Charles for pointing out the use of `org-link-search' in
`org-babel-exp-in-export-file' as the source of the problem.  I'm not
sure there's a clear solution here.  Given that there may be a different
outline structure between the original and exported file (e.g., some
headlines may be present in the former and absent from the later), in
the presence of multiple headings with the same name there is no obvious
(to me) way to find a given heading from the exported file in the
original file.

I've just pushed up a change, so that when headings have IDs these will
be used instead of the heading text to find related heading in the
original buffer.  This should provide a workaround when multiple
headings with the same text are desired---just add IDs to all such
headings.

Best,


 Cheers,

 Rainer


 HTH,

 Chuck

 Thanks,
 Eric
 
 
  When one header in a subtree which has the header argument
  :eval never
  has the same name as in a following subtree which should be evaluated on
  export, the second subtree is not exported. When the name of the header
  is changed, the subtree is exported as expected.
 
  --8---cut here---start-8---
  #+PROPERTY: exports both
  #+PROPERTY: session *tmp_R*
 
  * Some non-evaluated code
  :PROPERTIES:
  :eval:  never
  :END:
  ** This is the same header
  #+BEGIN_SRC R
  cat(\ntwo\n)
  #+END_SRC
 
  * Data Assessment Results
  ** This is the same header
  If the name of the header is changed, the subtree is evaluated on export.
  #+begin_src R
  cat(\nhere it is  at  at  at  at  at  at  at  at  at
  at  at  at  at  at  at  at  at  at  at  at  at 
 at  at  at  at  at  at  at  at  at  at  at  at  at
  at  at  at  at  at  at \n)
  #+end_src
  --8---cut here---end---8---
   
  Org-mode version 8.2.6 (release_8.2.6-920-gc6d698  at 
 /Users/rainerkrug/.emacs.d/org-mode/lisp/)
  GNU Emacs 24.3.1 (x86_64-apple-darwin13.0.0, Carbon Version 1.6.0 AppKit
 1265) of 2014-02-13 on Rainers-MacBook-Pro-2.local
 
  Cheers,
 
  Rainer
 






-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] Collapse LaTeX source before start of main document?

2014-06-06 Thread Eric Schulte
Matt Lundin m...@imapmail.org writes:

 Chris Malone chris.m.mal...@gmail.com writes:

 (Note: When using gmail, please adjust the settings to send your
 messages as plain text only instead of multipart/alternative.)

 When I include the actual contents of my abstract, this preliminary material
 section (the #+begin ... #+end block) is rather large.  I'd like to be able
 to put this material into a headline so that I could collapse it - but I
 don't want this headline exported as content of the main document.

 In other words, is there a property or tag that I can add to a headline that
 causes LaTeX export to ignore the fact that it is a headline (i.e. \chapter,
 \section, \subsection, etc.), but still export its contents?  Something
 like:

 You could add a hook to remove headlines with a prelim tag:

 --8---cut here---start-8---
 (defun my-org-export-remove-tagged-headlines (tag)
   (save-excursion
 (goto-char (point-min))
 (while (re-search-forward (concat : tag :) nil t)
   (delete-region (point-at-bol) (point-at-eol)

 (add-hook 'org-export-preprocess-hook (lambda () 
 (my-org-export-remove-tagged-headlines prelim)))
 --8---cut here---end---8---


I found the very useful but sadly outdated snippet from 2011.  If anyone
is interested, the following snippet implements the same functionality
within the new export framework.

--8---cut here---start-8---
(defun org-export-remove-prelim-headlines (tree backend info)
  Remove headlines tagged \prelim\ while retaining their
contents before any export processing.
  (org-element-map tree org-element-all-elements
(lambda (object)
  (when (and (equal 'headline (org-element-type object))
 (member prelim (org-element-property :tags object)))
(mapc (lambda (el)
(let ((new-object
   (if (equal 'headline (org-element-type el))
   (org-element-put-property el
 :level (1- (org-element-property :level el)))
 el)))
  (message %s level %s
   (org-element-property :raw-value new-object)
   (org-element-property :level new-object))
  (org-element-insert-before new-object object)))
  (cddr object))
(org-element-extract-element object)))
info nil org-element-all-elements)
  tree)

(add-hook 'org-export-filter-parse-tree-functions
  'org-export-remove-prelim-headlines)
--8---cut here---end---8---

In addition it promotes all headlines under the removed prelim-tagged
headline.  This is useful to support structures like the following.

--8---cut here---start-8---
* Appendix   :prelim:
#+LaTeX: \begin{appendices}
** Definitions
** Data Sets
** Tooling
#+LaTeX: \end{appendices}
--8---cut here---end---8---

Best,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] babel C, C++, D enhancement

2014-06-06 Thread Eric Schulte
= abcdef2 (org-babel-execute-src-block)
 +
  (ert-deftest ob-C/vector-var ()
  Test of a vector input variable
(org-test-at-id cc65d6b3-8e8e-4f9c-94cd-f5a00cdeceb5
 -(org-babel-next-src-block 2)
 +(org-babel-next-src-block 3)
 +(should (equal 122 (org-babel-execute-src-block)
 +
 +(ert-deftest ob-D/vector-var ()
 +Test of a vector input variable
 +  (org-test-at-id cc65d6b3-8e8e-4f9c-94cd-f5a00cdeceb5
 +(org-babel-next-src-block 4)
  (should (equal 122 (org-babel-execute-src-block)
  
  (ert-deftest ob-C/list-list-var ()
Test of a list list input variable
(org-test-at-id cc65d6b3-8e8e-4f9c-94cd-f5a00cdeceb5
 -(org-babel-next-src-block 3)
 +(org-babel-next-src-block 5)
  (should (equal '((1 3) (2 4)) (org-babel-execute-src-block)
  
 +(ert-deftest ob-D/list-list-var ()
 +  Test of a list list input variable
 +  (org-test-at-id cc65d6b3-8e8e-4f9c-94cd-f5a00cdeceb5
 +(org-babel-next-src-block 6)
 +(should (equal '((1 3) (2 4)) (org-babel-execute-src-block)
 +
 +
 +(ert-deftest ob-C/inhomogeneous_table ()
 +  Test inhomogeneous input table
 +  (org-test-at-id e112bc2e-419a-4890-99c2-7ac4779531cc
 +(org-babel-next-src-block 1)
 +(should (equal
 +  '((monday 34)
 +(tuesday 41)
 +(wednesday 56)
 +(thursday 17)
 +(friday 12)
 +(saturday 7)
 +(sunday 4)
 +(Friday friday))
 +  (org-babel-execute-src-block)
 +
 +(ert-deftest ob-D/inhomogeneous_table ()
 +  Test inhomogeneous input table
 +  (org-test-at-id e112bc2e-419a-4890-99c2-7ac4779531cc
 +(org-babel-next-src-block 2)
 +(should (equal
 +  '((monday 34)
 +(tuesday 41)
 +(wednesday 56)
 +(thursday 17)
 +(friday 12)
 +(saturday 7)
 +(sunday 4)
 +(Friday friday))
 +  (org-babel-execute-src-block)
 +
  ;;; test-ob-C.el ends here

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



[O] export \cite options with ox-bibtex

2014-06-06 Thread Eric Schulte
Hi,

I just pushed up a small change to ox-bibtex (in comtrib), so that it is
possible to include options in cite: links.  So for example the
following link [[cite:(Chapter 2)foo]] will be converted to the
following LaTeX \cite[Chapter 2](foo).

Best,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] a minor patch to awk invocation

2014-06-06 Thread Eric Schulte
Greg Minshall minsh...@acm.org writes:

 hi.  i just wandered down a rathole others could avoid.  the following
 program fails in (what was to me) a mysterious way:
 
 #+BEGIN_SRC awk :var a=2
 BEGIN{print $a;}
 #+END_SRC
 

 it turns out values for variables to awk need to be strings (rather than
 a number, as above).  below is a patch to give what might be a less
 mysterious error message.

 also: for an awk invocation with :var a=b, all occurrences of $a in
 the body of the awk code are changed to b.  i'm curious why this is
 done rather than invoking awk with -v a=b?  or, moving the
 initialization into a BEGIN{} block?  maybe because of the variety of
 awk variants loose in the world?


Hi Greg,

Thanks for pointing out this shortcoming and for suggesting the
command-line variable assignment option.  I've just pushed up a patch
which changes the behavior of awk code blocks to assign variables on the
command line, so the following now work.

#+begin_src awk :var a=2
BEGIN{ print a; }
#+end_src

#+RESULTS:
: 2

Thanks,


 cheers, Greg
 
 diff --git a/lisp/ob-awk.el b/lisp/ob-awk.el
 index ed98afd..162ddfb 100644
 --- a/lisp/ob-awk.el
 +++ b/lisp/ob-awk.el
 @@ -47,6 +47,8 @@
  (defun org-babel-expand-body:awk (body params)
Expand BODY according to PARAMS, return the expanded body.
(dolist (pair (mapcar #'cdr (org-babel-get-header params :var)))
 +(if (not (stringp (cdr pair)))
 + (error awk variable values must be strings))
  (setf body (replace-regexp-in-string
  (regexp-quote (format $%s (car pair))) (cdr pair) body)))
body)


-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



Re: [O] [babel][PATCHES] ob-R patches for review

2014-05-12 Thread Eric Schulte
 If not would you mind submitting a version of the patches split into
 multiple commits with as much of the hard-coded R code as feasible
 placed into customizable variables along the lines of the
 `org-babel-R-assign-elisp-function' variable suggested by Charles.  

 I am thinking of actually not providing the R code in org-variables, but
 to put them into R files and to source them. By doing this, the
 customization could be done in R, which will be much easier for R users
 then to customize emacs variables.


I think this is a bad idea, such external R source files may be hard to
manage and load reliably across systems and it is not clear where they
should live in the Org-mode repository.  Additionally, if the variables
simply hold R code text, then users can easily initialize them from R
files locally with something like the following.

(setq org-babel-R-assign-elisp-function
  (with-temp-buffer
(insert-file-contents-literally personal.R)
(buffer-string)))

I think this approach is much simpler.

Best,
Eric


 These would be sourced and stored into an environment org:functions,
 using the same approach as ESS is using to store functions into an
 environment ESSR. I would then put the variables transfered into
 org:variables. These environments would only exist in the search path,
 and not overwrite any user set objects in R.

 As it needs to be sourced for each R process once, the right place would
 be in  org-babel-R-initiate-session - correct?

 What would be the best place to put these R files? 

 One lesson I've certainly learned from the Org-mode mailing list is
 that you can't anticipate all of the ways that your code will be used,
 so up-front customizability generally pays off.

 OK - point taken - and I am definitely one of those users who thinks
 about unusual usages of certain features.

 Cheers,

 Rainer


 Thanks,
 Eric


 Thanks

 Rainer

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D



Re: [O] Queestion concerning lists - was: [babel][PATCHES] ob-R patches for review

2014-05-12 Thread Eric Schulte

 I am working on it, but I have a question concerning strings and lists
 in elisp.

 In the function  org-babel-execute:R it says:

 ,
 | (inside
 |(list (org-babel-expand-body:R body params graphics-file)))
 `

 I now want to convert inside to a comma separated string. I am doing
 now the following:

 ,
 | (replace-regexp-in-string \n ,  (format %s inside))
 `

 but this does not look elegant to me, as I am converting inside to a
 string and then do a replace. There is the function mapconcat, but I
 don't get it to work:

 ,
 | (replace-regexp-in-string \n ,  (format %s inside))
 | ( createOrgVariablesEnvironment(), plot(1))
 | 
 | (mapconcat 'identity inside , )
 |  createOrgVariablesEnvironment()
 | plot(1)
 `

 What am I missing?


The following should work.

  (mapconcat #'identity inside , )

If that doesn't give the expected result, maybe share an example value
of inside, with the expected results.

Best,
Eric


 Thanks,

 Rainer


 As it needs to be sourced for each R process once, the right place would
 be in  org-babel-R-initiate-session - correct?

 What would be the best place to put these R files? 

 One lesson I've certainly learned from the Org-mode mailing list is
 that you can't anticipate all of the ways that your code will be used,
 so up-front customizability generally pays off.

 OK - point taken - and I am definitely one of those users who thinks
 about unusual usages of certain features.

 Cheers,

 Rainer


 Thanks,
 Eric


 Thanks

 Rainer

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D



Re: [O] ob-lua.el

2014-05-12 Thread Eric Schulte
This looks good so far.

Does code execution work but it is untested, or has it not been
implemented?  Would you suggest adding this now or waiting for code
execution?  I don't see you listed on the contributors page, would you
be willing to do FSF copyright assignment?

http://orgmode.org/worg/org-contribute.html

Thanks!
Eric

die...@schoen.or.at writes:

 now with attachments, i hope



 Original Message 
From: Dieter Schoen die...@schoen.or.at
To: emacs-orgmode@gnu.org
Sent: Fri, May 9, 2014, 10:23 PM
Subject: Re: [O] ob-lua.el

At Wed, 07 May 2014 00:46:03 +0200,
Bastien wrote:
 
 Hi Dieter,
 
 die...@schoen.or.at writes:
 
  for a project I need to tangle lua files (including parameters and
  tables),
  and there seems to be no ob-lua.el (yet).
 
  so I shamelessly copied ob-python.el and adapted it to my needs.
  right now it can tangle lua, also with simple or table parameters.
 
  if anybody is interested, I can upload it.
 
 Yes, please do!
 
  before that, it should maybe be completed, and also pass some generic
  tangle test, I think.
  I have shortly looked at testing/examples/ob-shell-test.org. Is a
  test like this suitable?
 
 I suggest to look at testing/lisp/test-ob-shell.el.
 

sorry for the delay, I had to fix some quoting..

here is what i have already. it is not yet ERT tested, only manually.
ob-lua.el is capable to tangle code  which uses tables with one, two or many
columns.
i have not yet done any code executing tests.

first, here is my test harness:

#+NAME: simple-table
| simple one |
| two|
| three  |

is converted into

  sim={{simple one}, {two}, {three}}


#+NAME: assoc-table
| name| value |
|-+---|
| colour  | blue  |
| weather | fine  |

this is converted into

mapv={{colour, blue}, {weather, fine}}

i copied this behaviour (an associative map) from ob-shell.el

#+NAME: big-table
| name| value  | remark |
|-++|
| tool| emacs  | cool   |
| environment | debian | fair   |

and finally,

big={{tool, emacs, cool}, {environment, debian, fair}}


#part type=text/x-org filename=/home/dieter/git/org/code-exporter.org 
disposition=attachment
#/part

and ob-lua.el

#part type=application/emacs-lisp 
filename=/home/dieter/.emacs.d/elpa/org-20140505/ob-lua.el 
disposition=attachment
#/part

as i am quite new to emacs/org, i will be thankful for any feedback.

kind regards,
dieter


 ;;; ob-lua.el --- org-babel functions for lua evaluation

 ;; Copyright (C) 2009-2014 Free Software Foundation, Inc.

 ;; Authors: Eric Schulte
 ;; Dan Davison
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org

 ;; This file is part of GNU Emacs.

 ;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
 ;; the Free Software Foundation, either version 3 of the License, or
 ;; (at your option) any later version.

 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ;; GNU General Public License for more details.

 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs.  If not, see http://www.gnu.org/licenses/.

 ;;; Commentary:

 ;; Org-Babel support for evaluating lua source code.

 ;;; Code:
 (require 'ob)
 (eval-when-compile (require 'cl))

 (declare-function org-remove-indentation org )
 (declare-function lua-shell ext:lua-mode (optional argprompt))
 (declare-function lua-toggle-shells ext:lua-mode (arg))
 (declare-function run-lua ext:lua (cmd optional dedicated show))

 (defvar org-babel-tangle-lang-exts)
 (add-to-list 'org-babel-tangle-lang-exts '(lua . lua))

 (defvar org-babel-default-header-args:lua '())

 (defcustom org-babel-lua-command lua
   Name of the command for executing Lua code.
   :version 24.4
   :package-version '(Org . 8.0)
   :group 'org-babel
   :type 'string)

 (defcustom org-babel-lua-mode
   (if (or (featurep 'xemacs) (featurep 'lua-mode)) 'lua-mode 'lua)
   Preferred lua mode for use in running lua interactively.
 This will typically be either 'lua or 'lua-mode.
   :group 'org-babel
   :version 24.4
   :package-version '(Org . 8.0)
   :type 'symbol)

 (defvar org-src-preserve-indentation)

 (defcustom org-babel-lua-hline-to None
   Replace hlines in incoming tables with this when translating to lua.
   :group 'org-babel
   :version 24.4
   :package-version '(Org . 8.0)
   :type 'string)

 (defcustom org-babel-lua-None-to 'hline
   Replace 'None' in lua tables with this before returning.
   :group 'org-babel
   :version 24.4
   :package-version '(Org . 8.0)
   :type 'symbol)

 (defun org-babel-execute:lua (body params)
   Execute a block of Lua code with Babel.
 This function is called by `org-babel-execute-src-block'.
   (let* ((session (org-babel-lua-initiate-session

Re: [O] [babel][PATCHES] ob-R patches for review

2014-05-09 Thread Eric Schulte
Rainer M Krug rai...@krugs.de writes:

 Bastien b...@gnu.org writes:

 Hi Rainer,

 Rainer M Krug r.m.k...@gmail.com writes:

 I'll look at it again tomorrow and let you know as I made some changes
 since then. Do you prefer one patch to several?

 Up to Eric's taste -- but in general I think a series of patches
 is better, it allows you to isolate and fix conflicts more easily.


I agree, multiple patches make future maintenance easier.

 I missed some previous discussion in this thread.  Are these patches
 ready to be applied as is?



 IMO, the patches hard coded behaviors that would better be customizable
 and optional. 

 Rainer and I had some back and forth about this -- see the thread.

With respect to these points, I'm inclined to agree with Charles in the
following.

 All you have to do is add this:

 (defvar org-babel-R-assign-elisp-function 'org-babel-R-assign-elisp
   Name or definition of function to handle `:var name=value'
 header args.
   )

 and change one line in org-babel-variable-assignments:R from

 (org-babel-R-assign-elisp to

(funcall org-babel-R-assign-elisp-function

 and the user can provide her own elisp assignment function.

 This gives users who want special behavior like creating something
 other than a data.frame the option of providing their own function.

Would such a customization variable be difficult to add to your patches?
If not would you mind submitting a version of the patches split into
multiple commits with as much of the hard-coded R code as feasible
placed into customizable variables along the lines of the
`org-babel-R-assign-elisp-function' variable suggested by Charles.  One
lesson I've certainly learned from the Org-mode mailing list is that you
can't anticipate all of the ways that your code will be used, so
up-front customizability generally pays off.

Thanks,
Eric


 Thanks

 Rainer

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D



[O] bug#17416: bug#17416: insecure temp files in ob-screen.el

2014-05-08 Thread Eric Schulte
Glenn Morris r...@gnu.org writes:

 Eric Schulte wrote:

 org-babel-screen-session-write-temp-file and org-babel-screen-test seem
 to use predictable temp-file names, which is a security issue. Using
 `make-temp-file', or if the file names really need to be predictable,
 something equivalent to `doc-view-make-safe-dir' (there should really be
 a general utility function for this IMO) to first create a /tmp
 subdirectory would avoid this.

 I just pushed up a fix for this issue.  Thanks,

 If you mean

 http://orgmode.org/cgit.cgi/org-mode.git/commit/?id=fea672d30ef4701721c0d4aa70462760a6b21be7

 then's there still org-babel-screen-test.


Fixed.


 (These are definitely fixes that need merging into the emacs-24 branch.
 IIUC this means they need to be in your maint branch?)

Cherrypicked into maint.

Thanks,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D





Re: [O] [PATCH] Fix error prone babel table output format detection

2014-05-07 Thread Eric Schulte
This looks good to me.  Could you reformat the patch with

  git format-patch

and attach the results (this will be easier to apply).  Also, this patch
is small enough to apply without any sort of copyright attribution, but
if you think you might make larger contributions in the future, please
look over the org contribution instructions [1].

Thanks!
Eric


Footnotes: 
[1]  http://orgmode.org/worg/org-contribute.html

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D



Re: [O] [BUG] [babel] in :eval never with :session

2014-05-07 Thread Eric Schulte
Rainer M Krug rai...@krugs.de writes:

 The error is back:


You say back, was this error not present recently?  If so could you
isolate the commit at which this error appeared?

Thanks,
Eric


 When one header in a subtree which has the header argument
 :eval never
 has the same name as in a following subtree which should be evaluated on
 export, the second subtree is not exported. When the name of the header
 is changed, the subtree is exported as expected.

 --8---cut here---start-8---
 #+PROPERTY: exports both
 #+PROPERTY: session *tmp_R*

 * Some non-evaluated code
 :PROPERTIES:
 :eval:  never
 :END:
 ** This is the same header
 #+BEGIN_SRC R
 cat(\ntwo\n)
 #+END_SRC

 * Data Assessment Results
 ** This is the same header
 If the name of the header is changed, the subtree is evaluated on export.
 #+begin_src R
 cat(\nhere it is \n)
 #+end_src
 --8---cut here---end---8---
  
 Org-mode version 8.2.6 (release_8.2.6-920-gc6d698 @ 
 /Users/rainerkrug/.emacs.d/org-mode/lisp/)
 GNU Emacs 24.3.1 (x86_64-apple-darwin13.0.0, Carbon Version 1.6.0 AppKit 
 1265) of 2014-02-13 on Rainers-MacBook-Pro-2.local

 Cheers,

 Rainer

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D



[O] bug#17416: bug#17416: insecure temp files in ob-screen.el

2014-05-07 Thread Eric Schulte
Glenn Morris r...@gnu.org writes:

 Package: emacs,org-mode
 Version: 24.3.90
 Severity: important
 Tags: security

 org-babel-screen-session-write-temp-file and org-babel-screen-test seem
 to use predictable temp-file names, which is a security issue. Using
 `make-temp-file', or if the file names really need to be predictable,
 something equivalent to `doc-view-make-safe-dir' (there should really be
 a general utility function for this IMO) to first create a /tmp
 subdirectory would avoid this.


I just pushed up a fix for this issue.  Thanks,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D





Re: [O] [babel][PATCHES] ob-R patches for review

2014-05-07 Thread Eric Schulte
Rainer M Krug rai...@krugs.de writes:

 Hi

 Attached please find seven patches for review to implement the storing
 of org variables in their own environment and to make the org-issued R
 code look nicer in the R session.

 Thanks,

 Rainer

Hi Rainer,

Thanks for these patches.  I don't have the R experience to review or
maintain them, but I'm happy to apply them.

I missed some previous discussion in this thread.  Are these patches
ready to be applied as is?

Thanks,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D



Re: [O] [RFC] [PATCH] ob-core.el: allow the auto-generation of output file names for src blocks.

2014-05-04 Thread Eric Schulte
Hi Aaron,

Thanks for this patch, and especially for including documentation.  It
looks good to me, and it (largely [1]) passes all tests.

Aaron Ecay aarone...@gmail.com writes:

 Hi Eric, Bastien, Achim,

 Thanks so much for the feedback.  I’ve adopted the :file-ext approach
 suggested by Bastien, leaving the previous default behavior in place for
 blocks with a :file argument.

 2014ko apirilak 22an, Eric Schulte-ek idatzi zuen:

 [...]


 One option might be to borrow naming behavior from the comment
 functionality in ob-tangle which looks like the following (from line 426
 in ob-tangle.el).

 (let (...
   (source-name
(intern (or (nth 4 info)   ; explicit #+name:
(format %s:%d; constructed from header and position
(or (ignore-errors (nth 4 
 (org-heading-components)))
No heading)
block-counter
   ...))

 I’m not sure I like this approach.  It relies on counting source
 blocks, so an addition/deletion of a block could change the index.
 I’m worried that this can lead to the accumulation of many output
 files: heading:1.ext, heading:2.ext, ... all with no clear indication
 of what block they were spawned by.  It would also be possible for
 the result links in the buffer to become inconsistent with the actual
 block:auto-generated name mapping.

 I think I would prefer the code in this patch to do nothing in this case
 (not create a :file value), but for language-specific code that needs a
 :file to raise an error to prompt the user to add a name.


Fair enough, especially given that this default will be applied to *all*
code blocks, this seems like a reasonable approach.




 2. should :output-dir apply to the :file case as well?


 If you mean should :output-dir be used as the base when :file is a
 relative pathname then I'd say yes, and I think if this isn't the
 current behavior then the current behavior should be changed.

 Achim raises a backwards compatibility concern.  I am not sure how
 serious it is: the default settings (no :output-dir) are backwards
 compatible, and if users set that arg we ought to just give them what
 they ask for.

 Nonetheless, the new version of the patch conservatively obeys Achim’s
 suggestion.  I can change this to your suggestion, if that is the
 consensus.


Please do make this change, I'd then be happy to apply the resulting
patch.

Thanks again!
Eric


 To address a comment from Bastien: :output-dir accepts absolute as well
 as relative directory names.  Referring to a “subdirectory” was a
 mistake on my part; the docs in the new patch should be clearer.

 The updated patch (now with docs and tests) is attached to this email.

 Thanks again,

 --
 Aaron Ecay

 From 4b428820432752117c60b79da0a79fd4e50e4ba1 Mon Sep 17 00:00:00 2001
 From: Aaron Ecay aarone...@gmail.com
 Date: Tue, 22 Apr 2014 15:13:48 -0400
 Subject: [PATCH] ob-core.el: allow the auto-generation of output file names
  for src blocks.

 * lisp/ob-core.el (org-babel-generate-file-param): New function.
 (org-babel-get-src-block-info): Use it.
 * testing/lisp/test-ob.el (test-org-babel/file-ext-and-output-dir):
 New test.
 * doc/org.texi (Specific header arguments): Add doc for :file-ext and
 :output-dir header args.
 ---
  doc/org.texi   | 27 +++
  lisp/ob-core.el| 34 ++
  testing/examples/babel.org | 34 ++
  testing/lisp/test-ob.el| 14 ++
  4 files changed, 109 insertions(+)

 diff --git a/doc/org.texi b/doc/org.texi
 index 2546be1..79cc044 100644
 --- a/doc/org.texi
 +++ b/doc/org.texi
 @@ -14406,6 +14406,8 @@ argument in lowercase letters.  The following header 
 arguments are defined:
  be collected and handled
  * file::Specify a path for file output
  * file-desc::   Specify a description for file results
 +* file-ext::Specify an extension for file output
 +* output-dir::  Specify a directory to write file output to
  * dir:: Specify the default (possibly remote)
  directory for code block execution
  * exports:: Export code and/or results
 @@ -14840,6 +14842,31 @@ description for file code block results which are 
 inserted as Org mode links
  with no value the link path will be placed in both the ``link'' and the
  ``description'' portion of the Org mode link.
  
 +@node file-ext
 +@subsubsection @code{:file-ext}
 +@cindex @code{:file-ext}, src header argument
 +
 +The value of the @code{:file-ext} header argument is used to provide an
 +extension to write the file output to.  It is combined with the
 +@code{#+NAME:} of the source block and the value of the @ref{output-dir}
 +header argument to generate a complete file name.
 +
 +This header arg

Re: [O] [PATCH] Fix error prone babel table output format detection

2014-05-04 Thread Eric Schulte
Ian Kelling i...@iankelling.org writes:

 Ian Kelling i...@iankelling.org writes:
 It's a bit late.  here is the same patch with correct indentation.

 That patch went out of it's way not to check more of the list than was
 necessary, but after sending it, I kept thinking that it does extra
 things which possibly negate any performance benefit of not checking the
 whole list. So here is a simpler patch does the same thing, but goes
 over the whole list. I'd love to hear a more experienced emacs lisper
 weigh in on which is better.


Hi Ian,

You should use the `org-every' function here.  Look at the source of
that function to see code to efficiently perform this sort of check.

Best,


 -- 8 --
 Subject: [PATCH] Fix error prone babel table output format detection

 * lisp/ob-core.el: Test that all elements are in a list are lists or
 'hline instead of just the first.

 org-babel table output uses different formatting for a list of lists,
 but detects it incorrectly causing an error. An example of a block
 causing an error is an emacs lisp source block containing just 1 line:
 '((1) 2)
 ---
  lisp/ob-core.el |7 ---
  1 file changed, 4 insertions(+), 3 deletions(-)

 diff --git a/lisp/ob-core.el b/lisp/ob-core.el
 index 1348f04..05ccb00 100644
 --- a/lisp/ob-core.el
 +++ b/lisp/ob-core.el
 @@ -2184,9 +2184,10 @@ code  the results are extracted in the syntax of 
 the source
((funcall proper-list-p result)
 (goto-char beg)
 (insert (concat (orgtbl-to-orgtbl
 -(if (or (eq 'hline (car result))
 -(and (listp (car result))
 - (listp (cdr (car result)
 +(if (let ((proper t))
 +  (dolist (elem result proper)
 +(unless (or (listp elem) (eq elem 
 'hline))
 +  (setq proper nil
  result (list result))
  '(:fmt (lambda (cell) (format %s cell 
 \n))
 (goto-char beg) (when (org-at-table-p) (org-table-align)))

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D



Re: [O] python babel not running startup file

2014-04-25 Thread Eric Schulte
Yes, customize the org-babel-python-command variable.

Best,

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

 I have the PYTHONSTARTUP environment variable set to ~/.pythonrc. That
 file is not run by Org babel. Can anyone recommend how to execute that
 file, or some other method for customizing all Org babel python
 executions.

 Specifically, I load a custom colorbar in my ~/.pythonrc and
 ~/.ipythonrc files, and would like Org python to behave the same.

   -k.


-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D



Re: [O] [babel] Setting python interpreter version on per-block or per-subtree basis

2014-04-25 Thread Eric Schulte
The attached patch should allow the specification of the python command
through a new :python header argument.  E.g.,

#+begin_src python :python /path/to/python2
  return 1 + 2
#+end_src

If someone who actually uses python could confirm that it works as
expected then I'll be happy to apply it.

From d57887adc70c524199b3307b74f17ea5751450f0 Mon Sep 17 00:00:00 2001
From: Eric Schulte schulte.e...@gmail.com
Date: Fri, 25 Apr 2014 09:24:04 -0600
Subject: [PATCH] allow specification of python command w/header arg

  Using the :python header arg.

* lisp/ob-python.el (org-babel-execute:python): Locally set
  `org-babel-python-command' using a header argument.
---
 lisp/ob-python.el | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lisp/ob-python.el b/lisp/ob-python.el
index baa5764..eb25609 100644
--- a/lisp/ob-python.el
+++ b/lisp/ob-python.el
@@ -82,6 +82,8 @@ This function is called by `org-babel-execute-src-block'.
 	 (return-val (when (and (eq result-type 'value) (not session))
 		   (cdr (assoc :return params
 	 (preamble (cdr (assoc :preamble params)))
+	 (org-babel-python-command
+	  (or (cdr (assoc :python params)) org-babel-python-command))
  (full-body
 	  (org-babel-expand-body:generic
 	   (concat body (if return-val (format \nreturn %s return-val) ))
-- 
1.9.2


Best,
Eric

William Henney when...@gmail.com writes:

 Hi

 Is there an easy way to specify the python version to use for a particular
 block or sub-tree?

 My use case is that I have mainly migrated to python 3, but there is still
 the occasional library that has not been updated yet, so I need to fall
 back to python 2.7 for some tasks.

 I can work around the problem by putting the python 2 code in a separate
 org file and use

 # Local Variables:
 # org-babel-python-command: /path/to/python2
 # End:

 but keeping everything in the same file would be preferable.

 Thanks

 Will

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D


Re: [O] [babel] Setting python interpreter version on per-block or per-subtree basis

2014-04-25 Thread Eric Schulte
I've just applied this patch.  Thanks for the very attached nice test
and demonstration file.

Best,

William Henney when...@gmail.com writes:

 Dear Sacha, Ian, and Eric

 Thanks very much for your replies.  Sacha's way is a clever idea and works
 fine, but I think Eric's patch is the best solution in the long term.
  Please see attached test file - the patch works perfectly.  Although I did
 have to study the manual carefully to work out how get it to work using the
 #+call: syntax. The key is to use inside header arguments.  Ian's
 solution with shebang works when tangling but not for direct evaluation of
 the source block.

 Cheers

 Will




 On Fri, Apr 25, 2014 at 10:27 AM, Eric Schulte schulte.e...@gmail.comwrote:

 The attached patch should allow the specification of the python command
 through a new :python header argument.  E.g.,

 #+begin_src python :python /path/to/python2
   return 1 + 2
 #+end_src

 If someone who actually uses python could confirm that it works as
 expected then I'll be happy to apply it.



 Best,
 Eric

 William Henney when...@gmail.com writes:

  Hi
 
  Is there an easy way to specify the python version to use for a
 particular
  block or sub-tree?
 
  My use case is that I have mainly migrated to python 3, but there is
 still
  the occasional library that has not been updated yet, so I need to fall
  back to python 2.7 for some tasks.
 
  I can work around the problem by putting the python 2 code in a separate
  org file and use
 
  # Local Variables:
  # org-babel-python-command: /path/to/python2
  # End:
 
  but keeping everything in the same file would be preferable.
 
  Thanks
 
  Will

 --
 Eric Schulte
 https://cs.unm.edu/~eschulte
 PGP: 0x614CA05D



-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D



Re: [O] [RFC] [PATCH] ob-core.el: allow the auto-generation of output file names for src blocks.

2014-04-23 Thread Eric Schulte
 Looks useful to me, but :file png looks wrong, with too much
 implicit.  We should find something less confusing.

 One option would be to use :file-ext instead, to generate a :file
 parameter.  I didn’t go this route because autogenerating :file from
 other parameters seemed like too much magic.  But your points in the
 other direction are good.

 How does this sound as an algorithm:
 1. if :file is present, behave exactly as we do now
 2. if :file is absent but :file-ext and a #+name is present, generate a
:file parameter from :output-dir, the #+name, and :file-ext.


This sounds like a great approach to me.


 Open questions:
 1. should :file-ext without a #+name be a no-op, or an error?

One option might be to borrow naming behavior from the comment
functionality in ob-tangle which looks like the following (from line 426
in ob-tangle.el).

(let (...
  (source-name
   (intern (or (nth 4 info)   ; explicit #+name:
   (format %s:%d; constructed from header and position
   (or (ignore-errors (nth 4 (org-heading-components)))
   No heading)
   block-counter
  ...))

 
 2. should :output-dir apply to the :file case as well?


If you mean should :output-dir be used as the base when :file is a
relative pathname then I'd say yes, and I think if this isn't the
current behavior then the current behavior should be changed.

Thanks for this nice patch,
Eric


 --
 Aaron Ecay


-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D



Re: [O] [RFC] [PATCH] ob-core.el: allow the auto-generation of output file names for src blocks.

2014-04-23 Thread Eric Schulte
Bastien b...@gnu.org writes:

 Hi Aaron,

 Aaron Ecay aarone...@gmail.com writes:

 How does this sound as an algorithm:
 1. if :file is present, behave exactly as we do now
 2. if :file is absent but :file-ext and a #+name is present, generate a
:file parameter from :output-dir, the #+name, and :file-ext.

 I suggest this one:

 1. if :file is present, behave exactly as we do now

 2. if :file-ext is present:

- if #+name is present, generate a :file parameter
  from :output-dir, #+name and :file-ext

- otherwise, generate the :file parameter from
  :output-dir, the headline or the title or the
  current file name and :file-ext

 Just falling back on something sensible when :file is absent
 and :file-ext is specified.


FWIW I'm in full agreement here, see my other email for one sensible
alternative.  (Sorry to split up my reply, the hazards of an
asynch/batch email pull/read/write/push setup.)


 Open questions:
 1. should :file-ext without a #+name be a no-op, or an error?

 See above.

 2. should :output-dir apply to the :file case as well?

 To me yes.

 In overall I think would be good, but I'd like Eric and other
 babelist around here to have a look before we commit this.
 So perhaps another round of patch testing will be good.


I agree here.

Thanks again,


 Thanks!

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D



  1   2   3   4   5   6   7   8   9   10   >