;; Fred says: ;; This file contains settings for Emacs and XEmacs, my editor(s) of choice. ;; Most of it is just the defaults provided by the CSL. My additions are marked ;; by "Fred says:" ;; I especially recommend the section on enabling scroll wheel support. ;; CSL UNIX .emacs ;; ;; .emacs file ;; $Id: .emacs,v 1.17 2002/03/13 18:24:12 nmueller Exp $ ;; ;; This file contains customization information for the text editor emacs. The ;; language that is used is called elisp, which is an emacs version of lisp. ;; ########################################################################### ;; The following two lines fix a problem that some people have. The original ;; emacs mapped C-h to be the help screen. Unfortunately, this is the same ;; as backspace. So, attempting to press backspace would bring up a help ;; screen. The new key-binding for help is C-x h. (global-set-key "\^xh" 'help-for-help) (global-set-key "\^h" 'backward-delete-char-untabify) ;; Fred says: ;; The default behavior of M-h (select region) doesn't help me much, so I ;; redefine it like so to delete one word back (which corresponds nicely to C-h ;; (bacward-delete one character)) ; First, we need a function that can delete a word. (defun delete-word (arg) "Delete characters forward until encountering the end of a word. With argument, do this that many times." (interactive "*p") (delete-region (point) (save-excursion (forward-word arg) (point)))) ; Then we wrap that function in a function that deletes a word backward. (defun backward-delete-word (arg) "Delete characters backward until encountering the end of a word. With argument, do this that many times." (interactive "*p") (delete-word (- arg))) ; Then we set M-h to call the backward-delete-word function. (global-set-key "\M-h" 'backward-delete-word) ; ; Similarly, M-s doesn't seem to do anything useful by default, so I'll map it ; to the save-buffer command, which will make saving the current document a ; rather Mac-like task. Or something. (global-set-key "\M-s" 'save-buffer) ;; ;; require-final-newline ensures that every line of a text file ends with a ;; "newline" characted. Many unix utilities need a final newline in order to ;; read the last line of the file. You probably don't want to change this. (setq require-final-newline t) ;; Uncomment the following to see the line number, column number and time ;(line-number-mode t) ;(column-number-mode t) ;(display-time) ;; If you would like smooth scrolling, uncomment this line ;(setq scroll-step 1) ;; For a much better buffer list: (global-set-key "\C-x\C-b" 'electric-buffer-list) ;; ########################################################################### ;; The following is an example of how to customize the c-mode. There are ;; also different modes for asm, c++, lisp, perl, tcl, tex, etc... ;; you can have GNU, K&R, BSD, C++, Whitesmith ;(setq default-c-style 'K&R) ;; another useful option ;(setq c-auto-newline t) ;;; Re-enable from "novice" (put 'eval-expression 'disabled nil) (put 'downcase-region 'disabled t) ;; It's very annoying to do this (put 'upcase-region 'disabled t) ;; by accident! ;; Fred says: ;; Mousewheel support is really nice to have. Unfortunately, Emacs and XEmacs ;; handle it differently, so we need separate cases for each version. ; ; First, here's the code to make Emacs work: (cond ((and (not (string-match "XEmacs" emacs-version)) (defun sd-mousewheel-scroll-up (event) "Scroll window under mouse up by five lines." (interactive "e") (let ((current-window (selected-window))) (unwind-protect (progn (select-window (posn-window (event-start event))) (scroll-up 5)) (select-window current-window)))) (defun sd-mousewheel-scroll-down (event) "Scroll window under mouse down by five lines." (interactive "e") (let ((current-window (selected-window))) (unwind-protect (progn (select-window (posn-window (event-start event))) (scroll-down 5)) (select-window current-window)))) (global-set-key (kbd "") 'sd-mousewheel-scroll-up) (global-set-key (kbd "") 'sd-mousewheel-scroll-down) ))) ;---------- ; Next, the code to make XEmacs work: ; ; Note that I actually define the behavior of the scroll wheel alone and with ; shift, control, and meta modifiers applied. You can play with the arguments ; if you want faster or slower scrolling. (cond ((and (string-match "XEmacs" emacs-version)) (defun scroll-up-one (event) "Scroll up one line." (interactive "e") (scroll-up 1) ) (defun scroll-down-one (event) "Scroll down one line." (interactive "e") (scroll-down 1) ) (defun scroll-up-five (event) "Scroll up five lines." (interactive "e") (scroll-up 5) ) (defun scroll-down-five (event) "Scroll down five lines." (interactive "e") (scroll-down 5) ) (global-set-key 'button5 'scroll-up-five) (global-set-key 'button4 'scroll-down-five) (global-set-key '(control button5) 'scroll-up) (global-set-key '(control button4) 'scroll-down) (global-set-key '(meta button5) 'scroll-up-five) (global-set-key '(meta button4) 'scroll-down-five) (global-set-key '(shift button5) 'scroll-up-one) (global-set-key '(shift button4) 'scroll-down-one) )) ;; Options Menu Settings ;; ===================== ; no longer needed as of xemacs 21.4 ;(cond ; ((and (string-match "XEmacs" emacs-version) ; (boundp 'emacs-major-version) ; (or (and ; (= emacs-major-version 19) ; (>= emacs-minor-version 14)) ; (= emacs-major-version 20)) ; (fboundp 'load-options-file)) ; (load-options-file "~/.xemacs-options"))) ;; ============================ ;; End of Options Menu Settings ; load variable config for xemacs (needs the customize package) ;(cond ; ((and (string-match "XEmacs" emacs-version) ; (boundp 'emacs-major-version) ; (or (and ; (= emacs-major-version 19) ; (>= emacs-minor-version 14)) ; (= emacs-major-version 20)) ; (fboundp 'load-options-file)) ; (load-options-file "~/.xemacs"))) ;; ########################################################################### ;; add some colors to your emacs (not xemacs) session (cond ((and (not (string-match "XEmacs" emacs-version)) window-system) (global-font-lock-mode t) (setq font-lock-maximum-decoration t) ; some other font-lock stuff you can set ; (setq font-lock-maximum-decoration 2) ; (font-lock-make-faces t) ; (setq font-lock-face-attributes ; '((font-lock-comment-face "Firebrick") ; (font-lock-string-face "RosyBrown") ; (font-lock-keyword-face "Purple") ; (font-lock-function-name-face "Blue") ; (font-lock-variable-name-face "DarkGoldenrod") ; (font-lock-type-face "DarkOliveGreen") ; (font-lock-reference-face "CadetBlue"))) )) ;; Fred says: ;; The following code was added automatically by XEmacs when I modified various ;; settings from within the XEmacs GUI. I don't know what all of them do, but ;; I'll try to explain the ones I can: (custom-set-variables '(paren-mode (quote paren) nil (paren)) ; Specifies that, when doing paragraph/comment rewrapping (M-q -- try it some ; time on a big block of comments), lines should not be more than 80 columns ; long. '(fill-column 80) '(default-input-method "rfc1345") ; Honestly, the forward-delete key really should delete forward. :) '(delete-key-deletes-forward t) ; Displays current column number in the little status bar at the bottom of the ; window. '(column-number-mode t) ; Like previous entry, displays current line number. '(line-number-mode t) ; The big block cursor that envelops the entire character after the insertion ; point confuses my gentle, Mac-bred brain, so this replaces it with a nice, ; unconfusing vertical bar. '(bar-cursor 2) '(case-fold-search t) '(global-font-lock-mode t nil (font-lock)) ; When your insertion point is before a (, [, {, or (in HTML mode) <, this ; highlights the matching ), ], }, or >, and vice versa if it's *after* a ; *closing* symbol. '(show-paren-mode t nil (paren)) '(current-language-environment "UTF-8" t) ; I like to indent only two spaces in each new block of code. This option makes ; Python (my favorite casual programming language) mode do so. '(py-indent-offset 2) ; I guess this is how it knows my email address ... '(user-mail-address "fredrick@cs.wisc.edu" t) ; ... and this makes it not ask me for my email address every time. Or ; something. '(query-user-mail-address nil)) (custom-set-faces '(default ((t (:family "Clean"))) t)) ; I think this makes Emacs just insert spaces instead of tab characters when ; automatically indenting things. (setq-default indent-tabs-mode nil)