From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: Computations on properties Date: Wed, 09 Oct 2013 12:23:46 -0600 Message-ID: <87eh7ub8wd.fsf@gmail.com> References: <87k3hmsbsw.fsf@ericabrahamsen.net> <87bo2ymkq6.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48155) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTyQV-0002Hx-7k for emacs-orgmode@gnu.org; Wed, 09 Oct 2013 14:24:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VTyQQ-0007HS-Q4 for emacs-orgmode@gnu.org; Wed, 09 Oct 2013 14:24:03 -0400 Received: from mail-pd0-x22c.google.com ([2607:f8b0:400e:c02::22c]:39452) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTyQQ-0007HB-Fa for emacs-orgmode@gnu.org; Wed, 09 Oct 2013 14:23:58 -0400 Received: by mail-pd0-f172.google.com with SMTP id z10so1341908pdj.3 for ; Wed, 09 Oct 2013 11:23:57 -0700 (PDT) In-Reply-To: <87bo2ymkq6.fsf@gmail.com> (Thorsten Jolitz's message of "Wed, 09 Oct 2013 19:12:49 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Thorsten Jolitz Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Thorsten Jolitz writes: > Eric Abrahamsen writes: > >> Thierry Pell=C3=A9 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=20 >>> like RES=3D(VAL1*COEF+VAL2)/(COEF+1)=20 >>> >>> Something like=20 >>> * Mean Calculation >>> ... >>> :END: >>> >>> Mean Calculation=3DRES (where RES is the value of the result) >>> >>> I think to do this with a python script but is there a more org-mode/em= acs >>> 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=3D3f78f08a-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 c= an > use the results of one source-block (that produces the data) as input for > another source-block that does the real work.=20 > > * 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/41= 9) > (TAGS . :match:) (ALLTAGS . :match:) (BLOCKED . ) (ID . > 3f78f08a-ccca-4fc0-aba9-2a192f7a0e5c) (foo . 7) (bar . hippie) (CATEGORY . > 419)))) Or maybe something like the following... --=-=-= Content-Type: text/x-org Content-Disposition: inline; filename=property-computation.org * 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 #+RESULTS: | FILE | /tmp/property-computation.org | | BLOCKED | | | VAL1 | 5 | | VAL2 | 10 | | COEF | 10 | | CATEGORY | property-computation | --=-=-= Content-Type: text/plain -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D --=-=-=--