emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Computations on properties


From: Michael Brand
Subject: Re: [O] Computations on properties
Date: Thu, 10 Oct 2013 11:04:35 +0200

Hi Thierry

On Thu, Oct 10, 2013 at 8:39 AM, Thierry Pellé
<address@hidden> wrote:
> After some tests :
> ==> the idea of Michael
>> --------------------------------
>> * Mean Calculation
>>   :PROPERTIES:
>>   :VAL1:     5
>>   :VAL2:     10
>>   :COEF:     10
>>   :END:
>>
>>   Mean Calculation = call_mean() =5.454545454545454=
>>
>> * code :noexport:
>>   #+NAME: mean
>>   #+HEADER: :var val1='nil
>>   #+HEADER: :var val2='nil
>>   #+HEADER: :var coef='nil
>>   #+BEGIN_SRC emacs-lisp :exports none
>>     (setq
>>      val1 (string-to-number (org-entry-get
>>                              org-babel-current-src-block-location "VAL1" t))
>>      val2 (string-to-number (org-entry-get
>>                              org-babel-current-src-block-location "VAL2" t))
>>      coef (string-to-number (org-entry-get
>>                              org-babel-current-src-block-location "COEF" t)))
>>     (/ (+ (* val1 coef) val2) (+ coef 1.0))
>>   #+END_SRC
>> --------------------------------
>
> give an error ( "Symbol's value as variable is void:
> org-babel-current-src-block-location")

This I would expect from an org-version older than 8.1. Check

    C-h v org-babel-current-src-block-location
    M-x org-version

But if you did not change the version there might be some problem
before the first loading of ob-core.el. If you can reproduce it, maybe
with a fresh started Emacs, I hope that someone more familiar with
autoload etc. than me can help.

> ==> After some tests, it works in changing the "setq" part as
>  val1 (or val1 (string-to-number
>             (org-entry-get org-babel-current-src-block-location "VAL1" t)
>                 ))

This does still not deal with all cases. As you seem to dive deeper
please forget my simplified version posted earlier and see
testing/examples/babel.org.

> I can't figure out why...

See the attached patch that adds comments to
testing/examples/babel.org for the two "or" and more.

CCed Eric Schulte who I would like to ask to review and apply the patch.

> ==> I will try with python...

Start from the shell example in testing/examples/babel.org

Did you check if you need the t or nil for org-entry-get?

Michael

Attachment: 0001-Babel-add-comments-to-ERT-for-reading-properties.patch.txt
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]