Re: [O] [PATCH] ob-shell

2014-06-22 Thread Pascal Fleury
Hi Achim,

I was wondering how it would behave if the string that is put into a
variable contains newlines, backslashes and other things that bash (and
other shells) treats specially. The trick with cat and BABEL_TABLE is
resistant to this. As in many cases (when I use it at least) the variable
come from other parts of the org file and are computed through another
language (python in my case) I have such cases that would break.

Also, I think the test coverage for such things is limited for ob-shell.el
in the org test suite.
We should probably add some test cases for this, and then make sure it
works with your implementation as well.

--paf


On Sun, Jun 22, 2014 at 2:50 PM, Eric Schulte 
wrote:

> If this maintains existing functionality, please go ahead and apply it.
>
> Thanks,
>
> Achim Gratz  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 
> > 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."
> > --

[O] [Bug] element cache problem with repeating timestamps

2014-06-22 Thread Matt Lundin
A recent git pull broke logging with repeating todos. 

I'm guessing this has something to do with one of the recent changes to
the org element cache, since setting org-element-use-cache to nil solves
the problem.

Recipe to replicate:

1. /usr/bin/emacs -Q -l ~/minimal.el

Here is minimal.el:



minimal.el
Description: application/emacs-lisp

2. Open a file containing the following:

--8<---cut here---start->8---

* TODO Repeating task
  SCHEDULED: <2014-06-23 Mon 20:00 .+1d> 
  :LOGBOOK:
  - State "DONE"   from "TODO"   [2014-06-22 Sun 23:01]
  :END:
  :PROPERTIES:
  :LAST_REPEAT: [2014-06-22 Sun 23:01]
  :END:
--8<---cut here---end--->8---

3. Hit org-todo on the headline. The buffer then looks like this:

--8<---cut here---start->8---
* TODO Repeating task
<2014-06-23 Mon 20:00 .+1d>  SCHEDULED:  
  :LOGBOOK:
  - State "DONE"   from "TODO"   [2014-06-22 Sun 23:10]
  - State "DONE"   from "TODO"   [2014-06-22 Sun 23:10]
  - State "DONE"   from "TODO"   [2014-06-22 Sun 23:01]
  :END:
  :PROPERTIES:
  :LAST_REPEAT: [2014-06-22 Sun 23:10]
  :END:
--8<---cut here---end--->8---

Sometimes (more difficult to replicate) the LAST_REPEAT ends up in the
wrong place (e.g., the beginning of the buffer). Also, emacs sometimes
freezes when calling org-todo.

 - Org-mode version beta_8.3 (beta_8.3-16-g8ad206 @
   /home/user134/org-mode/lisp/)
 - 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

Thanks,
Matt


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

2014-06-22 Thread Eric Schulte
Aaron Ecay  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] Display only latest sub notes in agenda

2014-06-22 Thread Steffen Heilmann
Dear Sacha,

thanks for the very helpful code! Does exactly what I was looking for.

I have one additional question: At the moment the code also picks-up any dates 
that are in the body of the structure (this includes deadlines etc). How would 
I need to modify the code to only look at dates that actually are given in the 
headlines (*, ** or ***)? I tried to change the code myself but realized that 
the regexp was more complicated than I thought and did not get the modified 
code to work.


Thank you,

Steffen


[O] [patch, ox-latex] org-latex-logfiles-extensions

2014-06-22 Thread Rasmus
Hi, 

