Reputation: 476
I installed powershell package in emacs. I launched the powershell using M-x powershell. In the powershell window, I am able to run command like ls etc, but I am not able to execute powershell scripts. I tried to use cmd as a default shell in emacs and execute the powershell script from it as described here;
but it freezes. Similarly, when I am try to run vim in powershell/cmd within emacs it freezes. I want to point out that scripts and vim is working fine in powershell and cmd, if I am running it outside emacs.
Upvotes: 0
Views: 1372
Reputation: 2685
In M-x powershell
and M-x shell
, the terminal is "dumb" and only understands programs that print, but not programs that go fullscreen.
So, it will work with ls
, cat
, and cd
, but will fail on vim
, man
, and less
. I bet your script tries to open vim
, no?
This restriction exists for a reason: when a program goes fullscreen, it captures all keyboard input. So if you open vim
and type C-x
, does it run the Emacs command for C-x
or the Vim command? If you always run the Emacs command, that means when you type j
, it will insert j
into the Emacs buffer instead of scrolling down in Vim. Vim will become unusable. If you always run the Vim command, that means you can no longer use C-x C-c
to get out of Emacs, since the command will be absorbed by Vim.
One workaround is to use M-x term
. In term
all keystrokes are sent to the program, so you can open and use Vim like normal. To run an Emacs command, start with C-c
. You can read more about it here. I'm not sure it it exists in Windows.
Another workaround to use emacsclient
:
;; in init.el
(server-start)
# in a shell
$ emacsclient file.txt
This will open the file in your existing Emacs window. When you're done editting the file, press C-x #
to go back to the shell.
Upvotes: 1