[Mono-list] C# & emacs?

Martin Baulig martin@gnome.org
07 Dec 2002 15:29:36 +0100


Tim Haynes <thaynes@openlinksw.com> writes:

> "Rodrigo Poblanno Balp" <balpo@gmx.net> writes:
> 
> > Where should I copy my new .el files if I'm using Linux? The Readme.txt
> > that's included in the CMode3.zip only has instructions
> > for the Windows OS, cause in Linux there's no C:\Emacs
> 
> Somewhere in your `load-path', I would have said :)
> 
> Personally I set aside a ~/elisp/ directory for misc *.el files, and
> reference it with
> 
>   (add-to-list 'load-path "~/elisp")
> 
> in ~/.emacs.
> 
> You might also want to byte-compile the files for speed of loading.

I don't like the CMode3.zip very much since it just overrides the cc-mode files rather
than doing it cleanly.  You may want to use the other emacs mode from http://davh.dk/script/.

It is just one single file which works together with your existing cc-mode.

I'm also using a few local customizations in my ~/.emacs, don't know whether all of them
are still needed, but they may fix some indentation problems.

====
(defconst mono-csharp-attrib-key
  (concat "\[" c-symbol-key "\\(([^)]*)\\)?\]"))
(defconst mono-csharp-class-protection-key
  "\\(new\\|public\\|protected\\|internal\\|private\\|abstract\\|sealed\\)")
(defconst mono-csharp-class-parent-key
  (concat
   "\\(\\s +:\\s *" c-symbol-key
      "\\(\\s *,\\s *" c-symbol-key "\\)*"
   "\\)*"))

(defconst mono-csharp-class-key
  (concat
   "\\(" mono-csharp-attrib-key "\\)?"
   "\\(" mono-csharp-class-protection-key "\\s +\\)*"
   "\\(struct\\|class\\)\\s +"
   c-symbol-key
   "\\(" mono-csharp-class-parent-key "\\)?"))

(c-add-style "MonoC#Style"
	     '("C#"
	       (c-basic-offset . 8)
	       (c-comment-only-line-offset . 0)
	       (c-hanging-braces-alist . ((brace-list-open)
					  (brace-entry-open)
					  (substatement-open after)
					  (block-close . c-snug-do-while)))
	       (c-cleanup-list . (brace-else-brace))
	       (c-offsets-alist . (
				   (c                     . c-lineup-C-comments)
				   (inclass		  . 0)
				   (namespace-open	  . 0)
				   (namespace-close	  . 0)
				   (innamespace           . +)
				   (class-open		  . 0)
				   (class-close	          . 0)
				   (inclass		  . +)
				   (block-open            . 0)
				   (block-close           . 0)
				   (defun-open		  . 0)
				   (defun-block-intro     . +)
				   (defun-close           . 0)
				   (inline-open	          . 0)
				   (inline-close          . 0)
				   (statement-block-intro . +)
				   (brace-list-intro      . +)
				   ))
	       ))

(defun mono-csharp-mode-hook ()
  (cond (window-system
	 (turn-on-font-lock)
	 (c-set-style "MonoC#Style")
	 (setq c-class-key mono-csharp-class-key)
	 )))
(add-hook 'csharp-mode-hook 'mono-csharp-mode-hook)
(setq auto-mode-alist
      (append '(
		("\\.cs$" . csharp-mode)
		) auto-mode-alist ))
=====


-- 
Martin Baulig
martin@gnome.org