emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Maxima code blocks does not work in windows revisited
@ 2014-07-10 19:48 Juan Alvaro Fuentes
  2014-07-27 23:07 ` Bastien
  0 siblings, 1 reply; 9+ messages in thread
From: Juan Alvaro Fuentes @ 2014-07-10 19:48 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1688 bytes --]

Dear all,

It seems that maxima code blocks still does not work in windows as the
following code did not work when I tried to run it:

#+begin_src maxima
 a: 1+1;
 print(a);
#+end_src

This is an old issue already emailed to this emacs org-mode list in an
email dating from june 2011.

The conversation ended up with a final reflection which I copy next:

>* Okay, it definitely is a Windows problem. If I run the following command*
>* in a cygwin shell, everything works as expected:*
>
>* maxima --very-quiet -r*
>* 'batchload("c:/Users/weiss/AppData/Local/Temp/babel-17716aLH/maxima-17716hCp")$'*
>* nil*
>
>* However, it does not work in a Windows shell. But this is no longer an*
>* org issue.*
>
>* Bernd*


Trying to find the correct string that makes maxima execute the batch
file in windows I found that this command does work:

maxima --very-quiet -r
"batchload(\"c:/Users/alvaro/AppData/Local/Temp/babel-7740OHt/maxima-7740OpY.max\")$"

maxima --very-quiet -r
"batchload(\"c:/Users/alvaro/AppData/Local/Temp/babel-7740OHt/maxima-7740OpY.max\")$"

2


I tried to make this string when maxima is executed in the shell and
modifying ob-maxima.el found that this seems to work for windows 8,
emacs 24.4 and org 8.2.7b:


 (let* ((cmdline (or (cdr (assoc :cmdline params)) ""))
          (in-file (org-babel-temp-file "maxima-" ".max"))
		(cmd (format "%s --very-quiet -r \"batchload(\\\"%s\\\")$\" %s"
			     org-babel-maxima-command in-file cmdline)))


The problem is that my lisp skills are not very good, to say the
least, and sending a patch is one more problem so I write this email
if this can help anybody to makemaxima code blocks work in windows.


Thanks,

Juan Alvaro

[-- Attachment #2: Type: text/html, Size: 2920 bytes --]

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

* Re: Maxima code blocks does not work in windows revisited
  2014-07-10 19:48 Maxima code blocks does not work in windows revisited Juan Alvaro Fuentes
@ 2014-07-27 23:07 ` Bastien
  0 siblings, 0 replies; 9+ messages in thread
From: Bastien @ 2014-07-27 23:07 UTC (permalink / raw)
  To: Juan Alvaro Fuentes; +Cc: emacs-orgmode

Hi Juan,

Juan Alvaro Fuentes <juanalvaro.fuentes@upct.es> writes:

> It seems that maxima code blocks still does not work in windows as
> the following code did not work when I tried to run it:

I don't have a machine with Windows so I can't really help here, but I
hope an Org/Maxima/Windows user can help debugging this further.

Best,

-- 
 Bastien

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

* Re: Maxima code blocks does not work in windows revisited
  2022-11-02  4:47     ` Ihor Radchenko
@ 2022-11-02 15:17       ` Max Nikulin
  2022-11-02 20:11         ` Leo Butler
                           ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Max Nikulin @ 2022-11-02 15:17 UTC (permalink / raw)
  To: emacs-orgmode

On 02/11/2022 11:47, Ihor Radchenko wrote:
>>> (for reference, this email is a followup of
>>> https://orgmode.org/list/CA+ikm3wqA33xP4c3pVV+F2a-gn0dbEzsdx6Vf2cRd+37+u6pBA@mail.gmail.com)

Ihor, you recently applied an alternative patch to Org main branch. 
Emacs tree still has ob-maxima.el with single quotes around batchload.

Nikolay Kudryavtsev. Re: [PATCH] ob-maxima.el: Fix execution on MS 
Windows. Thu, 30 Dec 2021 23:54:10 +0300. 
https://list.orgmode.org/8cd49b4c-9342-a77f-d665-402c41432b57@gmail.com

> diff --git a/lisp/ob-maxima.el b/lisp/ob-maxima.el
> index dba12d7b6..52423db18 100644
> --- a/lisp/ob-maxima.el
> +++ b/lisp/ob-maxima.el
> @@ -84,7 +84,7 @@ (defun org-babel-execute:maxima (body params)
>  		(cmd (format "%s --very-quiet -r %s$ %s"
>  			     org-babel-maxima-command
>                               (shell-quote-argument
> -                              (format "batchload(%S)" in-file))
> +                              (format "\"batchload(\\\"%S\\\")\"" in-file))

Notice that code in the message you cited has "%s" and does not have 
`shell-quote-argument'. Extra quotes may discard effect of existing 
double pass escaping.

