From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric S Fraga Subject: Re: Possible Calc support for Org-Babel? Date: Fri, 29 Oct 2010 20:53:26 +0100 Message-ID: <87tyk4epxl.fsf@ucl.ac.uk> References: <7CDB7386-9B39-46CB-94E8-C6B5CBD59C4F@me.com> <87mxq0ajgw.fsf@gmail.com> <87zktxv6s2.fsf@gmail.com> <87y69h8d4t.fsf@ucl.ac.uk> <87y69ht5f5.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from [140.186.70.92] (port=58894 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PBv10-0007PY-Ux for emacs-orgmode@gnu.org; Fri, 29 Oct 2010 15:53:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PBv0z-0008EF-Gs for emacs-orgmode@gnu.org; Fri, 29 Oct 2010 15:53:30 -0400 Received: from vscane-a.ucl.ac.uk ([144.82.108.41]:35786) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PBv0z-0008Dt-Cb for emacs-orgmode@gnu.org; Fri, 29 Oct 2010 15:53:29 -0400 In-Reply-To: <87y69ht5f5.fsf@gmail.com> (Eric Schulte's message of "Fri, 29 Oct 2010 08:43:51 -0600") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Eric Schulte Cc: emacs-orgmode@gnu.org, Matthew Oesting "Eric Schulte" writes: > Eric S Fraga writes: > >> Eric, >> >> This is really nice! >> >> I had a problem initially in that calc-push-list was undefined. I had >> to initiate calc first so maybe a >> >> : (require 'calc) >> > > Ah yes, that is in the ob-calc.el file, but not in the code snippet I > shared. I'll commit this entire file to the repository. Ah, so should I use the code snippet you sent or should I be requiring 'ob-calc? In either case, I still have problems (see below). >> is required to ensure the functions you use are available? >> >> Then, out of the three examples you give, only one (3^3) worked. The >> others give me: >> > > I just made a change which should fix this issue. Very strange. I'm still seeing the same problems, both with calc-push-list not known (having to manually require 'calc) and then errors evaluating the 1+2 block: --8<---------------cut here---------------start------------->8--- Debugger entered--Lisp error: (wrong-type-argument stringp (2 "Expected a number")) string-match("\\` *\\([0-9]+\\) *\\'" (2 "Expected a number")) math-read-number((2 "Expected a number")) (list (math-read-number (calc-eval line))) (calc-push-list (list (math-read-number ...))) (if (string= "'" (substring line 0 1)) (funcall (lookup-key calc-mode-map ...) nil) (calc-push-list (list ...))) (progn (if (string= "'" ...) (funcall ... nil) (calc-push-list ...))) (if (> (length line) 0) (progn (if ... ... ...))) (when (> (length line) 0) (if (string= "'" ...) (funcall ... nil) (calc-push-list ...))) (lambda (line) (when (> ... 0) (if ... ... ...)))(" '+") mapcar((lambda (line) (when (> ... 0) (if ... ... ...))) (" 1" " 2" " '+" "")) org-babel-execute:calc(" 1\n 2\n '+\n" ((:colname-names) (:rowname-names) (:result-params "replace") (:result-type . value) (:comments . "") (:shebang . "") (:cache . "no") (:noweb . "no") (:tangle . "no") (:exports . "code") (:results . "replace") (:hlines . "no") (:session . "none"))) org-babel-execute-src-block(nil ("calc" " 1\n 2\n '+\n" ((:colname-names) (:rowname-names) (:result-params "replace") (:result-type . value) (:comments . "") (:shebang . "") (:cache . "no") (:noweb . "no") (:tangle . "no") (:exports . "code") (:results . "replace") (:hlines . "no") (:session . "none")) "" nil 0)) org-babel-execute-src-block-maybe() org-babel-execute-maybe() org-babel-execute-safely-maybe() run-hook-with-args-until-success(org-babel-execute-safely-maybe) org-ctrl-c-ctrl-c(nil) call-interactively(org-ctrl-c-ctrl-c nil nil) --8<---------------cut here---------------end--------------->8--- org is up to date as of a minute or two ago: : GNU Emacs 23.2.1 (i486-pc-linux-gnu, GTK+ Version 2.20.0) : of 2010-08-14 on raven, modified by Debian : Org-mode version 7.02trans (release_7.02.18.g9c83) > I'd be particularly interested if there are more natural or "idiomatic > calc" ways to interact with Calc through a code block than the one > implemented here. Well, I like being able to say, for instance, =src_calc(2010-1989)= and have the result appear in an export of the file. By the way, this works so some things are working just fine. Thanks, eric -- Eric S Fraga GnuPG: 8F5C 279D 3907 E14A 5C29 570D C891 93D8 FFFC F67D