From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Abrahamsen Subject: Re: Computations on properties Date: Wed, 09 Oct 2013 20:21:04 +0200 Message-ID: <877gdms3u7.fsf@ericabrahamsen.net> References: <87k3hmsbsw.fsf@ericabrahamsen.net> <87bo2ymkq6.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47437) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTyMp-0000UX-Dd for emacs-orgmode@gnu.org; Wed, 09 Oct 2013 14:20:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VTyMj-0006G7-Tr for emacs-orgmode@gnu.org; Wed, 09 Oct 2013 14:20:15 -0400 Received: from plane.gmane.org ([80.91.229.3]:39861) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTyMj-0006Fz-Mf for emacs-orgmode@gnu.org; Wed, 09 Oct 2013 14:20:09 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1VTyMh-0001L9-TG for emacs-orgmode@gnu.org; Wed, 09 Oct 2013 20:20:07 +0200 Received: from p4fdd2914.dip0.t-ipconnect.de ([79.221.41.20]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 09 Oct 2013 20:20:07 +0200 Received: from eric by p4fdd2914.dip0.t-ipconnect.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 09 Oct 2013 20:20:07 +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: emacs-orgmode@gnu.org Thorsten Jolitz writes: > Eric Abrahamsen writes: > >> Thierry Pellé 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. Sure, it's certainly doable, and in more than one way, but I think that's part of the problem: the reason the table-to-src-block-var process is so great is that it feels purpose-built to do what it does. For properties you've got search, column view, and the API, but it never quite feels like the potential is unlocked... > * 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))))