I installed emacs C# mode.
The .emacs file is as follows
(require 'csharp-mode)
(setq auto-mode-alist
(append '(("\\.cs$" . csharp-mode)) auto-mode-alist))
(defun my-csharp-mode-fn ()
"function that runs when csharp-mode is initialized for a buffer."
(setq default-tab-width 4)
)
(add-hook 'csharp-mode-hook 'my-csharp-mode-fn t)
It works pretty fine, but I see the block ({..}) is aligned what I intended. I mean, in some cases I have this.
private static int StringCompare(string x, string y)
{
int result;
if (x == null)
{
}
}
when I expect this
private static int StringCompare(string x, string y)
{
int result;
if (x == null)
{
}
}
Together with this, I always have 2 indentation for the code, but I want it to be 4.
My questions are
- How can I control the indentation in C# emacs mode?
- How can I control the '{' and '}' to have the same indentation as it's previous code.
- Does C# mode provide compilation to generate exe/dll file within the editor with commands?
I use emacs C# mode on Mac OS X/mono.
ADDED
I found that C# mode can also use C mode, so M-x c-set-style works, and awk style just works for me. The problem is that I have to turn on awk mode whenever I use c mode. Is there a way to run "M-x c-set-style and awk" mode automatically with c mode?