.emacs-my
changeset 713 e321e3b0c550
parent 709 2cb49be54b21
parent 712 b54c2306b184
child 714 29d5bc4953c6
--- a/.emacs-my	Fri Sep 30 01:01:49 2011 +0300
+++ b/.emacs-my	Fri Sep 30 18:24:32 2011 +0300
@@ -1488,13 +1488,16 @@
 (cwarn-mode 1)
 
 (setq c-echo-syntactic-information-p t)
-(add-hook 'c-mode-common-hook
- (lambda ()
-   ;; Automatically inserte newlines after special characters such as brace, comma, semi-colon, and colon.
-   (c-toggle-auto-newline -1)
-   ;; Delete all preceding whitespace by DEL.
-   (c-toggle-hungry-state -1)
-   ))
+
+(defun my-c-mode-common-hook ()
+  ;; Automatically inserte newlines after special characters such as brace, comma, semi-colon, and colon.
+  (c-toggle-auto-newline 1)
+  ;; Delete all preceding whitespace by DEL.
+  (c-toggle-hungry-state -1)
+  ;; Auto indent after typing colon according to `c-hanging-colons-alist'.
+  (c-toggle-electric-state 1)
+  )
+(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
 
 (defconst my-c-style
   '((c-tab-always-indent . t)
@@ -1520,6 +1523,7 @@
         ))
     (c-offsets-alist
      . (
+        (access-label . -)
         (arglist-intro . ++)
         (arglist-cont-nonempty . ++)
         (arglist-close . ++)
@@ -1540,20 +1544,19 @@
     (c-echo-syntactic-information-p . t))
   "My C Programming Style")
 
-(add-hook
- 'c-mode-common-hook
- '(lambda ()
-    (c-add-style "my" my-c-style t)
-    ;; If set 'c-default-style' before 'c-add-style'
-    ;; "Undefined style: my" error occured from 'c-get-style-variables'.
-    (setq c-default-style
-          '(
-            (java-mode . "my") (c-mode . "my") (csharp-mode . "my") (c++-mode . "my") (objc-mode . "my")
-            (idl-mode . "my")
-            (awk-mode . "awk")
-            (other . "my")
-            ))
-    ))
+(defun my-c-mode-style-hook ()
+  (c-add-style "my" my-c-style t)
+  ;; If set 'c-default-style' before 'c-add-style'
+  ;; "Undefined style: my" error occured from 'c-get-style-variables'.
+  (setq c-default-style
+        '(
+          (java-mode . "my") (c-mode . "my") (csharp-mode . "my") (c++-mode . "my") (objc-mode . "my")
+          (idl-mode . "my")
+          (awk-mode . "awk")
+          (other . "my")
+          ))
+  )
+(add-hook 'c-mode-common-hook 'my-c-mode-style-hook)
 
 ;;; ----------------------------------------------------------------
 (message "python")