CSharpRepl emacs integration?

那年仲夏 提交于 2019-12-07 09:43:47

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!