dot-emacs: Fix the C mode hacking.
[profile] / dot-emacs.el
index 1d550d3..0376bad 100644 (file)
@@ -313,23 +313,26 @@ get itself into a twist."
 (defadvice write-file (after mdw-autorevert activate)
   (mdw-check-autorevert))
 
-(defun mdwmail-mode ()
+(define-derived-mode  mdwmail-mode mail-mode "[mdw] mail"
   "Major mode for editing news and mail messages from external programs
 Not much right now.  Just support for doing MailCrypt stuff."
-  (interactive)
-  (kill-all-local-variables)
-  (use-local-map text-mode-map)
-  (setq local-abbrev-table text-mode-abbrev-table)
-  (setq major-mode 'mdwmail-mode)
-  (setq mode-name "[mdw] mail")
-  (set-buffer-file-coding-system 'utf-8)
-  (make-local-variable 'paragraph-separate)
-  (make-local-variable 'paragraph-start)
-  (setq paragraph-start (concat "[ \t]*[-_][-_][-_]+$\\|^-- \\|-----\\|"
-                               paragraph-start))
-  (setq paragraph-separate (concat "[ \t]*[-_][-_][-_]+$\\|^-- \\|-----\\|"
-                                  paragraph-separate))
-  (run-hooks 'text-mode-hook 'mdwmail-mode-hook 'mail-setup-hook))
+  :syntax-table nil
+  :abbrev-table nil
+  (run-hooks 'mail-setup-hook))
+
+(define-key mdwmail-mode-map [?\C-c ?\C-c] 'disabled-operation)
+
+(add-hook 'mdwail-mode-hook
+         (lambda ()
+           (set-buffer-file-coding-system 'utf-8)
+           (make-local-variable 'paragraph-separate)
+           (make-local-variable 'paragraph-start)
+           (setq paragraph-start
+                 (concat "[ \t]*[-_][-_][-_]+$\\|^-- \\|-----\\|"
+                         paragraph-start))
+           (setq paragraph-separate
+                 (concat "[ \t]*[-_][-_][-_]+$\\|^-- \\|-----\\|"
+                         paragraph-separate))))
 
 ;; --- How to encrypt in mdwmail ---
 
@@ -556,10 +559,13 @@ doesn't cope with anything approximating a complicated case."
             (t
              (local-set-key "\C-m" 'newline-and-indent))))
   (local-set-key [C-return] 'newline)
+  (make-variable-buffer-local 'page-delimiter)
+  (setq page-delimiter "\f\\|^.*-\\{6\\}.*$")
   (setq comment-column 40)
   (auto-fill-mode 1)
   (setq fill-column 77)
   (setq show-trailing-whitespace t)
+  (outline-minor-mode t)
   (mdw-set-font))
 
 ;; --- Set up all sorts of faces ---
@@ -658,6 +664,30 @@ the regular expressions in `mdw-backup-disable-regexps'."
     (font-lock-keyword-face :weight bold)
     (font-lock-constant-face :weight bold)
     (font-lock-reference-face :weight bold)
+    (message-cited-text
+       :foreground ,(if window-system "SeaGreen1" "green")
+       :slant italic)
+    (message-separator :background "red" :foreground "white" :weight bold)
+    (message-header-cc
+       :foreground ,(if window-system "SeaGreen1" "green")
+       :weight bold)
+    (message-header-newsgroups
+       :foreground ,(if window-system "SeaGreen1" "green")
+       :weight bold)
+    (message-header-subject
+       :foreground ,(if window-system "SeaGreen1" "green")
+       :weight bold)
+    (message-header-to
+       :foreground ,(if window-system "SeaGreen1" "green")
+       :weight bold)
+    (message-header-xheader
+       :foreground ,(if window-system "SeaGreen1" "green")
+       :weight bold)
+    (message-header-other
+       :foreground ,(if window-system "SeaGreen1" "green")
+       :weight bold)
+    (message-header-name
+       :foreground ,(if window-system "SeaGreen1" "green"))
     (woman-bold :weight bold)
     (woman-italic :slant italic)
     (diff-index :weight bold)
@@ -696,6 +726,11 @@ the regular expressions in `mdw-backup-disable-regexps'."
 
 ;; --- Make C indentation nice ---
 
+(eval-after-load "cc-mode"
+  '(progn
+     (define-key c-mode-map "*" nil)
+     (define-key c-mode-map "/" nil)))
+
 (defun mdw-c-style ()
   (c-add-style "[mdw] C and C++ style"
               '((c-basic-offset . 2)
@@ -1556,6 +1591,41 @@ strip numbers instead."
           (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
                 '(0 mdw-punct-face))))))
 
+;;;----- Erlang configuration -----------------------------------------------
+
+(setq erlang-electric-commannds
+      '(erlang-electric-newline erlang-electric-semicolon))
+
+(defun mdw-fontify-erlang ()
+
+  ;; --- Set fill prefix ---
+
+  (mdw-standard-fill-prefix "\\([ \t]*{?%*[ \t]*\\)")
+
+  ;; --- Fiddle with fontification ---
+
+  (make-local-variable 'font-lock-keywords)
+  (let ((erlang-keywords
+        (mdw-regexps "after" "and" "andalso"
+                     "band" "begin" "bnot" "bor" "bsl" "bsr" "bxor"
+                     "case" "catch" "cond"
+                     "div" "end" "fun" "if" "let" "not"
+                     "of" "or" "orelse"
+                     "query" "receive" "rem" "try" "when" "xor")))
+
+    (setq font-lock-keywords
+         (list
+          (list "%.*$"
+                '(0 font-lock-comment-face))
+          (list (concat "\\<\\(" erlang-keywords "\\)\\>")
+                '(0 font-lock-keyword-face))
+          (list (concat "^-\\sw+\\>")
+                '(0 font-lock-keyword-face))
+          (list "\\<[0-9]+\\(\\|#[0-9a-zA-Z]+\\|[eE][+-]?[0-9]+\\)\\>"
+                '(0 mdw-number-face))
+          (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
+                '(0 mdw-punct-face))))))
+
 ;;;----- Texinfo configuration ----------------------------------------------
 
 (defun mdw-fontify-texinfo ()
@@ -1976,6 +2046,17 @@ strip numbers instead."
    "\\([ \t]*\\([>#|:] ?\\)*[ \t]*\\)" 3)
   (auto-fill-mode 1))
 
+;;;----- Outline mode -------------------------------------------------------
+
+(defun mdw-outline-collapse-all ()
+  "Completely collapse everything in the entire buffer."
+  (interactive)
+  (save-excursion
+    (goto-char (point-min))
+    (while (< (point) (point-max))
+      (hide-subtree)
+      (forward-line))))
+
 ;;;----- Shell mode ---------------------------------------------------------
 
 (defun mdw-sh-mode-setup ()