riscy / shx-for-emacs

An Emacs shell-mode (and comint-mode) extension that enables displaying small plots and graphics and lets users write shell commands in Emacs Lisp.
GNU General Public License v3.0
218 stars 10 forks source link

Fix gnuplot commands under Windows build of Emacs #17

Closed p3r7 closed 4 years ago

p3r7 commented 4 years ago

Plotting shell commands can work under the Windows build of Emacs.

One requirement of course is to have gnuplot installed (either through MSYS or Cygwin, both got tested).

There is just a small specificity that would need to be changed to make shx compatible with this setup.

It has to do with quoting inside shx-insert-plot:

This line:

plot-command " \"" (shell-quote-argument filename) "\" "

Would have to be conditionally replaced with:

plot-command " " (shell-quote-argument filename) " "

This might have to do with the way shell-quote-argument behaves under windows:

(shell-quote-argument "aa")             ; => "\"aa\""

I've also attempted to play around with the value of w32-quote-process-args but did not end up with anything that works.

riscy commented 4 years ago

Interesting. Let me confirm whether the \" are even necessary in unixlike environments -- maybe they can be dropped entirely!

riscy commented 4 years ago

Double-checked and the \" are indeed necessary in unixlike environments. I think it's not too big of a hassle to add windows detection for these -- stay tuned.

riscy commented 4 years ago

I figure any unescaped " at the start or beginning of the string can safely be removed, so the fix turned out to be relatively simple -- I don't have a Windows PC to test on, but maybe this works for you?

p3r7 commented 4 years ago

I'll test it during the day. Thanks!

p3r7 commented 4 years ago

Tested under windows with filenames with and without spaces.

Both situations work.