4 ms·
Do it!
by sesuximo 6y ago
Do it!
- heinrichhartman 6y agoActually. I just added something similar to my emacs yesterday: (defun sh-line () (interactive) (let ((cmd (buffer-substring-no-properties (line-beginning-position) (line-end-position)))) (end-of-line) (newline) (insert (shell-command-to-string cmd)))) (local-set-key (kbd "M-RET") 'sh-line) With this Alt-RET will evaluate the last line in your shell, and insert the output.
- snazz 6y agoIt is worth mentioning that Emacs is a wee bit easier to script than notepad.exe :)
- TeMPOraL 6y agoSpeaking of Emacs, shells and WSL, I recently had to shell out from Emacs under WSL to git-bash under Windows proper, to run cmake to run MSBuild, and get the generation/compilation output all the way back. Turns out, while regular M-x shell-command would work, M-x async-shell-command (i.e. shell-command with appended &) would not - it wasn't able to communicate with the spawned process. I needed it to be async so that a compile wouldn't block my Emacs. The solution I came up with is a bit lower-level, looks like this: (make-process :name "some_name" :buffer "buffer" :command ("cmd" "to" "run") :connection-type 'pipe :coding 'utf-8-dos) Two key lines are :connection-type 'pipe, which solves the I/O issues, and :coding 'utf-8-dos, which ensures the output streamed to an Emacs buffer isn't polluted by ^M (CR from CRLF line ending). Now, if anyone figured out how to configure a connection to a language server across the WSL boundary, I'm all ears.
- heinrichhartman 6y agoDoes `M-x compile` not work for you on windows? This is what I use to do run build scripts async.
- jsrcout 6y agoThank you! Macintosh MPW had a very similar feature back in the day, it rocked. Haven't seen it since. Added to my .emacs!