The attached patch adds more extensions to
`org-latex-logfiles-extensiosn' that shows up when using latexmk and
beamer.

Also: Aaron, is there are reason why you did not include "bbl" in your
previous patch?

Note: while I personally very much like this feature the default
non-nil value of org-latex-remove-logfiles may slow down
compilation-time.  Since we have ox async export it's probably OK to
ignore this, but when not using async it could be annoying since Emacs
is locked.

Thanks,
Rasmus

-- 
And I faced endless streams of vendor-approved Ikea furniture. . .
>From a0a216af13ae16388bb49141c598811ea8848987 Mon Sep 17 00:00:00 2001
From: Rasmus 
Date: Mon, 23 Jun 2014 00:40:12 +0200
Subject: [PATCH] ox-latex.el: extends org-latex-logfiles-extensions

ox-latex.el (org-latex-logfiles-extensions): add more extensions
---
 lisp/ox-latex.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index ee207a3..e7789a4 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -962,7 +962,7 @@ file name as its single argument."
 	  (function)))
 
 (defcustom org-latex-logfiles-extensions
-  '("aux" "bcf" "blg" "figlist" "idx" "log" "nav" "out" "run.xml"
+  '("aux" "bcf" "blg" "fdb_latexmk" "fls" "figlist" "idx" "log" "nav" "out" "run.xml"
 "snm" "toc" "vrb" "xdv")
   "The list of file extensions to consider as LaTeX logfiles.
 The logfiles will be remove if `org-latex-remove-logfiles' is
-- 
2.0.0



Re: [O] [ANN] ox-extras

2014-06-22 Thread Rasmus
Rasmus  writes:

