Re: source blocks mangled when edited

2021-05-31 Thread Michael Gauland


On 31/05/21 9:42 pm, Sébastien Miquel wrote:
> There must be an issue with the `replace-buffer-contents` calls. Can
> you call `trace-function` on `replace-buffer-contents` and trigger the
> behaviour again to see what it returns ?
>
This is all the *trace-output* buffer shows:

==
1 -> (replace-buffer-contents #)
1 <- replace-buffer-contents: nil




Re: source blocks mangled when edited

2021-05-31 Thread Michael Gauland
On 31/05/21 8:15 pm, Sébastien Miquel wrote:
> The relevant functions are `org-edit-src-exit` and perhaps
> `org-src--contents-for-write-back`.
>
> Can you instrument these functions to see what's happening ? Is
> `org-src--contents-for-write-back` populating the buffer correctly ?
> Does the `replace-buffer-contents` call in `org-edit-src-exit` return
> `t` ?
>
I didn't instrument the functions, but found that there are two places
that test '(if (version< emacs-version "26.1"...'. If I change that to
use "version<=", the problem goes away (I'm still running 26.1). I don't
know whether this is the right fix (the underlying problem may be a
quirk in my system, and this is just masking it).  I'm hesitant to
submit a patch unless someone else can replicate the problem.




Re: source blocks mangled when edited

2021-05-31 Thread Michael Gauland
On 31/05/21 4:21 pm, Samuel Wales wrote:
> idk if this will help as you probably know all of it already.  butg
> you asked for any help so here goes.  i run maint, not master or any
> emacs versions.  weird that you are missing 3 cols?
Switching to the maint branch didn't change anything, but I found that I
was unable to reproduce the problem with commit
9802877fbe442a52b4e63782b84921f46cf5d56b, but *could* reproduce it from
commit d02ad1f207e1579aff8f36f740a065d71472c182. Since that commit
affects org-src.el, I may be on the right track.




source blocks mangled when edited

2021-05-30 Thread Michael Gauland
I've stared having trouble editing source blocks.    When I use C-c ' to
edit block, the editing behaves as expected, but when I C-c ' to return
to the main org file, the code is altered in strange ways.  I've had
trouble coming up with a really small example, but the attached file
seems to consistently demonstrate the problem, even when running emacs
without my settings.

The file has two identical source blocks. The first generally behaves
fine, though some lines get extra indentation.

The second suffers more serious distortions. For example, the first line
changes from "digraph G {" to "aph G {".

I've seen this with other types of code as well (at least SQL and json),
so it's not specific to dot.

I'm running emacs 26.1 on Debian 10.9, with org build from git.

I'm not even sure how to start tracking this down. Any help would be
greatly appreciated!

Kind regards,

Mike Gauland

#+BEGIN_SRC dot :file diagram1.png :cmdline -Kdot -Tpng
  digraph G {
  rankdir = "LR"
   pre [label="Preprocessor"]  
   subgraph cluster_inputs {
   label="Inputs"
   rankdir = "TB"
   input1 [label="input"]
   input2 [label="input"]
   input3 [label="∙\n∙\n∙",shape=none]
   input4 [label="input"]
   } -> pre

   pre -> final

   subgraph users {
 rankdir="TB"
 "End Users"
 "Resellers"
 "Corporate Users"
  }

  final -> "End Users"
  final -> "Resellers"
  final -> "Corporate Users"
  }
#+END_SRC

#+BEGIN_SRC dot :file diagram2.png :cmdline -Kdot -Tpng
  digraph G {
  rankdir = "LR"
   pre [label="Preprocessor"]  
   subgraph cluster_inputs {
   label="Inputs"
   rankdir = "TB"
   input1 [label="input"]
   input2 [label="input"]
   input3 [label="∙\n∙\n∙",shape=none]
   input4 [label="input"]
   } -> pre

   pre -> final

   subgraph users {
 rankdir="TB"
 "End Users"
 "Resellers"
 "Corporate Users"
  }

  final -> "End Users"
  final -> "Resellers"
  final -> "Corporate Users"
  }
#+END_SRC



header-args property

2021-04-01 Thread Michael Gauland
I'm confused about the use of the header-args property. It works as
expected when I
export a file, but not when I evaluate a code block manually. For example,
consider this file:

    #+PROPERTY: header-args :var x="Hello" :exports both

    #+begin_src shell
  echo X is $x
    #+end_src

When I export, the result of the code block is "X is Hello", but when I
use C-c
C-c to evaluate the block in emacs, I get "X is"--the variable isn't
defined.

In practice, this means I generally define things like :session for each
block,
rather than using a file-level property. Is this behaviour expected? 

Kind regards,

Mike




Re: "Org" source blocks and minted

2021-04-01 Thread Michael Gauland
Yes, this looks very promising. I'm looking forward to playing with it
when I have more time.


On 27/03/21 12:55 am, Juan Manuel Macías wrote:
> Hi  Timothy,
>
> I really like your approach. And it is org/emacscentric! Minted has
> never quite convinced me, and gives me some trouble with certain
> packages in LuaLaTeX that I have not been able to solve. Thank you for
> this promising alternative.
>
> Best regards,
>
> Juan Manuel 
>
> Timothy  writes:
>
>> Juan mentioned an Org lexer exists, but another approach that may be of
>> interest is using Emacs' own font-lock. I wrote a package that's like
>> HTMLize but works with LaTeX and currently have it sitting in my config.
>>
>> I plan on submitting a patch to Org at some point on this, but for now:
>> - https://github.com/tecosaur/engrave-faces
>> - https://tecosaur.github.io/emacs-config/config.html#pretty-code-blocks
>>
>> Sample output: all the code blocks in
>> https://tecosaur.github.io/emacs-config/config.pdf
>>
>> Since this uses Emacs' font-lock, this means that you can use any
>> language that you have a syntax-highlighting-mode for :)
>



"Org" source blocks and minted

2021-03-23 Thread Michael Gauland
I want to include an "org" source block in a document as an example, and
have it formatted with minted. Unfortunately, minted doesn't seem to
recognize "org" as a language,and the block is missing in the resulting
PDF. For the moment, I've changed this to a "text" source block, but it
would be nice to have syntax highlighting in the export.

Have any of you done this, or something similar?

Kind regards,
Mike


Re: LaTeX Headers not in partial export

2020-10-24 Thread Michael Gauland


On 25/10/20 3:45 pm, Kyle Meyer wrote:
> Michael Gauland writes:
>
>> --start of file--
>>
>> #+LATEX: \setminted{frame=single,framerule=1pt}
>>
>>
>> * Section
>>   #+begin_src sh :exports code
>>   echo "This is a code block
>>   #+end_src
>>
>> --end of file--
>>
>>
>> When I export the file to LaTeX, this line is inclued after
>> \begin{document}:
>>
>> \setminted{frame=single,framerule=1pt}
>>
>> When I export only the section--either by selecting it explicitly, or by
>> adding a "export" tag, that line is missing.
> Should that be #+LATEX_HEADER: instead of #+LATEX:?

Yes--that fixes it. Thanks for spotting that.





Re: LaTeX Headers not in partial export

2020-10-24 Thread Michael Gauland
On 24/10/20 4:00 am, Eric S Fraga wrote:
> On Friday, 23 Oct 2020 at 15:22, Mike Gauland wrote:
>> I have a number of #+LATEX directives at the top of my org file, for
>> configuring the minted package.
> Could you maybe post a minimal example?
>
This file demonstrates the problem, at least on my systems:

--start of file--

#+LATEX: \setminted{frame=single,framerule=1pt}


* Section
  #+begin_src sh :exports code
  echo "This is a code block
  #+end_src

--end of file--


When I export the file to LaTeX, this line is inclued after
\begin{document}:

\setminted{frame=single,framerule=1pt}

When I export only the section--either by selecting it explicitly, or by
adding a "export" tag, that line is missing.






Listings and dialects

2019-12-16 Thread Michael Gauland
My org files typically include source blocks from several different
languages.

I'm using the listings package for export to LaTeX. I'd like to give each
language a distinctive look (by changing the background or border colour).
I can do this manually by inserting a bit of LaTeX before each block, but
I'd like to avoid having to do that.

As far as I can tell, I can't easily tell the listings package to change
just one aspect of one language. I *can*, however, create a dialect of the
language, with a different appearance. If the language has a named dialect
I can use as a basis (such as awk, which has gnu and posix dialects), I can
then set the default dialect to my new dialect, and awk blocks are
formatted as I like.

Unfortunately, most of the languages I use (bash, sqlite, R), don't have a
name dialect. When I define a new dialect in terms of the default, unnamed
dialect, then set the default dialect to my version, listings throws a
wobbly.

My idea to work around this is to specify a dialect to the source block,
and, if that is present, have org include it in the language is passes to
listings.

So far, though, I haven't been able to puzzle out how to do this. I could
see it being done as a new switch to the code block (similiar to -n to
control line numbering), or as an argument to the block (such as :exports).

Which way would be most 'org-like'?  Any pointers on where to start  poking
around in the code?

Thanks for any assistance,
Mike


Re: Babel: Store script in external file

2019-12-16 Thread Michael Gauland
I've just started playing with #+INCLUDE, so I may not be using it
correctly, but this works for me.

I have a file 'sh_test', which looks like:
for i in $(seq 10); do
echo $i
done

My org file:
#+HEADER: :exports both
#+INCLUDE: "sh_test" src sh

And the results:

,
| for i in $(seq 10); do
| echo $i
| done
`

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10

Hope that helps.

Kind regards,
Mike


On Mon, Dec 16, 2019 at 2:22 PM Nathan Neff  wrote:

> Hello all,
>
> I think I'm missing something basic:  I'd like to have something like this:
>
> #+begin_src python
> #+filename: foo.py
>
> Instead of storing my Python code in the current org file, I would like
> Babel to read foo.py and execute it, as if it was inside the .org file.
>
> The foo.py mentioned above is fairly large, and I would like the code
> to be stored in a different file than my .org file, for brevity.
>
> Any ideas?  I feel like I'm missing something obvious.
>
> Thanks,
> --Nate
>


Customize listings per language?

2019-12-01 Thread Michael Gauland
I often have several different babel languages in the same file. I'd
like to be able make them easily distinguished by language (such as
having a different background or shadow).

As far as I can tell, the listings package doesn't let me override
settings by language.

The best solution I've so far is to precede each block with a
directive, such as:

#+ATTR_LATEX: :options rulesepcolor=\color{green}
#+begin_src elisp

Any suggestions for a less error-prone solution?

Kind regards,
Mike



Re: [O] [POLL] Should Org tempo be enabled by default? (expand templates thru e.g. "<s[TAB]")

2018-04-30 Thread Michael Gauland
Same here!


On 01/05/18 08:46, Peter Dewey Ore wrote:
> I second (third?) Richard and Jon. I use  appreciate the simplicity.
>
> On Mon, Apr 30, 2018 at 1:37 PM, Richard Lawrence
> >
> wrote:
>
> Jon Snader > writes:
>
> I use the  it enabled. I don't want to have to deal with a menu and its
> more complicated calling sequence
>
>
> I feel the same!  Please don't disable  complicated to use.
>
> -- 
> Best,
> Richard
>
>



Re: [O] Different listing styles for same babel language?

2017-08-06 Thread Michael Gauland
I recently wrote:

>> My org documents include lots of source code blocks, in a variety of
>> languages. I use the listings package to give each language a
>> distinctive look.
>>
>> Lately, my work has involved using shell commands on different machines,
>> as different users. I'd like to give each shell environment (e.g., local
>> user, normal user on remote host, root on remote host) a different look.
>> At the moment, I'm doing this by specifying different shells (bash,
>> dash, sh) for each. This works, especially since I'm not executing the
>> commands from emacs, so it doesn't matter which shell I specify.
>>
>> Is there a better way to do this?
>>
>
I've found that #+ATTR_LATEX: :options language= does exactly what I
was looking for. The attached example may be useful to others.
#+LATEX_HEADER: \lstset{frame=shadowbox}
#+LATEX_HEADER: \lstdefinelanguage{bash-local}{rulesepcolor=\color{cyan}}
#+LATEX_HEADER: \lstdefinelanguage{bash-remote}{rulesepcolor=\color{yellow}}
#+LATEX_HEADER: 
\lstdefinelanguage{bash-remote-root}{rulesepcolor=\color{orange}}
#+PROPERTY: header-args :eval never

#+ATTR_LATEX: :options language=bash-local
#+BEGIN_SRC bash :results output :eval ask
  # Run this script on the local host
  # Install the key in the VM:
  ssh-copy-id -i ~/.ssh/vm \
  -p 3022 user@127.0.0.1 
#+END_SRC

#+RESULTS:

#+ATTR_LATEX: :options language=bash-remote-root
#+BEGIN_SRC bash
  # Run this as root on the remote host
  apt-get update
  apt-get -y install  git 
#+END_SRC

#+ATTR_LATEX: :options language=bash-remote
#+BEGIN_SRC bash :results output :eval ask
  # Run this as a normal user on the remote host
  cd project
  git pull
  make
#+END_SRC



[O] Different listing styles for same babel language?

2017-07-23 Thread Michael Gauland
My org documents include lots of source code blocks, in a variety of
languages. I use the listings package to give each language a
distinctive look.

Lately, my work has involved using shell commands on different machines,
as different users. I'd like to give each shell environment (e.g., local
user, normal user on remote host, root on remote host) a different look.
At the moment, I'm doing this by specifying different shells (bash,
dash, sh) for each. This works, especially since I'm not executing the
commands from emacs, so it doesn't matter which shell I specify.

Is there a better way to do this? 

Would anyone else find it useful? I'm happy to  work on the code, if I'm
not the only one who'd use it.




[O] Different listing styles for same babel language?

2017-07-19 Thread Michael Gauland
My org documents include lots of source code blocks, in a variety of
languages. I use the listings package to give each language a
distinctive look.

Lately, my work has involved using shell commands on different machines,
as different users. I'd like to give each shell environment (e.g., local
user, normal user on remote host, root on remote host) a different look.
At the moment, I'm doing this by specifying different shells (bash,
dash, sh) for each. This works, especially since I'm not executing the
commands from emacs, so it doesn't matter which shell I specify.

Is there a better way to do this? 

Would anyone else find it useful? I'm happy to  work on the code, if I'm
not the only one who'd use it.




Re: [O] Exporting Source Blocks with Symbols

2016-01-17 Thread Michael Gauland
Just following up with my solution, in case anyone else is interested
(thanks to John Kitchin for pointing me in the right direction). First, I
should note that 'µ' exported correctly because I was using the unicode
element 'MICRO SYMBOL' instead of 'GREEK SMALL LETTER MU' (which looks the
same, but doesn't export).

The 'listings' package can only handle 8-bit characters, but you can tell it
to escape to LaTeX. The code block below adds a hook to escape the
characters I'm interested in, and adds the listing option to identify the
escape character (a symbol I've never used for anything else).

This code could certainly be improved, but it serves my needs, and may be
useful as a starting point for anyone trying to do something similar.
--Michael Gauland

#+BEGIN_SRC emacs-lisp :session :results value silent :exports none
;; Set up a filter to preserve greek symbols in code blocks
(setq org-export-filter-src-block-functions
  (list
(lambda (text backend info)
   (replace-regexp-in-string "\\([σβ]\\)" "§$\\1$§" text
   
(setq org-latex-listings-options '(("escapechar" "§")))
#+END_SRC



[O] Exporting Source Blocks with Symbols

2016-01-13 Thread Michael Gauland
I've become fond of using Greek symbols in my R code (mu, sigma, etc). R
handles these just fine, but most of them disappear in the listing when I
export to LaTeX (lower-case mu comes through OK). I think the basic problem
is the the listings package can't handle the characters. I've come across
some ideas for coping with this in LaTeX, but they involve modifying the
source (e.g., escaping the symbols to math mode). Of course if I do that, R
won't know what to do with the characters.

Any suggestions? Does babel provide any hooks for pre-processing source
blocks for export? I didn't find any, but I often miss what's right in front
of me (just ask my wife!).

Kind Regards,
Michael Gauland




Re: [O] [PATCH] Fix R table import

2015-01-04 Thread Michael Gauland
I'm using the latest from git, with some unrelated local modifications
(though to be sure I did a clean build from origin/master and had the
same problem).  Versions:

Org-mode version 8.3beta (release_8.3beta-758-g034d00.dirty @
/usr/local/share/emacs/site-lisp/org/)

GNU Emacs 24.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.10.7) of
2014-03-08 on lamiak, modified by Debian

R version 3.0.2 (2013-09-25) -- Frisbee Sailing


This is an Ubuntu system; my Debian system is pretty much the same,
and also shows the problem. Does this help?

On Sun, Jan 4, 2015 at 7:24 PM, Aaron Ecay aarone...@gmail.com wrote:
 Hi Michael,

 Thanks for this patch.  Before it is applied, though, I would like to
 understand why it is necessary.  Vikas said that he could not reproduce
 the problem you originally reported.  (Here is a web archived version of
 Vikas’s message, in case you did not see it at first:
 http://mid.gmane.org/b874ada0-1879-4021-b873-035ac85c4...@agrarianresearch.org)

 I cannot reproduce the problem either, using a very recent git version
 of org.

 I think we need some more information in order to understand why you are
 experiencing this misbehavior.  Can you tell us what version of org you
 have installed, i.e. the output of M-x org-version?

 Thanks,

 --
 Aaron Ecay



Re: [O] [PATCH] Fix R table import

2015-01-04 Thread Michael Gauland
My git has so many more commits because I'm sloppy about my local changes.

I had been using ESS 5.14 (from ELPA). When I switched to the latest
git version, the problem (at least seems to have) went away.

For my needs, I don't think this needs any further investigation,
though I'm happy to help if anyone else thinks it is important.

On Mon, Jan 5, 2015 at 1:35 PM, Aaron Ecay aarone...@gmail.com wrote:
 Hi Michael,

 Hmm.  I have

 Org-mode version 8.3beta (release_8.3beta-695-g390015 @ 
 /home/aecay/development/org-mode/lisp/)

 The git sha 034d00 from your org-version isn’t in my checkout.  Yours
 also thinks it’s 60ish commits ahead of where mine is (758 vs. 695).
 This is very strange; I don’t know what to make of it.

 I have:

 GNU Emacs 25.0.50.2 (x86_64-unknown-linux-gnu, GTK+ Version 3.14.6)

 What is your version of ESS?  (C-h v ess-version)  It’s 14.11 for me
 (actually a melpa install of the latest git version).

 I executed the attached elisp file, then loaded the attached org file,
 and could not reproduce the issue.  When doing so, the code that org
 executes is echoed to the *R* buffer.  Can you send what is echoed for
 you?  (You will have to edit in the appropriate paths to your org and
 ess installations, unless they are in emacs’s default load-path)

 I get:

 data.table - local({
  con - textConnection(
\A\   \B\   \C\
 \115\ \76\  \60\
  )
  res - utils::read.table(
con,
header= TRUE,
row.names = NULL,
sep   = \t,
as.is = TRUE
  )
  close(con)
  res
})
 data.table
 'org_babel_R_eoe'



 Thanks,

 --
 Aaron Ecay




Re: [O] org tables into R?

2015-01-03 Thread Michael Gauland
I modified the definition of ob-R-transfer-variable-table-with-header in
ob-R.el by changing 'sep' from \\\t\ to \\. Now


  #+BEGIN_SRC R :results output :exports both :session :var data.table=data
:colnames yes
  names(data.table)
  head(data.table)
  #+END_SRC

(note the addition of :colnames=yes) give me:

  #+RESULTS:
  : [1] A B C
  : A  B  C
  : 1 115 76 60
  : 2 124 78 55
  : 3 118 73 65
  : 4 114 75 61
  : 5 108 74 82

as I expect.

What is the current procedure to submit a patch?

Thanks,
Michael








[O] [PATCH] Fix R table import

2015-01-03 Thread Michael Gauland
ob-R.el: Fix R table import

* ob-R.el (ob-R-transfer-variable-table-with-header): Change separator from
tab to whitespace when reading in a table as a variable.

TINYCHANGE


 lisp/ob-R.el |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/ob-R.el b/lisp/ob-R.el
index 2470b4f..80b7161 100644
--- a/lisp/ob-R.el
+++ b/lisp/ob-R.el
@@ -108,7 +108,7 @@ this variable.)
con,
header= %s,
row.names = %s,
-   sep   = \\\t\,
+   sep   = \\,
as.is = TRUE
  )
  close(con)
-- 




[O] org tables into R?

2015-01-02 Thread Michael Gauland
I want to use an R block to manipulate data from an org table, but I'm not
getting what I expect. 

If I define a table like this:

  #+NAME: data
  |   A |   B |  C |
  |-+-+|
  | 115 |  76 | 60 |
  | 124 |  78 | 55 |
  | 118 |  73 | 65 |
  | 114 |  75 | 61 |
  | 108 |  74 | 82 |

and pass it into R like this:

  #+BEGIN_SRC R :results output :exports both :session :var data.table=data
  names(data.table)
  head(data.table)
  #+END_SRC

I expect to get a table with three columns (A, B, and C), but instead I
seem to get a single column named A.B.C:

  #+RESULTS:
  : [1] A.B.C
  :   A.B.C
  : 1 115 76 60
  : 2 124 78 55
  : 3 118 73 65
  : 4 114 75 61
  : 5 108 74 82


What am I doing wrong?

Thanks,
Michael Gauland




Re: [O] PNG R plots size

2013-12-17 Thread Michael Gauland
Vicente Vera vichovp at gmail.com writes:
 How can I control the size of a PNG graphic? Do I need to tweak
 something inside Org or specify something in R?

I use a line like this:

   #+HEADER: :res 300 :units cm :width 15 :height 15

to create a 15cm square PNG at 300 dpi.





Re: [O] org-babel generated images and +ATTR_LATEX

2013-10-24 Thread Michael Gauland
Mark Edgington edgimar at gmail.com writes:
 Anyhow, something that wasn't clear to me about your example is how you make
 the filename which is generated via org-babel-temp-file available for use
 within the code-block?

Babel takes care of that (plantuml interprets the :file argument as the name
of the file it should generate). I'm not sure the best way to get the file
name in to a Python block. You could probably pass the generated name in as
a :var parmater.





Re: [O] org-babel generated images and +ATTR_LATEX

2013-10-23 Thread Michael Gauland
Mark,
I think you want to use named results. My images typically look something
like this:

   #+NAME: architecture
   #+HEADER: :exports results
   #+HEADER: :file (org-babel-temp-file ./figure- .eps)
   #+HEADER: :cache yes
   #+BEGIN_SRC plantuml
   ...
   #+END_SRC

   #+NAME: fig-architecture
   #+CAPTION: Overview of mini-me architecture.
   #+ATTR_LaTeX: :width \textwidth :placement [h!bt]
   #+RESULTS: architecture
  
[[file:c:/Users/mgauland/AppData/Local/Temp/babel-5988Tli/figure-5988XRB.eps]]

Does that help?

Kind Regards,
Mike





[O] ebnf2ps for babel

2013-10-22 Thread Michael Gauland
I've had a play with adding babel support for ebnf2ps, to generate
railroad diagrams for a grammar.

I'd appreciate any comments on the attached code.

Would anyone else find this useful?

Kind Regards,
Mike Gauland
;;; ob-ebnf.el --- org-babel functions for ebnf evaluation

;; Copyright (C) your name here

;; Author: Michael Gauland
;; Keywords: literate programming, reproducible research
;; Homepage: http://orgmode.org
;; Version: 0.01

;;; License:

;; This program 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, or (at your option)
;; any later version.
;;
;; This program 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; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.

;;; Commentary:

;;; Org-Babel support for using ebnf2ps to generate encapsulated postscript
;;; railroad diagrams. It recogises these arguments:
;;;
;;; :file is required; it must include the extension '.eps.' All the rules
;;;   in the block will be drawn in the same file. This is done by
;;;   inserting a '[file' comment at the start of the block (see the
;;;   documentation for ebnf-eps-buffer for more information).
;;;
;;; :style specifies a value in ebnf-style-database. This provides the
;;;ability to customise the output. The style can also specify the
;;;gramnmar syntax (by setting ebnf-syntax); note that only ebnf,
;;;iso-ebnf, and yacc are supported by this file.

;;; Requirements:

;;; Code:
(require 'ob)
(require 'ob-ref)
(require 'ob-comint)
(require 'ob-eval)
(require 'ebnf2ps)

;; optionally declare default header arguments for this language
(defvar org-babel-default-header-args:ebnf '((:style . nil)))

;; Use ebnf-eps-buffer to produce an encapsulated postscript file.
;;
(defun org-babel-execute:ebnf (body params)
  Execute a block of Ebnf code with org-babel.  This function is
called by `org-babel-execute-src-block'
  (save-excursion
(let* ((dest-file (cdr (assoc :file params)))
	   (dest-dir (file-name-directory dest-file))
	   (dest-root (file-name-sans-extension
		   (file-name-nondirectory dest-file)))
   (dest-ext  (file-name-extension dest-file))
	   (style (cdr (assoc :style params)))
	   (current-dir default-directory)
	   (result nil))
  (with-temp-buffer
	(when style (ebnf-push-style style))
	(let 
	((comment-format
	  (cond ((string= ebnf-syntax 'yacc) /*%s*/)
		((string= ebnf-syntax 'ebnf) ;%s)
		((string= ebnf-syntax 'iso-ebnf) (*%s*))
		(t (setq result
			 (format EBNF error: format %s not supported.
 ebnf-syntax))
	  (setq ebnf-eps-prefix dest-dir)
	  (insert (format comment-format (format [%s dest-root)))
	  (newline)
	  (insert body)
	  (newline)
	  (insert (format comment-format (format ]%s dest-root)))
	  (ebnf-eps-buffer)
	  (when style (ebnf-pop-style
  result
  )))

(provide 'ob-ebnf)
;;; ob-ebnf.el ends here
#+TITLE: Org Babel EBNF Sample
#+AUTHOR:Michael Gauland
#+EMAIL: mikely...@amuri.net
#+DATE:  {{{time(%Y-%m-%d %H:%M)}}}
#+LaTeX_CLASS: article
#+LaTeX_CLASS_OPTIONS: [a4paper]
#+LaTeX_HEADER: \usepackage{epstopdf}
#+LATEX_HEADER: \definecolor{mygray}{gray}{0.8}
#+LATEX_HEADER: \lstset{rulesepcolor=\color{mygray}}
#+LaTeX_HEADER: 
\lstdefinelanguage{ebnf}{rulesepcolor=\color{cyan},frameround=,backgroundcolor=\color{mygray}}
#+PROPERTY: exports both

* EBNF
  #+HEADER: :file (org-babel-temp-file ./temp .eps)
  #+BEGIN_SRC ebnf
  sequence = this that.  
  alternation = this | that.
  #+END_SRC

  #+RESULTS:
  [[file:/tmp/babel-5910UgK/temp5910f9T.eps]]
* ISO-EBNF
  #+HEADER: :file (org-babel-temp-file ./temp .eps)
  #+HEADER: :style 'iso-ebnf
  #+BEGIN_SRC ebnf
  sequence = this, that;
  alternation = this | that;
  #+END_SRC

  #+RESULTS:
  [[file:/tmp/babel-5910UgK/temp5910S6B.eps]]
* YACC
  #+HEADER: :file (org-babel-temp-file ./temp .eps)
  #+HEADER: :style 'yacc
  #+BEGIN_SRC ebnf
  %%
  sequence: 'this'  'that';
  alternation: 'this' | 'that';
  #+END_SRC

  #+RESULTS:
  [[file:/tmp/babel-5910UgK/temp5910Uun.eps]]



Re: [O] Network Diagram

2013-09-29 Thread Michael Gauland
Esben Stien b0ef at esben-stien.name writes: 
 Any way to create something like a network diagram with org-mode?

I haven't tried doing network diagrams, but I've found dot (graphviz),
PlantUML, and Asymptote very flexible.




Re: [O] [PATCH] Emacs Org Babel Scheme (Geiser) support

2013-08-06 Thread Michael Gauland
Thanks for such a well-written, well-documented, and most of all useful
contribution!  Definitely a big improvement over my initial implementation.

I've applied the patch to my system, but I'm having trouble getting it to
work--I'm not getting any results. For example, this block:

#+BEGIN_SRC scheme 
(display This is the output)
This is the value
#+END_SRC 

Returns nil, whether I'm asking for output or value. I'm running emacs
23.4.1 on Debian wheezy, with Geiser 3.0.

Could you send me a copy of your ob-scheme.el to help me track this down?

Kind Regards,
Mike







[O] Number formatting in tables for LaTeX export

2013-04-30 Thread Michael Gauland
I have a table representing a memory map, something like this:

| Start | End  | Purpose|
|---+--+|
|   | 1E08 | Bootloader |
|  1E09 | 1FFF | Unused (Bootloader expansion)  |
|  2000 | 3F39 | Application|

When I export to LaTeX, '1E08' and '1E09' are interpreted as decimal
exponent numbers, and are exported as '1(08)' and '1(09)'.

The only way I've found to prevent this is to include the line:

#+ATTR_LaTeX: :mode verbatim

which produces a rather ugly fixed-font table.

Is there an existing solution to this? If not, any ideas for addressing it?

Kind Regards,
Mike Gauland




[O] [PATCH] Agenda: Fortnight time span

2013-04-30 Thread Michael Gauland
Agenda: Add fortnight as a time span

* lisp/org-agenda.el (org-agenda-custom-commands-local-options): Add
fortnight as a choice for org-agenda-span.
(org-agenda-span): Add fortnight as a choice for customising org-agenda-span.
(): Add 'Fortnight View' to the org-agenda-menu
(org-agenda-list): If number of days is 14, start the agenda on weekday (as
done for week-long agendas).
(org-agenda-ndays-to-span): Return 14 for 'fortnight'.
(org-agenda-span-to-ndays): Return 'fortnight' for a 14-day span
(org-agenda-later): Go forward 14 days for  a fortnight.
(org-agenda-view-mode-dispatch): Add 't' for fortnight view.
(org-agenda-fortnight-view): New function; similar to org-agenda-week-view.
(org-agenda-change-time-span): Recognise 'fortnight' as a span.
(org-agenda-compute-starting-span): Recognise 'fortnight' as a span.

I find it convenient to use org-agenda to look two weeks ahead; others may also.


---
 lisp/org-agenda.el |   32 ++--
 1 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index fe2c743..1d3b323 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -328,6 +328,7 @@ the daily/weekly agenda, see `org-agenda-skip-function'.)
 (const org-agenda-span)
 (choice (const :tag Day 'day)
 (const :tag Week 'week)
+(const :tag Fortnight 'fortnight)
 (const :tag Month 'month)
 (const :tag Year 'year)
 (integer :tag Custom)))
@@ -1135,6 +1136,7 @@ Custom commands can set this variable in the options
section.
   :group 'org-agenda-daily/weekly
   :type '(choice (const :tag Day day)
 (const :tag Week week)
+(const :tag Fortnight fortnight)
 (const :tag Month month)
 (const :tag Year year)
 (integer :tag Custom)))
@@ -2334,7 +2336,11 @@ The following commands are available:
  [Week View org-agenda-week-view
   :active (org-agenda-check-type nil 'agenda)
   :style radio :selected (eq org-agenda-current-span 'week)
-  :keys v w  (or just w)]
+  :keys v w]
+ [Fortnight View org-agenda-fortnight-view
+  :active (org-agenda-check-type nil 'agenda)
+  :style radio :selected (eq org-agenda-current-span 'fortnight)
+  :keys v f]
  [Month View org-agenda-month-view
   :active (org-agenda-check-type nil 'agenda)
   :style radio :selected (eq org-agenda-current-span 'month)
@@ -4170,7 +4176,7 @@ items if they have an hour specification like [h]h:mm.
   (sd (or start-day today))
   (ndays (org-agenda-span-to-ndays span sd))
   (org-agenda-start-on-weekday
-   (if (eq ndays 7)
+   (if (or (eq ndays 7) (eq ndays 14))
org-agenda-start-on-weekday))
   (thefiles (org-agenda-files nil 'ifmode))
   (files thefiles)
@@ -4339,6 +4345,7 @@ items if they have an hour specification like [h]h:mm.
   (cond ((symbolp n) n)
((= n 1) 'day)
((= n 7) 'week)
+   ((= n 14) 'fortnight)
(t n)))
 
 (defun org-agenda-span-to-ndays (span optional start-day)
@@ -4347,6 +4354,7 @@ START-DAY is an absolute time value.
   (cond ((numberp span) span)
((eq span 'day) 1)
((eq span 'week) 7)
+   ((eq span 'fortnight) 14)
((eq span 'month)
 (let ((date (calendar-gregorian-from-absolute start-day)))
   (calendar-last-day-of-month (car date) (caddr date
@@ -7825,6 +7833,8 @@ With prefix ARG, go forward that many times the
current span.
   (setq sd (+ arg sd)))
  ((eq span 'week)
   (setq sd (+ (* 7 arg) sd)))
+ ((eq span 'fortnight)
+  (setq sd (+ (* 14 arg) sd)))
  ((eq span 'month)
   (setq greg2 (list (+ (car greg) arg) (nth 1 greg) (nth 2 greg))
sd (calendar-absolute-from-gregorian greg2))
@@ -7854,7 +7864,7 @@ With prefix ARG, go backward that many times the
current span.
 (defun org-agenda-view-mode-dispatch ()
   Call one of the view mode commands.
   (interactive)
-  (message View: [d]ay[w]eek   [m]onth   [y]ear  
[SPC]reset  [q]uit/abort
+  (message View: [d]ay[w]eek for[t]night   [m]onth  
[y]ear   [SPC]reset  [q]uit/abort
   time[G]rid   [[]inactive  [f]ollow  [l]og[L]og-all   [c]lockcheck
   [a]rch-trees [A]rch-files clock[R]eport include[D]iary  
[E]ntryText)
   (let ((a (read-char-exclusive)))
@@ -7862,6 +7872,7 @@ With prefix ARG, go backward that many times the
current span.
   (?\  (call-interactively 'org-agenda-reset-view))
   (?d (call-interactively 'org-agenda-day-view))
   (?w (call-interactively 'org-agenda-week-view))
+  (?t (call-interactively 'org-agenda-fortnight-view))
   (?m (call-interactively 'org-agenda-month-view))
   (?y (call-interactively 

[O] Patchwork?

2013-04-10 Thread Michael Gauland
I haven't been able to connect to the patchwork server mentioned on the Worg
for the last couple of days. Is this link outdated, or is the server
temporarily unavailable?

Kind Regards,
Mike Gauland





Re: [O] New logo

2013-04-01 Thread Michael Gauland
Bastien bzg at altern.org writes:
 
 I asked many Org friends during the last few weeks, and we all
 agreed that an ostrich might be a good candidate.

I'm afraid this logo sends the wrong message. It should be showing the
non-org-users of the world with their heads in the sand.

Or maybe the logo should include the subterranean wonders of org the ostrich
(orgstrich?) is marveling at?

--Mike






Re: [O] :session question

2013-03-25 Thread Michael Gauland
Andreas Röhler andreas.roehler at easy-emacs.de writes:
 
 Would find it more natural if :session is the default, while a command
refresh makes a new one.

I don't think so, but perhaps I'm just used to the way it works now.  I use a
mix of session and non-session blocks. When I use plantuml, dot, or asymptote to
generate images, I don't use sessions (I'm not sure these languages even support
sessions). I almost always use sessions for R, because I want to use the same
data in different blocks. I also generally use sessions for Racket (scheme),
even when I don't to share data across blocks, so I don't need to wait for the
interpreter to start up for each block.

Kind Regards,
Mike Gauland




Re: [O] Help with babel results

2013-03-11 Thread Michael Gauland
On 11/03/13 12:48, Eric Schulte wrote:
 I've now committed this patch.
Thanks--that was fast.

Works for me now.

Kind Regards,
Mike




signature.asc
Description: OpenPGP digital signature


[O] Help with babel results

2013-03-09 Thread Michael Gauland
I'm working with an sqlite database of songs, and I've run into trouble
with titles that start with a '(' (for example,
(I Can't Get No) Satisfaction). 'Verbatim' results work:

#+BEGIN_SRC sqlite :db test-db :results verbatim
.mode csv
.separator |
drop table playlist;
create table playlist (title varchar, artist varchar);
insert into playlist values((I Can't Get No) Satisfaction,
Rolling Stones);
select * from playlist;
#+END_SRC

#+RESULTS:
: (I Can't Get No) Satisfaction|Rolling Stones

But :results table' reports:

eval: Symbol's function definition is void: I

It looks to me like org is trying to interpret (I Can't Get No) as emacs
lisp, but I haven't been able to figure out how to prevent that.

Advice would be greatly appreciated.

Kind Regards,
Mike



signature.asc
Description: OpenPGP digital signature


[O] [PATCH] ':wrap nowrap' disable wrapping

2013-03-02 Thread Michael Gauland
Babel: Disable wrapping

* lisp/ob-core.el (org-babel-insert-result): If the argument to ':wrap'
is 'nowrap', don't wrap the results.

* doc/org.texi (Header Arguments): Describe 'nowrap' behaviour.

This allows the results of a block to be inserted without wrapping, by
overriding a ':wrap' property defined in an enclosing scope.

diff --git a/doc/org.texi b/doc/org.texi
index bd22c7a..7fe49d2 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -13972,6 +13972,10 @@ to @code{#+BEGIN_} and @code{#+END_}, which will then be used to wrap the
 results.  If not string is specified then the results will be wrapped in a
 @code{#+BEGIN/END_RESULTS} block.
 
+The string ``nowrap'' (case insensitive) is treated specially. It will
+disable wrapping, if it has been turned on by setting the :wrap property at
+a higher outline level.
+
 @node Results of evaluation, Noweb reference syntax, Header arguments, Working With Source Code
 @section Results of evaluation
 @cindex code block, results of evaluation
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 275a4f7..bf84ef0 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -1893,6 +1893,13 @@ org - results are added inside of a \#+BEGIN_SRC org\ block.
   They are not comma-escaped when inserted, but Org syntax
   here will be discarded when exporting the file.
 
+wrap  if no argument is supplied, the results are added
+  inside a #+BEGIN_RESULTS block. If a string argument
+  is provided, the string is appended to #+BEGIN_ and
+  #+END_ to delimit the block, unless the string is
+  'nowrap' (case insensitive), in which case the results 
+  will *not* be wrapped.
+
 html  results are added inside of a #+BEGIN_HTML block.  This
   is a good option if you code block will output html
   formatted text.
@@ -2009,7 +2016,10 @@ code  the results are extracted in the syntax of the source
 		(setq end (point-marker))
 		;; possibly wrap result
 		(cond
-		 ((assoc :wrap (nth 2 info))
+		 ((let ((w (assoc :wrap (nth 2 info
+		(and w
+			 (or (not (stringp (cdr w)))
+			 (not (string= (upcase (cdr w)) NOWRAP)
 		  (let ((name (or (cdr (assoc :wrap (nth 2 info))) RESULTS)))
 		(funcall wrap (concat #+BEGIN_ name)
 			 (concat #+END_ (car (org-split-string name))


signature.asc
Description: OpenPGP digital signature


Re: [O] :wrap behaviour

2013-02-28 Thread Michael Gauland
Tom Regner tom at goochesa.de writes:
 
 I'd suggest: nowrap
 
 regards
 Tom


That inspires another idea: specifying :nowrap to turn off wrapping for the
block. Thus,

#+BEGIN_SRC emacs-lisp :nowrap 
...


would not be wrapped, even if :wrap were set at a higher level.




Re: [O] 13 failures on make ./update

2013-02-24 Thread Michael Gauland
Jude DaShiell jdashiel at shellworld.net writes:

 In toplevel form:

 ox.el:80:1:Error: Cannot open load file: tabulated-list

I ran into this as well, and resolved it by adding the tabulated-list package
from ELPA, and adding -L ~/.emacs.d/elpa/tabulated-list-0 to the definition of
EMACS in my local.mk.

Hope that helps.

Kind Regards,
Mike





[O] [PATCH] Turning off wrapping

2013-01-23 Thread Michael Gauland
I have file with a large number of SRC blocks, the output of which I
want to wrap as SRC (so I can use the listings package to format them
distinctly). The easiest way to do this is to make :wrap a global
property. Unfortunately, there are also a couple of places where I want
to turn off the wrapping, especially where I include source in-line. 
For example, this:

#+PROPERTY: wrap SRC fundamental

#+BEGIN_SRC emacs-lisp
This output comes from emacs.
#+END_SRC

This in-line src_emacs-lisp[:results value]{block} is wrapped.

produces:
,
| This output comes from emacs.
`

This in-line #+BEGIN_SRC fundamental block#+END_SRC is wrapped.

If I pass an empty :wrap in the in-line block, the result is still
wrapped, but as RESULTS instead of source.

The attached patch attempts to change this behaviour. Does anyone else
find this desirable? Is this patch a good way to do it?

Kind Regards,
Mike




diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 9e4c8b1..4d73fcc 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -1999,7 +1999,8 @@ code  the results are extracted in the syntax of the source
 		(setq end (point-marker))
 		;; possibly wrap result
 		(cond
-		 ((assoc :wrap (nth 2 info))
+		 ((and (assoc :wrap (nth 2 info))
+		   (cdr (assoc :wrap (nth 2 info
 		  (let ((name (or (cdr (assoc :wrap (nth 2 info))) RESULTS)))
 		(funcall wrap (concat #+BEGIN_ name)
 			 (concat #+END_ (car (org-split-string name))


signature.asc
Description: OpenPGP digital signature


Re: [O] Error building org-e-publish

2013-01-14 Thread Michael Gauland
J. David Boyd david at adboyd.com writes:

 Mine builds with no problem at all, using emacs 24.2.92.
 
 You sure you have the latest git source?  I just did an update a moment
 ago...
 

Thanks for the info. I've got the latest git, but I'm running emacs 23.2 (under
Debian).
I can evaluate all the code on org-e-publish.el, but get the error when I try to
byte-compile it.

I was able to build in on my Windows machine, which uses emacs 24.

Anyone able to build on emacs 23?  

Kind Regards,
Mike








Re: [O] Error building org-e-publish

2013-01-14 Thread Michael Gauland
Nick Dokos nicholas.dokos at hp.com writes:

 Not sure why emacs24 does not complain but org-e-publish contains this bit of
 code:
 ,
 | ...
 | (org-export-async-start 'ignore
 |   `(let ((org-e-publish-use-timestamps-flag
 |   (if ',force nil ,org-e-publish-use-timestamps-flag)))
 |  (org-e-publish-projects ',project-alist)))
 | ...
 `
 
 and org-export-async-start in contrib/lisp/org-export.el says:
 
 ,
 | (defmacro org-export-async-start  (fun rest body)
 |   Call function FUN on the results returned by BODY evaluation.
 |   ...
 `
 
 so there does seem to be a mismatch.

Thanks, Nick. If I change 'ignore to ignore (without the tick), it builds for me
on both systems.

Could you confirm that fixes it for you as well? If so, I'll submit a patch.

Thanks for you help.

--Mike






Re: [O] Error building org-e-publish

2013-01-14 Thread Michael Gauland
On 15/01/13 11:11, Nick Dokos wrote:
 Not sure I understand. Can you explain why that would be a good fix?

Looking further into it, I'm not sure it *is* right. I'll see if I can
track down the source of those lines, and who contributed them, before
second-guessing the intent.





signature.asc
Description: OpenPGP digital signature


[O] Error building org-e-publish

2013-01-13 Thread Michael Gauland
I'm having trouble building the latest code from git.

I don't normally use 'publish', but it appears to be required for some
of the exporters I use. I've added it to ORG_ADD_CONTRIB, but it fails
to build:

  Compiling file /home/mike/elisp/org-mode-clean/lisp/org-e-publish.el
at Mon Jan 14 11:51:11 2013
  org-e-publish.el:844:35:Error: Not a lambda list: (quote ignore)

The faulty line is simply
(org-e-publish-projects project-alist)

Has anyone else run into this?  Any advice would be greatly appreciated.

Kind Regards,
Mike



signature.asc
Description: OpenPGP digital signature


[O] [PATCH] Use geiser for babel scheme evaluation.

2013-01-08 Thread Michael Gauland
On 06/01/13 19:56, Bastien wrote:
 Well, I'm afraid we'll have to go the clean way: just document the
 deleted functions, the new ones, and the ones that have been
 rewritten. No need to go too much into details. Also let's rename
 `cleanse-org-babel-scheme-repl-map' to
 `org-babel-scheme-cleanse-repl-map'.

I've done the rename, un-dangled the parentheses, and prepared a changelog:


Babel: Use geiser to manage scheme sessions

* lisp/ob-scheme.el: Load the geiser library
(run-scheme): Removed
(org-babel-scheme-eoe): Removed
(org-babel-scheme-cmd): Removed
(scheme-program-name): Removed
(org-babel-scheme-repl-map): Hash mapping session names to sessions.
(org-babel-scheme-cleanse-repl-map): Remove dead sessions from map.
(org-babel-scheme-get-session-buffer): Return buffer associated with a
session.
(org-babel-scheme-set-session-buffer): Record the buffer associated with
a session.
(org-babel-scheme-get-buffer-impl): Return the scheme implementation
geiser associates with a buffer.
(org-babel-scheme-get-repl): Switch to the scheme REPL buffer for a
session, creating it if it doesn't exist.
(org-bable-scheme-make-session-name): Generate a name for a session, if
one was not specified.
(org-babel-scheme-execute-with-geiser): Execute scheme code, creating
the REPL if necessary.
(org-babel-execute-scheme): Rewritten to use geiser.
(org-babel-prep-session:scheme): Removed
(org-babel-scheme-initiate-session): Removed

This uses geiser to evaluate babel scheme source blocks, and generally
improves scheme support.

From bc33a46041086abd5d1fec321f104aa034823576 Mon Sep 17 00:00:00 2001
From: Michael Gauland mike_gaul...@stanfordalumni.org
Date: Wed, 9 Jan 2013 12:41:13 +1300
Subject: [PATCH] Use geiser for babel scheme evaluation.

---
 lisp/ob-scheme.el |  192 -
 1 files changed, 117 insertions(+), 75 deletions(-)

diff --git a/lisp/ob-scheme.el b/lisp/ob-scheme.el
index c9fa44a..31e0cad 100644
--- a/lisp/ob-scheme.el
+++ b/lisp/ob-scheme.el
@@ -2,7 +2,7 @@
 
 ;; Copyright (C) 2010-2013 Free Software Foundation, Inc.
 
-;; Author: Eric Schulte
+;; Authors: Eric Schulte, Michael Gauland
 ;; Keywords: literate programming, reproducible research, scheme
 ;; Homepage: http://orgmode.org
 
@@ -33,27 +33,16 @@
 ;; - a working scheme implementation
 ;;   (e.g. guile http://www.gnu.org/software/guile/guile.html)
 ;;
-;; - for session based evaluation cmuscheme.el is required which is
-;;   included in Emacs
+;; - for session based evaluation geiser is required, which is available from
+;;   ELPA.
 
 ;;; Code:
 (require 'ob)
-(eval-when-compile (require 'cl))
-
-(declare-function run-scheme ext:cmuscheme (cmd))
+(load-library geiser-impl)
 
 (defvar org-babel-default-header-args:scheme '()
   Default header arguments for scheme code blocks.)
 
-(defvar org-babel-scheme-eoe org-babel-scheme-eoe
-  String to indicate that evaluation has completed.)
-
-(defcustom org-babel-scheme-cmd guile
-  Name of command used to evaluate scheme blocks.
-  :group 'org-babel
-  :version 24.1
-  :type 'string)
-
 (defun org-babel-expand-body:scheme (body params)
   Expand BODY according to PARAMS, return the expanded body.
   (let ((vars (mapcar #'cdr (org-babel-get-header params :var
@@ -65,70 +54,123 @@
 )\n body ))
   body)))
 
-(defvar scheme-program-name)
+
+(defvar org-babel-scheme-repl-map (make-hash-table :test 'equal)
+  Map of scheme sessions to session names.)
+
+(defun org-babel-scheme-cleanse-repl-map ()
+  Remove dead buffers from the REPL map.
+  (maphash
+   (lambda (x y)
+ (when (not (buffer-name y))
+   (remhash x org-babel-scheme-repl-map)))
+   org-babel-scheme-repl-map))
+
+(defun org-babel-scheme-get-session-buffer (session-name)
+  Look up the scheme buffer for a session; return nil if it doesn't exist.
+  (org-babel-scheme-cleanse-repl-map) ; Prune dead sessions
+  (gethash session-name org-babel-scheme-repl-map))
+
+(defun org-babel-scheme-set-session-buffer (session-name buffer)
+  Record the scheme buffer used for a given session.
+  (puthash session-name buffer org-babel-scheme-repl-map))
+
+(defun org-babel-scheme-get-buffer-impl (buffer)
+  Returns the scheme implementation geiser associates with the buffer.
+  (with-current-buffer (set-buffer buffer)
+geiser-impl--implementation))
+
+(defun org-babel-scheme-get-repl (impl name)
+  Switch to a scheme REPL, creating it if it doesn't exist:
+  (let ((buffer (org-babel-scheme-get-session-buffer name)))
+(or buffer 
+(progn
+  (run-geiser impl)
+  (if name
+	  (progn 
+	(rename-buffer name t)
+	(org-babel-scheme-set-session-buffer name (current-buffer
+  (current-buffer)
+
+(defun org-babel-scheme-make-session-name (buffer name impl)
+  Generate a name for the session buffer.
+
+For a named session, the buffer name will be the session name.
+
+If the session is unnamed (nil), generate a name.
+
+If the session is 'none', use nil

Re: [O] [PATCH] Babel support for scheme using geiser

2013-01-05 Thread Michael Gauland
Bastien bzg at altern.org writes:
 In the meantime, please consider adding a 
 commit ChangeLog for your patch, 

Most of the file has changed dramatically--would you like the changelog to list
all the functions that have been added or altered, or would a simple statement
that the file underwent a major re-write be more appropriate?

 ...avoid dangling parentheses,

Noted. That's a bad habit I've picked up somewhere (probably too many years of C
programming.)

 and don't overwrite the first line... we are in 2013 

Also noted. Part of my brain refuses to acknowledge the new year until I'm back
at work. Regrettably, that won't be a problem after tomorrow.

Kind Regards,
Mike




[O] [PATCH] Babel support for scheme using geiser

2013-01-04 Thread Michael Gauland

Babel: User geiser for scheme interactions

* lisp/ob-scheme.el Major rewrite to support geiser

This patch uses geiser to execute scheme blocks.  Most features of babel
are tested and demonstrated in the attached org file.

Note that because :results output and :var blocks are wrapped before
being passed to scheme, (define...) will generate an error in such blocks.




From 655d0c1e870d8957974961c8bfc989a75096c60a Mon Sep 17 00:00:00 2001
From: Michael Gauland mike_gaul...@stanfordalumni.org
Date: Sat, 5 Jan 2013 08:03:19 +1300
Subject: [PATCH] Modify ob-scheme.el to use geiser.

---
 lisp/ob-scheme.el |  198 
 1 files changed, 122 insertions(+), 76 deletions(-)

diff --git a/lisp/ob-scheme.el b/lisp/ob-scheme.el
index 74e9a94..9e39c72 100644
--- a/lisp/ob-scheme.el
+++ b/lisp/ob-scheme.el
@@ -1,8 +1,8 @@
 ;;; ob-scheme.el --- org-babel functions for Scheme
 
-;; Copyright (C) 2010-2013  Free Software Foundation, Inc.
+;; Copyright (C) 2010-2012  Free Software Foundation, Inc.
 
-;; Author: Eric Schulte
+;; Authors: Eric Schulte, Michael Gauland
 ;; Keywords: literate programming, reproducible research, scheme
 ;; Homepage: http://orgmode.org
 
@@ -33,27 +33,16 @@
 ;; - a working scheme implementation
 ;;   (e.g. guile http://www.gnu.org/software/guile/guile.html)
 ;;
-;; - for session based evaluation cmuscheme.el is required which is
-;;   included in Emacs
+;; - for session based evaluation geiser is required, which is available from
+;;   ELPA.
 
 ;;; Code:
 (require 'ob)
-(eval-when-compile (require 'cl))
-
-(declare-function run-scheme ext:cmuscheme (cmd))
+(load-library geiser-impl)
 
 (defvar org-babel-default-header-args:scheme '()
   Default header arguments for scheme code blocks.)
 
-(defvar org-babel-scheme-eoe org-babel-scheme-eoe
-  String to indicate that evaluation has completed.)
-
-(defcustom org-babel-scheme-cmd guile
-  Name of command used to evaluate scheme blocks.
-  :group 'org-babel
-  :version 24.1
-  :type 'string)
-
 (defun org-babel-expand-body:scheme (body params)
   Expand BODY according to PARAMS, return the expanded body.
   (let ((vars (mapcar #'cdr (org-babel-get-header params :var
@@ -65,70 +54,127 @@
 )\n body ))
   body)))
 
-(defvar scheme-program-name)
+
+(defvar org-babel-scheme-repl-map (make-hash-table :test 'equal)
+  Map of scheme sessions to session names.)
+
+(defun cleanse-org-babel-scheme-repl-map ()
+  Remove dead buffers from the REPL map.
+  (maphash
+   (lambda (x y)
+ (when (not (buffer-name y))
+   (remhash x org-babel-scheme-repl-map)))
+   org-babel-scheme-repl-map))
+
+(defun org-babel-scheme-get-session-buffer (session-name)
+  Look up the scheme buffer for a session; return nil if it doesn't exist.
+  (cleanse-org-babel-scheme-repl-map) ; Prune dead sessions
+  (gethash session-name org-babel-scheme-repl-map))
+
+(defun org-babel-scheme-set-session-buffer (session-name buffer)
+  Record the scheme buffer used for a given session.
+  (puthash session-name buffer org-babel-scheme-repl-map))
+
+(defun org-babel-scheme-get-buffer-impl (buffer)
+  Returns the scheme implementation geiser associates with the buffer.
+  (with-current-buffer (set-buffer buffer)
+geiser-impl--implementation))
+
+(defun org-babel-scheme-get-repl (impl name)
+  Switch to a scheme REPL, creating it if it doesn't exist:
+  (let ((buffer (org-babel-scheme-get-session-buffer name)))
+(or buffer 
+(progn
+  (run-geiser impl)
+  (if name
+	  (progn 
+	(rename-buffer name t)
+	(org-babel-scheme-set-session-buffer name (current-buffer)))
+	)
+  (current-buffer)
+  
+
+(defun org-babel-scheme-make-session-name (buffer name impl)
+  Generate a name for the session buffer.
+
+For a named session, the buffer name will be the session name.
+
+If the session is unnamed (nil), generate a name.
+
+If the session is 'none', use nil for the session name, and
+org-babel-scheme-execute-with-geiser will use a temporary session.
+  (let ((result 
+	 (cond ((not name)
+		(concat buffer   (symbol-name impl)  REPL))
+	   ((string= name none) nil)
+	   (name
+result))
+
+(defun org-babel-scheme-execute-with-geiser (code output impl repl)
+  Execute code in specified REPL. If the REPL doesn't exist, create it
+using the given scheme implementation.
+
+Returns the output of executing the code if the output parameter
+is true; otherwise returns the last value.
+  (let ((result nil))
+(with-temp-buffer
+  (insert (format ;; -*- geiser-scheme-implementation: %s -*- impl))
+  (newline)
+  (insert (if output
+		  (format (with-output-to-string (lambda () %s)) code)
+		code)
+	  )
+  (geiser-mode)
+  (let ((repl-buffer (save-current-buffer (org-babel-scheme-get-repl impl repl
+	(when (not (eq impl (org-babel-scheme-get-buffer-impl (current-buffer
+	  (message Implementation mismatch: %s (%s) %s (s) impl (symbolp impl)
+		   (org-babel

Re: [O] [PATCH] Wrap: override default

2012-12-24 Thread Michael Gauland
On 24/12/12 21:43, Bastien wrote
 Well, the patch is wrong, if (cdr (assoc :wrap (nth 2 info)))
 is in the (and ...) sexp, no need to have it in the (or ...)
 sexp?

 I'll mark it as not applicable.  I let you propose another
 patch if you still need to fix an issue in this area.

 Thanks!

Good catch. I haven't been able to reproduce the original problem, so
I'm happy to abandon this patch.



signature.asc
Description: OpenPGP digital signature


[O] Error exporting empty results block

2012-12-24 Thread Michael Gauland
org-escape-code-in-region produces an 'Invalid search bound (wrong side
of point)' error when exporting a block that produces an empty wrapped
block. For example:

  #+BEGIN_SRC emacs-lisp :wrap fundamental :exports both
  (setq x nil)
  #+END_SRC

I'm exporting an empty block because I want the side effect of executing
the block. I have a large number of other blocks that produce non-empty
results, and I'm using a global :wrap setting for those.

Any suggestions on solving this would be appreciated.

Kind Regards,
Mike Gauland




signature.asc
Description: OpenPGP digital signature


Re: [O] Anyone using or working on ob-scheme?

2012-12-18 Thread Michael Gauland
On 19/12/12 13:48, Jeff Mickey wrote:
 I'm running into these problems as well. I was curious if you've had
 any time to work on this. As a general question to the org list: What
 dynamic languages similar to how scheme will interact with it's
 inferior process (python and ruby?) have decently complete org babel
 implementations that I can look at to fix parts of this? I'd like to
 get :session working. // jeff 
Thanks for asking, Jeff. I've had quite good success using geiser. I'm
still waiting to hear from the FSF about updating my assignment, but I'd
be happy to unofficially share my code with you in the meantime.

Kind Regards,
Mike Gauland




signature.asc
Description: OpenPGP digital signature


Re: [O] new latex exporter and attr_latex

2012-12-11 Thread Michael Gauland
François Allisson francois at allisson.co writes:

 
 Hi,
 
 The following example used to work for me
 
 ***
 #+ATTR_LATEX: align=lcr
 | left | center | right |
 ***
 Any change recently around attr_latex or align?
 


Yes, the syntax has changed; see 
http://thread.gmane.org/gmane.emacs.orgmode/62766

In short, you should use:
#+ATTR_LATEX: :align lcr

Kind Regards,
Mike





Re: [O] Babel give Marker does not point anywhere first run of LaTeX export; subsequent are fine

2012-12-10 Thread Michael Gauland
John Hendy jw.hendy at gmail.com writes:

 
 When I open an org file the first time and export to PDF via LaTeX, I
 get the error Marker does not point anywhere and the LaTeX export
 quits. Running it again without doing anything else succeeds, and all
 subsequent exports work fine.
 

What version of emacs are you running?  I haven't seen it on Windows 7 (NTEmacs
24), but have on Debian stable (emacs 23).

In my case, I tracked the problem down to comint.el (in the emacs lisp
directory). A function in there creates a temporary buffer ( *temp*), but
doesn't check to make sure the name is unique. Newer versions of comint.el don't
do this.

Let me know if you want further help troubleshooting this.

Kind Regards,
Mike Gauland





[O] [PATCH] Wrap: override default

2012-12-10 Thread Michael Gauland

* lisp/ob.el (org-babel-insert-result): only wrap if the :wrap value is 
non-null.

It can be convenient to specify the :wrap property at a higher level (e.g., file
or tree), rather than for each block. This patch allows you to override the
propery by specifying :wrap with no argument.

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

diff --git a/lisp/ob.el b/lisp/ob.el
index 0aba523..757bc06 100644
--- a/lisp/ob.el
+++ b/lisp/ob.el
@@ -1998,7 +1998,8 @@ code  the results are extracted in the syntax of the
source
(setq end (point-marker))
;; possibly wrap result
(cond
-((assoc :wrap (nth 2 info))
+((and (assoc :wrap (nth 2 info))
+  (cdr (assoc :wrap (nth 2 info
  (let ((name (or (cdr (assoc :wrap (nth 2 info))) RESULTS)))
(funcall wrap (concat #+BEGIN_ name) (concat #+END_ 
name
 ((member html result-params)
-- 
1.7.9






[O] [PATCH] Edit source: fix 'end' initialisation

2012-12-06 Thread Michael Gauland
I've been able to run org-edit-src-code just fine under NTEmacs
24.2.50.1 on Windows 7, but under GNU Emacs 23.2.1 on Debian, I got an
error:

Wrong type argument: integer-or-marker-p, nil

With the attached patch, I've been able to run it on both systems. The
change passes (make-marker) to (copy-marker), instead of nil.

Kind Regards,
Mike Gauland

From 9aca6bb03fe92adc7198c85699b2539bc811b414 Mon Sep 17 00:00:00 2001
From: Michael Gauland mike_gaul...@stanfordalumni.org
Date: Fri, 7 Dec 2012 10:44:09 +1300
Subject: [PATCH] Edit source: fix 'end' initialisation

* lisp/org-src.el: Create a marker to pass to copy-marker. This fixes a 'wrong
type argument' error when running org-edit-src-code (observed on Emacs 23.2.1).

The problem was that copy-marker expects a marker, and it was given nil. This
change gives it a marker that doesn't point anywhere, but still lets us set the
insertion type of the end marker.

TINYCHANGE
---
 lisp/org-src.el |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lisp/org-src.el b/lisp/org-src.el
index 97ee8c5..ab937b8 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -230,7 +230,7 @@ buffer.
 	 (beg (make-marker))
 	 ;; Move marker with inserted text for case when src block is
 	 ;; just one empty line, i.e. beg == end.
-	 (end (copy-marker nil t))
+	 (end (copy-marker (make-marker) t))
 	 (allow-write-back-p (null code))
 	 block-nindent total-nindent ovl lang lang-f single lfmt buffer msg
 	 begline markline markcol line col transmitted-variables)
-- 
1.7.2.5



signature.asc
Description: OpenPGP digital signature


[O] [new exporter] :wrap problems

2012-12-05 Thread Michael Gauland
I've run into trouble using the :wrap option with babel, with the new exporter.
Using :wrap to put the result in an EXAMPLE block works consistently, but
putting the result into a SRC block is inconsistent.  This example:

* :wrap example
  #+BEGIN_SRC ruby :results value :exports both :wrap EXAMPLE
  This string came from Ruby.
  #+END_SRC

  #+BEGIN_SRC ruby :results value :exports both :wrap SRC fundamental
  This string also came from Ruby.
  #+END_SRC

Works as I would expect with the old exporter, but the new exporter does not
process the generated SRC block. Exporting to ASCII gives me:

:wrap example
=

  ,
  | This string came from Ruby.
  `

  ,
  | This string came from Ruby.
  `

  ,
  | This string also came from Ruby.
  `

  #+BEGIN_SRC fundamental This string also came from Ruby.
  #+END_SRC fundamental

The HTML and LaTeX exporters behave similarly (ie., the old exporters work; the
new ones don't). The org files I'm using contain several such blocks, and I've
found that some will be exported corretly, and others won't, though I haven't
noticed any pattern.

Can anyone verify that this behaviour is not unique to my system (and perhaps
suggest where the problem may be?)

Kind Regards,
Mike Gauland




Re: [O] [new exporter] :wrap problems

2012-12-05 Thread Michael Gauland
Nicolas Goaziou n.goaziou at gmail.com writes:
 I only have time for a cursory look at the problem right now, but
 I notice one obvious error: :wrap src fundamental generates wrong Org
 syntax. It should be #+END_SRC not #+END_SRC fundamental.
 
 I assume that fixing it on the Babel side should make the problem go
 away.

That seems to do the trick--thanks for spotting it.

I'll submit a patch.

--Mike





[O] [PATCH] Babel: Fix the #+END_ directive from the :wrap param

2012-12-05 Thread Michael Gauland

* lisp/ob.el: Only use the :wrap argument up to the first space when creating
  the #+END_ directive.

Using an option like :wrap SRC fundamental was generating and end marker of
#+END_SRC fundamental, which caused the new exporter to fail to handle to
block properly.

TINYCHANGE
---
 lisp/ob.el |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
 mode change 100644 = 100755 lisp/ob.el

diff --git a/lisp/ob.el b/lisp/ob.el
old mode 100644
new mode 100755
index c030a7f..563233e
--- a/lisp/ob.el
+++ b/lisp/ob.el
@@ -1997,7 +1997,8 @@ code  the results are extracted in the syntax of the
source
(cond
 ((assoc :wrap (nth 2 info))
  (let ((name (or (cdr (assoc :wrap (nth 2 info))) RESULTS)))
-   (funcall wrap (concat #+BEGIN_ name) (concat #+END_ 
name
+   (funcall wrap (concat #+BEGIN_ name) 
+(concat #+END_ (car (split-string name))
 ((member html result-params)
  (funcall wrap #+BEGIN_HTML #+END_HTML))
 ((member latex result-params)
-- 
1.7.9






Re: [O] Anyone using or working on ob-scheme?

2012-11-26 Thread Michael Gauland
Thorsten Jolitz tjolitz at googlemail.com writes:
 I forgot all the details, I was an absolute starter with Elisp and I got
 stuck sometimes and received help from the org-babel creator Eric
 Schulte. Of course some language specific details caused problems, but
 the resulting code was not only a copy with some tiny changes. 
 
 Maybe you could figure out which parts of ob-scheme don't do what they
 should and then compare these parts with its counterparts in
 ob-picolisp - it might give you some ideas for alternative solutions.


That sounds like good advice. I'll start poking around, and see what I find.

Wish me luck!

Kind Regards,
Mike





Re: [O] Anyone using or working on ob-scheme?

2012-11-25 Thread Michael Gauland
Thorsten Jolitz tjolitz at googlemail.com writes:

 just as a side remark: I remember that, when trying to write
 ob-picolisp, I tried to base it on ob-scheme, since it seemed the next
 logical thing to do (its about two lisp dialects). And I was surprised
 how much had to be changed and how different the final results were.
 


Thanks for you response. Did you need to change so much because the languages
differed more than you expected, or was there another reason?  

Any tips you could provide based on your experience would be appreciated.

Kind Regards,
Mike





[O] Anyone using or working on ob-scheme?

2012-11-21 Thread Michael Gauland
I've recently started playing with guile source blocks, and haven't gotten the
results I expect. In particular, I've found that:
+ :results output only returns the first word of the output text.
+ :results value prompts me for a lisp expression, and returns
  whatever I give it.
+ :session generates the message Wrong type argument: stringp, nil
+ :session abc works the first time, but generates the message Buffer name 
  `abc' is in use when I try to evaluate the block again.

I'd like to hear from anyone who's had more success than I have, or who is
working on ob-scheme.el, before I wade into the code.

Kind Regards,
Mike





[O] Generating captions--is there a better way?

2012-11-01 Thread Michael Gauland
I use R to plot data, and like to include information about the plot in the
caption. I do this by combining two named SRC blocks--one for the image, and one
for the caption--and then put their #+RESULTS: together. The caption is the
tricky bit; I use R to print a string that starts with #+CAPTION:, shown in the
exmaple below. While this works, I've wondered if there is a more elegant way to
do this. How do others do this?

Kind Regards,
Mike Gauland

- example -

#+NAME: image
#+HEADER: :session
#+HEADER: :results graphics
#+HEADER: :exports results
#+HEADER: :file (org-babel-temp-file ./figure- .pdf)
#+BEGIN_SRC R
x - rnorm(100)
hist(x)
#+END_SRC

#+NAME: caption
#+HEADER: :session
#+HEADER: :results raw
#+HEADER: :exports results
#+BEGIN_SRC R 
print(paste(#+CAPTION: The mean value is ,
format(mean(x), digits=3),
., sep=));
#+END_SRC

#+RESULTS: caption
#+RESULTS: image





Re: [O] [ANN] Smart quotes in org-export.el

2012-10-31 Thread Michael Gauland
Nicolas Goaziou n.goaziou at gmail.com writes:

 Fixed. Thank you for testing this feature and reporting back errors.

Thanks for the fix. I've verified it works on both emacs 23 (the debian
package), and NTemacs (24).

Kind Regards,
Mike





Re: [O] [new exporter] Date format string not handled for LaTeX export

2012-10-30 Thread Michael Gauland
On 30/10/12 20:14, Nicolas Goaziou wrote:
 This is {{{time(...)}}}, not {{{date(...)}}}.

 {{{date(%c)}}} is another macro that is replaced with the #+DATE: value
 during export. Since you try to replace #+DATE: value with itself, you
 dive into an inf loop.

I think I understand what's going on now, but I'm still at a loss as to
how to get the date I want. Can I tell the exporter that the date on the
document should be derived from the current time (or the last
modification time), formatted a particular way? For example, I can use
this macro to put the current time in my document:

{{{time(%Y-%m-%d %H:%M)}}}

How can I set #+DATE to get an equivalent result?

Thanks for your help.

Kind regards,
Mike




signature.asc
Description: OpenPGP digital signature


Re: [O] [new exporter] Date format string not handled for LaTeX export

2012-10-30 Thread Michael Gauland
On 30/10/12 22:29, Nicolas Goaziou wrote:
 Doesn't

#+DATE: {{{time(%Y-%m-%d %H:%M)}}}

 get you what you expect?

That gives me an empty date string.



signature.asc
Description: OpenPGP digital signature


Re: [O] [new exporter] Date format string not handled for LaTeX export

2012-10-30 Thread Michael Gauland
Nicolas Goaziou n.goaziou at gmail.com writes:

 
 Hello,
 
 Nick Dokos nicholas.dokos at hp.com writes:
  Works for me.
 
 I also get a correct date with it, even with a minimal set-up.



Well, this is embarassing. I tackled it fresh, after a cup of coffee (for me)
and a re-start (emacs), and it's working. User error? Quantum effects? Whatever
the cause, thanks for your patience and support.

Kind regards,
Mike





Re: [O] [ANN] Smart quotes in org-export.el

2012-10-30 Thread Michael Gauland
Nicolas Goaziou n.goaziou at gmail.com writes:

 
 Hello,
 
 I've installed a smart quotes module in org-export.el (new exporter). It
 is off by default. You can turn it on globally with
 `org-export-with-smart-quotes' variable, or locally with:
 
   #+OPTIONS: ':t

I thought I'd give this a try, but when I try to export the file below (to HTML
or LaTeX), I get an error:

org-export-activate-smart-quotes: Wrong type argument: numberp, nil

If I disable the option, the export works (but without smart quotes, of course).

Regards,
Mike


--- example ---
#+OPTIONS: ':t
This is a 'test' file.

* Headline with 'quotes'
** Subheading with quotes.
   This is some 'text'.





Re: [O] [new exporter] Date format string not handled for LaTeX export

2012-10-29 Thread Michael Gauland
Nicolas Goaziou n.goaziou at gmail.com writes:
 On the other hand, you have a hard-coded macro to solve this problem:
 
   #+DATE: {{{time(%c)}}}
 
 It will work across every back-end (but you need the latest Org version,
 since I recently to fixed a bug related to it).

Thanks--that will do nicely. Unfortunately, I can't seem to get it working. When
I export to HTML, I get a blank date; when I try to export to LaTeX, the
exporter doesn't appear to do anything. After hitting ^G, the .tex file is
unchanged.

I've grabbed the latest from git
(commit 1f3a2c42c6317a4b0e97b237f079c51f0028cc90).








Re: [O] [new exporter] Date format string not handled for LaTeX export

2012-10-29 Thread Michael Gauland
Nicolas Goaziou n.goaziou at gmail.com writes:

 I just tried with a minimal init and it worked. Could you send the
 example you're trying to export?

The file is below. With a minimal init, I get the error Symbol's function
definition is void: org-macro-initialize-templates'. If I use my full .emacs
file, the exporter just seems to freeze up.

-- test.org -
#+DATE: {{{date(%c)}}}

This ia a test file.





[O] [new exporter] Date format string not handled for LaTeX export

2012-10-28 Thread Michael Gauland
When I provide a format string to the #+DATE: option, the old LaTeX exporter
correctly uses it to format the current date; the new exporter just uses the
format string for the date.

The new HTML exporter does not have this problem.





Re: [O] [new exporter]: LaTeX output from babel escapes comment delimiter

2012-10-25 Thread Michael Gauland
Thanks for trying to reproduce this. I tried again from 'emacs -Q', and couldn't
reproduce it either. I'm concluding it's due to some cruft in  my .emacs file,
and not a problem with the exporter.

--Mike





[O] Setting width of babel-generated image in LaTeX export?

2012-10-24 Thread Michael Gauland
I'm having trouble specifying the width of an image I export to LaTeX (with
either the new or old exporter). The snippet below demonstrates my problem. It
uses plantuml to generate an image file, using ATTR_LaTeX to specify the width.
When exported, the .tex file specifies the default width (.9\linewidth) for the
first image; the second image correctly specifies a width of 4cm.

Am I doing something wrong, or is this a bug?
Thanks,
Mike

* Snippet
  #+ATTR_LaTeX[width=3cm]:
  #+BEGIN_SRC plantuml :file test-output.png
  FirstState: A Really Wide State To Make The Image Wider Than The Text
  SecondState: Another Really Wide State To Make The Image Wider Than The Text
  FirstState -right- SecondState
  #+END_SRC

  #+RESULTS:
  [[file:test-output.png]]


  #+ATTR_LaTeX: width=4cm
  [[file:test-output.png]]





Re: [O] Setting width of babel-generated image in LaTeX export?

2012-10-24 Thread Michael Gauland
Thomas S. Dye tsd at tsdye.com writes:
 ...Here is how I've been generating figures for LaTeX export using the new
 exporter:

Thanks--that's just what I was looking for.




Re: [O] [new exporter] Enabling multiple exporters?

2012-10-21 Thread Michael Gauland
On 22/10/12 02:01, Nicolas Goaziou wrote:
  

 Correct. The window displaying the UI is probably too short to display
 it completely.

 I've pushed a commit in order to fix this. It is better now?

Thanks for looking into it. I am running a small screen (netbook), but
your commit doesn't seem to change anything.

If I change to a smaller font, the full menu is presented, so this is
consistent with the problem being related to window size.

---Mike





signature.asc
Description: OpenPGP digital signature


Re: [O] [new exporter] Enabling multiple exporters?

2012-10-20 Thread Michael Gauland
On 20/10/12 23:11, Nicolas Goaziou wrote:
 Probably nothing (excepted requiring 'org-export, which doesn't hurt,
 but is useless).

 Try to restart Emacs first.



Thanks for the suggestion, but that doesn't help.

I've found that the problem is really with the menu. If I press the
appropriate keys to use an exporter which isn't shown in the menu, the
export is done correctly.The exporter are all present in the variable
org-export-dispatch-menu-entries, so I suspect something is wrong with
the code to display the menu.




signature.asc
Description: OpenPGP digital signature


[O] [new exporter] Enabling multiple exporters?

2012-10-18 Thread Michael Gauland
I've just started playing with the new exporter. My .emacs files includes:

(require 'org-export)
(require 'org-e-latex)
(require 'org-e-html)
(require 'org-e-odt)
(require 'org-e-beamer)

But when I run org-export-dispatch, the only choices I get are 'Export to ODT'
and 'Publish'.

If I comment out (require 'org-e-odt) and restart emacs, org-export-dispatch
offers to 'Export to LaTeX' or 'Publish'.

I'm using the latest from git.

What am I doing wrong?

Thanks,
Mike





Re: [O] [new exporter] Enabling multiple exporters?

2012-10-18 Thread Michael Gauland
Thomas S. Dye tsd at tsdye.com writes:
 If I'm not mistaken, 'org-export is no longer required.  Could you try
 without that require to see if you get what you expect?

Thanks for the reply, Tom. Unfortunately, removing that line doesn't change the
behaviour.




Re: [O] special characters for HTML

2011-05-19 Thread Michael Gauland
michael holzer michi_holzer_news at gmx.at writes:

 ...when i'm using this in a word (e.g. l\aumlstig) this fails. if i put a 
 space
 behind \auml i get the umlaut, but obviously i don't want the space there...
 so how is this supposed to be done?

Use an empty set of braces to mark the end of the special character:

l\auml{}stig

--Mike





[O] Re: Use-cases for babel

2011-04-02 Thread Michael Gauland
Marcelo de Moraes Serpa celoserpa at gmail.com writes:

 We could also use this thread for additional ideas on how org-babel
 could be used.

I generally use org-babel with PlantUML, dot, or ditaa to generate diagrams as
part of my exported document. I find this especially useful for programming
notes, as it keeps everything in one file, but I also use it for more formal
design documents and presentations.

--Mike Gauland








[O] [PATCH] EPS support for ob-plantuml

2011-03-26 Thread Michael Gauland
EPS export from Plantuml is now in beta testing; this patch makes it available 
through org-babel.

To generate an EPS from Plantuml, give your source block a ':file' with the 
extension '.eps'.

If you want to include the EPS files in PDF generated from org-export, include 
the line

#+LaTex_header: \usepackage{epstopdf}

in your org file.

--Mike Gauland

diff --git a/lisp/ob-plantuml.el b/lisp/ob-plantuml.el
index fbebd35..b57aad6 100644
--- a/lisp/ob-plantuml.el
+++ b/lisp/ob-plantuml.el
@@ -62,6 +62,8 @@ This function is called by `org-babel-execute-src-block'.
 (expand-file-name org-plantuml-jar-path))
(if (string= (file-name-extension out-file) svg)
 -tsvg )
+   (if (string= (file-name-extension out-file) eps)
+-teps )
 -p  cmdline   
(org-babel-process-file-name in-file)
  


signature.asc
Description: Digital signature


[Orgmode] Re: SQLite in 7.01h?

2010-12-04 Thread Michael Gauland
I believe all you need to do is change 'Sqlite' to 'sqlite' (all lower case) in
the +BEGIN_SRC line.

--Mike



___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[Orgmode] Babel DOS

2010-11-16 Thread Michael Gauland
I'm having trouble executing a shell script under Microsoft Windows using
org-babel. When I evaluate this:

#+begin_src sh :results output
echo Hello
#+end_src

I get this:
#+results:
: Microsoft Windows XP [Version 5.1.2600]
: (C) Copyright 1985-2001 Microsoft Corp.
: 
: c:\home\mike\notes-hgMore? 

It looks like the shell is invoked as expeced, but the 'echo' command does not
appear to be executed.  I've used babel to execute shell script under Linux, and
have used other babel languages (ditaa, plantuml, dot) under Windows, but this
is the first time I've tried the DOS shell.

Am I doing something obviously wrong, or is it time to fire up the debugger?

Any advice would be appreciated.

Regards,
Mike


pgp3w03yybx8I.pgp
Description: PGP signature
___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[Orgmode] Re: [babel] support plantuml

2010-08-29 Thread Michael Gauland
I've run into a minor problem using this under Microsoft Windows. One of my
machines puts a space in the temporary folder path, which causes the redirection
to fail.  I've fixed it locally by applying shell-quote-argument to in-file and
out-file in org-bable-execute:plantuml.

--Mike



___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


Re: [Orgmode] Estimate ranges in column view

2010-07-20 Thread Michael Gauland
Great news, Carsten--still works correctly.

Thanks for the chance to contribute!

--Mike

___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


Re: [Orgmode] Estimate ranges in column view

2010-06-22 Thread Michael Gauland
Carsten,
Here is a patch for a new 'est+' summary type, including corresponding changes 
for xemacs and the manual. I've done basic testing on the GNU emacs version, 
but not the xemacs code.  

I'm not sure the change to the manual provides the right amount of information
in the right place; I'd be happy to re-write to make it find in
better. Similarly, the name of the summary type is entirely up to you.

I didn't know whether to send this directly to you, or to the list; if it 
should go to the list I'd be happy to send it there directly.

Thanks for the chance to contribute,
Mike
diff --git a/doc/org.texi b/doc/org.texi
index 17615e0..529be4d 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -4723,9 +4723,10 @@ optional.  The individual parts have the following 
meaning:
 @{:m...@}@r{Smallest time value in column.}
 @{:m...@}@r{Largest time value.}
 @{:m...@}   @r{Arithmetic mean of time values.}
-@{@@m...@}   @r{Minimum age (in days/hours/mins/seconds).}
-@{@@m...@}   @r{Maximum age (in days/hours/mins/seconds).}
-@{@@m...@}  @r{Arithmetic mean of ages (in 
days/hours/mins/seconds).}
+@{@@m...@}@r{Minimum age (in days/hours/mins/seconds).}
+@{@@m...@}@r{Maximum age (in days/hours/mins/seconds).}
+@{@@m...@}   @r{Arithmetic mean of ages (in 
days/hours/mins/seconds).}
+@{e...@}@r{Add low-high estimates.}
 @end example
 
 @noindent
@@ -4733,6 +4734,22 @@ Be aware that you can only have one summary type for any 
property you
 include. Subsequent columns referencing the same property will all display the
 same summary information.
 
+The 'est+' summary type requires further explanation. It is used for
+combining task estimates, expressed as low-high ranges. For example, instead
+of estimating a particular task will take 5 days, you might estimate it as
+5-6 days if you're fairly confident you know how much woark is required, or
+1-10 days if you don't really know what needs to be done.  Both ranges
+average at 5.5 days, but the first represents a more predictable delivery.
+
+When combining a set of such estimates, simply adding the lows and highs
+produces an unrealistically wide result. Instead, 'est+' adds the statistical
+mean and variance of the sub-tasks, generating a final estimate from the sum.
+For example, suppose you had ten tasks, each of which was estimated at 0.5 to
+2 days of work. Straight addition produces an estimate of 5 to 20 days,
+representing what to expect if everything goes either extremely well or
+extremely poorly. In contrast, 'est+' estimates the full job more
+realistically, at 10-15 days.
+
 Here is an example for a complete columns definition, along with allowed
 values.
 
diff --git a/lisp/org-colview-xemacs.el b/lisp/org-colview-xemacs.el
index 152d9fe..90bf4c4 100644
--- a/lisp/org-colview-xemacs.el
+++ b/lisp/org-colview-xemacs.el
@@ -917,7 +917,8 @@ around it.
 (@max max_age max (lambda (x) (- org-columns-time x)))
 (@mean mean_age
  (lambda (rest x) (/ (apply '+ x) (float (length x
- (lambda (x) (- org-columns-time x
+ (lambda (x) (- org-columns-time x)))
+(est+ estimate org-estimate-combine))
   Operator - format,function,calc  map.
  Used to compile/uncompile columns format and completing read in
  interactive function org-columns-new.
@@ -1206,6 +1207,7 @@ Don't set this, this is meant for dynamic scoping.)
 (defun org-columns-number-to-string (n fmt optional printf)
   Convert a computed column number to a string value, according to FMT.
   (cond
+   ((memq fmt '(estimate)) (org-estimate-print n printf))
((not (numberp n)) )
((memq fmt '(add_times max_times min_times mean_times))
 (let* ((h (floor n)) (m (floor (+ 0.5 (* 60 (- n h))
@@ -1250,9 +1252,9 @@ Don't set this, this is meant for dynamic scoping.)
(setq sum (+ (string-to-number (pop l)) (/ sum 60
  sum))
((memq fmt '(checkbox checkbox-n-of-m checkbox-percent))
-   (if (equal s [X]) 1. 0.01))
-   (t (string-to-number s)))
-0))
+(if (equal s [X]) 1. 0.01))
+   ((memq fmt '(estimate)) (org-string-to-estimate s))
+   (t (string-to-number s)
 
 (defun org-columns-uncompile-format (cfmt)
   Turn the compiled columns format back into a string representation.
@@ -1693,6 +1695,42 @@ This will add overlays to the date lines, to show the 
summary for each day.
   (format %dd %02dh %02dm %02ds days hours minutes seconds))
 ))
 
+(defun org-estimate-mean-and-var (v)
+  Return the mean and variance of an estimate.
+  (let* ((low (float (car v)))
+ (high (float (cadr v)))
+ (mean (/ (+ low high) 2.0))
+ (var (/ (+ (expt (- mean low) 2.0) (expt (- high mean) 2.0)) 2.0)))
+(list  mean var)
+))
+
+(defun org-estimate-combine (rest el)
+  Combine a list of estimates, using mean and variance.

Re: [Orgmode] Tables in ASCII export

2010-02-19 Thread Michael Gauland
carsten.dominik this behavior is now the default, controlled by the new user 
option
carsten.dominik `org-export-ascii-table-widen-columns'.

Thanks. That's a start, but what I really want is to have long cells folded, so
that one table row might become several lines in the ASCII export. For example,
if my table looks like this in org:

| / | 10R | 20 |
|   | 1 | The quick brown fo= |
|   | 2 | Now is the time for  |


I want my ASCII export to look like this:

  1   The quick brown fox
  jumped over the lazy
  dogs.
  2   Now is the time for
  all good me to come
  to the aid of the
  party.

I've started looking at org-table-align to get a feel for how org deals with
tables, but I'm still trying to puzzle out where this folding should be done. 
Any advice on that?

Thanks,
Mike


___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[Orgmode] org-babel-sh and Microsoft Windows

2010-02-07 Thread Michael Gauland
I tried using org-babel-sh at work, where I run emacs under Microsoft Windows,
but only received an oddly-formatted message about (quote sh) not being
recognised as a command. After mucking around with org-babel-sh.el, I modified
the call to shell-command-on-region, changing the hard-coded sh to (as I
recall) cmd /k). This looks promising, but I wonder if there are any other
changes I'll need to make. Also, would it be better to adapt org-babel-sh to
handle Microsoft's shell, or to implement a new org-babel language?

Thanks for your advice,
Mike


___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[Orgmode] Tables in ASCII export

2010-02-07 Thread Michael Gauland
When I export tables to ASCII, I'd like the rows to expand as necessary so the
full contents is visible. I've has a look at org-exp.el, but I'm at a bit of a
loss as to where to start mucking in. Any pointers would be greatly appreciated!

Thanks,
Mike


___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


Re: [Orgmode] org-babel-sh and Microsoft Windows

2010-02-07 Thread Michael Gauland
Thanks! I'll give that a go!


___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode