;; .emacs -*- coding: utf-8 -*- ;; Be sure to check .emacs.local if something appears to have ;; no effect here. ;;---------------------------------------------------------------------- ;; Global Key Bindings ;; Add some customizations (global-set-key "\C-Xh" 'help) (global-set-key "\C-O" 'overwrite-mode) (global-set-key "\C-Cg" 'goto-line) (global-set-key "\C-Cq" 'save-buffers-kill-emacs) (global-set-key "\C-Ck" 'browse-kill-ring) (global-set-key "\C-Z" 'undo) ;; disable keys I accidentally hit too much (global-unset-key "\C-Xf") (global-unset-key "\C-X\C-C") (global-unset-key '[home]) (global-unset-key '[end]) (global-unset-key '[insert]) ;;---------------------------------------------------------------------- ;; Disable the more and more numerous annoything things about emacs ;; Allow some "risky" local variables, the way emacs handles this is ;; retarded (setq safe-local-variable-values '((make-backup-files . nil) (py-indent-offset . 4))) ;; Disable mouse wheel acceleration, the stupidest thing ever invented ;; (Well, even if it isn't the stupidest thing ever invented per se, ;; it is the stupidest thing ever done to make it as fast as it is.) (setq mouse-wheel-progressive-speed nil) ;; Turn on column number mode (we're not using 24K baud modems any more) (column-number-mode t) ;; Disable menu and tool bar. And to think I started using Emacs ;; because it didn't have crap like this. (menu-bar-mode 0) (tool-bar-mode 0) ;; Disable some checks (put 'downcase-region 'disabled nil) (put 'upcase-region 'disabled nil) ;; Turn off anything that might ever pop up other than an empty buffer ;; or a file specified on the command line (setq inhibit-startup-screen t) (setq inhibit-startup-echo-area-message t) (setq inhibit-startup-buffer-menu t) (setq inital-major-mode 'fundamental-mode) ;; Turn off split screens if multiple files were specified (add-hook 'window-setup-hook 'delete-other-windows) ;; Put scroll bar on the right ;; ;; The fascist GNU Emacs creators decided that left scroll bars were the ;; One True Way and tried to inflict this upon the helpless public by ;; removing documentation that told you how to control scroll bar position. ;; ;; They actually had a good point: it's easier to scroll a window in the ;; background that way. ;; ;; But, in their arrogance they believed they had settled this matter once ;; and for all and that it was their right to decide for everyone else. ;; Problem is, something else was more important to me, namely wanting to ;; paste with the middle button without always accidentally warping me to ;; some other point in the buffer because I was a little off. ;; ;; I really appreciate these guys making free software possible, but ;; sometimes I just want to throttle them. ;; ;; Fortunately, Google came to the rescue. (set-scroll-bar-mode 'right) ;;---------------------------------------------------------------------- ;; Custom functionality ;; At last I decide to save the backup files all to one folder (setq backup-directory-alist '(("." . "~/.backups"))) ;; Override the switch-to-buffer command to not create new buffers (defun switch-to-buffer-nocreate (buffer) "Switch to buffer but do not create a new buffer" (interactive (list (read-buffer "Switch to buffer:" (other-buffer) t))) (switch-to-buffer buffer)) (global-set-key "\C-xb" 'switch-to-buffer-nocreate) ;; Add some special insert sequences (defun cwb-insert-tm () (interactive) (insert "™")) (global-set-key "\C-Ct" 'cwb-insert-tm) ;;---------------------------------------------------------------------- ;; Additional libraries ;; Set up personal load path (setq load-path (cons "/home/cabanks/.emacs.d" load-path)) ;; Add unicode-charmap function (autoload 'unicode-charmap "unicode-charmap" "Load a Unicode charmap" t) (global-set-key "\C-Cu" 'unicode-charmap) ;; fcap mode (autoload 'fcap-mode "fcap-mode" "Fortran capitalization minor mode." t) ;;---------------------------------------------------------------------- ;; Mode list adjustments ;; Remove all annoying modes from auto mode lists (defun replace-alist-mode (alist oldmode newmode) (dolist (aitem alist) (if (eq (cdr aitem) oldmode) (setcdr aitem newmode)))) (replace-alist-mode auto-mode-alist 'tex-mode 'latex-mode) (replace-alist-mode auto-mode-alist 'perl-mode 'fundamental-mode) (replace-alist-mode auto-mode-alist 'html-mode 'text-mode) (replace-alist-mode auto-mode-alist 'makefile-mode 'fundamental-mode) (replace-alist-mode auto-mode-alist 'sh-mode 'fundamental-mode) (replace-alist-mode auto-mode-alist 'tcl-mode 'fundamental-mode) (replace-alist-mode auto-mode-alist 'awk-mode 'fundamental-mode) (replace-alist-mode auto-mode-alist 'f90-mode 'fundamental-mode) (replace-alist-mode auto-mode-alist 'octave-mode 'fundamental-mode) (replace-alist-mode auto-mode-alist 'asm-mode 'fundamental-mode) (replace-alist-mode auto-mode-alist 'xrdb-mode 'fundamental-mode) (replace-alist-mode interpreter-mode-alist 'perl-mode 'fundamental-mode) (replace-alist-mode interpreter-mode-alist 'tcl-mode 'fundamental-mode) (replace-alist-mode interpreter-mode-alist 'awk-mode 'fundamental-mode) (replace-alist-mode interpreter-mode-alist 'sh-mode 'fundamental-mode) (replace-alist-mode interpreter-mode-alist 'asm-mode 'fundamental-mode) ;; Add some new fields to auto mode lists (setq auto-mode-alist (cons '("\\.pyf$" . fortran-mode) auto-mode-alist)) (setq auto-mode-alist (cons '("\\.inc$" . fortran-mode) auto-mode-alist)) (setq auto-mode-alist (cons '("\\.hrl$" . text-mode) auto-mode-alist)) (setq auto-mode-alist (cons '("\\.jl$" . lisp-mode) auto-mode-alist)) (setq auto-mode-alist (cons '("\\.d$" . java-mode) auto-mode-alist)) (setq auto-mode-alist (cons '("\\.cs$" . java-mode) auto-mode-alist)) ;;---------------------------------------------------------------------- ;; Major mode hooks ;; Python mode hooks (defun custom-python-mode () (turn-on-font-lock) (set-only-quasi-obnoxious-colors) (setq indent-tabs-mode nil) (setq py-indent-offset 4) (setq py-which-shell "python")) (add-hook 'python-mode-hook 'custom-python-mode) ;; C mode hooks (unfortunately, I'm using C) ;; Try this with Java, too (defun custom-c-mode () (turn-on-font-lock) (set-only-quasi-obnoxious-colors) (setq indent-tabs-mode nil) (setq fill-prefix " ") (setq c-hanging-comment-starter-p nil) (setq c-hanging-comment-ender-p nil) (setq c-basic-offset 4) (c-set-offset 'arglist-intro c-basic-offset) (c-set-offset 'substatement-open 0) (setq comment-column 48)) (add-hook 'c-mode-hook 'custom-c-mode) (add-hook 'c++-mode-hook 'custom-c-mode) (add-hook 'java-mode-hook 'custom-c-mode) ;; Change colors for font-lock-mode to something only quasi-obnoxious (defun set-only-quasi-obnoxious-colors () (set-face-foreground 'font-lock-string-face "Navy") (set-face-foreground 'font-lock-comment-face "Red") (dolist (sym '(py-builtins-face py-pseudo-keyword-face py-XXX-tag-face py-decorators-face font-lock-builtin-face font-lock-constant-face font-lock-doc-face font-lock-function-name-face font-lock-keyword-face font-lock-type-face font-lock-variable-name-face font-lock-warning-face)) (condition-case nil (set-face-foreground sym "Black") (error nil)))) ;; fundamental mode--freaking fundamental mode--needs a hook (defun custom-fundamental-mode () (define-key (current-local-map) "\C-I" 'self-insert-command)) ;;---------------------------------------------------------------------- ;; Settings for miscellaneous modes ;; Set autofill in LaTeX mode (add-hook 'latex-mode-hook (lambda () (auto-fill-mode))) ;; Automatically set FCap mode for Fortran (add-hook 'fortran-mode-hook 'fcap-mode) ;; Some Fortran settings (setq fortran-comment-indent-style nil) (setq fortran-continuation-string "&") ;;---------------------------------------------------------------------- ;; Load the machine-local emacs (load "/home/cabanks/.emacs.d/local.el" nil t nil) ;;---------------------------------------------------------------------- ;; Finally, a section for emacs to insert stuff on my behalf. ;; Should always be empty.