X-Git-Url: https://git.distorted.org.uk/~mdw/profile/blobdiff_plain/cfa1824e2674ca83f7d8b543889ce7d77003858b..3c40e4528968844b262be2a212b23205c0646e26:/el/dot-emacs.el diff --git a/el/dot-emacs.el b/el/dot-emacs.el index f917905..bd29385 100644 --- a/el/dot-emacs.el +++ b/el/dot-emacs.el @@ -52,6 +52,11 @@ This may be at the expense of cool features.") (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 @@ -91,6 +96,14 @@ This may be at the expense of cool features.") (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) @@ -893,7 +906,11 @@ doesn't match any of the regular expressions in (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'.") @@ -924,6 +941,41 @@ doesn't match any of the regular expressions in (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) @@ -1932,6 +1984,85 @@ doesn't match any of the regular expressions in (mdw-post-config-mode-hack)) ;;;-------------------------------------------------------------------------- +;;; 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))))) + + ;; Hack key bindings. + (local-set-key [?{] 'mdw-self-insert-and-indent) + (local-set-key [?}] 'mdw-self-insert-and-indent) + + ;; Final hacking. + (mdw-post-config-mode-hack)) + +;;;-------------------------------------------------------------------------- ;;; Awk programming configuration. ;; Make Awk indentation nice. @@ -2010,16 +2141,29 @@ doesn't match any of the regular expressions in ;; 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 @@ -2167,20 +2311,17 @@ strip numbers instead." (defun mdw-fontify-asm () (modify-syntax-entry ?' "\"") (modify-syntax-entry ?. "w") - (modify-syntax-entry ?; "." - ) - (modify-syntax-entry asm-comment-char "") (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 "