;;; .emacs --- GNU Emacs 19.28+ startup file ;; Copyright (C) 1996, 1997, 2000, 2001 by Raymond Penners. ;; Author: Raymond Penners ;; Time-stamp: <2001-09-28 17:09:34 pennersr> ;;; Code: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; System dependencies ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Running XEmacs? (setq my-is-xemacs (string-match "XEmacs" emacs-version)) (setq load-path (cons "~/emacs/lisp/" load-path)) ;; Under XEmacs 19.14, system-name is unset?? (if (not (boundp 'system-name)) (setq system-name "???")) (cond ;; Home ((string-match "^sphinx" system-name) (progn))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Definitions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Returns t if this version of Emacs is at least MAJOR.MINOR, nil otherwise. (defun my-emacs-version-ge (major minor) "" (or (> emacs-major-version major) (and (= emacs-major-version major) (>= emacs-minor-version minor)))) ;;; Same as REQUIRE, but returns t/nil on success/failure (defun my-require (feature &optional file-name) (progn (if (not (featurep feature)) (load (or file-name (symbol-name feature)) t)) (featurep feature))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Processes ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Shell (if (and (boundp 'my-win32-shell) (eq system-type 'windows-nt)) (progn (setq shell-file-name my-win32-shell) (setq explicit-shell-file-name my-win32-shell))) (add-hook 'comint-output-filter-functions 'comint-watch-for-password-prompt) (add-hook 'comint-output-filter-functions 'comint-strip-ctrl-m) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Mail/News ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; RMAIL (setq rmail-file-name "~/Mail/rmail/main") (setq rmail-secondary-file-directory "~/Mail/rmail") (setq rmail-secondary-file-regexp "") ;;; Mail (setq mail-signature t) (setq mail-yank-prefix "> ") (setq mail-archive-file-name "~/Mail/rmail/sent") (add-hook 'mail-setup-hook (function (lambda () (define-key mail-mode-map "\C-n" 'mail-abbrev-next-line) (define-key mail-mode-map "\M->" 'mail-abbrev-end-of-buffer) (turn-on-font-lock) (mail-abbrevs-setup)))) ;;; Gnus ;; Gnus specifics have been moved to .gnus ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Programming ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Separator (defun my-c-header () "" (interactive) (progn (execute-kbd-macro (read-kbd-macro "M-< / * RET * SPC")) (insert (file-name-nondirectory buffer-file-name)) (execute-kbd-macro (read-kbd-macro "RET * RET * SPC Copyright SPC (C) SPC")) (insert (substring (current-time-string) -4)) (execute-kbd-macro (read-kbd-macro "SPC")) (insert user-full-name) (execute-kbd-macro (read-kbd-macro "RET * RET * SPC Time-stamp: SPC <> RET */ RET")))) ;;; Separator (defun my-c-separator () "" (interactive) (progn (let ((name (read-from-minibuffer "Name: "))) (execute-kbd-macro (read-kbd-macro "RET C-a C-q C-l RET TAB / C-u 70 * RET TAB * SPC")) (insert name) (execute-kbd-macro (read-kbd-macro "RET TAB C-u 70 * / RET"))))) ;;; Function header (defun my-c-function () "" (interactive) (progn (let ((name (read-from-minibuffer "Name: "))) (execute-kbd-macro (read-kbd-macro "RET TAB / * * RET TAB * SPC")) (insert name) (execute-kbd-macro (read-kbd-macro "RET TAB * / RET"))))) ;;; C/C++ (add-to-list 'auto-mode-alist '("\\.hpp\\'" . c++-mode)) (setq compilation-read-command t) (add-hook 'c-mode-common-hook (function (lambda () (define-key c-mode-map "\C-m" 'newline-and-indent) (make-local-variable 'dabbrev-case-fold-search) (setq dabbrev-case-fold-search nil) (local-set-key "\C-cs" 'my-c-separator) (local-set-key "\C-ch" 'my-c-header) (local-set-key "\C-cf" 'my-c-function)))) ;;; Perl (add-hook 'perl-mode-hook (function (lambda () ;; GNU style (setq perl-indent-level 2 perl-continued-statement-offset 2 perl-continued-brace-offset 0 perl-brace-offset 0 perl-brace-imaginary-offset 0 perl-label-offset -2)))) ;;; Python (if (load "python-mode" t) (progn (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode)) (add-hook 'python-mode-hook (function (lambda () ;; GNU style (turn-on-font-lock)))))) ;;; PHP (if (load "php-mode" t) (progn (add-to-list 'auto-mode-alist '("\\.php\\'" . php-mode))) (progn (add-to-list 'auto-mode-alist '("\\.php\\'" . html-mode)))) ;;; Miscellaneous (setq imenu-auto-rescan t) (add-to-list 'auto-mode-alist '("\\.asp\\'" . html-mode)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Word processing ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; TeX (setq tex-dvi-view-command (if (eq window-system 'x) "xdvi" "dvi2tty * | cat -s")) ;;; AUC TeX (if (my-require 'tex-site) (progn (setq TeX-auto-save t) (setq TeX-parse-self t) (setq-default TeX-master t) (add-hook 'LaTeX-mode-hook (function (lambda () (outline-minor-mode 1)))))) ;;; Miscellaneous (add-hook 'text-mode-hook 'turn-on-auto-fill) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Display ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Widgets (if (not my-is-xemacs) (if (eq window-system nil) (progn (menu-bar-mode nil)) (progn (menu-bar-mode t) (scroll-bar-mode t)))) ;;; Font-locking ;; turns on font-locking, if available (if (not (fboundp 'turn-on-font-lock)) (defun turn-on-font-lock () (if (or (eq window-system 'x) (eq window-system 'win32)) (font-lock-mode t)))) ;; Look flashy... (setq search-highlight t) (setq font-lock-maximum-decoration t) (require 'paren) ;; Turn on font-locking for supported modes (if (fboundp 'global-font-lock-mode) (global-font-lock-mode t) (progn (add-hook 'c++-mode-hook 'turn-on-font-lock) (add-hook 'c-mode-hook 'turn-on-font-lock) (add-hook 'dired-mode-hook 'turn-on-font-lock) (add-hook 'emacs-lisp-mode-hook 'turn-on-font-lock) (add-hook 'help-mode-hook 'turn-on-font-lock) (add-hook 'lisp-mode-hook 'turn-on-font-lock) (add-hook 'makefile-mode-hook 'turn-on-font-lock) (add-hook 'pascal-mode-hook 'turn-on-font-lock) (add-hook 'perl-mode-hook 'turn-on-font-lock) (add-hook 'latex-mode-hook 'turn-on-font-lock) (add-hook 'LaTeX-mode-hook 'turn-on-font-lock) (add-hook 'rmail-show-message-hook 'turn-on-font-lock) (add-hook 'rmail-summary-mode-hook 'turn-on-font-lock) (add-hook 'sh-set-shell-hook 'turn-on-font-lock) (add-hook 'shell-script-mode-hook 'turn-on-font-lock))) ;; Java mode ignores global-font-lock-mode, so force font-locking. (19.34) (add-hook 'java-mode-hook 'turn-on-font-lock) ;;; Miscellaneous ;; Knäkkebrøt (standard-display-european t) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Miscellaneous ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Auto insert (if (fboundp 'auto-insert) (progn ;; Note: Trailing '/' seems necessary! (setq auto-insert-directory "~/emacs/insert/") (add-hook 'find-file-hooks 'auto-insert))) ;;; Key bindings (global-set-key "\C-m" 'newline-and-indent) (global-set-key "\C-cg" 'goto-line) (global-set-key [f7] 'compile) (global-set-key "\C-cc" 'compile) (global-set-key "\C-ci" 'imenu) ;;; Date/Time (setq european-calendar-style t) (cond ((or (not (eq system-type 'windows-nt)) (my-emacs-version-ge 19 31)) (if (my-require 'appt) (add-hook 'diary-hook 'appt-make-list)) (display-time))) (setq display-time-24hr-format t) (setq mark-diary-entries-in-calendar t) (setq view-diary-entries-initially t) (setq cal-tex-diary t) (setq number-of-diary-entries 7) (add-hook 'diary-display-hook 'fancy-diary-display) (add-hook 'list-diary-entries-hook 'include-other-diary-files) (add-hook 'mark-diary-entries-hook 'mark-included-diary-files) (add-hook 'list-diary-entries-hook 'sort-diary-entries t) (setq diary-file "~/emacs/diary") (if (file-exists-p diary-file) (diary)) ;;; dired mode (add-hook 'dired-load-hook (function (lambda () (setq dired-x-hands-off-my-keys nil) (load "dired-x")))) (add-hook 'dired-mode-hook (function (lambda () (setq dired-omit-files-p nil) (setq truncate-lines t)))) ;;; Minibuffer (load "complete" t) (resize-minibuffer-mode 1) (setq enable-recursive-minibuffers t) ;;; Avoid "C:\T> ren foo.bar foo.bar~" bug on Weirdos'95 ;; (if (eq system-type 'windows-nt) (setq backup-inhibited t)) ;;; Read/write hooks (if (fboundp 'time-stamp) (add-hook 'write-file-hooks 'time-stamp)) (if (fboundp 'copyright-update) (add-hook 'write-file-hooks 'copyright-update)) (if (fboundp 'auto-compression-mode) (auto-compression-mode 1)) ;;; Server (if (and (not (eq system-type 'windows-nt)) (fboundp 'server-start)) (server-start)) ;;; Miscellaneous (if (fboundp 'auto-show-mode) (auto-show-mode 1)) (setq visible-bell nil) (line-number-mode 1) (setq ps-paper-type 'ps-a4) (setq next-line-add-newlines nil) (setq garbage-collection-messages t) (setq find-file-visit-truename t) (setq bookmark-default-file "~/emacs/bookmarks") (setq-default indent-tabs-mode nil) (load "desktop") ;;; Automatically added by Emacs (put 'narrow-to-region 'disabled nil) (put 'eval-expression 'disabled nil) (put 'erase-buffer 'disabled nil) (put 'downcase-region 'disabled nil) (put 'upcase-region 'disabled nil) (put 'narrow-to-page 'disabled nil) ;;; .emacs ends here