[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[BUG] ob-calc and decimal number in :var [9.7-pre (release_9.6.17-1446-g
From: |
Visuwesh |
Subject: |
[BUG] ob-calc and decimal number in :var [9.7-pre (release_9.6.17-1446-g252971 @ /home/viz/lib/emacs/straight/build/org/)] |
Date: |
Thu, 28 Mar 2024 17:51:46 +0530 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Remember to cover the basics, that is, what you expected to happen and
what in fact did happen. You don't know how to make a good report? See
https://orgmode.org/manual/Feedback.html#Feedback
Your bug report will be posted to the Org mailing list.
------------------------------------------------------------------------
In emacs -Q, try evaluating the source block
#+BEGIN_SRC calc :var thetarot=1.3
1/thetarot
#+END_SRC
and witness the following error:
Debugger entered--Lisp error: (wrong-type-argument listp 1.3)
nth(2 1.3)
calc-div-fractions(1 1.3)
math-div(1 1.3)
math-mul-or-div(1 1.3 nil t)
math-combine-prod(1 1.3 nil t t)
math-simplify-one-divisor((1 1.3) (1.3))
math-simplify-divisor((1 1.3) (1.3) nil t)
math-simplify-divide((/ 1 1.3))
#f(compiled-function (expr) #<bytecode -0xce707cc7797ed02>)((/ 1 1.3))
math-simplify-step((/ 1 1.3))
math-simplify((/ 1 1.3))
calc-normalize-fancy((/ 1 1.3))
calc-normalize((/ 1 1.3))
math-evaluate-expr((/ 1 1.3))
#f(compiled-function (line) #<bytecode -0x1da56b5a0e8d9337>)("1/thetarot")
mapc(#f(compiled-function (line) #<bytecode -0x1da56b5a0e8d9337>)
("1/thetarot"))
org-babel-execute:calc("1/thetarot\11" ((:var thetarot . 1.3)
(:colname-names) (:rowname-names) (:result-params "replace") (:result-type .
value) (:results . "replace") (:exports . "code") (:session . "none") (:cache .
"no") (:noweb . "no") (:hlines . "no") (:tangle . "no")))
org-babel-execute-src-block(nil ("calc" "1/thetarot\11" ((:var thetarot .
1.3) (:colname-names) (:rowname-names) (:result-params "replace") (:result-type
. value) (:results . "replace") (:exports . "code") (:tangle . "no") (:hlines .
"no") (:noweb . "no") (:cache . "no") (:session . "none")) "" nil 148
"(ref:%s)"))
org-ctrl-c-ctrl-c(nil)
funcall-interactively(org-ctrl-c-ctrl-c nil)
call-interactively(org-ctrl-c-ctrl-c nil nil)
command-execute(org-ctrl-c-ctrl-c)
This happens because the decimal number 1.3 is not in the format calc
expects. A VERY DIRTY patch to do this is
diff --git a/lisp/ob-calc.el b/lisp/ob-calc.el
index f36df77ff..6ef09032a 100644
--- a/lisp/ob-calc.el
+++ b/lisp/ob-calc.el
@@ -111,7 +116,7 @@ EL is taken from the output of `math-read-exprs'."
(if (and (eq 'var (car el)) (member (cadr el) org--var-syms))
(progn
(calc-recall (cadr el))
- (prog1 (calc-top 1)
+ (prog1 (math-read-exprs (format "%S" (calc-top 1)))
(calc-pop 1)))
(mapcar #'org-babel-calc-maybe-resolve-var el))
el))
but unfortunately, I don't have the time currently to polish this up.
If someone doesn't beat me to it, I will send a more polished+tested
patch by the beginning of May (if I get a lot of free time, I can try to
make one in the meanwhile).
Emacs : GNU Emacs 30.0.50 (build 2, x86_64-pc-linux-gnu, X toolkit, cairo
version 1.18.0, Xaw scroll bars)
of 2024-02-17
Package: Org mode version 9.7-pre (release_9.6.17-1446-g252971 @
/home/viz/lib/emacs/straight/build/org/)
- [BUG] ob-calc and decimal number in :var [9.7-pre (release_9.6.17-1446-g252971 @ /home/viz/lib/emacs/straight/build/org/)],
Visuwesh <=