JoeRiel / maplev

Emacs mode for Maple
Other
13 stars 4 forks source link

Issues while installing. Symbol's value as variable is void: ’load-path #4

Open eedahl opened 6 years ago

eedahl commented 6 years ago

I'm trying to install this mode, but I'm having a couple issues. I pasted the contents of src/ into .emacs.d/maple and ran byte-recompile-directory on the folder, but emacs skipped all the files. I also tried to force it, but it didn't help.

Adding this to my init.el


(autoload ’maplev-mode "maplev" "Maple editing mode" ’interactive)
(setq auto-mode-alist
    (cons ‘("\\.mpl\\’" . maplev-mode) auto-mode-alist))```
I get the following error: Symbol's value as variable is void: ’load-path

I'm using GNU Emacs 25.3.1 (x86_64-w64-mingw32) with Spacemacs.
JoeRiel commented 6 years ago

The elisp function byte-recompile-directory, by default, only recompiles files that have already been compiled (have a .elc). Use C-u 0 M-x byte-recompile-directory.

Where is this init.el file? I'll assume that's your emac initialization file (I use .emacs). That load-path is not assigned seems strange. Did you try (add-to-list 'load-path (concat user-emacs-directory "maple"))?

eedahl commented 6 years ago

All right, I got the compilation to start, albeit with questioning luck:

Compiling file d:/Dropbox/dev/.emacs.d/maple/button-lock.el at Tue May 29 19:35:19 2018

Compiling file d:/Dropbox/dev/.emacs.d/maple/maplev-cmaple.el at Tue May 29 19:35:21 2018
maplev-cmaple.el:38:1:Error: Cannot open load file: No such file or directory, maplev-config

Compiling file d:/Dropbox/dev/.emacs.d/maple/maplev-common.el at Tue May 29 19:35:33 2018
maplev-common.el:11:1:Error: Cannot open load file: No such file or directory, maplev-custom

Compiling file d:/Dropbox/dev/.emacs.d/maple/maplev-config.el at Tue May 29 19:35:39 2018

Compiling file d:/Dropbox/dev/.emacs.d/maple/maplev-custom.el at Tue May 29 19:35:40 2018
maplev-custom.el:10:1:Error: Cannot open load file: No such file or directory, maplev-config

Compiling file d:/Dropbox/dev/.emacs.d/maple/maplev-help.el at Tue May 29 19:35:41 2018
maplev-help.el:10:1:Error: Cannot open load file: No such file or directory, maplev-re

Compiling file d:/Dropbox/dev/.emacs.d/maple/maplev-history.el at Tue May 29 19:35:42 2018
maplev-history.el:21:1:Error: Cannot open load file: No such file or directory, maplev-custom

Compiling file d:/Dropbox/dev/.emacs.d/maple/maplev-indent.el at Tue May 29 19:35:43 2018
maplev-indent.el:27:1:Error: Cannot open load file: No such file or directory, maplev-custom

Compiling file d:/Dropbox/dev/.emacs.d/maple/maplev-mint.el at Tue May 29 19:35:43 2018
maplev-mint.el:10:1:Error: Cannot open load file: No such file or directory, maplev-config

Compiling file d:/Dropbox/dev/.emacs.d/maple/maplev-re.el at Tue May 29 19:35:44 2018

Compiling file d:/Dropbox/dev/.emacs.d/maple/maplev-sb.el at Tue May 29 19:35:44 2018
maplev-sb.el:43:1:Error: Cannot open load file: No such file or directory, maplev-re

Compiling file d:/Dropbox/dev/.emacs.d/maple/maplev-trace.el at Tue May 29 19:35:45 2018

Compiling file d:/Dropbox/dev/.emacs.d/maple/maplev-utils.el at Tue May 29 19:35:46 2018
maplev-utils.el:10:1:Error: Cannot open load file: No such file or directory, maplev-re

Compiling file d:/Dropbox/dev/.emacs.d/maple/maplev-version.el at Tue May 29 19:35:46 2018

Compiling file d:/Dropbox/dev/.emacs.d/maple/maplev-view.el at Tue May 29 19:35:47 2018
maplev-view.el:10:1:Error: Cannot open load file: No such file or directory, maplev-config

Compiling file d:/Dropbox/dev/.emacs.d/maple/maplev-warn.el at Tue May 29 19:35:47 2018
maplev-warn.el:55:1:Error: Cannot open load file: No such file or directory, maplev-custom

Compiling file d:/Dropbox/dev/.emacs.d/maple/maplev.el at Tue May 29 19:35:48 2018
maplev.el:107:1:Error: Cannot open load file: No such file or directory, button-lock

Compiling file d:/Dropbox/dev/.emacs.d/maple/ob-maple.el at Tue May 29 19:35:48 2018
ob-maple.el:30:1:Error: Cannot open load file: No such file or directory, maplev

My init.el is in my .emacs.d folder. I think I was having problems with user-emacs-directory too so that's why I used ~/.emacs.d/maple, though i see now I forgot to paste that in above, so like so:

(add-to-list ’load-path (concat user-emacs-directory "maple")) ;; or 'loadpath "~/.emacs.d/maple"
(autoload ’maplev-mode "maplev" "Maple editing mode" ’interactive)
(setq auto-mode-alist
    (cons ‘("\\.mpl\\’" . maplev-mode) auto-mode-alist))

I don't know if this is a Spacemacs thing. I have standard emacs with the .emacs.d provided by Spacemacs, installed a Rust layer, put your source files in a maple directory, did the recompile (failing at first) and then added the previous lines to init.el, trying a couple different places in there and in ~/.spacemacs. Running with --debug-init this is what i get: Screenshot from Gyazo

JoeRiel commented 6 years ago

If load-path is a void-variable, I'd think your setup has serious issues. Not sure that can even happen; load-path is defined in C-code. Try executing C-h v load-path.

eedahl commented 6 years ago

Yeah I see how that's a problem. It's not void when running C-h v load-path so I don't know what that's about. I'll see if I can figure something out in Spacemacs' chat, and if not it's probably about time to configure my own emacs because this doesn't seem like an issue with MapleV.

eedahl commented 6 years ago

It seems to be the issue was that copy-pasting from the PDF gave a non-ascii quote that emacs didn't recognise. Would never have caught that in a million years but there it is. And now it compiled with no issues.

My only remaining issue is configuration. The docs are telling me to modify maplev-executable-alist, but I [can't find anything quite like it](Screenshot from Gyazo). I'm guessing something like needs to go somewhere:

'(maplev-executable-alist
    ("maple13 "C:/Program Files (x86)/Maple 13/bin.win/cmaple.exe" nil "C:/Program Files (x86)/Maple 13/bin.win/mint.exe")
    ("maple2018" "C:/Program Files/Maple 2018/bin.X86_64_WINDOWS/cmaple.exe" nil "C:/Program Files/Maple 2018/bin.X86_64_WINDOWS/mint.exe"))

but putting it in manually in the config file doesn't work/breaks a lot of things.

JoeRiel commented 6 years ago

Ah that makes sense. I should have thought of that (having load-path be a void-variable is crazy, but having something that looks like load-path is understandable). On careful inspection I can see that the quote in your posted elisp is wrong. Thanks for letting me know. I'll add a warning to the PDF.

eedahl commented 6 years ago

A warning makes sense! I don't know if there's a way to enforce a particular single-quote in the texi->latex pipeline but that might also work.

Indeed it is, thanks! That does explain the complete explosion, but not quite why I can't seem to find maplev-executable-alist in the customisation options. It would be looking for something like

'(maplev-executable-alist
    ("maple13" "C:/Program Files (x86)/Maple 13/bin.win/cmaple.exe" nil "C:/Program Files (x86)/Maple 13/bin.win/mint.exe")
    ("maple2018" "C:/Program Files/Maple 2018/bin.X86_64_WINDOWS/cmaple.exe" nil "C:/Program Files/Maple 2018/bin.X86_64_WINDOWS/mint.exe"))

plus-or-minus single-quotes in front of the list entries right? I'll take a closer look at it.

JoeRiel commented 6 years ago

I got rid of maplev-executable-alist, mainly because I almost never use different versions of maple, and when I do, prefer to do so by project. That can now be handled with maplev-config, which I put in a project dependent .maplev file.

eedahl commented 6 years ago

Okay that makes a certain kind of sense, though it's unclear to me how to set this up using maplev-config and .maplev. I use different versions since I use many different machines and it varies which versions I have available, where they are, (and which versions compile my code without errors), but my emacs is the same via Dropbox.

JoeRiel commented 6 years ago

When maplev-mode is executed in a buffer, by default it will search backwards through the file hierarchy, starting from the file associated with the buffer, for a .maplev file, which, if it finds, it will then load (it assumes it is an elisp file). For my setup, a typical .maplev file is

(let ((proj-root "/home/joe/maple/Bark"))
  (maplev-config
   :maple-options "-B -A2 -e2"  ; configure libname and error/warning levels of Maple 
   :mint-options "-l -V -D MINTONLY"        ; -l: ignore leading underscore; -V: verbose (in smint)
   :include-path (list "/home/joe" proj-root)      ; add proj-root to the include path for Maple and Mint 
   :compile (format "make -C %s mla-install" proj-root)))

To select a particular maple executable and mint executable, you would use the :maple and :mint slots. See help for maplev-config.

JoeRiel commented 6 years ago

Apologies, I missed the (old) references to maplev-executables-alist in the doc. Will remove those and add some comments indicating the change.

eedahl commented 6 years ago

Ok, very nice! Might be worthwhile to add an example file like the one above for emacs noobs like myself. I don't remember seeing one. I'll play around with it, thank you. The plugin seems very nice so far I must say, and I'm looking forward to seeing it in action with these last issues worked out.

Not related to my setup issues, but I'm curious if it's possible to extend syntax highlighting to library functions (like Tensor and DifferentialGeometry). This is likely already explained in the docs so I'll take a look. I don't know if it already does it, but it seems like syntax highlighting and/or maybe even piping the output through a LaTeX preview like the one you get in org-mode should be possible? if not very practical, it seems reasonably useful for very complicated outputs.

JoeRiel commented 6 years ago

Look in Chapter 9 of the maplev manual. I need better links to it from the start.
What sort of syntax highlighting do you have in mind, for Tensor and DiffGeom? Particular exports? An interesting option might be to have an elisp command that automatically highlights all exports of a particular Maple package. Implementing it in a clean manner might be a trick (the interaction with maple is the fun part). Note that included in this release is ob-maple, which provides some very crude interaction with org-mode. Not for prettyprinting, but for piping commands through. I didn't describe it in the manual 'cause it's a work in progress (very slow progress).

eedahl commented 6 years ago

The pdf could perhaps also benefit from a ToC if it's possible.

I'm thinking about particular exports -- what I do in VS Code is to go to the online Maple docs and take all available functions from a given module. Automatic highlights to all exports of a package would be pretty cool. I have no idea how you would get a list of exports like that, but if something like providing the names of libraries you want highlighting for was possible, (or even lookup for with(lib) commands?) that would be really nice. In which case it may make sense to keep imports and standard functions different colours so they stand out. At least in my code the library functions tend to do most of the heavy lifting so it's nice when they pop out.

With tensors there are infix operators &t, &s and &w as well which tend to bleed into the sea of summands since most tensor expressions don't have a lot of highlighting. Ideally I'd present them as the usual tensor products, a dot and wedge respectively but that may be too much (though could maybe be accomplished with glyphs). I probably like an unusual amount of highlighting, which is part of why I want to use emacs to being with. I can probably figure some of this out from chapter 9.

Org mode interaction seems potentially pretty cool. Perhaps it's possible to use Maple's LaTeX commands and call C-u C-u org-preview-latex-fragment on the output buffer for particularly nasty output.

JoeRiel commented 6 years ago

There is a ToC, it's at the back. That's how texi2pdf typically generates ToCs, it avoids have to process the file twice to compute the page references. I use xpdf as my pdf reader and it's left panel more or less serves as the ToC.

Displaying neutral operators as special characters is an interesting idea, though there is some danger to it. I'll look into providing hooks to make it possible.

eedahl commented 6 years ago

That makes sense enough, especially if you're coming from French math haha.

Nice! What dangers are you anticipating? I suppose it's the kind of thing that should be up to each particular user and even then used sparingly.

JoeRiel commented 6 years ago

Changing source code on-the-fly, even if only for viewing, means you're never sure what is really there. It's sort of like the issue you had with the forward-quote (bad example). Also, it might mess with some maplev mint commands that use the line number and character position from mint, which must use the real source.

eedahl commented 6 years ago

Ah so it couldn't be a pure view sort of thing, I was under the impression that it was possible to decouple it from the source code by using glyphs or perhaps this. But yeah as you point out even then it might be a little bit iffy. 2D math anyone?

JoeRiel commented 6 years ago

Possibly prettify-symbols-mode could be used. I'll put it on my list of things to look into. Thanks for the suggestion.

eedahl commented 6 years ago

Glad you found it interesting. Thanks for being so helpful despite my general emacs cluelessness.

eedahl commented 6 years ago

This seems odd: I've (hopefully) set up my .maplev file in the project directory, but when trying to run the buffer with C-c C-c b I get the following message:

Usage: c:\Program Files (x86)\Maple 13\bin.win\mint.exe [-klqsSxv] [-a...] [-A...] [-b...] [-d...] [-D...] [-i...] [-I...] [-o...] [-t...] [-U...] [-w...] [file]

It looks like it's trying to run mint and passing it something weird when I ostensibly sent cmaple.exe my mpl file. My .maplev file looks like

(let ((proj-root "D:/Dropbox/dev/phd/CAS/pp_boost_xydep"))
  (maplev-config
   :maple "C:/Program Files (x86)/Maple 13/bin.win/cmaple.exe"
   :mint "C:/Program Files (x86)/Maple 13/bin.win/mint.exe"
   :mint-options "-l -V -D MINTONLY"
   :include-path (list "/" proj-root)
   ))
JoeRiel commented 6 years ago

In :mint-options change -V to -v. The -V is for smint, which is for Maplesoft developers (I'm one). Also you can elide the -D MINTONLY. That defines a macro which I use in Maple source that assigns code only when running mint. It's purpose is to silence various mint nags. Note that I ran into that error just a few days ago, so readily identified it. For no good reason smint uses -V rather than -v for verbose.

Note that if you aren't using $include statements in your Maple source, you don't need to assign :include-path, and thus could get rid of the let and proj-root stuff. But it doesn't hurt and will serve as a guide if you later use include statements.

Here's a tip, not sure if it is documented in the info. In any of your maple source files, you can add the comment, at the left margin #LINK somefile where somefile is a relative path to some file. That will hyperlink it in maplev-mode so clicking it opens the file. In my main maple project file I usually have a link to the associated .maplev file: #LINK ../.maplev and also one to the Makefile (which I use to build the library).

eedahl commented 6 years ago

Oh cool, I did not know that. It doesn't seem to fix it though, it's still giving me a usage message for mint when I'm trying to call cmaple.

Here is a proof of concept using prettify-symbols-vscode btw., and it seems like it could work pretty well: I have my cursor on one of the symbols where &t is shown: Screenshot from Gyazo

JoeRiel commented 6 years ago

Hmm. Alas I didn't provide an option to skip the call to mint, which it first does mainly because doing usually avoids a fair amount of grief. Try executing C-c b which only calls mint. I assume you'll get the same error. I need to add some code to improve debugging.

That output looks nice; I can see your motivation for wanting that. Am thinking you want to replace the sum's with add's [in the maple code].

eedahl commented 6 years ago

That explains why it's calling mint! Indeed running mint alone gives the same answer. If you end up pushing an update for that let me know and I'll see what comes out.

I did not know add existed and it seems to be just lazy enough to do what I've been trying to solve with single quotes, thanks!

eedahl commented 6 years ago

This may be a hint. I modified the mint.bat file and tried running from that

"C:\Program Files (x86)\Maple 13\bin.win\mint.exe" %1 %2 %3 %4 %5 %6 %7 %8 %9

so :mint "C:/Program Files (x86)/Maple 13/bin.win/mint.bat". It seems like it's not stripping the quotes, trying to pass the whole argument list as a single argument:

d:\Dropbox\dev\phd\CAS\pp_boost_xydep>"C:\Program Files (x86)\Maple 13\bin.win\mint.exe" "-q  -l -v -D MINTONLY -I D:/Dropbox/dev/phd/CAS/pp_boost_xydep"        
Usage: C:\Program Files (x86)\Maple 13\bin.win\mint.exe [-klqsSxv] [-a...] [-A...] [-b...] [-d...] [-D...] [-i...] [-I...] [-o...] [-t...] [-U...] [-w...] [file]

EDIT: Moving the last quote out of the path like so

"C:\Program Files (x86)\Maple 13\bin.win\mint.exe %1 %2 %3 %4 %5 %6 %7 %8 %9"

makes it clear that it's struggling to parse a -q that's added on to the settings provided by the .maplev file:

d:\Dropbox\dev\phd\CAS\pp_boost_xydep>"C:\Program Files (x86)\Maple 13\bin.win\mint.exe "-q -S -l -v -D MINTONLY -I D:/Dropbox/dev/phd/CAS/pp_boost_xydep"        " 
'"C:\Program Files (x86)\Maple 13\bin.win\mint.exe "-q' is not recognized as an internal or external command,
operable program or batch file.

I thought this might be a curiosity with older versions of Maple, but the same happens for 2018

d:\Dropbox\dev\phd\CAS\pp_boost_xydep>"C:\Program Files\Maple 2018\bin.X86_64_WINDOWS\mint.exe "-q  -l -v -D MINTONLY -I D:/Dropbox/dev/phd/CAS/pp_boost_xydep"        " 
'"C:\Program Files\Maple 2018\bin.X86_64_WINDOWS\mint.exe "-q' is not recognized as an internal or external command,
operable program or batch file.
JoeRiel commented 6 years ago

Yeah, that's undoubtedly the problem. Getting shell stuff to work on Windows is a pain. Are you using Windows 10? I use this on Windows 7 occasionally, will test out the current version on their later tonight. I don't have ready access to Maple 13, but suspect that won't matter.

eedahl commented 6 years ago

Yeah I'm using Windows 10. I tried it on Maple 2018 and it failed (see edit) so I'm assuming this is relatively version independent. I am using Maple 16 at the university office but I can't test that before Monday.

Edit: Strange thing, in the input above, sometimes there's an additional -S and sometimes there isn't.

JoeRiel commented 6 years ago

Found a solution that appears to work for both Linux and Windows. Need to do some more thorough testing to see whether it will allow spaces in include paths, which Windows user's are frequently stuck with.

eedahl commented 6 years ago

Nice, that was fast

eedahl commented 6 years ago

Did you manage to find time to test it? I'd like to try it out :)

JoeRiel commented 6 years ago

Yes. And it works. But there is a catch. I've hated, from day one, the internal design of the communication with Maple. It's a bodge, mainly because cmaple has a flaw; it doesn't handle prompts correctly when used non-interactively. I've wrestled with this for a long time and yesterday decided to redo the interface. Instead of communicating with cmaple, it will communicate with an OpenMaple binary that I'll provide. I've got that working here, on Linux; now I have to get it to work on Windows.

eedahl commented 6 years ago

This is honestly the first time I've hard of OpenMaple, but it nevertheless sounds very interesting. Would it mean new capabilities and features etc. in the long run?

JoeRiel commented 6 years ago

Not immediately, though there are some features I've meant to add but didn't because the Maple/Emacs connection was never reliable enough. If I get this right, it should be. Features such as highlighting the exports of a selected package. Actually, I have code in there to do that, but haven't used it in forever so don't expect that it works.

eedahl commented 6 years ago

Already there it looks to be blowing the VS Code plugin out of the water though. That's quite interesting. I'm looking forward to it.