>                               cmdline)))
>  	   (with-temp-file in-file (insert (org-babel-maxima-expand body params)))
>  	   (message cmd)

Really robust solution require a dedicated maxima option that allows to 
pass file name as a separated argument instead of a part of expression,




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

* Re: Maxima code blocks does not work in windows revisited
  2022-11-02 15:17       ` Max Nikulin
@ 2022-11-02 20:11         ` Leo Butler
  2022-11-03  2:35           ` Max Nikulin
  2022-11-03  6:08         ` Ihor Radchenko
  2022-11-03  6:09         ` Ihor Radchenko
  2 siblings, 1 reply; 9+ messages in thread
From: Leo Butler @ 2022-11-02 20:11 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode@gnu.org

On Wed, Nov 02 2022, Max Nikulin <manikulin@gmail.com> wrote:

> On 02/11/2022 11:47, Ihor Radchenko wrote:
>>>> (for reference, this email is a followup of
>>>> https://orgmode.org/list/CA+ikm3wqA33xP4c3pVV+F2a-gn0dbEzsdx6Vf2cRd+37+u6pBA@mail.gmail.com)
>
> Ihor, you recently applied an alternative patch to Org main
> branch. Emacs tree still has ob-maxima.el with single quotes around
> batchload.
>
> Nikolay Kudryavtsev. Re: [PATCH] ob-maxima.el: Fix execution on MS
> Windows. Thu, 30 Dec 2021 23:54:10 +0300. 
> https://list.orgmode.org/8cd49b4c-9342-a77f-d665-402c41432b57@gmail.com
>
>> diff --git a/lisp/ob-maxima.el b/lisp/ob-maxima.el
>> index dba12d7b6..52423db18 100644
>> --- a/lisp/ob-maxima.el
>> +++ b/lisp/ob-maxima.el
>> @@ -84,7 +84,7 @@ (defun org-babel-execute:maxima (body params)
>>  		(cmd (format "%s --very-quiet -r %s$ %s"
>>  			     org-babel-maxima-command
>>                               (shell-quote-argument
>> -                              (format "batchload(%S)" in-file))
>> +                              (format "\"batchload(\\\"%S\\\")\"" in-file))
>
> Notice that code in the message you cited has "%s" and does not have
> `shell-quote-argument'. Extra quotes may discard effect of existing 
> double pass escaping.

Yes, OP should try this solution first. If it fails, then there is
some problem in `shell-quote-argument' that needs to be fixed.

My 2c.
Leo

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

* Re: Maxima code blocks does not work in windows revisited
  2022-11-02 20:11         ` Leo Butler
@ 2022-11-03  2:35           ` Max Nikulin
  2022-11-03 10:01             ` Fraga, Eric
  0 siblings, 1 reply; 9+ messages in thread
From: Max Nikulin @ 2022-11-03  2:35 UTC (permalink / raw)
  To: emacs-orgmode

