revohour · 2022-06-30 09:19
I'm using emacs on WSL and I want to unify the emacs and windows clipboard. I can run power shell commands to interact with the windows clipboard and integrate it easily enough, but a new powershell instance each time is too slow, so I want one instance of powershell that I send commands to and get output from. I can program it myself with `start-process` I think but it'll be a pain, and it seems like not an uncommon thing to want to do, so my question is is whether there's something ready made for that kind of use case
7890yuiop · 2022-06-30 09:26
You could use a `M-x shell` session, and base your command on `comint-redirect-send-command`.
mickeyp · 2022-06-30 10:05
There's myriad ways. /u/7890yuiop is one way.
Here's another that's a bit more specific:
1. `M-x comint-run` to run `powershell.exe` or whatever it's called.
2. Use the following snippet to send commands:
(comint-redirect-send-command-to-process
"my command\n"
(get-buffer-create "*powershell output*")
(get-buffer-process "*powershell*")
nil)
You can replace `nil` with `t` if you want the command to echo in the `*powershell*` buffer.
Note the name of the buffer depends on the command; so you may have to tweak that.
Also, I don't know if powershell works with `\n` or if you need `\r\n` to properly terminate the command.
Finally, can you not use `w32-get/set-clipboard-data`?