* How to calculate sum of property in tree?
@ 2016-04-23 9:22 Rainer Hansen
2016-04-24 9:11 ` Rainer Hansen
0 siblings, 1 reply; 2+ messages in thread
From: Rainer Hansen @ 2016-04-23 9:22 UTC (permalink / raw)
To: emacs-orgmode
Hi,
I would like Emacs to calculate the price for the travel cost
(21.90). This should be calculated as sum of the values of the property
"Price" in the elements of the tree. How do I do that in Emacs Lisp?
----------------------------------------------
* Travel cost -- 21.90 EUR
** Train Eusirchen -- Bonn, src_emacs-lisp{(org-entry-get (point) "Price")} EUR
:PROPERTIES:
:Price: 7.70
:END:
** Bus Euskirchen -- Stotzheim, src_emacs-lisp{(org-entry-get (point) "Price")} EUR
:PROPERTIES:
:Price: 2.40
:END:
** Taxi Bonn, src_emacs-lisp{(org-entry-get (point) "Price")} EUR
:PROPERTIES:
:Price: 11.80
:END:
----------------------------------------------
Thanks!
Rainer
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: How to calculate sum of property in tree?
2016-04-23 9:22 How to calculate sum of property in tree? Rainer Hansen
@ 2016-04-24 9:11 ` Rainer Hansen
0 siblings, 0 replies; 2+ messages in thread
From: Rainer Hansen @ 2016-04-24 9:11 UTC (permalink / raw)
To: emacs-orgmode
> Hi,
>
> I would like Emacs to calculate the price for the travel cost
> (21.90). This should be calculated as sum of the values of the property
> "Price" in the elements of the tree. How do I do that in Emacs Lisp?
I found one way to do it. I defined the COLUMNS property with %Price{+},
i.e. sum numbers in column 'Price and format result with `%.2f'
(always two decimals after point). After that I added the property
'Price' and, while cursor on 'Price', with `C-c C-c (`org-property-action')' and choosing option c
(compute) the value of 'Price' got calculated.
I added the same inline Emacs Lisp expression to the headline to include
the result (21.90) in the headline.
-------8<----------------8<-------------
* Travel cost -- src_emacs-lisp{(org-entry-get (point) "Price")} EUR
:PROPERTIES:
:COLUMNS: %Price{+;%.2f}
:Price: 21.90
:END:
** Train Eusirchen -- Bonn, src_emacs-lisp{(org-entry-get (point) "Price")} EUR
:PROPERTIES:
:Price: 7.70
:END:
** Bus Euskirchen -- Stotzheim, src_emacs-lisp{(org-entry-get (point) "Price")} EUR
:PROPERTIES:
:Price: 2.40
:END:
** Taxi Bonn, src_emacs-lisp{(org-entry-get (point) "Price")} EUR
:PROPERTIES:
:Price: 11.80
:END:
-------8<----------------8<-------------
Any ideas on how to improve that solution?
Rainer Hansen <rainer.hansen@gmx.net> writes:
>
> ----------------------------------------------
> * Travel cost -- 21.90 EUR
>
> ** Train Eusirchen -- Bonn, src_emacs-lisp{(org-entry-get (point) "Price")} EUR
> :PROPERTIES:
> :Price: 7.70
> :END:
> ** Bus Euskirchen -- Stotzheim, src_emacs-lisp{(org-entry-get (point) "Price")} EUR
> :PROPERTIES:
> :Price: 2.40
> :END:
>
> ** Taxi Bonn, src_emacs-lisp{(org-entry-get (point) "Price")} EUR
> :PROPERTIES:
> :Price: 11.80
> :END:
> ----------------------------------------------
>
> Thanks!
>
> Rainer
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-04-24 9:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-23 9:22 How to calculate sum of property in tree? Rainer Hansen
2016-04-24 9:11 ` Rainer Hansen
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).