emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* value of properties
@ 2010-11-07  9:05 Alin Soare
  2010-11-09 22:00 ` Alin Soare
  0 siblings, 1 reply; 5+ messages in thread
From: Alin Soare @ 2010-11-07  9:05 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 795 bytes --]

Hi,

I have been using org mode for a few days and I am impressed.

I have followed a few tutorials and videos, however I want to solve a
problem and I did not find how can I do it.

I have 2 tables , and every such table has a variable $sum, that is the sum
of a column. Because I am lisp engineer, I used the formula '(+ @I..@II);N
to compute it, I prefer lisp to calc.

My problems are

1: to export the value of the $sum from one table, and make global
computations using it
2: to compute the value of some property in function of such variables,
defined inside tables.

Afterwards, can I compute the value of a property in function of the value
of other properties ?

Probably my question is stupid, I do not know, because I did not understand
yet the principles of properties of org mode.

[-- Attachment #1.2: Type: text/html, Size: 864 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
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

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

* Re: value of properties
  2010-11-07  9:05 value of properties Alin Soare
@ 2010-11-09 22:00 ` Alin Soare
  2010-11-10 12:15   ` Christian Moe
  2010-11-11 13:10   ` Christian Moe
  0 siblings, 2 replies; 5+ messages in thread
From: Alin Soare @ 2010-11-09 22:00 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 2324 bytes --]

Hi again,

I write you again, perhaps this time somebody can help me solve the problem.

Suppose I have a list like this


* TODO vêtements [0/0]                               :total:
  :PROPERTIES:
  :total:     0
  :END:

  - pour week end
   - [ ] X    30
   - [X] Y    80
   - [ ] Z    100
   - [ ] W   20
  - pour les loisirs
   - [X] X   30
   - [ ] Y  80
   - [ ] Z   10
  - pour la maison:
   - [ ] pantoufle 25

I want to add all values of the fields that are crossed and keep the sum
into the value of the property 'total'. Is it possible to do it using org
mode ? I looked over many documents, but not found.

Other problem, suppose I have this table inside the same file.


    |   | quoi  |    prix |
    |---+-------+---------|
    |   | X     |     500 |
    |   | Y     |     700 |
    |   | Z     |     100 |
    |   | W     |     100 |
    |   | T     |     100 |
    |---+-------+---------|
    | # | Total |    1500 |
    | ^ |       | montant |
  #+TBLFM: $montant='(+ @I..@II);N

I wish to sum the value of the variable $montant with the value of the
property 'total' from the other part (from the list), and use the result in
other computations.

Are these things possible using org mode ?

I looked today over some examples of babel language, but I did not find what
I need.



Thanks in advance for any help.


Alin Soare.




2010/11/7 Alin Soare <as1789@gmail.com>

> Hi,
>
> I have been using org mode for a few days and I am impressed.
>
> I have followed a few tutorials and videos, however I want to solve a
> problem and I did not find how can I do it.
>
> I have 2 tables , and every such table has a variable $sum, that is the sum
> of a column. Because I am lisp engineer, I used the formula '(+ @I..@II);N
> to compute it, I prefer lisp to calc.
>
> My problems are
>
> 1: to export the value of the $sum from one table, and make global
> computations using it
> 2: to compute the value of some property in function of such variables,
> defined inside tables.
>
> Afterwards, can I compute the value of a property in function of the value
> of other properties ?
>
> Probably my question is stupid, I do not know, because I did not understand
> yet the principles of properties of org mode.
>
>
>

