emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to document/comment a complex org table formula


From: Uwe Brauer
Subject: Re: how to document/comment a complex org table formula
Date: Mon, 05 Jul 2021 19:08:20 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

>>> "TV" == Tim Visher <tim.visher@gmail.com> writes:

> On Mon, Jul 5, 2021 at 10:14 AM Eric S Fraga <e.fraga@ucl.ac.uk> wrote:
>> Sorry; I cannot help you directly.
>> 
>> My rule of thumb is that if formulas are getting too complex to
>> understand/recall clearly, it's time to use a proper programming
>> language instead.  The nice thing about org is you can have tables as
>> inputs to and outputs of src blocks...
>> 
>> My papers often have awk source blocks that process tables to generate
>> statistics for some (numerical) experiments.
>> 
>> Spreadsheets, org tables being an example of such, are brilliant tools
>> for simple calculations but are pretty much "write only programming
>> languages".
>> 

> I had never heard of using an org table as input into a source block.
> That's really interesting.

> The OP also poses an interesting idea that I have occasionally wanted. I
> have generally accomplished this by simply including the documentation
> above or below the table. In other words just having human text around it
> that says 'This =formula= bit is because of X'.

> But the idea of a multiline TBLFM syntax seems to be already be almost
> supported. I was mildly shocked to find that this mostly works

> ```
> |---+---|
> | a | 1 |
> | b | 3 |
> |---+---|
> |   | 4 |

> #+TBLFM: @2$2=@-1*3
> #+TBLFM: @3$2=vsum(@I..II)

> ```

> Note that I don't need the usual `::` separation between formulas. Where it
> breaks down is that I can't seem to reevaluate the whole table's formula by
> whacking `C-u C-c C-c` anymore 

You have to put the cursor on the beginning of each #+TBLFM
and hit C-u C-c C-c

> and, obviously, there's no syntax for adding
> comments. Also I doubt that I'd be able to use any of org's keys for
> editing formulas. I wonder how hard it would be to extend org's
> understanding of the TBLFM to allow for this kind of syntax.

Well the following  works!

#+begin_src elisp
|----+----+----+---+---+----|
|  1 |  4 |  5 | 3 | 3 |  6 |
|  3 | 12 | 15 | 9 | 2 | 11 |
| 12 |  2 | 14 | 7 | 3 | 10 |
#+TBLFM: $3=vsum($1..$2);f1:: #one comment
#+TBLFM: $6=vsum($4..$5);f1:: #second comment
#+end_src


> Once you had it then adding a comment character to it should be very simple.

I hoped to add comments to the formula editor, but that most likely
requires text-properties or overlays or something of that sort.

Regards

Attachment: smime.p7s
Description: S/MIME cryptographic signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]