all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [BUG] ob-calc and decimal number in :var [9.7-pre (release_9.6.17-1446-g252971 @ /home/viz/lib/emacs/straight/build/org/)]
@ 2024-03-28 12:21 Visuwesh
  2024-03-28 12:37 ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Visuwesh @ 2024-03-28 12:21 UTC (permalink / raw)
  To: emacs-orgmode


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/)


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [BUG] ob-calc and decimal number in :var [9.7-pre (release_9.6.17-1446-g252971 @ /home/viz/lib/emacs/straight/build/org/)]
  2024-03-28 12:21 [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
@ 2024-03-28 12:37 ` Ihor Radchenko
  2024-05-02 12:27   ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Ihor Radchenko @ 2024-03-28 12:37 UTC (permalink / raw)
  To: Visuwesh; +Cc: emacs-orgmode

Visuwesh <visuweshm@gmail.com> writes:

> 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)

Confirmed.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG] ob-calc and decimal number in :var [9.7-pre (release_9.6.17-1446-g252971 @ /home/viz/lib/emacs/straight/build/org/)]
  2024-03-28 12:37 ` Ihor Radchenko
@ 2024-05-02 12:27   ` Ihor Radchenko
  2024-05-02 12:40     ` Visuwesh
  0 siblings, 1 reply; 4+ messages in thread
From: Ihor Radchenko @ 2024-05-02 12:27 UTC (permalink / raw)
  To: Visuwesh; +Cc: emacs-orgmode

Ihor Radchenko <yantar92@posteo.net> writes:

>> #+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)
>
> Confirmed.

Fixed, on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=dd12e9c76

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG] ob-calc and decimal number in :var [9.7-pre (release_9.6.17-1446-g252971 @ /home/viz/lib/emacs/straight/build/org/)]
  2024-05-02 12:27   ` Ihor Radchenko
@ 2024-05-02 12:40     ` Visuwesh
  0 siblings, 0 replies; 4+ messages in thread
From: Visuwesh @ 2024-05-02 12:40 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

[வியாழன் மே 02, 2024] Ihor Radchenko wrote:

> Ihor Radchenko <yantar92@posteo.net> writes:
>
>>> #+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)
>>
>> Confirmed.
>
> Fixed, on main.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=dd12e9c76

Great, thanks!  Unfortunately, I couldn't find the time to find a proper
fix, thank you for your fix.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-05-02 12:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-28 12:21 [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
2024-03-28 12:37 ` Ihor Radchenko
2024-05-02 12:27   ` Ihor Radchenko
2024-05-02 12:40     ` Visuwesh

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.