emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Feature-Request/Question: how to apply a calc/elisp function to a column in org-column-view
@ 2008-10-09  1:57 Eric Schulte
  2008-10-09  5:35 ` Carsten Dominik
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Schulte @ 2008-10-09  1:57 UTC (permalink / raw)
  To: Org-mode

Hi,

In columnview, I'm looking to be able to apply a calc/elisp function to
a columns values before the column view is generated.  This is
specifically for columnviews captured in tables.

  (see info:org:Capturing column view)

This has come up before, and Carsten was nice enough to make it possible
to recalculate the column view automatically using an existing #+TBLFM
line inside the columnview dynamic block.

However, I would like to *replace* a column's value with a calculated
result.  This is because I am sometimes storing very *large* lists as
properties (large enough that Emacs chokes when trying to manage tables
with such large cells), and then trying to use columnview to generate
tables of calculated properties of these lists.

I realize that this is both an edge-case and a bastardization of the
intended use of columnview, and I would be happy to put the required
effort into implementing such a feature, but I have become tangled in
the columnview code, and don't know where I should look to insert this
functionality.

I was thinking this should be part of either
`org-dblock-write:columnview', or `org-columns', and then I noticed
`org-columns-compute-all' which seemed promising but upon inspection was
somewhat opaque.

Could anyone familiar with org-colview.el point me in the right
direction?

Should I just abandon the use of columnview for this task, and instead
write an independent function which sucks in the properties and spits
out the table?

Many Thanks -- Eric

As a "simple" example see below, I'd like to be able to generate the
given table using the given #+COLUMNS line (or something like it)

* example

#+COLUMNS:  %ITEM %d %f %=f+d
#+BEGIN: columnview :id "results"
| ITEM        |  d | f | f+d |
|-------------+----+---+-----|
| *** Results |    |   |     |
| **** run1   | 33 | 2 |  35 |
| **** run2   | 34 | 2 |  36 |
| **** run3   | 35 | 2 |  37 |
| **** run4   | 36 | 2 |  38 |
#+END:


** Results
   :PROPERTIES:
   :ID:       results
   :END:

*** run1
   :PROPERTIES:
   :d: 33
   :f: 2
   :END:

*** run2
   :PROPERTIES:
   :d: 34
   :f: 2
   :END:

*** run3
   :PROPERTIES:
   :d: 35
   :f: 2
   :END:

*** run4
   :PROPERTIES:
   :d: 36
   :f: 2
   :END:

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Feature-Request/Question: how to apply a calc/elisp function to a column in org-column-view
  2008-10-09  1:57 Feature-Request/Question: how to apply a calc/elisp function to a column in org-column-view Eric Schulte
@ 2008-10-09  5:35 ` Carsten Dominik
  0 siblings, 0 replies; 2+ messages in thread
From: Carsten Dominik @ 2008-10-09  5:35 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Org-mode

Hi Eric,

one conceivable way out would be this:

First you do create a column view that does contain all the columns  
that you need, and then you use TBLFM to create additional columns  
with the desired results.  That will leave you with a table with all  
the values you need, but with a few columns too many, right?  You  
could then use the orgtbl send/receive mechanism to send this table to  
a different location in the same buffer.  On the way you can skip the  
columns you do not want, this is the :skip parameter to the orgtbl-to- 
generic translator function.  If that is not enough, you could write  
your own translator function which does do more complex operations.

Clearly a hack, and maybe you need to ask yourself if you want to do  
this kind of complex operations in Org-mode, or maybe if you are  
better off to use an external, full spreasheet program for this.

A completely independent way would be to implement a separate function  
that updates property values according to your formulas, so you could  
create additional properties this way, *before* you cal column view to  
extract the table.  Such a function would be easy to write if the  
formulas only connect values within a single entries, i.e. if they do  
not depend on children or parent values.  Such a function would be easy:

- Walk the outline tree
- At each stop check if you want to do a calculation, for example only  
do it
   if all properties that you need already exist.
- if yes, use org-entry-get to get the property values
- Do your calculation and put the result back into a new property.

For large outlines/tables, this is definitely going to be slow.  Org  
and column view are not optimized for large datasets.

HTH, for now.

- Carsten

On Oct 9, 2008, at 3:57 AM, Eric Schulte wrote:

> Hi,
>
> In columnview, I'm looking to be able to apply a calc/elisp function  
> to
> a columns values before the column view is generated.  This is
> specifically for columnviews captured in tables.
>
>  (see info:org:Capturing column view)
>
> This has come up before, and Carsten was nice enough to make it  
> possible
> to recalculate the column view automatically using an existing #+TBLFM
> line inside the columnview dynamic block.
>
> However, I would like to *replace* a column's value with a calculated
> result.  This is because I am sometimes storing very *large* lists as
> properties (large enough that Emacs chokes when trying to manage  
> tables
> with such large cells), and then trying to use columnview to generate
> tables of calculated properties of these lists.
>
> I realize that this is both an edge-case and a bastardization of the
> intended use of columnview, and I would be happy to put the required
> effort into implementing such a feature, but I have become tangled in
> the columnview code, and don't know where I should look to insert this
> functionality.
>
> I was thinking this should be part of either
> `org-dblock-write:columnview', or `org-columns', and then I noticed
> `org-columns-compute-all' which seemed promising but upon inspection  
> was
> somewhat opaque.
>
> Could anyone familiar with org-colview.el point me in the right
> direction?
>
> Should I just abandon the use of columnview for this task, and instead
> write an independent function which sucks in the properties and spits
> out the table?
>
> Many Thanks -- Eric
>
> As a "simple" example see below, I'd like to be able to generate the
> given table using the given #+COLUMNS line (or something like it)
>
> * example
>
> #+COLUMNS:  %ITEM %d %f %=f+d
> #+BEGIN: columnview :id "results"
> | ITEM        |  d | f | f+d |
> |-------------+----+---+-----|
> | *** Results |    |   |     |
> | **** run1   | 33 | 2 |  35 |
> | **** run2   | 34 | 2 |  36 |
> | **** run3   | 35 | 2 |  37 |
> | **** run4   | 36 | 2 |  38 |
> #+END:
>
>
> ** Results
>   :PROPERTIES:
>   :ID:       results
>   :END:
>
> *** run1
>   :PROPERTIES:
>   :d: 33
>   :f: 2
>   :END:
>
> *** run2
>   :PROPERTIES:
>   :d: 34
>   :f: 2
>   :END:
>
> *** run3
>   :PROPERTIES:
>   :d: 35
>   :f: 2
>   :END:
>
> *** run4
>   :PROPERTIES:
>   :d: 36
>   :f: 2
>   :END:
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-10-09  5:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-09  1:57 Feature-Request/Question: how to apply a calc/elisp function to a column in org-column-view Eric Schulte
2008-10-09  5:35 ` Carsten Dominik

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).