问题
I happen to know mono's CSharpRepl, are there emacs csharp mode that use this to run REPL in one window, and compile/run the C# code in the other window just like python mode?
回答1:
You could just create a lisp function to call the CSharpRepl and assign a key to call it when you're working on C# code. For example, you could put the following in your Emacs init file (assuming the CSharpRepl executable "csharp" is in your PATH):
(defun csharp-repl ()
"Open a new side-by-side window and start CSharpRepl in it."
(interactive)
(split-window-side-by-side)
(other-window 1)
(comint-run "csharp"))
(global-set-key [f11] 'csharp-repl)
So, if you're editing a C# program (using whatever mode you prefer), you can now press F11 and the CSharpRepl will open up in a new window so that you can interactively evaluate C# code.
回答2:
A slight addition to the accepted answer. Brings up an existing buffer if it exists.
(defun csharp-repl ()
"Switch to the CSharpRepl buffer, creating it if necessary."
(interactive)
(let ((buf (get-buffer "*csharp*")))
(if buf
(pop-to-buffer buf)
(progn
(split-window)
(other-window 1)
(comint-run "csharp")))))
(define-key csharp-mode-map (kbd "C-c C-z") 'csharp-repl)
来源:https://stackoverflow.com/questions/6207068/csharprepl-emacs-integration