[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Orgmode] Re: Possible Calc support for Org-Babel?
From: |
Sébastien Vauban |
Subject: |
[Orgmode] Re: Possible Calc support for Org-Babel? |
Date: |
Fri, 29 Oct 2010 13:27:40 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (windows-nt) |
Hi Eric,
"Eric Schulte" wrote:
> I've thrown together a very naive first pass at a function for evaluating
> calc code blocks. This inverts the normal calc (as I understand it) use of '
> prefixes and assumes that every line is an algebraic expression unless that
> line is prefixed with a ' in which case it is taken as a stack operation.
>
> This *does* change the value of the stack, allowing multiple code blocks to
> collaborate, in effect treating the stack as a session. I'd be interested to
> hear what real calc users think of this approach.
>
> Best -- Eric
>
> to use this evaluate the following function, and then try the subsequent
> code blocks
>
> evaluate this code block to add support for calc code blocks
> #+begin_src emacs-lisp
> (defun org-babel-execute:calc (body params)
> "Execute a block of calc code with Babel."
> (mapcar
> (lambda (line)
> (when (> (length line) 0)
> (if (string= "'" (substring line 0 1))
> (funcall (lookup-key calc-mode-map (substring line 1)) nil)
> (calc-push-list (list (math-read-number (calc-eval line)))))))
> (split-string body "[\n\r]"))
> (calc-eval (calc-top 1)))
> #+end_src
Tried to run the following:
> This block pushes 1 and 2 on the stack, then adds them
> #+begin_src calc
> 1
> 2
> '+
> #+end_src
--8<---------------cut here---------------start------------->8---
executing Calc code block...
if: Symbol's function definition is void: calc-push-list
--8<---------------cut here---------------end--------------->8---
Required =calc= by calling =C-x * *=:
--8<---------------cut here---------------start------------->8---
+-> Requiring `calc-macs'
+-> Requiring `calc-macs'...done
Loading c:/Program Files/Emacs-23/emacs/lisp/calc/calc-loaddefs.el...
C-x * (Type ? for a list of Calc options)
+-> Requiring `calc-ext'
+-> Requiring `calc' (already loaded)
+-> Requiring `calc-macs' (already loaded)
+-> Requiring `calc-ext'...done
+-> Requiring `calc-ext' (already loaded)
+-> Requiring `calc-macs' (already loaded)
Loading nil...
+-> Requiring `calc-menu'
+-> Requiring `calc-menu'...done
+-> Requiring `calc' (already loaded)
+-> Requiring `calc-macs' (already loaded)
--8<---------------cut here---------------end--------------->8---
Tried again:
--8<---------------cut here---------------start------------->8---
calc-do-embedded: Syntax error
--8<---------------cut here---------------end--------------->8---
> This block evaluates 3^3 with calc pushing the result on the stack and
> returning it into the Org-mode buffer
> #+begin_src calc
> 3^3
> #+end_src
>
> This block evaluates (2+2)*4 pushing the result on the stack, it then
> calls calc-plus adding the top two elements on the stack (one of which
> is left over from the previous code block).
> #+begin_src calc
> (2+2)*4
> '+
> #+end_src
On the 2 lasts, I had another error:
--8<---------------cut here---------------start------------->8---
executing Calc code block...
+-> Requiring `calc' (already loaded)
+-> Requiring `calc-macs' (already loaded)
calc-push-list: Symbol's value as variable is void: calc-command-flags
--8<---------------cut here---------------end--------------->8---
Best regards,
Seb
--
Sébastien Vauban
- [Orgmode] Possible Calc support for Org-Babel?, Matthew Oesting, 2010/10/22
- Re: [Orgmode] Possible Calc support for Org-Babel?, Eric Schulte, 2010/10/26
- Re: [Orgmode] Possible Calc support for Org-Babel?, Eric Schulte, 2010/10/29
- Re: [Orgmode] Possible Calc support for Org-Babel?, Carsten Dominik, 2010/10/29
- Re: [Orgmode] Possible Calc support for Org-Babel?, Eric S Fraga, 2010/10/29
- Re: [Orgmode] Possible Calc support for Org-Babel?, Eric Schulte, 2010/10/29
- Re: [Orgmode] Possible Calc support for Org-Babel?, Eric Schulte, 2010/10/29
- Re: [Orgmode] Possible Calc support for Org-Babel?, Eric S Fraga, 2010/10/29
- Re: [Orgmode] Possible Calc support for Org-Babel?, Eric Schulte, 2010/10/29
- Message not available
- Message not available
- Re: [Orgmode] Possible Calc support for Org-Babel?, Eric S Fraga, 2010/10/30
- [Orgmode] Re: Possible Calc support for Org-Babel?,
Sébastien Vauban <=
- Re: [Orgmode] Re: Possible Calc support for Org-Babel?, Eric Schulte, 2010/10/29