The very unofficial .emacs home MichaelAWolf.emacs
what is this all about ?
customization basics
special topics
local dotfiles
dotfiles on the web
new and updated pages
useful sites and pages
search locally
OS/2 Emacs
Latest Additions
local files:
John J. Glynn
David Jolley

linked files:


The Emacs wiki
ODP search for Emacs
;; -*- lisp -*- 

;; This is my .emacs file.  I don't know who the original author of this
;; was, but I'd be happy to give credit to whomever deserves it.
;; I've made a few modifications myself, though, mainly in the color 
;; scheme I'm using.  I've also gone through this file and added comments
;; as an explanation to various items here.  Hopefully you'll like some
;; of what I have here, and find it useful.  

;; You can email me at < >. 

;; I don't know whether I am legally able to put a license on a configuration
;; file like this, but assuming that I can, consider it licensed under
;; the GNU GPL.  Change it, share it, learn from it. :)  That's what GNU,
;; and free software in general, is all about.  

;; And remember, Emacs Is The One True Text Editor (tm). :) 

;; The first line sets emacs to lisp mode.  If I had used -*- c -*-, it would
;; go to c-mode, -*- perl -*- to perl-mode, etc. 

(c-set-style "bsd") 
;; I prefer BSD style C indentation over the default GNU style.  Other choices
;; are gnu, k&r,  whitesmith, etc.  You can change this on fly using 
;; M-x c-set-style.  Use tab to see the options. 

(line-number-mode 1)
;; This tells emacs to show the line number in each modeline. 
;; The modeline is the bar across the bottom of each buffer (except the 
;; minibuffer, the line of text at the very bottom of the emacs 
;; window), which displays various info about the buffer. 

(column-number-mode 1)
;; This tells emacs to show the column number in each modeline. 

(setq scroll-step 1)
;; When you scroll down with the cursor, emacs will move down the buffer one 
;; line at a time, instead of in larger amounts.

(menu-bar-mode nil)
;; This turns off the GUI menus in X.  You can toggle this at any point with
;; M-x menu-bar-mode.  If you're new to emacs, you might want to disable this.
;; (Or would that be reenable it?)  In my case, though, an extra line of 
;; emacs real estate never hurts. :) 

(fset 'yes-or-no-p 'y-or-n-p)
;; Makes things a little bit more consistent.

;; Automagically starts emacs server, so you can load files from other 'terms.

;; At the end of the GNU emacs specific things, I have two lines regarding 
;; some session management stuff.  I've explained more there. 

(font-lock-mode 1)

(load "/home/mike/emacs/mutt")
;; This just loads mutt.elc (don't need to put in .el or .elc), a handy mode 
;; when you use emacs as your text editor with the mutt email client.  (You 
;; can find out a lot more about mutt at <>. Speaking of
;; email, you can use emacs itself as a mail editor. M-x mail is one way, and
;; there are probably other elisp packages for this as well. )  This 
;; is a good way to use your own elisp packages when you don't have root 
;; access on a given machine.  If you want to byte-compile an elisp package,
;; you can do so by typing M-x byte-compile-file, and then choosing the file
;; you want byte compiled.  It'll load a lot faster when you do that.  

;; You can supposedly find lots of elisp packages at 
;;, which is considered
;; to be the cannonical site. 

;; Also remember that in emacs, tab completion can save you a good deal of 
;; typing, much like in a lot of shells.  

(defvar running-xemacs 
  (string-match "XEmacs\\|Lucid" emacs-version))
(cond ((and (not running-xemacs) 
            (>= emacs-major-version 19))
       ;; Checks to see if you're running xemacs
       ;; or GNU emacs.  I usually use GNU emacs, but am set up to use both.
       (setq text-mode-hook (function (lambda () (turn-on-auto-fill)))
             inhibit-startup-message t)

       ;; These tell emacs to associate certain filename extensions with 
       ;; certain modes.  I use cc-mode.el (c++-mode) for C as well as C++
       ;; code.  It is fairly all-encompassing, also working with other C-like
       ;; languages, such as Objective C and Java. 
       (setq auto-mode-alist (cons '("\\.text$" . text-mode) auto-mode-alist))
       (setq auto-mode-alist (cons '("\\.txt$" . text-mode) auto-mode-alist))
       (setq auto-mode-alist (cons '("\\.doc$" . text-mode) auto-mode-alist))
       (setq auto-mode-alist (cons '("\\.awk$" . awk-mode) auto-mode-alist))
       (setq auto-mode-alist (cons '("\\.perl$" . perl-mode) auto-mode-alist))
       (setq auto-mode-alist (cons '("\\.plx$" . perl-mode) auto-mode-alist))
       (setq auto-mode-alist (cons '("\\.pl$" . perl-mode) auto-mode-alist))
       (setq auto-mode-alist (cons '("\\.C$" . c++-mode) auto-mode-alist))
       (setq auto-mode-alist (cons '("\\.cc$" . c++-mode) auto-mode-alist))
       (setq auto-mode-alist (cons '("\\.c$" . c++-mode) auto-mode-alist))
       (setq auto-mode-alist (cons '("\\.h$" . c++-mode) auto-mode-alist))
       (setq auto-mode-alist (cons '("\\.cpp$" . c++-mode) auto-mode-alist))
       (setq auto-mode-alist (cons '("\\.cxx$" . c++-mode) auto-mode-alist))
       (setq auto-mode-alist (cons '("\\.tcl$" . tcl-mode) auto-mode-alist))
       (setq auto-mode-alist (cons '("\\.sh$" . shell-script-mode) 
       (setq auto-mode-alist (cons '("\\.zsh$" . shell-script-mode)
       (setq completion-ignored-extensions;; Filename completion ignores these.
      (append completion-ignored-extensions 
                     '(".CKP" ".u" ".press" ".imp" ".BAK")))
       (put 'eval-expression 'disabled nil)

       ;; Here are some keyboard shortcuts that are handy.  They're pretty 
       ;; easy to define.  The last thing is the same as you'd type using 
       ;; M-x (presumably).  It's probably a good idea to use global-unset-key
       ;; before defining it to something else, just in case.  You can see a 
       ;; list of all the keyboard bindings with M-x describe-bindings.

       (global-unset-key "\M-n")
       (global-set-key "\M-n" 'gnus)
       (global-unset-key "\C-j")
       (global-set-key "\C-j" 'goto-line)
       (global-unset-key "\M-o")
       (global-set-key "\M-o" 'other-window)
       (global-unset-key "\M-m")
       (global-set-key "\M-m" 'buffer-menu)
       (global-unset-key "\M-p")
       (global-set-key "\M-p" 'split-window)

       ;; These two below set M-Backspace
       (global-unset-key "\M-\C-?")
       (global-set-key "\M-\C-?" 'kill-buffer)
       ;; (global-unset-key "\M-\C-f")
       ;; (global-set-key "\M-\C-f" 'font-lock-mode)
       (define-key ctl-x-map "t" 
         '(lambda () (interactive) ;; Toggle date display.
     (setq display-time-day-and-date
                  (not display-time-day-and-date))
            (display-time-filter 1 display-time-string)))
       (load "mh-e" nil t)
       (load "gnus" nil t)
       (load "time" nil t)

       ;; Here are some color preferences.  I've spent a good deal of time
       ;; adjusting color settings, trying to get it to look good and also be
       ;; fairly easy to read. 
       (setq default-frame-alist 
             (append default-frame-alist 
                     ;;'((foreground-color . "yellow")
              '((foreground-color . "green")
                       ;; '((foreground-color . "wheat")
                (background-color . "black")
                       ;; (cursor-color . "green3"))))
                (cursor-color . "blue"))))
       (set-face-foreground 'bold "yellow")
       (set-face-background 'bold "grey40")
       (set-face-foreground 'bold-italic "yellow green")
       (set-face-foreground 'italic "yellow3")
       (set-face-foreground 'region "white")
       (set-face-background 'region "blue")

       ;; These lines tell emacs to automagically font-lock buffers which are
       ;; covered by various modes. 
        emacs-lisp-mode-hook '(lambda () (font-lock-mode 1))
        lisp-mode-hook '(lambda () (font-lock-mode 1))
        c-mode-hook '(lambda () (font-lock-mode 1))
        c++-mode-hook '(lambda () (font-lock-mode 1))
        html-mode-hook '(lambda () (font-lock-mode 1))
        shell-script-mode-hook '(lambda () (font-lock-mode 1))
        makefile-mode-hook '(lambda () (font-lock-mode 1))
        mutt-mode-hook '(lambda () (font-lock-mode 1))
        perl-mode-hook '(lambda () (font-lock-mode 1))
        cperl-mode-hook '(lambda () (font-lock-mode 1))
        c++-c-mode-hook '(lambda () (font-lock-mode 1))
        tex-mode-hook '(lambda () (font-lock-mode 1))
        shell-mode-hook '(lambda () (font-lock-mode 1))
        dired-mode-hook '(lambda () (font-lock-mode 1))
        rmail-mode-hook '(lambda () (font-lock-mode 1))
        rmail-summary-mode-hook '(lambda () (font-lock-mode 1))
        compilation-mode-hook '(lambda () (font-lock-mode 1)))
       ;; Here is more font-lock coloring stuff. 
       (make-face 'fl-comment-face)
       (set-face-foreground 'fl-comment-face "white")
       ;;(set-face-background 'fl-comment-face "black")
       (setq font-lock-comment-face 'fl-comment-face)
       ;; I'm not totally sure what the difference between fl-doc-string-face 
       ;; and fl-string-face is; I have them set to the same color, though. 
       (make-face 'fl-doc-string-face)
       ;; (set-face-foreground 'fl-doc-string-face "orange")
       ;; (setq font-lock-doc-string-face 'fl-doc-string-face)
       (set-face-foreground 'fl-doc-string-face "orange")
       (setq font-lock-doc-string-face 'fl-doc-string-face)

       (make-face 'fl-string-face)
       (set-face-foreground 'fl-string-face "red")
       (setq font-lock-string-face 'fl-string-face)
       (make-face 'fl-function-name-face)
       (set-face-foreground 'fl-function-name-face "DeepSkyBlue")
       (setq font-lock-function-name-face 'fl-function-name-face)
       (make-face 'fl-keyword-face)
       (set-face-foreground 'fl-keyword-face "blue")
       (setq font-lock-keyword-face 'fl-keyword-face)
       ;; In this instance, type refers to variable types in C: int, char, etc.
       (make-face 'fl-type-face)
       (set-face-foreground 'fl-type-face "cyan")
       (setq font-lock-type-face 'fl-type-face)
       (set-face-foreground 'modeline "black")
       (set-face-background 'modeline "white")
       (set-face-foreground 'highlight "black")
       (set-face-foreground 'secondary-selection "black")
       (set-face-foreground 'highlight "black")

      ;; Works to save your current emacs session -- your buffers, positions 
      ;; within them, etc, and to reload your old emacs session when you start
      ;; emacs up again.  The first time you want to do this, you also need 
      ;; to do "M-x desktop-save". 
      ;; The reason that I have this down here towards the end of the file is
      ;; that all the nice font-locking stuff is otherwise ignored -- you'd 
      ;; need to do "M-x font-lock-mode" by hand, for each buffer, every time.
      ;; That's no good. 

;; Here's where I keep xemacs-specific stuff. 
;; It isn't currently working at the moment.  Some of the stuff at the top
;; of the file reverses xemacs' defaults.  It wouldn't be difficult to fix.
 ((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 "/home/mike/.xemacs-options")))
;; ============================
;; End of Options Menu Settings

 '(user-mail-address "" t)
 '(query-user-mail-address nil))
All content copyright by the contributors. Website maintained with Emacs , wsmake and html-helper-mode
Emacs community logo by Daniel Lundin Last updated on Sat Jan 22 14:49:24 2005 by Ingo Koch