* Spreadsheet and weighted means
@ 2008-09-20 7:00 Nicolas Goaziou
2008-09-29 8:43 ` Carsten Dominik
0 siblings, 1 reply; 14+ messages in thread
From: Nicolas Goaziou @ 2008-09-20 7:00 UTC (permalink / raw
To: emacs-orgmode
Hello,
I stumbled upon this problem : I'd like to compute the weighted mean of
some values, even though cells might be empty. In fact, I'm aiming at
something like this :
| | Coeff. | 0.2 | 0.5 | 1 |
|-----------+--------+--------+--------+--------|
| Name | Mean | Test 1 | Test 2 | Test 3 |
|-----------+--------+--------+--------+--------|
| Student A | 10 | 15 | 12 | 8 |
| Student B | 12 | | 16 | 10 |
where 10=(15*0.2+12*0.5+8*1)/(0.2+0.5+1) and 12=(16*0.5+10*1)/(0.5+1)
I just can't guess what has to be put in @3$2 as a column formula to
calculate those mean means… I perhaps have overlooked something simple.
Anyway, if anyone has a clue here, I will be pleased to hear it.
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Spreadsheet and weighted means
2008-09-20 7:00 Spreadsheet and weighted means Nicolas Goaziou
@ 2008-09-29 8:43 ` Carsten Dominik
2008-09-29 8:44 ` Carsten Dominik
2008-10-01 16:46 ` Nicolas Goaziou
0 siblings, 2 replies; 14+ messages in thread
From: Carsten Dominik @ 2008-09-29 8:43 UTC (permalink / raw
To: Nicolas Goaziou; +Cc: emacs-orgmode
On Sep 20, 2008, at 9:00 AM, Nicolas Goaziou wrote:
> Hello,
>
> I stumbled upon this problem : I'd like to compute the weighted mean
> of
> some values, even though cells might be empty. In fact, I'm aiming at
> something like this :
>
> | | Coeff. | 0.2 | 0.5 | 1 |
> |-----------+--------+--------+--------+--------|
> | Name | Mean | Test 1 | Test 2 | Test 3 |
> |-----------+--------+--------+--------+--------|
> | Student A | 10 | 15 | 12 | 8 |
> | Student B | 12 | | 16 | 10 |
>
> where 10=(15*0.2+12*0.5+8*1)/(0.2+0.5+1) and 12=(16*0.5+10*1)/(0.5+1)
>
> I just can't guess what has to be put in @3$2 as a column formula to
> calculate those mean means… I perhaps have overlooked something
> simple.
> Anyway, if anyone has a clue here, I will be pleased to hear it.
Hi Nicolas, there s no builtin way to deal with this, in particular
with the fact that you want to treat empty fields as non-existing, and
therefore also to ignore the corresponding weight.
You cou write a Lisp function to do this, though:
(defun my-wmean (values weights)
(let ((vsum 0) (wsum 0))
(while (and values weights)
(setq v (pop values) w (pop weights))
(unless (equal "" v)
(setq vsum (+ vsum (* (string-to-number w) (string-to-number v)))
wsum (+ wsum (string-to-number w)))))
(/ vsum wsum)))
The you could use this as your equation:
| | Coeff. | 0.2 | 0.5 | 1 |
|-----------+--------+--------+--------+--------|
| Name | 0 | Test 1 | Test 2 | Test 3 |
|-----------+--------+--------+--------+--------|
| Student A | 10 | 15 | 12 | 8 |
| Student B | 12 | | 16 | 10 |
#+TBLFM: $2='(wmean '($3..$5) '(@1$3..@1$5));E%d
Note the use of the E flag, to make sure empty fields are not skipped,
but passed through as empty strings.......
Hope this helps.
- Carsten
>
>
> --
> Nicolas Goaziou
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: 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] 14+ messages in thread
* Re: Spreadsheet and weighted means
2008-09-29 8:43 ` Carsten Dominik
@ 2008-09-29 8:44 ` Carsten Dominik
2008-10-01 16:46 ` Nicolas Goaziou
1 sibling, 0 replies; 14+ messages in thread
From: Carsten Dominik @ 2008-09-29 8:44 UTC (permalink / raw
To: Carsten Dominik; +Cc: emacs-orgmode
On Sep 29, 2008, at 10:43 AM, Carsten Dominik wrote:
>
> On Sep 20, 2008, at 9:00 AM, Nicolas Goaziou wrote:
>
>> Hello,
>>
>> I stumbled upon this problem : I'd like to compute the weighted
>> mean of
>> some values, even though cells might be empty. In fact, I'm aiming at
>> something like this :
>>
>> | | Coeff. | 0.2 | 0.5 | 1 |
>> |-----------+--------+--------+--------+--------|
>> | Name | Mean | Test 1 | Test 2 | Test 3 |
>> |-----------+--------+--------+--------+--------|
>> | Student A | 10 | 15 | 12 | 8 |
>> | Student B | 12 | | 16 | 10 |
>>
>> where 10=(15*0.2+12*0.5+8*1)/(0.2+0.5+1) and 12=(16*0.5+10*1)/(0.5+1)
>>
>> I just can't guess what has to be put in @3$2 as a column formula to
>> calculate those mean means… I perhaps have overlooked something
>> simple.
>> Anyway, if anyone has a clue here, I will be pleased to hear it.
>
> Hi Nicolas, there s no builtin way to deal with this, in particular
> with the fact that you want to treat empty fields as non-existing,
> and therefore also to ignore the corresponding weight.
>
> You cou write a Lisp function to do this, though:
>
> (defun my-wmean (values weights)
> (let ((vsum 0) (wsum 0))
> (while (and values weights)
> (setq v (pop values) w (pop weights))
> (unless (equal "" v)
> (setq vsum (+ vsum (* (string-to-number w) (string-to-number v)))
> wsum (+ wsum (string-to-number w)))))
> (/ vsum wsum)))
>
>
> The you could use this as your equation:
>
> | | Coeff. | 0.2 | 0.5 | 1 |
> |-----------+--------+--------+--------+--------|
> | Name | 0 | Test 1 | Test 2 | Test 3 |
> |-----------+--------+--------+--------+--------|
> | Student A | 10 | 15 | 12 | 8 |
> | Student B | 12 | | 16 | 10 |
> #+TBLFM: $2='(wmean '($3..$5) '(@1$3..@1$5));E%d
Typo: the function call must be `my-wmean', not just `wmean'.
- CarstenG
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Spreadsheet and weighted means
2008-09-29 8:43 ` Carsten Dominik
2008-09-29 8:44 ` Carsten Dominik
@ 2008-10-01 16:46 ` Nicolas Goaziou
2008-10-01 19:26 ` Carsten Dominik
1 sibling, 1 reply; 14+ messages in thread
From: Nicolas Goaziou @ 2008-10-01 16:46 UTC (permalink / raw
To: Carsten Dominik; +Cc: emacs-orgmode
Carsten Dominik <dominik@uva.nl> writes:
Hello,
> Hi Nicolas, there s no builtin way to deal with this, in particular
> with the fact that you want to treat empty fields as non-existing, and
> therefore also to ignore the corresponding weight.
>
> You cou write a Lisp function to do this, though:
>
> (defun my-wmean (values weights)
> (let ((vsum 0) (wsum 0))
> (while (and values weights)
> (setq v (pop values) w (pop weights))
> (unless (equal "" v)
> (setq vsum (+ vsum (* (string-to-number w) (string-to-number
> v)))
> wsum (+ wsum (string-to-number w)))))
> (/ vsum wsum)))
Well, thank you very much: it does the job.
I don't want to be picky but I'll investigate on a way to have an empty
string instead of a sorry 0 whenever a student hasn't sat for any exam.
Finally, I wondered if it would be useful to make it built-in as
weighted means are somewhat popular in education.
Anyway, thanks again.
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Spreadsheet and weighted means
2008-10-01 16:46 ` Nicolas Goaziou
@ 2008-10-01 19:26 ` Carsten Dominik
2008-10-01 19:45 ` Embedded elisp formulas, was: " Eric Schulte
2008-10-04 8:49 ` Nicolas Goaziou
0 siblings, 2 replies; 14+ messages in thread
From: Carsten Dominik @ 2008-10-01 19:26 UTC (permalink / raw
To: Nicolas Goaziou; +Cc: emacs-orgmode
Hi Nicolas,
On Oct 1, 2008, at 6:46 PM, Nicolas Goaziou wrote:
> Carsten Dominik <dominik@uva.nl> writes:
>
> Hello,
>
>> Hi Nicolas, there s no builtin way to deal with this, in particular
>> with the fact that you want to treat empty fields as non-existing,
>> and
>> therefore also to ignore the corresponding weight.
>>
>> You cou write a Lisp function to do this, though:
>>
>> (defun my-wmean (values weights)
>> (let ((vsum 0) (wsum 0))
>> (while (and values weights)
>> (setq v (pop values) w (pop weights))
>> (unless (equal "" v)
>> (setq vsum (+ vsum (* (string-to-number w) (string-to-number
>> v)))
>> wsum (+ wsum (string-to-number w)))))
>> (/ vsum wsum)))
>
> Well, thank you very much: it does the job.
>
> I don't want to be picky but I'll investigate on a way to have an
> empty
> string instead of a sorry 0 whenever a student hasn't sat for any
> exam.
Well, you can do this by leaving the formatting to the function
instead of the formula under the table:
(defun my-wmean (values weights)
(let ((vsum 0) (wsum 0))
(while (and values weights)
(setq v (pop values) w (pop weights))
(unless (equal "" v)
(setq vsum (+ vsum (* (string-to-number w) (string-to-number v)))
wsum (+ wsum (string-to-number w)))))
(if (= vsum 0) "" (format "%.1f" (/ vsum wsum)))))
The you could use this as your equation:
| | Coeff. | 0.2 | 0.5 | 1 |
|-----------+--------+--------+--------+--------|
| Name | | Test 1 | Test 2 | Test 3 |
|-----------+--------+--------+--------+--------|
| Student A | 10.0 | 15 | 12 | 8 |
| Student B | 12.7 | | 16 | 11 |
| Student C | | | | |
#+TBLFM: $2='(my-wmean '($3..$5) '(@1$3..@1$5));E
>
> Finally, I wondered if it would be useful to make it built-in as
> weighted means are somewhat popular in education.
Well, I could do that, of course. But which version of this
function? What ouput etc?
I guess this would then be the original version, which returns a
number, and which returns 0 if the student has done absolutely
nothing....
- Carsten
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Embedded elisp formulas, was: Spreadsheet and weighted means
2008-10-01 19:26 ` Carsten Dominik
@ 2008-10-01 19:45 ` Eric Schulte
2008-10-01 20:29 ` Paul R
2008-10-04 8:49 ` Nicolas Goaziou
1 sibling, 1 reply; 14+ messages in thread
From: Eric Schulte @ 2008-10-01 19:45 UTC (permalink / raw
To: Carsten Dominik; +Cc: emacs-orgmode
Carsten Dominik <dominik@uva.nl> writes:
[...]
> Well, you can do this by leaving the formatting to the function
> instead of the formula under the table:
>
>
> (defun my-wmean (values weights)
> (let ((vsum 0) (wsum 0))
> (while (and values weights)
> (setq v (pop values) w (pop weights))
> (unless (equal "" v)
> (setq vsum (+ vsum (* (string-to-number w) (string-to-number v)))
> wsum (+ wsum (string-to-number w)))))
> (if (= vsum 0) "" (format "%.1f" (/ vsum wsum)))))
>
>
> The you could use this as your equation:
>
> | | Coeff. | 0.2 | 0.5 | 1 |
> |-----------+--------+--------+--------+--------|
> | Name | | Test 1 | Test 2 | Test 3 |
> |-----------+--------+--------+--------+--------|
> | Student A | 10.0 | 15 | 12 | 8 |
> | Student B | 12.7 | | 16 | 11 |
> | Student C | | | | |
> #+TBLFM: $2='(my-wmean '($3..$5) '(@1$3..@1$5));E
This raises an issue I've been running into recently, If I have a
multi-line elisp function (I guess same issue would apply for multi-line
shell commands) that I want to use from an org file (for example to
compute table columns), is there a way to save and load the function
from the org file? I've tried multiline [[elisp: ]] links but they
don't work well, maybe something like...
[[eval-source]]
#+BEGIN_SOURCE elisp
#+END_SOURCE
Thanks -- Eric
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Embedded elisp formulas, was: Spreadsheet and weighted means
2008-10-01 19:45 ` Embedded elisp formulas, was: " Eric Schulte
@ 2008-10-01 20:29 ` Paul R
2008-10-02 0:03 ` Eric Schulte
0 siblings, 1 reply; 14+ messages in thread
From: Paul R @ 2008-10-01 20:29 UTC (permalink / raw
To: Eric Schulte; +Cc: Carsten Dominik, emacs-orgmode
On Wed, 01 Oct 2008 12:45:34 -0700, "Eric Schulte" <schulte.eric@gmail.com> said:
> This raises an issue I've been running into recently, If I have
> a multi-line elisp function (I guess same issue would apply for
> multi-line shell commands) that I want to use from an org file (for
> example to compute table columns), is there a way to save and load
> the function from the org file? I've tried multiline [[elisp: ]]
> links but they don't work well, maybe something like...
maybe you can use the emacs facility to load code when visiting
a file. For more information, read the following info node :
File: emacs, Node: Specifying File Variables
--
Paul
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Embedded elisp formulas, was: Spreadsheet and weighted means
2008-10-01 20:29 ` Paul R
@ 2008-10-02 0:03 ` Eric Schulte
2008-10-02 11:44 ` Carsten Dominik
0 siblings, 1 reply; 14+ messages in thread
From: Eric Schulte @ 2008-10-02 0:03 UTC (permalink / raw
To: Paul R; +Cc: Carsten Dominik, emacs-orgmode
Paul R <paul.r.ml@gmail.com> writes:
> On Wed, 01 Oct 2008 12:45:34 -0700, "Eric Schulte" <schulte.eric@gmail.com> said:
>
>> This raises an issue I've been running into recently, If I have
>> a multi-line elisp function (I guess same issue would apply for
>> multi-line shell commands) that I want to use from an org file (for
>> example to compute table columns), is there a way to save and load
>> the function from the org file? I've tried multiline [[elisp: ]]
>> links but they don't work well, maybe something like...
>
> maybe you can use the emacs facility to load code when visiting
> a file. For more information, read the following info node :
> File: emacs, Node: Specifying File Variables
I looked at this, but then I ran across org-eval.el in the
org/contrib/lisp directory. With (require 'org-eval) in my .emacs I can
put something like the following
<lisp>
(defun my-specific-function-for-this-file (org-tabl-cell)
(format "%S"
(do-something-special
(read org-tabl-cell))))
</lisp>
in an org file and org-eval is nice enough to evaluate the code defining
the function upon opening the file, to display only the name of the
function in a special face, and to allow me to edit the function in the
appropriate mode with C-' (also works for ruby/shell/python/etc...).
Everything I could have asked for!
It nice to request a feature and find it's already implemented.
Thanks -- Eric
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Embedded elisp formulas, was: Spreadsheet and weighted means
2008-10-02 0:03 ` Eric Schulte
@ 2008-10-02 11:44 ` Carsten Dominik
2008-10-08 23:12 ` ANN: org-eval-light.el was: " Eric Schulte
2008-11-06 1:19 ` Eric Schulte
0 siblings, 2 replies; 14+ messages in thread
From: Carsten Dominik @ 2008-10-02 11:44 UTC (permalink / raw
To: Eric Schulte; +Cc: Paul R, emacs-orgmode
On Oct 2, 2008, at 2:03 AM, Eric Schulte wrote:
> Paul R <paul.r.ml@gmail.com> writes:
>
>> On Wed, 01 Oct 2008 12:45:34 -0700, "Eric Schulte" <schulte.eric@gmail.com
>> > said:
>>
>>> This raises an issue I've been running into recently, If I have
>>> a multi-line elisp function (I guess same issue would apply for
>>> multi-line shell commands) that I want to use from an org file (for
>>> example to compute table columns), is there a way to save and load
>>> the function from the org file? I've tried multiline [[elisp: ]]
>>> links but they don't work well, maybe something like...
>>
>> maybe you can use the emacs facility to load code when visiting
>> a file. For more information, read the following info node :
>> File: emacs, Node: Specifying File Variables
>
> I looked at this, but then I ran across org-eval.el in the
> org/contrib/lisp directory. With (require 'org-eval) in my .emacs I
> can
> put something like the following
>
> <lisp>
> (defun my-specific-function-for-this-file (org-tabl-cell)
> (format "%S"
> (do-something-special
> (read org-tabl-cell))))
> </lisp>
>
> in an org file and org-eval is nice enough to evaluate the code
> defining
> the function upon opening the file, to display only the name of the
> function in a special face, and to allow me to edit the function in
> the
> appropriate mode with C-' (also works for ruby/shell/python/etc...).
> Everything I could have asked for!
>
> It nice to request a feature and find it's already implemented.
Before starting to use org-eval.el, I'd like to make sure that
everyone understands that loading org-eval.el turns any org-mode file
into an executable. That means that you have to start being careful
with org-mode files you receive from others or download from the
internet. Just like you would run a program from the web only if you
trust the source, you should then only load such files into Emacs if
you trust the source. I am not saying this to keep you from using org-
eval, I am am using it myself, but please be aware of this issue.
One more remark: a <lisp> tag is evaluated by jit-lock (i.e. by the
font-lock mechanism), just before Emacs tries to make it visible. The
reason for this is that the original indent for this functionality was
to produce and display dynamic content on a page. In large files,
font locking can be delayed until the segment in question comes into
view in the Emacs window.
To be sure to get this code evaluated immediately when visiting a
file, you might want to put the snippets close to the beginning of
the file.
- Carsten
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Spreadsheet and weighted means
2008-10-01 19:26 ` Carsten Dominik
2008-10-01 19:45 ` Embedded elisp formulas, was: " Eric Schulte
@ 2008-10-04 8:49 ` Nicolas Goaziou
1 sibling, 0 replies; 14+ messages in thread
From: Nicolas Goaziou @ 2008-10-04 8:49 UTC (permalink / raw
To: Carsten Dominik; +Cc: emacs-orgmode
Hello,
Carsten Dominik <dominik@uva.nl> writes:
> (defun my-wmean (values weights)
> (let ((vsum 0) (wsum 0))
> (while (and values weights)
> (setq v (pop values) w (pop weights))
> (unless (equal "" v)
> (setq vsum (+ vsum (* (string-to-number w) (string-to-number
> v)))
> wsum (+ wsum (string-to-number w)))))
> (if (= vsum 0) "" (format "%.1f" (/ vsum wsum)))))
But in this case, there's no difference between one who didn't work and
one who just wasn't there: 0 0 and "empty" "empty" will have the same
"empty" mean, won't they ?
>> Finally, I wondered if it would be useful to make it built-in as
>> weighted means are somewhat popular in education.
>
> Well, I could do that, of course. But which version of this function?
> What ouput etc?
> I guess this would then be the original version, which returns a
> number, and which returns 0 if the student has done absolutely
> nothing....
Though it seems more of a rhetorical question, I would be tempted to
answer that any of them would be useful.
On the other hand, I can live with "my-wmean" in my .emacs.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 14+ messages in thread
* ANN: org-eval-light.el was: Re: Embedded elisp formulas, was: Spreadsheet and weighted means
2008-10-02 11:44 ` Carsten Dominik
@ 2008-10-08 23:12 ` Eric Schulte
2008-11-06 1:19 ` Eric Schulte
1 sibling, 0 replies; 14+ messages in thread
From: Eric Schulte @ 2008-10-08 23:12 UTC (permalink / raw
To: Carsten Dominik; +Cc: Paul R, emacs-orgmode
> Before starting to use org-eval.el, I'd like to make sure that
> everyone understands that loading org-eval.el turns any org-mode file
> into an executable. That means that you have to start being careful
> with org-mode files you receive from others or download from the
> internet. Just like you would run a program from the web only if you
> trust the source, you should then only load such files into Emacs if
> you trust the source. I am not saying this to keep you from using
> org-
> eval, I am am using it myself, but please be aware of this issue.
>
> One more remark: a <lisp> tag is evaluated by jit-lock (i.e. by the
> font-lock mechanism), just before Emacs tries to make it visible. The
> reason for this is that the original indent for this functionality was
> to produce and display dynamic content on a page. In large files,
> font locking can be delayed until the segment in question comes into
> view in the Emacs window.
> To be sure to get this code evaluated immediately when visiting a
> file, you might want to put the snippets close to the beginning of
> the file.
>
I've made some changes to org-eval and packaged them into a new
org-eval-light.el file. While this reworked version loses some of the
automatic evaluation, and most all of the similarity to Emacs Muse that
the original org-eval tried to maintain, I believe that it represents
(for me at least) a safer and more use-able way of packaging and calling
source code from inside of org-files.
The changes include...
,----[org-eval-light.el]
| ;;; Changes: by Eric Schulte
| ;;
| ;; 1) forms are only executed manually, (allowing for the execution of
| ;; an entire subtree of forms)
| ;; 2) use the org-mode style src blocks, rather than the muse style
| ;; <code></code> blocks
| ;; 3) forms are not replaced by their outputs, but rather the output
| ;; is placed in the buffer immediately following the src block
| ;; commented by `org-eval-light-make-region-example' (when
| ;; evaluated with a prefix argument no output is placed in the
| ;; buffer)
| ;; 4) add defadvice to org-ctrl-c-ctrl-c so that when called inside of
| ;; a source block it will call `org-eval-light-current-snippet'
`----
The amount of new code is minimal, but I think it provides a nice
alternative for source code evaluation, and hopefully takes org-mode one
step closer to being a first-class Experimentation and
Reproducible-Research tool. Here is a link to the code
http://github.com/eschulte/org-contrib/tree/master/org-eval-light.el
As a side note, I feel that org-mode should be listed here
http://www.reproducibleresearch.org/tools_and_resources.html
Thanks -- Eric
^ permalink raw reply [flat|nested] 14+ messages in thread
* ANN: org-eval-light.el was: Re: Embedded elisp formulas, was: Spreadsheet and weighted means
2008-10-02 11:44 ` Carsten Dominik
2008-10-08 23:12 ` ANN: org-eval-light.el was: " Eric Schulte
@ 2008-11-06 1:19 ` Eric Schulte
2008-11-09 7:02 ` Carsten Dominik
1 sibling, 1 reply; 14+ messages in thread
From: Eric Schulte @ 2008-11-06 1:19 UTC (permalink / raw
To: Carsten Dominik; +Cc: Paul R, emacs-orgmode
Carsten Dominik <dominik@uva.nl> writes:
> Before starting to use org-eval.el, I'd like to make sure that
> everyone understands that loading org-eval.el turns any org-mode file
> into an executable. That means that you have to start being careful
> with org-mode files you receive from others or download from the
> internet. Just like you would run a program from the web only if you
> trust the source, you should then only load such files into Emacs if
> you trust the source. I am not saying this to keep you from using
> org-
> eval, I am am using it myself, but please be aware of this issue.
>
> One more remark: a <lisp> tag is evaluated by jit-lock (i.e. by the
> font-lock mechanism), just before Emacs tries to make it visible. The
> reason for this is that the original indent for this functionality was
> to produce and display dynamic content on a page. In large files,
> font locking can be delayed until the segment in question comes into
> view in the Emacs window.
> To be sure to get this code evaluated immediately when visiting a
> file, you might want to put the snippets close to the beginning of
> the file.
>
I've made some changes to org-eval and packaged them into a new
org-eval-light.el file. While this reworked version loses some of the
automatic evaluation, and most all of the similarity to Emacs Muse that
the original org-eval tried to maintain, I believe that it represents
(for me at least) a safer and more use-able way of packaging and calling
source code from inside of org-files.
The changes include...
,----[org-eval-light.el]
| ;;; Changes: by Eric Schulte
| ;;
| ;; 1) forms are only executed manually, (allowing for the execution of
| ;; an entire subtree of forms)
| ;; 2) use the org-mode style src blocks, rather than the muse style
| ;; <code></code> blocks
| ;; 3) forms are not replaced by their outputs, but rather the output
| ;; is placed in the buffer immediately following the src block
| ;; commented by `org-eval-light-make-region-example' (when
| ;; evaluated with a prefix argument no output is placed in the
| ;; buffer)
| ;; 4) add defadvice to org-ctrl-c-ctrl-c so that when called inside of
| ;; a source block it will call `org-eval-light-current-snippet'
`----
The amount of new code is minimal, but I think it provides a nice
alternative for source code evaluation, and hopefully takes org-mode one
step closer to being a first-class Experimentation and
Reproducible-Research tool. The code is available here
http://github.com/eschulte/org-contrib/tree/master%2Forg-eval-light.el?raw=true
As a side note, I feel that org-mode should be listed here
http://www.reproducibleresearch.org/tools_and_resources.html
Thanks -- Eric
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: ANN: org-eval-light.el was: Re: Embedded elisp formulas, was: Spreadsheet and weighted means
2008-11-06 1:19 ` Eric Schulte
@ 2008-11-09 7:02 ` Carsten Dominik
2008-11-10 19:51 ` Daniel Clemente
0 siblings, 1 reply; 14+ messages in thread
From: Carsten Dominik @ 2008-11-09 7:02 UTC (permalink / raw
To: Eric Schulte; +Cc: Paul R, emacs-orgmode
Any votes for including this into the contrib directory?
- Carsten
On Nov 6, 2008, at 2:19 AM, Eric Schulte wrote:
> Carsten Dominik <dominik@uva.nl> writes:
>
>> Before starting to use org-eval.el, I'd like to make sure that
>> everyone understands that loading org-eval.el turns any org-mode file
>> into an executable. That means that you have to start being careful
>> with org-mode files you receive from others or download from the
>> internet. Just like you would run a program from the web only if you
>> trust the source, you should then only load such files into Emacs if
>> you trust the source. I am not saying this to keep you from using
>> org-
>> eval, I am am using it myself, but please be aware of this issue.
>>
>> One more remark: a <lisp> tag is evaluated by jit-lock (i.e. by the
>> font-lock mechanism), just before Emacs tries to make it visible.
>> The
>> reason for this is that the original indent for this functionality
>> was
>> to produce and display dynamic content on a page. In large files,
>> font locking can be delayed until the segment in question comes into
>> view in the Emacs window.
>> To be sure to get this code evaluated immediately when visiting a
>> file, you might want to put the snippets close to the beginning of
>> the file.
>>
>
> I've made some changes to org-eval and packaged them into a new
> org-eval-light.el file. While this reworked version loses some of the
> automatic evaluation, and most all of the similarity to Emacs Muse
> that
> the original org-eval tried to maintain, I believe that it represents
> (for me at least) a safer and more use-able way of packaging and
> calling
> source code from inside of org-files.
>
> The changes include...
>
> ,----[org-eval-light.el]
> | ;;; Changes: by Eric Schulte
> | ;;
> | ;; 1) forms are only executed manually, (allowing for the
> execution of
> | ;; an entire subtree of forms)
> | ;; 2) use the org-mode style src blocks, rather than the muse style
> | ;; <code></code> blocks
> | ;; 3) forms are not replaced by their outputs, but rather the output
> | ;; is placed in the buffer immediately following the src block
> | ;; commented by `org-eval-light-make-region-example' (when
> | ;; evaluated with a prefix argument no output is placed in the
> | ;; buffer)
> | ;; 4) add defadvice to org-ctrl-c-ctrl-c so that when called
> inside of
> | ;; a source block it will call `org-eval-light-current-snippet'
> `----
>
>
> The amount of new code is minimal, but I think it provides a nice
> alternative for source code evaluation, and hopefully takes org-mode
> one
> step closer to being a first-class Experimentation and
> Reproducible-Research tool. The code is available here
> http://github.com/eschulte/org-contrib/tree/master%2Forg-eval-light.el?raw=true
>
> As a side note, I feel that org-mode should be listed here
> http://www.reproducibleresearch.org/tools_and_resources.html
>
> Thanks -- Eric
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Re: ANN: org-eval-light.el was: Re: Embedded elisp formulas, was: Spreadsheet and weighted means
2008-11-09 7:02 ` Carsten Dominik
@ 2008-11-10 19:51 ` Daniel Clemente
0 siblings, 0 replies; 14+ messages in thread
From: Daniel Clemente @ 2008-11-10 19:51 UTC (permalink / raw
To: org-mode
[-- Attachment #1.1: Type: text/plain, Size: 1090 bytes --]
> Any votes for including this into the contrib directory?
>
> - Carsten
I think that org-eval-light.el could even replace org-eval.el if -light-
had an option to eval automatically all code snippets when you open a file.
This way it would act like org-eval and at the same time it could be made
secure.
It could have a setting „what to do with code when opening a file" with
options: „never run", „ask before running" and „run without asking".
The action of asking whether to evaluate code is similar to Emacs' local
variables behaviour.
Someone suggested using „local variables" to define functions, but:
1. You can only call the defined functions through (funcall 'function). This
is bad because you can't control how the current code will call your
functions; for instance how org will call org-dblock-write:this-function
2. The section where you define local variables has picky and uneasy rules
about handling of line breaks and special characters.
Therefore I think that org-eval* is needed and that the 2 could be
combined.
-- Daniel
[-- Attachment #1.2: Type: text/html, Size: 1478 bytes --]
[-- Attachment #2: Type: text/plain, Size: 204 bytes --]
_______________________________________________
Emacs-orgmode mailing list
Remember: 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] 14+ messages in thread
end of thread, other threads:[~2008-11-10 19:51 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-20 7:00 Spreadsheet and weighted means Nicolas Goaziou
2008-09-29 8:43 ` Carsten Dominik
2008-09-29 8:44 ` Carsten Dominik
2008-10-01 16:46 ` Nicolas Goaziou
2008-10-01 19:26 ` Carsten Dominik
2008-10-01 19:45 ` Embedded elisp formulas, was: " Eric Schulte
2008-10-01 20:29 ` Paul R
2008-10-02 0:03 ` Eric Schulte
2008-10-02 11:44 ` Carsten Dominik
2008-10-08 23:12 ` ANN: org-eval-light.el was: " Eric Schulte
2008-11-06 1:19 ` Eric Schulte
2008-11-09 7:02 ` Carsten Dominik
2008-11-10 19:51 ` Daniel Clemente
2008-10-04 8:49 ` Nicolas Goaziou
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.