[-- Attachment #1.2: Type: text/html, Size: 2879 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
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

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

* Re: Re: value of properties
  2010-11-09 22:00 ` Alin Soare
@ 2010-11-10 12:15   ` Christian Moe
  2010-11-11 13:10   ` Christian Moe
  1 sibling, 0 replies; 5+ messages in thread
From: Christian Moe @ 2010-11-10 12:15 UTC (permalink / raw)
  To: Alin Soare; +Cc: emacs-orgmode

On 11/9/10 11:00 PM, Alin Soare wrote:
>
> Hi again,
>
> I write you again, perhaps this time somebody can help me solve the
> problem.

I'll take a shot at this,  but others may have better solutions to 
your first problem.

>
> Suppose I have a list like this
>
>
> * TODO vêtements [0/0]                               :total:
>    :PROPERTIES:
>    :total:     0
>    :END:
>
>    - pour week end
>     - [ ] X    30
>     - [X] Y    80
>     - [ ] Z    100
>     - [ ] W   20
>    - pour les loisirs
>     - [X] X   30
>     - [ ] Y  80
>     - [ ] Z   10
>    - pour la maison:
>     - [ ] pantoufle 25
>
> I want to add all values of the fields that are crossed and keep the
> sum into the value of the property 'total'. Is it possible to do it
> using org mode ? I looked over many documents, but not found.

I think the short answer is no -- Org mode does not know to extract 
numbers from list items. By far the easiest way to get calculations 
like this done is to put the data in a table.

Otherwise you'd need to write your own function for it. You could use 
Org functions to advance from one list item to another, and 
org-entry-put to put the result in the :total: property, but the rest 
I think you'd have to do from scratch. I'm not going to do that.

Now, if your list looked like this instead (admittedly an unnatural 
way to do it):

* TODO vêtements
   :PROPERTIES:
   :total:    110
   :END:

** pour week end [1/4]
*** TODO 30			        :X:
*** DONE 80				:Y:
*** TODO 100				:Z:
*** TODO 20				:W:
** pour les loisirs [1/3]
*** DONE 30				:X:
*** TODO 80				:Y:
*** TODO 10				:Z:
** pour la maison [0/1]
*** TODO 25				:pantoufle:

... you could draw on Org functionality to e.g. write a function like 
this:

   (defun my-org-get-total-done ()
     "Sets the `total' property of the heading at point to the sum of 
the figures in the subheadings marked DONE. Warning: The text of each 
heading must be a number."
     (interactive)
     (let (entries total)
       (setq entries
             (org-map-entries '(string-to-number (nth 4 
(org-heading-components)))
                              "/+DONE"
                              'tree))
       (setq total
             (format "%s" (reduce '+ entries)))
       (org-entry-put nil "total" total)))

You'd want to improve on it, by
- adding error handling (what if there's a heading that does not 
contain just a number?);
- giving the user a choice of keywords to match -- e.g., sometimes you 
might want a total only for the `X' garments, so you'd want to pass 
`X/+DONE' to org-map-entries;
- making updates automatic not manual (using 
org-checkbox-statistics-hook?)

> Other problem, suppose I have this table inside the same file.
>
>
 >
>      |   | quoi  |    prix |
>      |---+-------+---------|
>      |   | X     |     500 |
>      |   | Y     |     700 |
>      |   | Z     |     100 |
>      |   | W     |     100 |
>      |   | T     |     100 |
>      |---+-------+---------|
>      | # | Total |    1500 |
>      | ^ |       | montant |
>    #+TBLFM: $montant='(+ @I..@II);N
>
> I wish to sum the value of the variable $montant with the value of the
> property 'total' from the other part (from the list), and use the
> result in other computations.

This is comparatively easy...

Give the table a TBLNAME, e.g. `prices':
#+TBLNAME: prices
|   | quoi  |    prix |
|---+-------+---------|
|   | X     |     500 |
...etc.

Then you can use the ordinary remote reference syntax, see 
info:org:References.

Give the entry an ID property, e.g. `clothes':
* TODO vêtements
   :ID: clothes
   :total: 110
   :END:

You'll need some Lisp to reference it, see formula below.

| What                    | How much |
|-------------------------+----------|
| Total from last table   |     1500 |
| Value of total property |      110 |
|-------------------------+----------|
| Sum                     |     1610 |
#+TBLFM: @2$2=remote(prices, $montant)::@3$2='(org-entry-get 
(org-find-entry-with-id "clothes") "total")::@4$2=vsum(@I..@II)


Yours,
Christian

> Are these things possible using org mode ?

> I looked today over some examples of babel language, but I did not
> find what I need.
>
>
>
> Thanks in advance for any help.
>
>
> Alin Soare.
>
>
>
>
> 2010/11/7 Alin Soare <as1789@gmail.com <mailto:as1789@gmail.com>>
>
>     Hi,
>
>     I have been using org mode for a few days and I am impressed.
>
>     I have followed a few tutorials and videos, however I want to
>     solve a problem and I did not find how can I do it.
>
>     I have 2 tables , and every such table has a variable $sum, that
>     is the sum of a column. Because I am lisp engineer, I used the
>     formula '(+ @I..@II);N to compute it, I prefer lisp to calc.
>
>     My problems are
>
>     1: to export the value of the $sum from one table, and make global
>     computations using it
>     2: to compute the value of some property in function of such
>     variables, defined inside tables.
>
>     Afterwards, can I compute the value of a property in function of
>     the value of other properties ?
>
>     Probably my question is stupid, I do not know, because I did not
>     understand yet the principles of properties of org mode.
>
>
>
>
>
> _______________________________________________
> 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


-- 

Christian Moe
E-mail:  mail@christianmoe.com
Website: http://christianmoe.com

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

* Re: Re: value of properties
  2010-11-09 22:00 ` Alin Soare
  2010-11-10 12:15   ` Christian Moe
@ 2010-11-11 13:10   ` Christian Moe
  2010-11-11 13:20     ` Alin Soare
  1 sibling, 1 reply; 5+ messages in thread
From: Christian Moe @ 2010-11-11 13:10 UTC (permalink / raw)
  To: Alin Soare; +Cc: emacs-orgmode

Hi again,

On second thought, I think you want to forget the solution I posted 
earlier today to your first problem. The sensible Org way to do it 
would be:

- using headings with TODOs, not list items with checkboxes (as in my 
earlier example)
- putting the numbers in a property, not the heading text,
- defining a column view,
- capturing the column view as a table in a dynamic block,
and
- adding a formula to that table that will extract and sum only the 
DONE items.

I may post a full example later.

Yours,
Christian

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

* Re: Re: value of properties
  2010-11-11 13:10   ` Christian Moe
@ 2010-11-11 13:20     ` Alin Soare
  0 siblings, 0 replies; 5+ messages in thread
From: Alin Soare @ 2010-11-11 13:20 UTC (permalink / raw)
  To: mail; +Cc: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 998 bytes --]

> On second thought, I think you want to forget the solution I posted earlier
> today to your first problem. The sensible Org way to do it would be:
>
> - using headings with TODOs, not list items with checkboxes (as in my
> earlier example)
> - putting the numbers in a property, not the heading text,
> - defining a column view,
> - capturing the column view as a table in a dynamic block,
> and
> - adding a formula to that table that will extract and sum only the DONE
> items.
>
>

Thanks again :)

No, it's enough; from your first post I did understand the principles of
solving my problem :).

The idea is to get the informations from the org-table(speedsheets),
org-list, and other org data  into an emacs-lisp list, and afterwards I can
play with the captured data :).

I am investigating now the org functions that capture and that set
properties.

I will post a code  after I write the functions that make what I want to do,
and for now I am deepen the capabilities of org mode.


Alin.

[-- Attachment #1.2: Type: text/html, Size: 1301 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
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

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

end of thread, other threads:[~2010-11-11 13:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-07  9:05 value of properties Alin Soare
2010-11-09 22:00 ` Alin Soare
2010-11-10 12:15   ` Christian Moe
2010-11-11 13:10   ` Christian Moe
2010-11-11 13:20     ` Alin Soare

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).