(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
(concat "(" (buffer-string) ")")))))))
(cdr (assq sym mdw-config)))
+;; Local variables hacking.
+
+(defun run-local-vars-mode-hook ()
+ "Run a hook for the major-mode after local variables have been processed."
+ (run-hooks (intern (concat (symbol-name major-mode)
+ "-local-variables-hook"))))
+(add-hook 'hack-local-variables-hook 'run-local-vars-mode-hook)
+
;; Set up the load path convincingly.
(dolist (dir (append (and (boundp 'debian-emacs-flavor)
(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 mdw-do-misc-mode-hacking
+ (setq show-trailing-whitespace t)
+ (mdw-whitespace-mode 1)))
+(add-hook 'hack-local-variables-hook 'mdw-post-local-vars-misc-mode-config)
(eval-after-load 'gtags
'(progn
(if (not mdw-point-overlay-mode)
(mdw-remove-point-overlay)
(overlay-put mdw-point-overlay 'window (selected-window))
- (move-overlay mdw-point-overlay (point) (1+ (point)) (current-buffer))))
+ (if (bolp)
+ (move-overlay mdw-point-overlay
+ (point) (1+ (point)) (current-buffer))
+ (move-overlay mdw-point-overlay
+ (1- (point)) (point) (current-buffer)))))
(defvar mdw-point-overlay-buffers nil
"List of buffers using `mdw-point-overlay-mode'.")
(lambda () (if (not (minibufferp)) (mdw-point-overlay-mode t))))
;;;--------------------------------------------------------------------------
+;;; Fullscreen-ness.
+
+(defvar mdw-full-screen-parameters
+ '((menu-bar-lines . 0)
+ ;(vertical-scroll-bars . nil)
+ )
+ "Frame parameters to set when making a frame fullscreen.")
+
+(defvar mdw-full-screen-save
+ '(width height)
+ "Extra frame parameters to save when setting fullscreen.")
+
+(defun mdw-toggle-full-screen (&optional frame)
+ "Show the FRAME fullscreen."
+ (interactive)
+ (when window-system
+ (cond ((frame-parameter frame 'fullscreen)
+ (set-frame-parameter frame 'fullscreen nil)
+ (modify-frame-parameters
+ nil
+ (or (frame-parameter frame 'mdw-full-screen-saved)
+ (mapcar (lambda (assoc)
+ (assq (car assoc) default-frame-alist))
+ mdw-full-screen-parameters))))
+ (t
+ (let ((saved (mapcar (lambda (param)
+ (cons param (frame-parameter frame param)))
+ (append (mapcar #'car
+ mdw-full-screen-parameters)
+ mdw-full-screen-save))))
+ (set-frame-parameter frame 'mdw-full-screen-saved saved))
+ (modify-frame-parameters frame mdw-full-screen-parameters)
+ (set-frame-parameter frame 'fullscreen 'fullboth)))))
+
+;;;--------------------------------------------------------------------------
;;; General fontification.
(defmacro mdw-define-face (name &rest body)
(mdw-define-face mdw-ellipsis-face
(((type tty)) :foreground "blue") (t :foreground "grey60"))
(let ((dollar (make-glyph-code ?$ 'mdw-ellipsis-face))
- (backslash (make-glyph-code ?\ 'mdw-ellipsis-face))
+ (backslash (make-glyph-code ?\\ 'mdw-ellipsis-face))
(dot (make-glyph-code ?. 'mdw-ellipsis-face))
(bar (make-glyph-code ?| mdw-ellipsis-face)))
(set-display-table-slot standard-display-table 0 dollar)
;; 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.
(or (booleanp value)
(every (lambda (v) (memq v '(?\" ?')))
(if (listp value) value (list value)))))
-(put 'mdw-conf-quote-normal 'safe-local-variable '
- mdw-conf-quote-normal-acceptable-value-p)
+(put 'mdw-conf-quote-normal 'safe-local-variable
+ 'mdw-conf-quote-normal-acceptable-value-p)
(defun mdw-fix-up-quote ()
"Apply the setting of `mdw-conf-quote-normal'."
(if (listp flag) flag (list flag)))
(set-syntax-table table)
(and font-lock-mode (font-lock-fontify-buffer)))))))
-(defun mdw-fix-up-quote-hack ()
- "Unpleasant hack to call `mdw-fix-up-quote' at the right time.
-Annoyingly, `hack-local-variables' is done after `set-auto-mode'
-so we wouldn't see a local-variable setting of
-`mdw-conf-quote-normal' in `conf-mode-hook'. Instead, wire
-ourselves onto `hack-local-variables-hook' here, and check the
-setting once it's actually been made."
- (add-hook 'hack-local-variables-hook 'mdw-fix-up-quote t t))
-(add-hook 'conf-mode-hook 'mdw-fix-up-quote-hack t)
+(add-hook 'conf-mode-local-variables-hook 'mdw-fix-up-quote t t)
;;;--------------------------------------------------------------------------
;;; Shell scripts.
(let ((executable-set-magic #'(lambda (s &rest r) s)))
(sh-set-shell shell-name)))
+ ;; Don't insert here-document scaffolding automatically.
+ (local-set-key "<" 'self-insert-command)
+
;; Now enable my keys and the fontification.
(mdw-misc-mode-config)
"\\([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)