Macaulay2 in VSCode, slight settings improvement

141 views
Skip to first unread message

KSchwede

unread,
May 17, 2020, 3:42:57 PM5/17/20
to Macaulay2
Hi all,

I realized something that I think others might find useful.

If you are using VSCode, and perhaps using the Macaulay2 extension by correysharris, hitting F12 will start a terminal and run Macaulay2 in it (if configured).  Hitting alt-enter will copy the current line to the terminal (like F11 in emacs).  

But there is another option that you might find useful.  You can run the no windows version of Macaulay2 in emacs, in a vscode terminal.  

I created a simple bash script that runs 
emacs -nw -f M2
the -nw runs emacs in tty (non-windows) mode.  The -f M2 runs Macaulay2 on startup.
Then is vscode's settings, I pointed the macaulay2 executable location to that bash script (ctrl+,  then search for macaulay2)
(probably it would be better if the command line arguments were exposed to the user in the vscode macaulay2 package, but this works fine for now).

Additionally, I added the lines
 (add-hook 'emacs-startup-hook
          (lambda () (delete-other-windows)) t)
 (unless (display-graphic-p)
   (menu-bar-mode -1))
to my .emacs file in my home directory so that Macaulay2 won't split the window in emacs when its first run, and so emacs won't have a menu bar in tty mode.

Anyways, here's a screenshot of what it looks like:

VSCodeM2Screenshot.png

These sorts of small hacks should also work in Mahrud's Macaulay2 interface for Atom.


KSchwede

unread,
May 17, 2020, 4:09:36 PM5/17/20
to Macaulay2
For some reason, the screenshot is small above (and doesn't get larger on my screen when I click on it), so I'm attaching it here as well.
VSCodeM2Screenshot.png

KSchwede

unread,
Apr 7, 2022, 2:17:13 PM4/7/22
to Macaulay2
One other quick comment.  

Recently there have been some changes in some vscode shortcuts, the following changes might help things behave slightly better.

You may want to turn off the Ctrl+UpArrow and Ctrl+DownArrow keyboard shortcuts for the terminal, as they don't do the right thing in emacs (and the terminal captures them and doesn't send them to emacs).  

Also, you might want to adjust  
Terminal › Integrated: Allow Chords
as this lets things like Ctrl+k go to the terminal (so you can cut a line for instance) and not be capture by vscode.

Reply all
Reply to author
Forward
0 new messages