> Aaron Ecay  writes:
>
>> 2014ko ekainak 21an, Aaron Ecay-ek idatzi zuen:
>>
>> [...]
>>
 Eventually, if you insist on writing your full preamble within the
 document, you can start to write it in a LaTeX-mode buffer, copy it in
 your Org document and add "#+LATEX_HEADER: " in front of each line.
 This last step is done easily with `string-rectangle' (C-x r t).
>>> 
>>> This is basically making the user do (something like) org-edit-special
>>> manually.  It can probably be automated somewhat – I’ll work on a
>>> patch.
>>
>> This is now implemented in a new library in contrib, ox-extras.  This is
>> intended as a semi-official, semi-curated repository for helpful pieces of
>> org export hooks and customizations.  Differently than worg, the aim is to
>> make it easy for users to load the snippets through the ox-extras-activate
>> function.  Even so, I hope this will be an “executable wiki” where anyone
>> (who has commit access to the org repo) is free to contribute new hook
>> functions and improve existing ones.
>>
>> In the present case, if you execute
>>
>> (ox-extras-activate '(latex-header-blocks))
>>
>> you will be able to use blocks of the following form:
>>
>> #+header: :header yes
>> #+begin_latex
>>
>>   \foo{}
>>   \bar{}
>> #+end_latex
>>
>> These will be transformed so that the begin/end wrapper is removed and
>> each line is prepended with #+latex_header: on export.  They can be
>> edited as latex code with the usual org-edit-special function (C-c ').
>>
>> The #+header: :header yes line is a bit confusing.  The first #+header:
>> is part of org syntax that allows us to tag blocks (and other elements)
>> with plists.  The :header yes in the plist indicates that this block
>> should be treated as a latex_header, and not a normal type of latex
>> block.
>
> You did not attach a file and you probably want to make it as s new
> message without the ref to the previous thread.

Sorry, it's in contrib as you said :) My mistake.

-- 
Bang bang




Re: [O] [ANN] ox-extras

2014-06-22 Thread Rasmus
Aaron Ecay  writes:

> 2014ko ekainak 21an, Aaron Ecay-ek idatzi zuen:
>
> [...]
>
>>> Eventually, if you insist on writing your full preamble within the
>>> document, you can start to write it in a LaTeX-mode buffer, copy it in
>>> your Org document and add "#+LATEX_HEADER: " in front of each line.
>>> This last step is done easily with `string-rectangle' (C-x r t).
>> 
>> This is basically making the user do (something like) org-edit-special
>> manually.  It can probably be automated somewhat – I’ll work on a
>> patch.
>
> This is now implemented in a new library in contrib, ox-extras.  This is
> intended as a semi-official, semi-curated repository for helpful pieces of
> org export hooks and customizations.  Differently than worg, the aim is to
> make it easy for users to load the snippets through the ox-extras-activate
> function.  Even so, I hope this will be an “executable wiki” where anyone
> (who has commit access to the org repo) is free to contribute new hook
> functions and improve existing ones.
>
> In the present case, if you execute
>
> (ox-extras-activate '(latex-header-blocks))
>
> you will be able to use blocks of the following form:
>
> #+header: :header yes
> #+begin_latex
>
>   \foo{}
>   \bar{}
> #+end_latex
>
> These will be transformed so that the begin/end wrapper is removed and
> each line is prepended with #+latex_header: on export.  They can be
> edited as latex code with the usual org-edit-special function (C-c ').
>
> The #+header: :header yes line is a bit confusing.  The first #+header:
> is part of org syntax that allows us to tag blocks (and other elements)
> with plists.  The :header yes in the plist indicates that this block
> should be treated as a latex_header, and not a normal type of latex
> block.

You did not attach a file and you probably want to make it as s new
message without the ref to the previous thread.

In any case, I don't like the spirit of the exercise:

   This is intended as a semi-official, semi-curated repository for
   helpful pieces of org export hooks and customizations.

If it's helpful (enough) it should be ox.el, I guess, or
ox-ENGINGE.el. . .  Parallel, semi-official extension to ox itself
doesn't sound nice.

But with high probability I'm just lacking the right insights!

—Rasmus

-- 
To err is human. To screw up a 10⁶ times per second, you need a computer




Re: [O] Get links from Firefox/Safari into orgmode

2014-06-22 Thread Uwe Koloska
Am 20.06.2014 19:43, schrieb Daniel Franke:
> as the subject says, I would like to get links from any browser (i
> almost don’t care which one) into org mode.

With firefox you can use the CoLT (Copy Link Text) add-on
 https://addons.mozilla.org/de/firefox/addon/colt/
with this format string
 : [[%U][%T]]

Hope this helps
Uwe



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  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 
> 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] How to never have the Footnote heading generated?

2014-06-22 Thread Grant Rettke
The former, and you explained something that I didn't even know that I
should have known, too.

Thanks!
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


On Sun, Jun 22, 2014 at 9:30 AM, Matt Lundin  wrote:
> Grant Rettke  writes:
>
>>> What I was aiming for was to have in-line footnotes that did have
>>> randomly generated IDs so that I one still may reference them.
>
>> Here is what I had intended:
>>
>> (setq org-footnote-define-inline +1)
>> (setq org-footnote-auto-label 'random)
>> (setq org-footnote-auto-adjust nil)
>
> Nice! I misunderstood the initial question. The above works fine for me
> as a way to insert inline footnotes with random labels. When I call
> org-footnote-action, I get the following.
>
>  - Here is a footnote.[fn:5952d54e: A footnote]
>
>>> I misunderstood though, because the footnotes will still get defined
>>> in the Footnote section, too.
>
> Could you please explain what you mean here? The above settings do not
> create a footnote section when I call org-footnote-action or
> org-footnote-new. But you could use (setq org-footnote-section nil) to
> ensure that any footnote definitions (if they exist) will be placed in
> the same section as the footnote reference.
>
> Or do you mean the label for "Footnotes" in, say, html export? If so, I
> believe you can configure the variable org-html-footnotes-section.
>
> Best,
> Matt



[O] [Babel] [possible bug] Empty src block prevents other block to expand

2014-06-22 Thread Nicolas Girard
The empty src block at the beginning of the following file prevents
"capture-tmpl" to expand when tangling.

Admittedly, this empty src block shouldn't exist in the first place,
it's just a residue of some former confg of mine that didn't cause any
problem until I upgraded Org to the latest ELPA package
(8.2.7a-elpaplus -- 20140619).

The test file is
---8<---
* Empty org block
#+begin_src org :noweb yes
#+end_src
* Other blocks
#+name: capture-tmpl
#+begin_src org :results value
  ,* A
  :PROPERTIES:
  :ID: %(org-id-new)
  :END:
#+end_src

#+name: capture
#+begin_src emacs-lisp :tangle no
  ("C" "Capture" entry "
  <>")
#+end_src

#+begin_src emacs-lisp :noweb yes
  (add-to-list 'org-capture-templates '
  <> 'append)
#+end_src
---8<---

And the Makefile I used is simply
---8<---
all: conf.el

%.el: %.org
emacs --batch -Q -l ob-tangle -l ob-org \
--eval '(setq org-babel-use-quick-and-dirty-noweb-expansion t)' \
--eval '(setq org-confirm-babel-evaluate nil)' \
--eval '(org-babel-tangle-file "$<" "$@" "emacs-lisp")'
---8<---


Cheers,

Nicolas



Re: [O] How to never have the Footnote heading generated?

2014-06-22 Thread Matt Lundin
Grant Rettke  writes:

>> What I was aiming for was to have in-line footnotes that did have
>> randomly generated IDs so that I one still may reference them.

> Here is what I had intended:
>
> (setq org-footnote-define-inline +1)
> (setq org-footnote-auto-label 'random)
> (setq org-footnote-auto-adjust nil)

Nice! I misunderstood the initial question. The above works fine for me
as a way to insert inline footnotes with random labels. When I call
org-footnote-action, I get the following.

 - Here is a footnote.[fn:5952d54e: A footnote]

>> I misunderstood though, because the footnotes will still get defined
>> in the Footnote section, too. 

Could you please explain what you mean here? The above settings do not
create a footnote section when I call org-footnote-action or
org-footnote-new. But you could use (setq org-footnote-section nil) to
ensure that any footnote definitions (if they exist) will be placed in
the same section as the footnote reference.

Or do you mean the label for "Footnotes" in, say, html export? If so, I
believe you can configure the variable org-html-footnotes-section.

Best,
Matt



Re: [O] How to never have the Footnote heading generated?

2014-06-22 Thread Grant Rettke
Here is what I had intended:

(setq org-footnote-define-inline +1)
(setq org-footnote-auto-label 'random)
(setq org-footnote-auto-adjust nil)
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


On Sun, Jun 22, 2014 at 7:56 AM, Grant Rettke  wrote:
> Thank you Matt.
>
> What I was aiming for was to have in-line footnotes that did have
> randomly generated IDs so that I one still may reference them. I
> misunderstood though, because the footnotes will still get defined in
> the Footnote section, too. I will look at what it takes to have a new
> footnote type with that behavior.
> 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
>
>
> On Sat, Jun 21, 2014 at 9:20 PM, Matt Lundin  wrote:
>> Grant Rettke  writes:
>>
>>> I want only to use in-line footnotes and never to have them
>>> automatically entered into an auto created Footnote heading.
>>
>> An easy way to create inline footnotes is to use the following setting:
>>
>> (setq org-footnote-auto-label nil)
>>
>> Then, when you call org-footnote-action, simply press return for an
>> "anonymous" (i.e., inline) footnote.
>>
>>  - The footnote looks like this.[fn:: Like this one]
>>
>> Best,
>> Matt



Re: [O] How to never have the Footnote heading generated?

2014-06-22 Thread Grant Rettke
Thank you Matt.

What I was aiming for was to have in-line footnotes that did have
randomly generated IDs so that I one still may reference them. I
misunderstood though, because the footnotes will still get defined in
the Footnote section, too. I will look at what it takes to have a new
footnote type with that behavior.
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


On Sat, Jun 21, 2014 at 9:20 PM, Matt Lundin  wrote:
> Grant Rettke  writes:
>
>> I want only to use in-line footnotes and never to have them
>> automatically entered into an auto created Footnote heading.
>
> An easy way to create inline footnotes is to use the following setting:
>
> (setq org-footnote-auto-label nil)
>
> Then, when you call org-footnote-action, simply press return for an
> "anonymous" (i.e., inline) footnote.
>
>  - The footnote looks like this.[fn:: Like this one]
>
> Best,
> Matt



Re: [O] BEGIN_LATEX_HEADER [cont]

2014-06-22 Thread Nicolas Goaziou
Ken Mankoff  writes:

> It is not a 1x operation, it is a per-document operation. For example,
> in my use-case that started this whole discussion, each publication
> requires tweaking a dozen or more lines of biblatex config.

Of course there are an amount of lines that depends on the document.
This is where #+LATEX keywords comes handy.


Regards,

-- 
Nicolas Goaziou



Re: [O] BEGIN_LATEX_HEADER [cont]

2014-06-22 Thread Nicolas Goaziou
Aaron Ecay  writes:

> This is basically making the user do (something like) org-edit-special
> manually.

That is an interesting idea. `org-edit-special' could be improved to
edit clusters of export keywords (e.g. #+LATEX) in a dedicated buffer.

Recognizing a keyword as an export keyword is doable (i.e. iterate over
registered back-ends and check export keywords they define), but finding
the appropriate major-mode for the alternate buffer seems cumbersome. It
could be hard-coded, but that is not very practical. It could also be
decided in the export back-end definition.


Regards,

-- 
Nicolas Goaziou



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

2014-06-22 Thread Achim Gratz

When using a shell block with a :session, the specified shell is ignored
and the original value of org-babel-sh-command (defaulting to the value
of shell-file-name as set at load-time) gets used.  The following patch
fixes this, however there are still several other problems with how
shells are invoked and how shell sessions are used that need to be
addressed.

>From ed034803b9fd87d8f9d382303fc950d83b88711f Mon Sep 17 00:00:00 2001
From: Achim Gratz 
Date: Sun, 22 Jun 2014 11:16:41 +0200
Subject: [PATCH] ob-shell: honor the specified shell for :session

* lisp/ob-shell.el: Remove defcustom `org-babel-sh-command' and
  replace with `shell-file-name' throughout.
  (org-babel-variable-assignments:sh): Make check for bash work in more
  cases.

The original code and the patched version rely on the shell being
available via PATH.  Instead the shell name should be mapped to the
appropriate executable via an alist and invoked via an absolute
filename.  For security reasons the permissible shells should probably
be taken from /etc/shells or equivalent by default.  Instead of
checking for bash, the same or another alist could provide the
information of whether or not the shell supports arrays (which indeed
were introduced by ksh originally).
---
 lisp/ob-shell.el | 15 ---
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/lisp/ob-shell.el b/lisp/ob-shell.el
index 474a8f2..720af8f 100644
--- a/lisp/ob-shell.el
+++ b/lisp/ob-shell.el
@@ -38,13 +38,6 @@
 
 (defvar org-babel-default-header-args:sh '())
 
-(defcustom org-babel-sh-command shell-file-name
-  "Command used to invoke a shell.
-Set by default to the value of `shell-file-name'.  This will be
-passed to `shell-command-on-region'"
-  :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."
@@ -63,7 +56,7 @@ (defcustom org-babel-shell-names
  (lambda (name)
(eval `(defun ,(intern (concat "org-babel-execute:" name)) (body params)
 		,(format "Execute a block of %s commands with Babel." name)
-		(let ((org-babel-sh-command ,name))
+		(let ((shell-file-name ,name))
 		  (org-babel-execute:shell body params)
  (second value
 
@@ -152,7 +145,7 @@ (defun org-babel-variable-assignments:sh (params)
 		 "hline"
 (mapcar
  (lambda (pair)
-   (if (string= org-babel-sh-command "bash")
+   (if (string-match "bash$" shell-file-name)
 	   (org-babel-variable-assignments:bash
 (car pair) (cdr pair) sep hline)
  (org-babel-variable-assignments:sh-generic
@@ -217,7 +210,7 @@ (defun org-babel-sh-evaluate (session body &optional params stdin cmdline)
(call-process-shell-command
 (if shebang
 script-file
-  (format "%s %s" org-babel-sh-command script-file))
+  (format "%s %s" shell-file-name script-file))
 stdin-file
 (current-buffer) nil cmdline)
(buffer-string
@@ -255,7 +248,7 @@ (defun org-babel-sh-evaluate (session body &optional params stdin cmdline)
(insert body))
  (set-file-modes script-file #o755)
  (org-babel-eval script-file ""))
- (org-babel-eval org-babel-sh-command (org-babel-trim body)))
+ (org-babel-eval shell-file-name (org-babel-trim body)))
 (when results
   (let ((result-params (cdr (assoc :result-params params
 (org-babel-result-cond result-params
-- 
2.0.0



Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

SD adaptation for Waldorf microQ V2.22R2:
http://Synth.Stromeko.net/Downloads.html#WaldorfSDada


Re: [O] [PATCH] ob-java.el: Add `:var' variables import

2014-06-22 Thread Thierry Banel
Hi Bart

Good, this was a missing feature.

Is there any reason to embed variables in an inner "Data" class ?

Regards
Thierry


Le 22/06/2014 00:30, Bart Post a écrit :
> * lisp/ob-java.el: (org-babel-execute:java): Inject a private static
> class inside the Java class designated by
> `:classname'.
> (org-babel-variable-assignments:java): Assign the header variables to
> static fields in a private static class
> `Data'.
> (org-babel-java-var-to-java): Translate string to String, list to
> java.util.List, float to double and others to int.
> ---
>  lisp/ob-java.el | 39 ++-
>  1 file changed, 38 insertions(+), 1 deletion(-)
>
> diff --git a/lisp/ob-java.el b/lisp/ob-java.el
> index 8c64171..a2a1f40 100644
> --- a/lisp/ob-java.el
> +++ b/lisp/ob-java.el
> @@ -58,7 +58,13 @@ parameters may be used, like javac -verbose"
>(src-file (concat classname ".java"))
>(cmpflag (or (cdr (assoc :cmpflag params)) ""))
>(cmdline (or (cdr (assoc :cmdline params)) ""))
> -  (full-body (org-babel-expand-body:generic body params))
> +  (split-body
> +   (split-string body (concat classname "[\n\t ]*{")))
> +  (full-body
> +   (org-babel-expand-body:generic
> +(concat (car split-body) (concat classname " {\n") 
> (org-babel-variable-assignments:java params)
> +(mapconcat 'identity (cdr split-body) (concat classname " 
> {")))
> +params))
>(compile
> (progn (with-temp-file src-file (insert full-body))
>(org-babel-eval
> @@ -80,6 +86,37 @@ parameters may be used, like javac -verbose"
> (org-babel-pick-name
>  (cdr (assoc :rowname-names params)) (cdr (assoc :rownames 
> params)))
>  
> +(defun org-babel-variable-assignments:java (params)
> +  "Return an internal Java class assigning the block's variables."
> +  (concat "private static class Data {\n"
> +   (mapconcat 'identity
> +  (mapcar
> +   (lambda (pair)
> + (format "public static %s %s = %s;"
> + (cond
> +  ((stringp (cdr pair)) "String")
> +  ((listp (cdr pair)) "java.util.List")
> +  ((floatp (cdr pair)) "double")
> +  (t "int"))
> + (car pair)
> + (org-babel-java-var-to-java (cdr pair
> +   (mapcar #'cdr (org-babel-get-header params :var)))
> +  "\n")
> +   "\n}")
> +  )
> +
> +(defun org-babel-java-var-to-java (var)
> +  "Convert an elisp value to a java string.
> +Convert an elisp value, VAR, into a string of Java source code
> +specifying a variable of the same value."
> +  (if (listp var)
> +  (concat "java.util.Arrays.asList(" (mapconcat 
> #'org-babel-java-var-to-java var ", ") ")")
> +(if (equal var 'hline)
> + "null"
> +  (format
> +   (if (and (stringp var) (string-match "[\n\r]" var)) "\"\"%S\"\"" "%S")
> +   var
> +
>  (provide 'ob-java)
>  
>  




Re: [O] [PATCH] ob-shell (was: 2 Org tests failing)

2014-06-22 Thread Achim Gratz
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 
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.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Waldorf MIDI Implementation & additional documentation:
http://Synth.Stromeko.net/Downloads.html#WaldorfDocs


Re: [O] LaTex best practice in org-mode

2014-06-22 Thread Thorsten Jolitz
Shiyuan  writes:

Hi,

> We can write LaTex directly in org-mode without put it in a SRC block.
> When the code is exported, the latex syntax will be handled correctly
> to html or pdf. That's very nice part of org mode. However, if we don't
> put the latex code into a SRC block, the latex syntax is not correctly
> highlighted (in the code attached below, the first equation is not
> highlighted). Another benefit of putting the latex code into SRC block
> is that we can easily switch to the latex mode to edit the code
> snippet using C-c ' and in the latex mode, we can use some full-fleged
> latex package like auctex. However, the latex code in the SRC block is
> ignored when exported to html. For example, when I exported the
> following to html, the first equation shows up in the html but the
> second seconed does not. Any way to make the html exporter to
> generated the second equation too without taking away the
> BEGIN_SRC/END_SRC? What's the best practice to write latex in
> org-mode. Thanks. 
>
> \begin{equation}
> \label{eq:test}
> Bx=b
> \end{equation}
>
> #+BEGIN_SRC latex 
>
> \begin{equation}
> \label{eq:test}
> Ax=b
> \end{equation}
> #+END_SRC

When you know how to write Emacs Lisp, you should probably define a
derived export backend from ox-html:

,[ C-h f org-export-define-derived-backend RET ]
| org-export-define-derived-backend is a compiled Lisp function in
| `ox.el'.
| 
| (org-export-define-derived-backend CHILD PARENT &rest BODY)
| 
| Create a new back-end as a variant of an existing one.
| 
| CHILD is the name of the derived back-end.  PARENT is the name of
| the parent back-end.
| 
| BODY can start with pre-defined keyword arguments.  The following
| keywords are understood:
| 
|   :export-block
| 
| String, or list of strings, representing block names that
| will not be parsed.  This is used to specify blocks that will
| contain raw code specific to the back-end.  These blocks
| still have to be handled by the relative `export-block' type
| translator.
| 
|   :filters-alist
| 
| Alist of filters that will overwrite or complete filters
| defined in PARENT back-end.  See `org-export-filters-alist'
| for a list of allowed filters.
| 
|   :menu-entry
| 
| Menu entry for the export dispatcher.  See
| `org-export-define-backend' for more information about the
| expected value.
| 
|   :options-alist
| 
| Alist of back-end specific properties that will overwrite or
| complete those defined in PARENT back-end.  Refer to
| `org-export-options-alist' for more information about
| structure of the values.
| 
|   :translate-alist
| 
| Alist of element and object types and transcoders that will
| overwrite or complete transcode table from PARENT back-end.
| Refer to `org-export-define-backend' for detailed information
| about transcoders.
| 
| As an example, here is how one could define "my-latex" back-end
| as a variant of `latex' back-end with a custom template function:
| 
|   (org-export-define-derived-backend 'my-latex 'latex
|  :translate-alist '((template . my-latex-template-fun)))
| 
| The back-end could then be called with, for example:
| 
|   (org-export-to-buffer 'my-latex "*Test my-latex*")
| 
| [back]
`

and in that backend do only one thing, define a new transcode function
for element `src-block'

,[ C-h v org-element-all-elements RET ]
| org-element-all-elements is a variable defined in `org-element.el'.
| Its value is (babel-call center-block clock comment comment-block
| diary-sexp drawer dynamic-block example-block export-block fixed-width
| footnote-definition headline horizontal-rule inlinetask item keyword
| latex-environment node-property paragraph plain-list planning
| property-drawer quote-block section special-block src-block table
| table-row verse-block)
| 
| 
|   This variable may be risky if used as a file-local variable.
| 
| Documentation:
| Complete list of element types.
| 
| [back]
`

that uses this function to export a src-block with ox-latex

,[ C-h f org-export-with-backend RET ]
| org-export-with-backend is a compiled Lisp function in `ox.el'.
| 
| (org-export-with-backend BACKEND DATA &optional CONTENTS INFO)
| 
| Call a transcoder from BACKEND on DATA.
| BACKEND is an export back-end, as returned by, e.g.,
| `org-export-create-backend', or a symbol referring to
| a registered back-end.  DATA is an Org element, object, secondary
| string or string.  CONTENTS, when non-nil, is the transcoded
| contents of DATA element, as a string.  INFO, when non-nil, is
| the communication channel used for export, as a plist.
| 
| [back]
`

whenever

,[ C-h f org-element-property RET ]
| org-element-property is a compiled Lisp function in `org-element.el'.
| 
| (org-element-property PROPERTY ELEMENT)
| 
| Extract the value from the PROPERTY of an ELEMENT.
| 
| [back]
`

returns 'latex  for property :language.

But maybe a simple filter could the work too and somebody

Re: [O] Get total number of items

2014-06-22 Thread Thorsten Jolitz
Chris Henderson  writes:

> Is there a way to get the total number of items at the parent level? I
> have lots of ** under a * and I'd like to see the number at a glance.

that was asked before, here is what I came up with [using (apply '+ ...)
instead of (eval (append (list '+ ...) ...)) would even be better]:

> Here is a generalised form:
>
> #+begin_src emacs-lisp
>   (defun count-org-items (&optional level operator match scope skip)
> "Print a counting of outline items."
> (interactive)
> (let ((headline-level (or level 1)) ; 1-8
>   (op (or operator '=))) ; '>= '<= '> '<
> (save-excursion
>   (message "Counting of level%s%d outline items (match=%s, scope=%s, 
> skip=%s): %d"
>op headline-level match scope skip
>(eval (append (list '+)
>  (org-map-entries
>   `(lambda () (if (,op (org-outline-level) 
> ,headline-level) 1 0))
>   match scope skip)))
> #+end_src
>
> usage:
>
> ,
> | (count-org-items 2 '<= "WAITING" 'file)
> `
>
> result:
>
> ,--
> | "Counting of level<=2 outline items (match=WAITING, scope=file,
> | skip=nil): 3"
> `--
>
> see C-h f org-map-entries for more info, its very powerful. Use it
> with M-: (count-org-items ...) or write a more sophisticated
> (interactive) spec.

-- 
cheers,
Thorsten




Re: [O] still seeing semi-regular lockups

2014-06-22 Thread Nicolas Goaziou
Hello,

Daimrod  writes:

> Thanks for investigating.

I made some progress. Alas I didn't find a definitive answer yet.

The problem is related to `quail-input-method', which let-binds
`inhibit-modifications-hooks' to t. This is usually done around
a function that modifies text properties in a buffer.

However, in that case, it calls `quail-start-translation',
`quail-self-insert-command', `quail-self-insert-command' and eventually
`quail-update-translation', which modifies the _contents_ of the buffer
(twice actually, with `quail-delete-region' at line 1555 in
"quail.el.gz" and with `insert' at line 1579).

Since these modifications happen when `inhibit-modifications-hooks' is
non-nil, `after-change-functions' are never called, and the cache cannot
be updated properly, ending in a corrupted state.

There is a workaround for this: if `input-method-use-echo-area' is
non-nil, these modifications happen in the minibuffer, and, thus, the
buffer is not modified.

I also tried to set `inhibit-modifications-hooks' to nil around the two
locations where the buffer is modified (see above), but something odd
happens. Indeed, in that case, `after-change-functions' are called once
too many (i.e, the same buffer modification triggers these calls twice),
corrupting again the buffer. Unfortunately, I have no explanation about
this yet.


Regards,

-- 
Nicolas Goaziou