;;; An adaptation of Gary T. Leavens 's .emacs file ;;; ;;; Last updated on $Date: 2002/08/21 16:05:53 $ ;;; ;;; Feel free to browse, copy, and tweak as desired. ;;; I try to make these sensible for anyone to just use, ;;; but of course I offer no warranty on anything here. ;;; If you're new to emacs type the escape key, then x, ;;; then help-with-tutorial and then the return key. ;;; That is: M-x help-with-tutorial RET ;;; Files mentioned below are found in "~/emacs" and "/usr/unsup/emacs" ;;; This means if you're looking for leavens's files, ;;; they are in ~leavens/emacs. For example, for user leavens, ;;; (load "mode-customizations") loads the file whose source is in ;;; ~leavens/emacs/mode-customizations.el ;;; (setq load-path (cons "~/emacs" (cons "/usr/unsup/emacs" load-path))) ;;; for my PC I use instead of the above: ;; (setq load-path ;; (cons "~/emacs" (append-load-path (list "c:/cygwin/usr/unsup/emacs")))) ;;; Load my emacs-lisp files from the directory ~/emacs/ (see above). ;;; If these don't exist, they are silently ignored, ;;; because of the `t' at the end of the load command ;;; ;; Customization of various emacs modes (load "mode-customizations" t) ;; Other commands of mine (these don't take effect unless invoked) (load "my-commands" t) ;; Customizations for the local system, varies between HP, Vincent etc... (load "local-customization" t) ;; Allow undo of scrolling by M-x unscroll (load "unscroll" t) ;; Are we running XEmacs or Emacs? (defvar running-xemacs (string-match "XEmacs\\|Lucid" emacs-version)) ;; Turn on font-lock mode for Emacs (cond ((not running-xemacs) (global-font-lock-mode t))) ;; Enable wheelmouse support by default (if (not running-xemacs) (if (and (>= emacs-major-version 20) (>= emacs-minor-version 7)) (require 'mwheel)) ; Emacs (mwheel-install) ; XEmacs ) ;;; Disabling commands and key bindings (disaster prevention) ;;; The following disable key sequences that can cause ;;; big or unnoticed mistakes (put 'zap-to-char 'disabled t) ; M-z (put 'rmail-edit-current-message 'disabled 't) (global-unset-key "\C-x\C-u") ; C-x C-u (upcase-region) vs. C-x u (undo) (global-unset-key "\C-x\C-l") ; downcase of region can be disaster (global-unset-key "\C-xf") ; can use set-fill-column explicitly ;;; I don't use emacs to change directories, just to get to files (setq find-file-run-dired nil) ; never run dired ;;; it's safer to not allow local variable lists to take effect automatically (setq enable-local-variables 'query) ;;; Setting new commands and key bindings (make it do what I want) ;;; Make backspace (BS) work as most people expect (thanks to Bob Glickstein) ;;; ; make BS delete characters backwards, just like DEL (global-set-key "\C-h" 'backward-delete-char-untabify) ; put help on M-? (i.e., ESC ?) (global-set-key "\M-?" 'help-command) ;;; Make the behavior of a selection be as in many standard apps, so you can ;;; type right over it or delete it by using backspace. ;;; (pc-selection-mode) ;;; Dragon Dictate customizations (load "dragondictate" t) ;;; Function key binding, the \M-O ones come from Kermit in emacs mode... ;;; (global-set-key "\M-OP" 'help) (global-set-key [f2] 'goto-line) (global-set-key "\M-OQ" 'goto-line) (global-set-key [f3] 'begin) (global-set-key "\M-OR" 'begin) (global-set-key "\M-OA" 'previous-line) (global-set-key "\M-OB" 'next-line) (global-set-key "\M-OC" 'forward-char) (global-set-key "\M-OD" 'backward-char) ;;; Keys from my keyboard when using kermit that's not in emacs mode (:-( ;;; (global-set-key "\M-[A" 'previous-line) (global-set-key "\M-[B" 'next-line) (global-set-key "\M-[C" 'forward-char) (global-set-key "\M-[D" 'backward-char) ;;; key bindings that are useful especially for flow control (ISN, telnet), ;;; which sometimes eats all the C-s and C-q chars, ;;; and which I can live with all the time anyway. ;;; (global-set-key "\C-\\" 'isearch-forward) (global-set-key "\C-^" 'quoted-insert) (global-set-key "\M-s" 'isearch-forward-regexp) (define-key isearch-mode-map "\C-\\" 'isearch-repeat-forward) (define-key isearch-mode-map "\C-^" 'isearch-quote-char) ;;; Other customizations ;;; The following is important for the Windows file system, ;;; which uses ~ at the end of a name to control long file names! ;;; I use it also under Unix, so that sharing files on Windows works... (setq version-control t) ;;; Preserve links of files when editing ;;; (setq backup-by-copying-when-linked 't) ;;; Make ~ backup files even when using RCS or SCCS ;;; (setq vc-make-backup-files 't) ;;; Make files always end in a newline ;;; (setq require-final-newline 't) ;;; Mode-line customization ;;; ; I don't want constantly check my email, so make it look like there's no mail (setq display-time-mail-file ".non-existent-file") ; I like to know what day it is... (setq display-time-day-and-date t) ; display the time in the mode-line (display-time) ;;; Java mode ;;; (add-to-list 'completion-ignored-extensions ".class") ;;; I use .m4 for a preprocessor for some Java files (add-to-list 'auto-mode-alist '("\\.m4$" . java-mode)) ;;; The following should really be JML mode, but we don't have that yet... (add-to-list 'auto-mode-alist '("\\.refines-java$" . java-mode)) (add-to-list 'auto-mode-alist '("\\.java-refined$" . java-mode)) (add-to-list 'auto-mode-alist '("\\.spec$" . java-mode)) (add-to-list 'auto-mode-alist '("\\.spec-refined$" . java-mode)) (add-to-list 'auto-mode-alist '("\\.refines-spec$" . java-mode)) (add-to-list 'auto-mode-alist '("\\.jml$" . java-mode)) (add-to-list 'auto-mode-alist '("\\.jml-refined$" . java-mode)) (add-to-list 'auto-mode-alist '("\\.refines-jml$" . java-mode)) ;;; Also JML developers consider .*-refined-generic and .*-generic ;;; files to be Java files (add-to-list 'auto-mode-alist '("\\.java-refined-generic$" . java-mode)) (add-to-list 'auto-mode-alist '("\\.java-generic$" . java-mode)) (add-to-list 'auto-mode-alist '("\\.spec-refined-generic$" . java-mode)) (add-to-list 'auto-mode-alist '("\\.spec-generic$" . java-mode)) (add-to-list 'auto-mode-alist '("\\.jml-refined-generic$" . java-mode)) (add-to-list 'auto-mode-alist '("\\.jml-generic$" . java-mode)) (add-hook 'java-mode-hook (function (lambda () (make-local-variable 'indent-tabs-mode) (setq indent-tabs-mode nil) (fset 'main (lambda () (interactive) (insert "public static void main(String [] argv) {") (c-indent-command) (insert "\n}") (c-indent-command) (insert "\n") (forward-line -1) (insert "System.out.println(\"\");\n") (forward-line -1) (c-indent-command) (end-of-line) (backward-char 3))) (if window-system (progn (font-lock-mode)))))) ;;; ANTLR mode (autoload 'antlr-mode "antlr-mode" nil t) (add-to-list 'auto-mode-alist '("\\.g\\'" . antlr-mode)) (add-hook 'speedbar-load-hook ; would be too late in antlr-mode.el (lambda () (speedbar-add-supported-extension ".g"))) (add-hook 'antlr-mode-hook (function (lambda () (make-local-variable 'indent-tabs-mode) (setq indent-tabs-mode nil) (if window-system (progn (font-lock-mode)))))) ;;; Make expanded...g files default to read-only mode (add-hook 'antlr-mode-hook (function (lambda () (if (string-match "expanded.*\\.g" (buffer-name)) (toggle-read-only 1) nil)))) ;;; uncomment the following to turn on viper-mode if you are a vi user ; (viper-mode)