;;; ;;; Map ^S to ^\ and ^Q to ^^. ;;; (defun cntl-S-fix () (setq keyboard-translate-table (make-string 128 0)) (let ((i 0)) (while (< i 128) (aset keyboard-translate-table i i) (setq i (1+ i)))) (aset keyboard-translate-table ?\034 ?\^s) (aset keyboard-translate-table ?\^s ?\034) (aset keyboard-translate-table ?\036 ?\^q) (aset keyboard-translate-table ?\^q ?\036)) ;;; Only do it if you're not on console (assumed to be in X) (if (not (getenv "DISPLAY")) (cntl-S-fix)) (setq text-mode-hook '(lambda () (auto-fill-mode 1))) (global-font-lock-mode t) (setq font-lock-maximum-decoration t) ;(setq abbrev-mode t) (read-abbrev-file) (setq tex-dvi-view-command "xd *") (display-time) (set-face-foreground 'default "black") (set-face-background 'modeline "darkorange") (set-face-foreground 'modeline "black") (set-face-background 'region "magenta") (set-face-foreground 'region "orange") ; This is to not display the initial message (which says to a novice ; user what to do first if he/she is confused). (setq inhibit-startup-message t) ; This disables down-arrow and C-n at the end of a buffer from adding ; a new line to that buffer. (setq next-line-add-newlines nil) ;;; Overlap between window-fulls when scrolling by pages (setq next-screen-context-lines 3) ; ;;; Key customizations. (global-set-key "\C-xg" 'goto-line) (global-set-key "\C-x\C-b" 'electric-buffer-list) (global-set-key "\M-i" 'indent-relative) (global-set-key "\C-xy" 'insert-register) (global-set-key "\M-*" 'query-replace-regexp) (global-set-key [f1] 'info) ;(defun previous-window (arg) ; "Switch to previous window." ; (interactive "p") ; (other-window (- arg))) (global-set-key [M-home] 'previous-window) (global-set-key [M-end] 'other-window) (global-set-key [C-home] 'beginning-of-buffer) (global-set-key [C-end] 'end-of-buffer) (global-set-key [M-kp-divide] 'dabbrev-expand) (global-set-key [M-right] 'end-of-line) (global-set-key [M-left] 'beginning-of-line) (global-set-key [C-prior] 'enlarge-window) (global-set-key [C-next] 'shrink-window) (global-set-key "\M-z" (function (lambda () (interactive) (scroll-down 1)))) (global-set-key "\C-z" (function (lambda () (interactive) (scroll-up 1)))) ; This makes `apropos' and `super-apropos' do everything that they can. (setq apropos-do-all t) (defun my-textmode-stuff () "My own Text-Mode routine. Customizes dynamic abbrevs." (set (make-local-variable 'dabbrev-case-fold-search) t) (set (make-local-variable 'dabbrev-case-replace) t) (set (make-local-variable 'dabbrev-upcase-means-case-search) t)) (add-hook 'text-mode-hook 'turn-on-auto-fill) (add-hook 'text-mode-hook 'my-textmode-stuff) ; (defun my-elisp-stuff () "My own Emacs Lisp stuff. Currently remaps ^J and ^M and customizes dynamic abbrevs." (set (make-local-variable 'dabbrev-case-fold-search) nil) (set (make-local-variable 'dabbrev-case-replace) nil) (define-key emacs-lisp-mode-map "\C-j" 'newline) (define-key emacs-lisp-mode-map "\C-m" 'newline-and-indent)) (add-hook 'emacs-lisp-mode-hook 'my-elisp-stuff) (defun my-info-stuff () "My own Info stuff. Currently sets faces and some variables." (set-face-foreground 'info-xref "orange") (set-face-background 'info-xref "steelblue2") ;lightgray (set-face-foreground 'info-node "red") (set-face-background 'info-node "steelblue2") ;lightgray (setq automatic-footnotes "On")) (add-hook 'Info-mode-hook 'my-info-stuff) (setq auto-mode-alist (append '(("\\.txh$" . texinfo-mode)) auto-mode-alist)) (defun my-texinfo-stuff () "My own Texinfo mode customizations." (set (make-local-variable 'dabbrev-case-fold-search) nil) (set (make-local-variable 'dabbrev-case-replace) nil) (define-key emacs-lisp-mode-map "\C-j" 'newline) (define-key emacs-lisp-mode-map "\C-m" 'newline-and-indent)) (add-hook 'texinfo-mode-hook 'my-texinfo-stuff) ; ;;; Automatically makes the matching paren stand out in color. (condition-case err (show-paren-mode t) (error (message "Cannot show parens %s" (cdr err)))) ;;; Enable some commands we need. (put 'narrow-to-region 'disabled nil) (put 'downcase-region 'disabled nil) (put 'upcase-region 'disabled nil) ; ;;; Font-locking faces set-up ; ;; Switch on font-lock for every mode which supports it. (if (fboundp 'global-font-lock-mode) (global-font-lock-mode t) (add-hook 'find-file-hooks 'turn-on-font-lock)) ;;; Each element of the list should be of the form ;;; (FACE FOREGROUND BACKGROUND BOLD-P ITALIC-P UNDERLINE-P) ;;; where FACE should be one of the face symbols, and the subsequent element ;;; items should be the attributes for the corresponding Font Lock mode ;;; faces. Attributes FOREGROUND and BACKGROUND should be strings (default ;;; if nil), while BOLD-P, ITALIC-P, and UNDERLINE-P should specify the ;;; corresponding face attributes (yes if non-nil). ;;; (setq font-lock-face-attributes '((font-lock-comment-face "red" nil nil t nil) (font-lock-string-face "violetred4" nil nil t nil) (font-lock-keyword-face "darkorchid" nil t nil nil) (font-lock-type-face "green4" nil nil nil nil) (font-lock-function-name-face "darkorange" nil t nil nil) (font-lock-variable-name-face "blue4" nil nil nil nil) (font-lock-reference-face "steelblue4" nil nil nil nil))) ; previously A had reference-face as nil nil nil t - but I hate underlining! ; (setq font-lock-maximum-decoration t) (setq font-lock-maximum-size (if font-lock-maximum-decoration (* 70 1024) (* 150 1024))) ; ;; This fontifies the compilation buffer when compilation exits. (defun my-compilation-finish-function (buf msg) "This is called after the compilation exits. Currently just highlights the compilation messages." (save-excursion (set-buffer buf) (font-lock-fontify-buffer))) (setq compilation-finish-function 'my-compilation-finish-function) ; ;; Setting this to t makes scrolling faster, but may momentarily present ;; unfontified areas when you scroll into them. ;(setq lazy-lock-defer-driven t) ; ;; Lazy-lock setup (autoload 'turn-on-lazy-lock "lazy-lock" "Unconditionally turn on Lazy Lock mode.") (add-hook 'font-lock-mode-hook 'turn-on-lazy-lock) (setq lazy-lock-minimum-size (* 4 1024)) (setq lazy-lock-stealth-time 16) (setq lazy-lock-defer-time 0.15) (setq lazy-lock-stealth-nice 1) (setq lazy-lock-stealth-lines 60) (setq font-lock-maximum-size nil) ; appropriate with lazy-lock ; ;;; This enables archive browsing and editing. (setq auto-mode-alist (cons '("\\.\\(arc\\|zip\\|lzh\\|zoo\\)\\'" . archive-mode) auto-mode-alist)) (autoload 'archive-mode "arc-mode" "Major mode for editing archives." t) ; ;;; This loads a package which enables automatic scrolling when long ;;; lines are truncated. (condition-case err (require 'auto-show) (error (message "Cannot auto-scroll long lines %s" (cdr err)))) ; ;;; This enables automatic resizing of the minibuffer when its contents ;;; won't fit into a single line. (condition-case err (resize-minibuffer-mode 1) (error (message "Cannot resize minibuffer %s" (cdr err)))) ; ;;; Dired-x installation and customization. ; ;;; This makes `dired-jump' and `dired-jump-other-window' work ;;; even *before* `dired' has been loaded. (define-key global-map "\C-x\C-j" 'dired-jump) ; ;;; This installs `dired-x.el' when `dired' is first invoked, and also ;;; replaces `find-file' with `dired-x-find-file'. (add-hook 'dired-load-hook (function (lambda () (setq dired-x-hands-off-my-keys nil) (load "dired-x") ;; Set dired-x global variables here. For example: ;; (setq dired-guess-shell-gnutar "gtar") (setq dired-local-variables-file "_dired") (setq dired-no-confirm '(byte-compile chmod compress copy load move print shell symlink uncompress)) ))) (add-hook 'dired-mode-hook (function (lambda () ;; Set dired-x buffer-local variables here. For example: ;; (setq dired-omit-files-p t) ))) ; ;;; Electric Buffer Menu mode customization. (defun my-ebuf-stuff () "My own Electric Buffer Menu stuff. Currently binds some convenience keys." (define-key electric-buffer-menu-mode-map [up] 'previous-line) (define-key electric-buffer-menu-mode-map [down] 'next-line) (define-key electric-buffer-menu-mode-map [next] 'scroll-up) (define-key electric-buffer-menu-mode-map [previous] 'scroll-down) (define-key electric-buffer-menu-mode-map [left] 'scroll-right) (define-key electric-buffer-menu-mode-map [right] 'scroll-left)) (add-hook 'electric-buffer-menu-mode-hook 'my-ebuf-stuff) ; ;;; This installs the `saveplace' package and defines where the places ;;; in visited files are saved between sessions. ;(condition-case err ; (require 'saveplace) ; (error ; (message "Cannot save places %s" (cdr err)))) ;(setq-default save-place t) ; place saved in all files ;(setq save-place-file "~/_places.sav") ; ;;; Ps-Print customization. (setq ps-header-lines 3) (setq ps-paper-type 'ps-a4) ; ;;; This enables automatic saving of the Emacs desktop configuration into ;;; a file called `emacs.desktop'. Should be as near the .emacs file end ;;; as possible. (condition-case err (progn (load "desktop") (desktop-load-default) (if (file-exists-p (concat "./" desktop-basefilename)) (desktop-read))) (error (message "Cannot save desktop %s" (cdr err)))) (setq desktop-missing-file-warning nil)