On 03/11/2022 03:11, Leo Butler wrote:
> On Wed, Nov 02 2022, Max Nikulin wrote:
> 
>> On 02/11/2022 11:47, Ihor Radchenko wrote:
>>>>> (for reference, this email is a followup of
>>>>> https://orgmode.org/list/CA+ikm3wqA33xP4c3pVV+F2a-gn0dbEzsdx6Vf2cRd+37+u6pBA@mail.gmail.com)
>>
>> Ihor, you recently applied an alternative patch to Org main
>> branch. Emacs tree still has ob-maxima.el with single quotes around
>> batchload.
>>
>> Nikolay Kudryavtsev. Re: [PATCH] ob-maxima.el: Fix execution on MS
>> Windows. Thu, 30 Dec 2021 23:54:10 +0300.
>> https://list.orgmode.org/8cd49b4c-9342-a77f-d665-402c41432b57@gmail.com
>>
>>> diff --git a/lisp/ob-maxima.el b/lisp/ob-maxima.el
>>> index dba12d7b6..52423db18 100644
>>> --- a/lisp/ob-maxima.el
>>> +++ b/lisp/ob-maxima.el
>>> @@ -84,7 +84,7 @@ (defun org-babel-execute:maxima (body params)
>>>   		(cmd (format "%s --very-quiet -r %s$ %s"
>>>   			     org-babel-maxima-command
>>>                                (shell-quote-argument
>>> -                              (format "batchload(%S)" in-file))
>>> +                              (format "\"batchload(\\\"%S\\\")\"" in-file))
>>
>> Notice that code in the message you cited has "%s" and does not have
>> `shell-quote-argument'. Extra quotes may discard effect of existing
>> double pass escaping.
> 
> Yes, OP should try this solution first. If it fails, then there is
> some problem in `shell-quote-argument' that needs to be fixed.

To be clear. I believe that Mati should try the code from the Org "main" 
branch, not the patch Ihor posted in this thread. If I got it correctly, 
Mati currently has some problems with plots, ghostscript, etc.

Is there anything wrong with the following command (I am unsure 
concerning Temp location)? If so, what is the proper escaping for 
cmd.exe+maxima?

(let ((system-type 'ms-dos)
       (org-babel-maxima-command "maxima")
       (in-file "c:\\Temp\\maxima-XXXXXX.max")
       (cmdline ""))
   (message
    "%s"
    (format "%s --very-quiet -r %s$ %s"
	   org-babel-maxima-command
	   (shell-quote-argument
	    (format "batchload(%S)" in-file))
	   cmdline)))

maxima --very-quiet -r "batchload(\"c:\\Temp\\maxima-XXXXXX.max\")"$

(there is a trailing space)




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

* Re: Maxima code blocks does not work in windows revisited
  2022-11-02 15:17       ` Max Nikulin
  2022-11-02 20:11         ` Leo Butler
@ 2022-11-03  6:08         ` Ihor Radchenko
  2022-11-03  6:09         ` Ihor Radchenko
  2 siblings, 0 replies; 9+ messages in thread
From: Ihor Radchenko @ 2022-11-03  6:08 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode

Max Nikulin <manikulin@gmail.com> writes:

> On 02/11/2022 11:47, Ihor Radchenko wrote:
>>>> (for reference, this email is a followup of
>>>> https://orgmode.org/list/CA+ikm3wqA33xP4c3pVV+F2a-gn0dbEzsdx6Vf2cRd+37+u6pBA@mail.gmail.com)
>
> Ihor, you recently applied an alternative patch to Org main branch. 
> Emacs tree still has ob-maxima.el with single quotes around batchload.
>
> Nikolay Kudryavtsev. Re: [PATCH] ob-maxima.el: Fix execution on MS 
> Windows. Thu, 30 Dec 2021 23:54:10 +0300. 
> https://list.orgmode.org/8cd49b4c-9342-a77f-d665-402c41432b57@gmail.com

Thanks for pointing this out!
I do not use Windows, so it is hard to check how things are there. I
assumed that the report herein is not the latest main, which may or may
not be the case.

-- 
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] 9+ messages in thread

* Re: Maxima code blocks does not work in windows revisited
  2022-11-02 15:17       ` Max Nikulin
  2022-11-02 20:11         ` Leo Butler
  2022-11-03  6:08         ` Ihor Radchenko
@ 2022-11-03  6:09         ` Ihor Radchenko
  2 siblings, 0 replies; 9+ messages in thread
From: Ihor Radchenko @ 2022-11-03  6:09 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode

Max Nikulin <manikulin@gmail.com> writes:

> On 02/11/2022 11:47, Ihor Radchenko wrote:
>>>> (for reference, this email is a followup of
>>>> https://orgmode.org/list/CA+ikm3wqA33xP4c3pVV+F2a-gn0dbEzsdx6Vf2cRd+37+u6pBA@mail.gmail.com)
>
> Ihor, you recently applied an alternative patch to Org main branch. 
> Emacs tree still has ob-maxima.el with single quotes around batchload.
>
> Nikolay Kudryavtsev. Re: [PATCH] ob-maxima.el: Fix execution on MS 
> Windows. Thu, 30 Dec 2021 23:54:10 +0300. 
> https://list.orgmode.org/8cd49b4c-9342-a77f-d665-402c41432b57@gmail.com

Thanks for pointing this out!
I do not use Windows, so it is hard to check how things are there. I
assumed that the report herein is on the latest main, which may or may
not be the case.

-- 
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] 9+ messages in thread

* Re: Maxima code blocks does not work in windows revisited
  2022-11-03  2:35           ` Max Nikulin
@ 2022-11-03 10:01             ` Fraga, Eric
  2022-11-03 15:54               ` Max Nikulin
  0 siblings, 1 reply; 9+ messages in thread
From: Fraga, Eric @ 2022-11-03 10:01 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode@gnu.org

On Thursday,  3 Nov 2022 at 09:35, Max Nikulin wrote:
> maxima --very-quiet -r "batchload(\"c:\\Temp\\maxima-XXXXXX.max\")"$


Should the $ not be within the quotes?
-- 
: Eric S Fraga, with org release_9.5.5-853-g7b9d8e in Emacs 29.0.50

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

* Re: Maxima code blocks does not work in windows revisited
  2022-11-03 10:01             ` Fraga, Eric
@ 2022-11-03 15:54               ` Max Nikulin
  0 siblings, 0 replies; 9+ messages in thread
From: Max Nikulin @ 2022-11-03 15:54 UTC (permalink / raw)
  To: emacs-orgmode

On 03/11/2022 17:01, Fraga, Eric wrote:
> On Thursday,  3 Nov 2022 at 09:35, Max Nikulin wrote:
>> maxima --very-quiet -r "batchload(\"c:\\Temp\\maxima-XXXXXX.max\")"$
> 
> Should the $ not be within the quotes?

Does "$" have any special meaning in cmd.exe? I do not mind that it 
should be inside `format' first argument.

I do not have a Windows machine to test and not motivated enough to try 
Emacs in wine.

P.S. To avoid tricky escaping I strongly prefer direct exec to shell 
commands. Unfortunately as soon as TRAMP is involved, shell is the only 
option. Ssh supports command strings only and passes them to shell.




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

end of thread, other threads:[~2022-11-03 15:55 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-10 19:48 Maxima code blocks does not work in windows revisited Juan Alvaro Fuentes
2014-07-27 23:07 ` Bastien
  -- strict thread matches above, loose matches on Subject: below --
2022-11-01  7:45 [O] " Mati
2022-11-01  8:04 ` Ihor Radchenko
2022-11-01 10:34   ` Mati
2022-11-02  4:47     ` Ihor Radchenko
2022-11-02 15:17       ` Max Nikulin
2022-11-02 20:11         ` Leo Butler
2022-11-03  2:35           ` Max Nikulin
2022-11-03 10:01             ` Fraga, Eric
2022-11-03 15:54               ` Max Nikulin
2022-11-03  6:08         ` Ihor Radchenko
2022-11-03  6:09         ` Ihor Radchenko

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).