(debug 0))
`',(make-regexp list))
+(defun mdw-wrong ()
+ "This is not the key sequence you're looking for."
+ (interactive)
+ (error "wrong button"))
+
;; Some error trapping.
;;
;; If individual bits of this file go tits-up, we don't particularly want
(whitespace-mode arg))
(setq show-trailing-whitespace whitespace-mode)))
+(defvar mdw-do-misc-mode-hacking nil)
+
(defun mdw-misc-mode-config ()
(and mdw-auto-indent
(cond ((eq major-mode 'lisp-mode)
nil)
(t
(local-set-key "\C-m" 'newline-and-indent))))
+ (set (make-local-variable 'mdw-do-misc-mode-hacking) t)
(local-set-key [C-return] 'newline)
(make-local-variable 'page-delimiter)
(setq page-delimiter "\f\\|^.*-\\{6\\}.*$")
(setq comment-column 40)
(auto-fill-mode 1)
(setq fill-column 77)
- (setq show-trailing-whitespace t)
- (mdw-whitespace-mode 1)
(and (fboundp 'gtags-mode)
(gtags-mode))
(if (fboundp 'hs-minor-mode)
(reveal-mode t)
(trap (turn-on-font-lock)))
-(defun mdw-post-config-mode-hack ()
- (mdw-whitespace-mode 1))
+(defun mdw-post-local-vars-misc-mode-config ()
+ (when (and mdw-do-misc-mode-hacking
+ (not buffer-read-only))
+ (setq show-trailing-whitespace t)
+ (mdw-whitespace-mode 1)))
+(add-hook 'hack-local-variables-hook 'mdw-post-local-vars-misc-mode-config)
+
+(defadvice toggle-read-only (after mdw-angry-fruit-salad activate)
+ (when mdw-do-misc-mode-hacking
+ (setq show-trailing-whitespace (not buffer-read-only))
+ (mdw-whitespace-mode (if buffer-read-only 0 1))))
(eval-after-load 'gtags
'(progn
;; And anything else is punctuation.
(list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
- '(0 mdw-punct-face))))
-
- (mdw-post-config-mode-hack)))
+ '(0 mdw-punct-face))))))
;;;--------------------------------------------------------------------------
;;; AP calc mode.
;; And anything else is punctuation.
(list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
- '(0 mdw-punct-face)))))
-
- (mdw-post-config-mode-hack))
+ '(0 mdw-punct-face))))))
;;;--------------------------------------------------------------------------
;;; Java programming configuration.
;; And anything else is punctuation.
(list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
- '(0 mdw-punct-face)))))
-
- (mdw-post-config-mode-hack))
+ '(0 mdw-punct-face))))))
;;;--------------------------------------------------------------------------
;;; Javascript programming configuration.
;; And anything else is punctuation.
(list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
- '(0 mdw-punct-face)))))
-
- (mdw-post-config-mode-hack))
+ '(0 mdw-punct-face))))))
;;;--------------------------------------------------------------------------
;;; Scala programming configuration.
"\\|" "\\\\" "." "\\)"
"\\('\\)")
'(1 "\"")
- '(4 "\"")))))
-
- (mdw-post-config-mode-hack))
+ '(4 "\""))))))
;;;--------------------------------------------------------------------------
;;; C# programming configuration.
;; And anything else is punctuation.
(list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
- '(0 mdw-punct-face)))))
-
- (mdw-post-config-mode-hack))
+ '(0 mdw-punct-face))))))
(define-derived-mode csharp-mode java-mode "C#"
"Major mode for editing C# code.")
'(0 mdw-number-face))
(list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
- '(0 mdw-punct-face)))))
-
- (mdw-post-config-mode-hack))
+ '(0 mdw-punct-face))))))
(defun mdw-fontify-inferior-fsharp ()
(mdw-fontify-fsharp)
;; And anything else is punctuation.
(list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
+ '(0 mdw-punct-face))))))
+
+;;;--------------------------------------------------------------------------
+;;; Rust programming configuration.
+
+(setq-default rust-indent-offset 2)
+
+(defun mdw-self-insert-and-indent (count)
+ (interactive "p")
+ (self-insert-command count)
+ (indent-according-to-mode))
+
+(defun mdw-fontify-rust ()
+
+ ;; Hack syntax categories.
+ (modify-syntax-entry ?= ".")
+
+ ;; Fontify keywords and things.
+ (make-local-variable 'font-lock-keywords)
+ (let ((rust-keywords
+ (mdw-regexps "abstract" "alignof" "as"
+ "become" "box" "break"
+ "const" "continue" "create"
+ "do"
+ "else" "enum" "extern"
+ "false" "final" "fn" "for"
+ "if" "impl" "in"
+ "let" "loop"
+ "macro" "match" "mod" "move" "mut"
+ "offsetof" "override"
+ "priv" "pub" "pure"
+ "ref" "return"
+ "self" "sizeof" "static" "struct" "super"
+ "true" "trait" "type" "typeof"
+ "unsafe" "unsized" "use"
+ "virtual"
+ "where" "while"
+ "yield"))
+ (rust-builtins
+ (mdw-regexps "array" "pointer" "slice" "tuple"
+ "bool" "true" "false"
+ "f32" "f64"
+ "i8" "i16" "i32" "i64" "isize"
+ "u8" "u16" "u32" "u64" "usize"
+ "char" "str")))
+ (setq font-lock-keywords
+ (list
+
+ ;; Handle the keywords defined above.
+ (list (concat "\\<\\(" rust-keywords "\\)\\>")
+ '(0 font-lock-keyword-face))
+ (list (concat "\\<\\(" rust-builtins "\\)\\>")
+ '(0 font-lock-variable-name-face))
+
+ ;; Handle numbers too.
+ (list (concat "\\<\\("
+ "[0-9][0-9_]*"
+ "\\(" "\\(\\.[0-9_]+\\)?[eE][-+]?[0-9_]+"
+ "\\|" "\\.[0-9_]+"
+ "\\)"
+ "\\(f32\\|f64\\)?"
+ "\\|" "\\(" "[0-9][0-9_]*"
+ "\\|" "0x[0-9a-fA-F_]+"
+ "\\|" "0o[0-7_]+"
+ "\\|" "0b[01_]+"
+ "\\)"
+ "\\([ui]\\(8\\|16\\|32\\|64\\|s\\|size\\)\\)?"
+ "\\)\\>")
+ '(0 mdw-number-face))
+
+ ;; And anything else is punctuation.
+ (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
'(0 mdw-punct-face)))))
- (mdw-post-config-mode-hack))
+ ;; Hack key bindings.
+ (local-set-key [?{] 'mdw-self-insert-and-indent)
+ (local-set-key [?}] 'mdw-self-insert-and-indent))
;;;--------------------------------------------------------------------------
;;; Awk programming configuration.
;; And anything else is punctuation.
(list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
- '(0 mdw-punct-face)))))
-
- (mdw-post-config-mode-hack))
+ '(0 mdw-punct-face))))))
;;;--------------------------------------------------------------------------
;;; Perl programming style.
;; Miscellaneous fiddling.
(modify-syntax-entry ?$ "\\")
(modify-syntax-entry ?$ "\\" font-lock-syntax-table)
+ (modify-syntax-entry ?: "." font-lock-syntax-table)
(mdw-standard-fill-prefix "\\([ \t]*#+[ \t]*\\)")
;; Now define fontification things.
(make-local-variable 'font-lock-keywords)
(let ((perl-keywords
- (mdw-regexps "and" "break" "cmp" "continue" "do" "else" "elsif" "eq"
- "for" "foreach" "ge" "given" "gt" "goto" "if"
- "last" "le" "lt" "local" "my" "ne" "next" "or"
- "our" "package" "redo" "require" "return" "sub"
- "undef" "unless" "until" "use" "when" "while")))
+ (mdw-regexps "and"
+ "break"
+ "cmp" "continue"
+ "default" "do"
+ "else" "elsif" "eq"
+ "for" "foreach"
+ "ge" "given" "gt" "goto"
+ "if"
+ "last" "le" "local" "lt"
+ "my"
+ "ne" "next"
+ "or" "our"
+ "package"
+ "redo" "require" "return"
+ "sub"
+ "undef" "unless" "until" "use"
+ "when" "while")))
(setq font-lock-keywords
(list
;; And anything else is punctuation.
(list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
- '(0 mdw-punct-face)))))
-
- (mdw-post-config-mode-hack))
+ '(0 mdw-punct-face))))))
(defun perl-number-tests (&optional arg)
"Assign consecutive numbers to lines containing `#t'. With ARG,
;; And anything else is punctuation.
(list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
- '(0 mdw-punct-face))))
-
- (mdw-post-config-mode-hack))
+ '(0 mdw-punct-face)))))
;; Define Python fontification styles.
;; And anything else is punctuation.
(list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
- '(0 mdw-punct-face)))))
-
- (mdw-post-config-mode-hack))
+ '(0 mdw-punct-face))))))
;;;--------------------------------------------------------------------------
;;; Assembler mode.
(defun mdw-fontify-asm ()
(modify-syntax-entry ?' "\"")
(modify-syntax-entry ?. "w")
- (modify-syntax-entry ?; "."
- )
- (modify-syntax-entry asm-comment-char "<b")
(modify-syntax-entry ?\n ">")
(setf fill-prefix nil)
(mdw-standard-fill-prefix "\\([ \t]*;+[ \t]*\\)"))
-(define-derived-mode x86-asm-mode asm-mode "x86 assembler"
- "Assembler mode variant which uses `#' as the comment character."
- (set (make-variable-buffer-local 'asm-comment-char) ?#))
-
-(define-derived-mode arm-asm-mode asm-mode "ARM assembler"
- "Assembler mode variant which uses `@' as the comment character."
- (set (make-variable-buffer-local 'asm-comment-char) ?@))
+(defun mdw-asm-set-comment ()
+ (modify-syntax-entry ?; "."
+ )
+ (modify-syntax-entry asm-comment-char "<b")
+ (setq comment-start (string asm-comment-char ? )))
+(add-hook 'asm-mode-local-variables-hook 'mdw-asm-set-comment)
+(put 'asm-comment-char 'safe-local-variable 'characterp)
;;;--------------------------------------------------------------------------
;;; TCL configuration.
"\\([eE]\\([-+]\\|\\)[0-9_]+\\|\\)")
'(0 mdw-number-face))
(list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
- '(0 mdw-punct-face))))
- (mdw-post-config-mode-hack))
+ '(0 mdw-punct-face)))))
;;;--------------------------------------------------------------------------
;;; Dylan programming configuration.
"\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\|"
"\\_<[-+*/=<>:&|]+\\_>"
"\\)")
- '(0 mdw-punct-face)))))
-
- (mdw-post-config-mode-hack))
+ '(0 mdw-punct-face))))))
;;;--------------------------------------------------------------------------
;;; Algol 68 configuration.
"\\>")
'(0 mdw-number-face))
(list "\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/"
- '(0 mdw-punct-face)))))
-
- (mdw-post-config-mode-hack))
+ '(0 mdw-punct-face))))))
;;;--------------------------------------------------------------------------
;;; REXX configuration.
;; And everything else is punctuation.
(list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
- '(0 mdw-punct-face)))))
-
- (mdw-post-config-mode-hack))
+ '(0 mdw-punct-face))))))
;;;--------------------------------------------------------------------------
;;; Standard ML programming style.
;; And anything else is punctuation.
(list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
- '(0 mdw-punct-face)))))
-
- (mdw-post-config-mode-hack))
+ '(0 mdw-punct-face))))))
;;;--------------------------------------------------------------------------
;;; Haskell configuration.
"\\([eE]\\([-+]\\|\\)[0-9]+\\|\\)")
'(0 mdw-number-face))
(list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
- '(0 mdw-punct-face)))))
-
- (mdw-post-config-mode-hack))
+ '(0 mdw-punct-face))))))
;;;--------------------------------------------------------------------------
;;; Erlang configuration.
(list "\\<[0-9]+\\(\\|#[0-9a-zA-Z]+\\|[eE][+-]?[0-9]+\\)\\>"
'(0 mdw-number-face))
(list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
- '(0 mdw-punct-face)))))
-
- (mdw-post-config-mode-hack))
+ '(0 mdw-punct-face))))))
;;;--------------------------------------------------------------------------
;;; Texinfo configuration.
;; Fontify TeX special characters as punctuation.
(list "[{}]+"
- '(0 mdw-punct-face))))
-
- (mdw-post-config-mode-hack))
+ '(0 mdw-punct-face)))))
;;;--------------------------------------------------------------------------
;;; TeX and LaTeX configuration.
;; Fontify TeX special characters as punctuation.
(list "[$^_{}#&]"
- '(0 mdw-punct-face))))
-
- (mdw-post-config-mode-hack))
+ '(0 mdw-punct-face)))))
;;;--------------------------------------------------------------------------
;;; SGML hacking.
"\\([eE]\\([-+]\\|\\)[0-9_]+\\|\\)")
'(0 mdw-number-face))
(list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
- '(0 mdw-punct-face))))
- (mdw-post-config-mode-hack))
+ '(0 mdw-punct-face)))))
;; Lispy languages.
"\\)\\_>")
'(0 mdw-number-face))
(list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
- '(0 mdw-punct-face))))
-
- (mdw-post-config-mode-hack))
+ '(0 mdw-punct-face)))))
(defun comint-send-and-indent ()
(interactive)