From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: emacs-orgmode@gnu.org
Subject: Re: Computations on properties
Date: Thu, 10 Oct 2013 06:52:00 +0200 [thread overview]
Message-ID: <87mwmhramn.fsf@ericabrahamsen.net> (raw)
In-Reply-To: 87eh7ub8wd.fsf@gmail.com
Eric Schulte <schulte.eric@gmail.com> writes:
> Thorsten Jolitz <tjolitz@gmail.com> writes:
>
>> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>>
>>> Thierry Pellé <thierry.pelle@soliavos.fr> writes:
>>>
>>>> Hi,
>>>> I'm seeking how to do something like that
>>>>
>>>> Let the following text inserted in an org-mode file
>>>>
>>>> * Mean Calculation
>>>> :PROPERTIES:
>>>> :VAL1: 5
>>>> :VAL2: 10
>>>> :COEF: 10
>>>> :END:
>>>>
>>>> I would like to append the result of a computation
>>>> like RES=(VAL1*COEF+VAL2)/(COEF+1)
>>>>
>>>> Something like
>>>> * Mean Calculation
>>>> ...
>>>> :END:
>>>>
>>>> Mean Calculation=RES (where RES is the value of the result)
>>>>
>>>> I think to do this with a python script but is there a more org-mode/emacs
>>>> method to do it?
>>>
>>> Sometimes I think it would be nice to have a way to draw property values
>>> directly into a babel block, the way you can with table data. Sort of
>>> like:
>>>
>>> * Heading
>>> :PROPERTIES:
>>> :ID: 3f78f08a-ccca-4fc0-aba9-2a192f7a0e5a
>>> :foo: 5
>>> :bar: puppy
>>> :END:
>>>
>>> #+BEGIN_SRC emacs-lisp :var alist=3f78f08a-ccca-4fc0-aba9-2a192f7a0e5a
>>>
>>> And in the block, the "alist" variable would look like '(:foo 5 :bar
>>> "puppy").
>>>
>>> What would be even better would be to run a tags search on matching
>>> headlines and feed all property drawers into a single block, as a list
>>> of alists. Just thinking out loud...
>>
>> This is probably not really what you want, but at least somehow related. I
>> would not know how to do this via source-block arguments, but maybe you can
>> use the results of one source-block (that produces the data) as input for
>> another source-block that does the real work.
>>
>> * Heading 1 :match:
>> :PROPERTIES:
>> :ID: 3f78f08a-ccca-4fc0-aba9-2a192f7a0e5a
>> :foo: 5
>> :bar: puppy
>> :END:
>>
>> * Heading 2
>> :PROPERTIES:
>> :ID: 3f78f08a-ccca-4fc0-aba9-2a192f7a0e5b
>> :foo: 6
>> :bar: yuppy
>> :END:
>>
>>
>> * Heading 3 :match:
>> :PROPERTIES:
>> :ID: 3f78f08a-ccca-4fc0-aba9-2a192f7a0e5c
>> :foo: 7
>> :bar: hippie
>> :END:
>>
>>
>> #+begin_src emacs-lisp :results raw
>> (let ((lst))
>> (org-map-entries
>> (lambda () (cons (org-entry-properties) lst))
>> "match" 'file))
>> #+end_src
>>
>> #+results:
>> ((((FILE . /home/tj/News/drafts/drafts/419) (TAGS . :match:) (ALLTAGS
>> . :match:) (BLOCKED . ) (ID . 3f78f08a-ccca-4fc0-aba9-2a192f7a0e5a) (foo . 5)
>> (bar . puppy) (CATEGORY . 419))) (((FILE . /home/tj/News/drafts/drafts/419)
>> (TAGS . :match:) (ALLTAGS . :match:) (BLOCKED . ) (ID .
>> 3f78f08a-ccca-4fc0-aba9-2a192f7a0e5c) (foo . 7) (bar . hippie) (CATEGORY .
>> 419))))
>
> Or maybe something like the following...
>
> * Mean Calculation
> :PROPERTIES:
> :VAL1: 5
> :VAL2: 10
> :COEF: 10
> :END:
>
> #+begin_src python :var props=(mapcar (lambda (p) (list (car p) (cdr p))) (org-entry-properties))
> return props
> #+end_src
This is very cool! Thanks.
> #+RESULTS:
> | FILE | /tmp/property-computation.org |
> | BLOCKED | |
> | VAL1 | 5 |
> | VAL2 | 10 |
> | COEF | 10 |
> | CATEGORY | property-computation |
next prev parent reply other threads:[~2013-10-10 4:51 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-09 12:19 Computations on properties Thierry Pellé
2013-10-09 12:50 ` Thorsten Jolitz
2013-10-09 13:32 ` Thierry Pellé
2013-10-09 15:29 ` Eric Abrahamsen
2013-10-09 17:12 ` Thorsten Jolitz
2013-10-09 18:21 ` Eric Abrahamsen
2013-10-09 18:23 ` Eric Schulte
2013-10-10 4:52 ` Eric Abrahamsen [this message]
2013-10-09 19:27 ` Michael Brand
2013-10-10 6:39 ` Thierry Pellé
2013-10-10 9:04 ` Michael Brand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87mwmhramn.fsf@ericabrahamsen.net \
--to=eric@ericabrahamsen.net \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.