;; .emacs -*- coding: utf-8 -*- ;; Be sure to check .emacs.local if something appears to have ;; no effect here. ;; Set some key bindings (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-Cu" 'unicode-charmap) (global-set-key "\C-Ck" 'browse-kill-ring) (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 menu and tool bar (menu-bar-mode 0) (tool-bar-mode 0) ;; Override the swtich-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) ;; 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) ;; Set up personal load path and autoloads (setq load-path (cons "/home/cabanks/lib/emacs/" load-path)) (autoload 'unicode-charmap "unicode-charmap" "Load a Unicode charmap" t) (autoload 'fcap-mode "fcap-mode" "Fortran capitalization minor mode." t) (autoload 'python-mode "python-mode-ovr" "Python editing mode (with some personal tweaks)" t) ;; 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) ;; 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)) ;; Some Fortran settings (setq fortran-comment-indent-style nil) (setq fortran-continuation-string "&") ;; Python mode hooks (defun custom-python-mode () (setq indent-tabs-mode nil) (setq py-indent-offset 4)) (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 () (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) ;; Turn on column number mode (column-number-mode t) ;; Disable some checks (put 'downcase-region 'disabled nil) (put 'upcase-region 'disabled nil) ;; load the machine-local emacs (load "/home/cabanks/.emacs-local" nil t nil)