The very unofficial .emacs home ElijahDaniel.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
;; Data structure manipulation functions        
;; load miscellaneous elisp stuff
(require 'cl)

;; list manipulation
(defun ewd-fold (init op list)
  "OP is a function taking two arguments.  For each element in LIST, call OP
on the accumulated result so far (beginning with INIT) and the element."
  (if (null list) init
    (ewd-fold (funcall op init (car list)) op (cdr list))))

;; alist manipulation
(defun mapassoc (func alist)
  "map func down alist, listing results"
  (mapcar (lambda (entry) (ewd-apply func entry)) alist))

(defun mapa (func alist)
  "map func down alist, ignoring results"
  (mapc (lambda (entry) (ewd-apply func entry)) alist))

;; list/dotted pair manipulation
(defun ewd-apply (func &rest args)
  "Act just like `apply', only the final argument can end with a dotted pair
instead of nil."
  (let ((revargs (reverse args)))
    (apply 'apply func (reverse (cons (ewd-standardize (car revargs))
                                      (cdr revargs))))))
(defun ewd-standardize (l)
  "Return a standard list (ending in nil) which contains the same elements
as L."
   ((null l) '())
   ((not (listp l)) (list l))
   (t (cons (car l) (ewd-standardize (cdr l))))))

;; Programming commands
;; If point is in a class definition, return the name of the class. Otherwise,
;; return nil.
(defun ewd-classname ()
  "If the point is in a class definition, get the name of the class.  Return
nil otherwise."
    (let ((brace (assoc 'inclass (c-guess-basic-syntax))))
      (if (null brace) '()
        (goto-char (cdr brace))
        (let ((class-open (assoc 'class-open (c-guess-basic-syntax))))
          (if class-open (goto-char (cdr class-open)))
          (if (looking-at "^class[ \t]+\\([A-Za-z_][^ \t:{]*\\)")
              (buffer-substring (match-beginning 1) (match-end 1))
            (error "Error parsing class definition!")))))))

;; Insert function prototype in current header file and matching
;; function body in implementation file. 
(defun ewd-insert-new-method (rettype proto)
  "Insert a method into the current header file at point. Insert
implementation, too.  This function expects the implementation file to
be named foo.cpp and in the same directory as the current file, foo.h."
  (interactive "sReturn type: \nsPrototype: ")
  (let ((classname (ewd-classname))
        (c-tab-always-indent t))
    (if (null classname) (message "Not in class definition!")
      (unless (string-equal rettype "") (setq rettype (concat rettype " ")))
      (insert rettype proto ";\n")
        (find-file (concat
                    (file-name-sans-extension (buffer-file-name))
        (insert "\n\n")
        (insert rettype classname "::" proto "\n{\n}\n")))))

;; Insert function comment file template from
;; ~/templates directory
(defun insert-function-comment ()  
  "Insert function comment"
  (let ((nchars (cadr (insert-file-contents "~/templates/function.cpp"))))
    (forward-char nchars)))
;; Interactive editing commands
;; fill current buffer
(defun ewd-fill-buffer ()
  "Fill current buffer (see `fill-region' for details)"
  (fill-region (point-min) (point-max)))

;; repaint current block and recenter around current line
(defun ewd-font-lock-repaint (&optional pos)
  "Repaint current block and recenter buffer around current line.  With pos,
pos is passed as an argument to recenter."
  (interactive "P")
  (if (null pos)
    (recenter pos)))

;; issue ewd-compile-command in the current directory
(defvar ewd-compile-command "build-nt DEBUG="
  "*The command ewd-docompile should issue in the current directory.  This
command must take the /a flag to indicate a \"rebuild all\".")
(defun ewd-docompile (&optional all)
  "Issues `ewd-compile-command' in the current directory,
presumably to build the current project.  If ALL is specified,
rebuild all."
  (interactive "P")
   (concat ewd-compile-command (unless (null all) " /a")))
  (pop-to-buffer "*compilation*" t)
  (goto-char (point-max)))

;; duplicate current line
(require 'misc)
(defun ewd-dup-line()
  "Copy the current line and insert copy as the following line."
    (forward-line 1)
    (insert "\n")))

;; move to the beginning of buffer without clobbering the mark
(defun ewd-beginning-of-buffer-nomark ()
  "Move point to the beginning of the current buffer
without clobbering the mark."
  (goto-char (point-min)))  

;; move to the end of buffer without clobbering the mark
(defun ewd-end-of-buffer-nomark ()                  
  "Move point to the end of the current buffer without
clobbering the mark."            
  (goto-char (point-max)))

;; open speedbar frame or switch between frames if it's open already.
(defvar speedbar-frame nil)
(defun ewd-speedbar-frame (&optional ARG)
  "If the speedbar frame is not open, open it.  If it is open and ARG is
specified, close it.  Otherwise, switch between frames.
`speedbar-get-focus' should already do something like this, but it's a
little buggy."
  (interactive "P")
  (if speedbar-frame
      (if (null ARG)
        (speedbar-frame-mode -1))
    (speedbar-frame-mode 1)))

;; print X font name for Windows font
(if (eq window-system 'w32)
    (defun ewd-get-x-font-name ()
      "Select font from dialog box, then print X font name in current buffer."
      (insert (prin1-to-string (w32-select-font)))))

;; add a string in front of all lines in the region
(defun ewd-prepend (start end s)
  "Add a string in front of all lines in the region."
  (interactive "*r\nMEnter a string: ")
       (progn (goto-char start) (beginning-of-line) (point))
       (progn (goto-char end) (end-of-line) (point)))
      (goto-char (point-min))
      (while (not (eobp))
        (insert s)
        (forward-line 1)))))
;; remove a string from the beginning of all lines in the region
(defun ewd-unprepend (start end s)    
  "Remove a string from the front of all lines in the region."
  (interactive "*r\nMEnter a string: ")
       (progn (goto-char start) (beginning-of-line) (point))
       (progn (goto-char end) (end-of-line) (point)))
      (goto-char (point-min))         
      (while (not (eobp))
        (if (looking-at (regexp-quote s))
            (delete-region (match-beginning 0) (match-end 0)))
        (forward-line 1)))))
;; add a comment character in front of all lines in the region
(defun ewd-comment-region (start end)
  "Add one comment character in front of all lines in
the region."       
  (interactive "*r")                  
  (or comment-start (setq comment-start (read-input "Comment char?: ")))
  (ewd-prepend start end comment-start))
;; remove a comment character from in front of all lines in the region
(defun ewd-uncomment-region (start end)
  "Remove one comment character from in front of all lines in
the region."
  (interactive "*r")                  
  (or comment-start (setq comment-start (read-input "Comment char?: ")))
  (ewd-unprepend start end comment-start))

;; Buffer manipulation functions
(defun yic-next-buffer ()         
  "Switch to next buffer in current window. []"
  (let ((buffers (nreverse (buffer-list))))
    (while (eq (string-to-char (buffer-name (car buffers))) 32)
      (setq buffers (cdr buffers)))
    (switch-to-buffer (car buffers))))
(defun yic-other-buffer ()
  "Switch to the other buffer (2nd in list-buffer) in
current window."                                      
  (switch-to-buffer (other-buffer)))

(defun ewd-kill-current-buffer ()
  "Kill current buffer."    
  (if (equal (buffer-name) "*scratch*")
      (progn (delete-region (point-min) (point-max))
             (if (> (ewd-buffer-count) 1) (bury-buffer)))
    (kill-buffer (current-buffer))))
;; Tweak built-in behaviors
;; make cursor stay in the same column when scrolling
(defadvice scroll-up (around ewd-scroll-up first act)
  "Keep cursor in the same column."
  (let ((col (current-column)))
    (move-to-column col)))
(defadvice scroll-down (around ewd-scroll-down first act)
  "Keep cursor in the same column."
  (let ((col (current-column)))
    (move-to-column col))) 
;; Make subsequently opened frames offset from the first one
(defvar ewd-frame-offset 25
  "*Amount to offset each subsequently created frame")
(defadvice x-create-frame-with-faces (before ewd-create-frame activate)
  "Make subsequent frames open at an offset"
  (let* ((topelt (assoc 'top default-frame-alist))
         (leftelt (assoc 'left default-frame-alist))
         (top (if (null topelt)
                  (car (setq default-frame-alist
                             (cons '(top . 0) default-frame-alist)))
         (left (if (null leftelt)
                   (car (setq default-frame-alist
                              (cons '(left . 0) default-frame-alist)))
         (toppos (cdr top))
         (leftpos (cdr left)))
    (setcdr top (+ toppos ewd-frame-offset))
    (setcdr left (+ leftpos ewd-frame-offset))))

;; telnet with telnet.exe written by Naftali Ramati (
;; Thanks to Zoltan Kemenczy (
(defun zoltan-telnet (host)
  "Open a network login connection to host named HOST (a string).
Communication with HOST is recorded in a buffer `*telnet-HOST*'.
Normally input is edited in Emacs and sent a line at a time."
  (interactive "sOpen telnet connection to host: ")
  (let* ((comint-delimiter-argument-list '(?\  ?\t))
         (name (concat "telnet-" (comint-arguments host 0 nil) ))
         (buffer (get-buffer (concat "*" name "*")))
    (if (eq window-system 'w32)
        (setq telnet-new-line "\n"))
    (if (and buffer (get-buffer-process buffer))
        (pop-to-buffer (concat "*" name "*"))
      (pop-to-buffer (make-comint name telnet-program nil host))
      (setq process (get-buffer-process (current-buffer)))
      (set-process-filter process 'telnet-initial-filter)
      (accept-process-output process)
      (setq comint-input-sender 'telnet-simple-send)
      (setq telnet-count telnet-initial-count))))

;; Toggle keypad as prefix / keypad as numbers
;; make keypad numbers be treated as prefix keys
(defun ewd-kp-as-prefix ()                 
  "Make keypad numbers act as prefix keys."
  (define-key function-key-map [kp-0] [27 ?0])
  (define-key function-key-map [kp-1] [27 ?1])
  (define-key function-key-map [kp-2] [27 ?2])      
  (define-key function-key-map [kp-3] [27 ?3]) 
  (define-key function-key-map [kp-4] [27 ?4])
  (define-key function-key-map [kp-5] [27 ?5])
  (define-key function-key-map [kp-6] [27 ?6])
  (define-key function-key-map [kp-7] [27 ?7])
  (define-key function-key-map [kp-8] [27 ?8])
  (define-key function-key-map [kp-9] [27 ?9])
  (define-key function-key-map [kp-decimal] [27 ?-])
  (message "Keypad numbers are prefix keys."))
;; make keypad numbers be treated as numbers
(defun ewd-kp-as-num ()
  "Make keypad numbers act as numbers."
  (define-key function-key-map [kp-0] [?0])
  (define-key function-key-map [kp-1] [?1])
  (define-key function-key-map [kp-2] [?2])           
  (define-key function-key-map [kp-3] [?3])
  (define-key function-key-map [kp-4] [?4])
  (define-key function-key-map [kp-5] [?5])
  (define-key function-key-map [kp-6] [?6])
  (define-key function-key-map [kp-7] [?7])         
  (define-key function-key-map [kp-8] [?8])
  (define-key function-key-map [kp-9] [?9])
  (define-key function-key-map [kp-decimal] [?.])
  (message "Keypad numbers are numbers."))

;; toggle the way keypad numbers are interpreted
(defun ewd-toggle-kp-usage ()
  "Switch the way keypad numbers are interpreted."
  (cond ((eq ewd-kp-usage 'num)           
         (setq ewd-kp-usage 'prefix))
        ((eq ewd-kp-usage 'prefix)         
         (setq ewd-kp-usage 'num))))

;; Miscellaneous utility functions
;; Get current number of non-internal buffers
(defun ewd-buffer-count (&optional FRAME)
  "Return number of non-internal buffers currently alive.  If FRAME is
specified,count buffers in FRAME."
  (ewd-fold 0 (lambda (buffers each)
                (if (eq ?  (string-to-char (buffer-name each))) buffers
                  (+ 1 buffers)))
            (buffer-list FRAME)))
;; Change how charaters are transposed
(defun gosmacs-transpose-chars ()
  "The real way to transpose characters with ^T: always
transpose the previous two characters from where the
point is."                                
  (interactive nil)
  (forward-char -1)
  (transpose-chars 1))                     

;; Set up environment
;; Make bash work right.  This requires Cygwin bash from
(if (eq window-system 'w32)
    (setq process-coding-system-alist         
          (cons '("bash" . raw-text-unix) process-coding-system-alist)))
;; Backup files/versioning
(setq make-backup-files nil)      ; don't make pesky backup files
(setq version-control 'never)     ; don't use version numbers for backup files

;; Environment
(setq tab-width 5)                      ; tab = 5 spaces
(setq-default indent-tabs-mode nil)     ; use spaces (not tabs) for indenting
(setq kill-ring-max 10)                 ; don't save too many kills
(setq require-final-newline t)          ; always terminate last line in file
(setq default-major-mode 'text-mode)    ; default mode is text mode
(setq next-screen-context-lines 1)      ; # of lines of overlap when scrolling
(setq auto-save-interval 300)           ; autosave every N characters typed
(setq default-fill-column 77)           ; the column beyond which do word wrap
(setq scroll-preserve-screen-position t); make pgup/dn remember current line
(setq next-line-add-newlines nil)       ; don't scroll past end of file
(setq ewd-kp-usage 'num)                ; keypad numbers are numbers by default
(global-auto-revert-mode 1)             ; autorevert buffers if files change
(if (eq window-system 'w32)
    (setq w32-enable-italics t))        ; enable italics on Windows

;; Paren matchine
(show-paren-mode t)                        ; highlight matching parens, etc
(setq show-paren-style 'parenthesis)       ; highlight character, not expression
(setq blink-matching-paren-distance 51200) ; distance to match paren as

;; Define colors
(mapa 'w32-define-rgb-color
      '((216 208 200 "PlumBackground")
        ( 72  64  96 "PlumTitleBar")
        ( 40  72  72 "PlumSelection")
        (120  96  88 "PlumCursor")
        ( 64  40  64 "PlumDesktop")))

;; Set up paths
(setq Info-directory-list '("d:/emacs/elisp-info" "d:/emacs/info"))
(setq exec-path (cons "~/bin" exec-path))

;; modeline options
(which-func-mode t)                 ; show current function in modeline
(setq display-time-day-and-date t)  ; display day and date
(display-time)                      ; display the time

;; Set up frame position and coloring
(setq default-frame-alist
        (top . 50)
        (left . 100)
        (width . 110)
        (height . 40)
        (cursor-color . "brown4")
        (background-color . "floral white")
        (font . "-*-Courier New-normal-r-*-*-13-*-*-*-c-*-iso8859-1")

;; Make .com and .out files be text rather than binary
(setq file-name-buffer-file-type-alist
      (cons '("\\.\\(com\\|out\\)$") file-name-buffer-file-type-alist)) 

;; Set up additional packages             
;; make end-of-line conversion easier.  The eol-conversion package was written
;; by Francis J. Wright <>.  Available from
(setq eol-mnemonic-dos ?\\)
(setq eol-mnemonic-mac ?:)
(setq eol-mnemonic-unix ?/)
(setq eol-mnemonic-undecided ??)
(require 'eol-conversion)
;; Set up gnuserv (so double-clicking a file associated with emacs does not
;; fire up a new instance).  The gnuserv package was written by Nico Francois
;; <>.  Available from
(require 'gnuserv)
(setq gnuserv-frame (selected-frame))

;; Make telnet-mode work
(require 'telnet)
(setq telnet-program "~/bin/telnet.exe")
(fset 'telnet 'zoltan-telnet)

;; Make ange-ftp work through the firewall
(setq ange-ftp-gateway-host "")
(setq ange-ftp-smart-gateway-port 1555)
(setq ange-ftp-smart-gateway t)
(setq ange-ftp-local-host-regexp
(setq ange-ftp-skip-msgs
       "^200 \\(PORT\\|Port\\) \\|^331 \\|^150 \\|^350 \\|^227 \\|"
       "^[0-9]+ bytes \\|^Connected \\|^$\\|^Remote system\\|^Using\\|"
       "^ \\|Password:\\|^Data connection \\|^local:\\|^Trying\\|^125 \\|"
       "^550-\\|^221 .*oodbye")
(setq ange-ftp-gateway-program-interactive nil)
(setq ange-ftp-tmp-name-template 
      (concat (expand-file-name (getenv "TEMP")) "/ange-ftp"))
(setq ange-ftp-gateway-tmp-name-template 
      (concat (expand-file-name (getenv "TEMP")) "/ange-ftp"))

;; make a spiffy, organized buffer menu
(require 'msb)

;; Set up syntax highlighting (font-lock) 
(cond (window-system
       (require 'font-lock-menu) 
       (setq font-lock-maximum-decoration t) 
       (global-font-lock-mode t)        
       (setq font-lock-support-mode 'lazy-lock-mode) 
       (setq font-lock-defer-on-scrolling nil) 
       (setq font-lock-defer-on-the-fly nil) 
       (setq lazy-lock-defer-time 0)         
       (setq lazy-lock-minimum-size 10240)   

;; Set up C pretty-printing
;; define a new indentation style
(c-add-style "Eli"
               (c-basic-offset . 4)
               (c-comment-continuation-stars . "*")
               (compile-command . nil)
               (dabbrev-case-replace . nil)
               (c-auto-newline . t)
               (c-cleanup-list . (scope-operator
               (c-offsets-alist . ((string . 0)
                                   (substatement-open . 0)
                                   (knr-argdecl-intro . 0)
                                   (inline-open . 0)
                                   (case-label . *)
                                   (access-label . /)
                                   (statement-case-intro . *)
                                   (statement-case-open . *)
                                   (arglist-close . c-lineup-close-paren)
                                   (inextern-lang . 0)))

;; define extra C types to font-lock
(setq c-font-lock-extra-types
       '("BOOL" "BSTR" "LPC?\\(W\\|T\\|OLE\\)?\\STR" "HRESULT"
         "BYTE" "DWORD" "SOCKET" "idl_char"
         "idl_boolean" "idl_byte" "idl_\\(short\\|long\\)_float"
         "boolean32" "unsigned\\(32\\|16\\)"
         "SAFEARRAY" "boolean" "UINT" "ULONG")

;; define extra C++ types to font-lock
(setq c++-font-lock-extra-types

;; Set up hooks for often-used major modes 

;; set up hooks for c-perl-mode.  Available from
(add-hook 'perl-mode-hook
             (local-set-key "\M-t" 'tab-to-tab-stop)
             (local-set-key "\M-g" 'goto-line)
             (local-set-key "\C-l" 'ewd-font-lock-repaint)
             (setq cperl-hairy t)
             (setq perl-indent-level 0)
             (setq perl-continued-statement-offset 0)                
             (setq perl-brace-offset 2)
             (setq perl-continued-brace-offset 2)
             (setq perl-brace-imaginary-offset 2)
             (setq perl-label-offset 0)

(add-hook 'c-mode-common-hook                         
           (lambda ()
             (imenu-add-to-menubar "Functions")
             (local-set-key "\M-t" 'tab-to-tab-stop)
             (local-set-key "\M-g" 'goto-line)
             (c-set-style "Eli")

(add-hook 'c-mode-hook                         
           (lambda ()
             (modify-syntax-entry ?_ "w" c-mode-syntax-table)
(add-hook 'c++-mode-hook                                             
           (lambda ()
             (modify-syntax-entry ?_ "w" c++-mode-syntax-table)
             (local-unset-key "\C-c:")

(add-hook 'emacs-lisp-mode-hook 
           (lambda ()                                 
             (local-set-key "\M-t" 'tab-to-tab-stop)
             (local-set-key "\M-g" 'goto-line)
             (local-set-key "\C-l" 'ewd-font-lock-repaint)

(add-hook 'text-mode-hook                 
           (lambda ()           

(add-hook 'makefile-mode-hook
             (local-unset-key "\C-c:")

;;(add-hook 'shell-mode-hook
;;          (function
;;           (lambda ()        
;;             (setq comint-scroll-show-maximum-output 'this)
;;             (setq comint-completion-addsuffix t)
;;             (setq comint-process-echoes nil)
;;             (setq comint-eol-on-send t)
;;             (setq w32-quote-process-args ?\")
;;             (make-variable-buffer-local 'comint-completion-addsuffix)
;;             )))

;; Set up additional modes                     
;; a better Perl mode                             
(autoload 'perl-mode "cperl-mode" "better mode for editing Perl programs" t)

;; windows-specific modes
(autoload 'bat-generic-mode "generic-x" "Windows BAT file editing mode" t)
(autoload 'inf-generic-mode "generic-x" "Windows INF file editing mode" t)
(autoload 'rc-generic-mode "generic-x" "Windows RC file editing mode" t)
(autoload 'reg-generic-mode "generic-x" "Windows REG file editing mode" t)

;; read man pages without external programs.  Woman package written by
;; Francis J. Wright <>. Available from
(autoload 'woman "woman" "Read man pages without external programs" t)
(setq woman-path "d:/emacs/etc")
(setq woman-imenu t)

;; a better HTML editing mode.  Written by Nelson Minar <>.
;; Available from
(autoload 'html-helper-mode "html-helper-mode" "HTML major mode." t)
(setq html-helper-do-write-file-hooks t) 
(setq html-helper-build-new-buffer t)   
(setq html-helper-address-string
      "Eli Daniel &lt;;")
(setq tempo-interactive t)              

;; COBOL mode for ANSI COBOL.  Written by Arne Steuer and Stefano Ianigro.
(autoload 'cobol-mode "cobol-mode" "major mode for editing COBOL programs" t)

;; Nice TeXing for Windows.  Requires AucTeX, available from
;; and MikTeX, available from
(if (eq window-system 'w32)
    (require 'tex-site))
;; Set up the speedbar.  The speedbar that comes with emacs 20.3.1 is broken.
;; Use the one from
;; instead.
(when window-system
  (autoload 'speedbar-frame-mode "speedbar" "Popup a speedbar frame" t)
  (autoload 'speedbar-get-focus "speedbar" "Jump to speedbar frame" t))

;; Set up Source Safe mode
(require 'source-safe)
(setq ss-program "C:/Program Files/Microsoft Visual Studio/vss/win32/ss.exe")
(setq ss-project-dirs '(("^d:/devel/wmw/mc" . "$/MC/")
                        ("^d:/devel/wmw/sc" . "$/SC/")
                        ("^d:/devel/wmw/generator" . "$/generator/")))

;; Set global keybindings       
(mapa 'global-set-key
 '(([f7] . ewd-docompile)
   ([f4] . ewd-speedbar-frame)
   ([f11] . ewd-dup-line)
   ([end] . end-of-line)
   ([C-end] . ewd-end-of-buffer-nomark)
   ([home] . beginning-of-line)
   ([C-home] . ewd-beginning-of-buffer-nomark)
   ([apps] . execute-extended-command)
   ([C-right] . forward-sexp)
   ([C-left] . backward-sexp)
   ("\C-cd" . ediff-buffers)
   ("\C-m" . newline-and-indent)
   ("\C-x\C-p" . bury-buffer)
   ("\C-x\C-n" . yic-next-buffer)
   ("\C-x\C-o" . yic-other-buffer)
   ("\C-x\C-k" . ewd-kill-current-buffer)
   ("\C-h\C-v" . apropos-variable)
   ("\C-c;" . ewd-comment-region)
   ("\C-c:" . ewd-uncomment-region)
   ("\C-t" . gosmacs-transpose-chars)
   ("\C-ck" . ewd-toggle-kp-usage)
   ("\C-l" . ewd-font-lock-repaint)
   ("\C-cf" . ewd-get-x-font-name)
   ("\C-ci" . ewd-insert-new-method)
   ("\C-c\C-f" . ewd-fill-buffer)

;; Modify menus 
(cond (window-system
       ;; Speedbar
       (define-key-after (lookup-key global-map [menu-bar tools])
         [speedbar-menu-separator] '("--" . speedbar-menu-separator) t)
       (define-key-after (lookup-key global-map [menu-bar tools])
         [speedbar] '("Speedbar" . speedbar-frame-mode) t)))

(cond ((eq window-system 'w32)
       ;; Select font
       (define-key-after (lookup-key global-map [menu-bar edit])
         [select-font-menu-separator] '("--" . select-font-menu-separator) t)
       (define-key-after (lookup-key global-map [menu-bar edit])
         [get-font-name] '("Get X font name" . ewd-get-x-font-name) t)))
;; Map arrow keys to correct functions in dial-in       
(add-hook 'term-setup-hook
           (lambda ()                 
             (define-key esc-map "["  nil)
             (define-key esc-map "[A" 'previous-line)
             (define-key esc-map "[B" 'next-line)
             (define-key esc-map "[C" 'forward-char)
             (define-key esc-map "[D" 'backward-char)
             (define-key esc-map "[OA" 'previous-line)
             (define-key esc-map "[OB" 'next-line)
             (define-key esc-map "[OC" 'forward-char)
             (define-key esc-map "[OD" 'backward-char)
;; Set auto-mode-alist
(setq auto-mode-alist
      '(("\\.[Cc][Oo][Mm]\\'" . text-mode)
        ("\\.bat\\'" . bat-generic-mode)
        ("\\.inf\\'" . inf-generic-mode)
        ("\\.rc\\'" . rc-generic-mode)
        ("\\.reg\\'" . reg-generic-mode)
        ("\\.cob\\'" . cobol-mode)
        ("\\.cbl\\'" . cobol-mode)
        ("\\.te?xt\\'" . text-mode)
        ("\\.c\\'" . c-mode)
        ("\\.h\\'" . c++-mode)
        ("\\.tex$" . LaTeX-mode)
        ("\\.sty$" . LaTeX-mode)
        ("\\.bbl$" . LaTeX-mode)
        ("\\.bib$" . BibTeX-mode)
        ("\\.el\\'" . emacs-lisp-mode)
        ("\\.scm\\'" . scheme-mode)
        ("\\.l\\'" . lisp-mode)
        ("\\.lisp\\'" . lisp-mode)
        ("\\.f\\'" . fortran-mode)
        ("\\.F\\'" . fortran-mode)
        ("\\.for\\'" . fortran-mode)
        ("\\.p\\'" . pascal-mode)
        ("\\.pas\\'" . pascal-mode)
        ("\\.ad[abs]\\'" . ada-mode)
        ("\\.\\([pP][Llm]\\|al\\)\\'" . perl-mode)
        ("\\.s?html?\\'" . html-helper-mode)
        ("\\.idl\\'" . c++-mode)
        ("\\.cc\\'" . c++-mode)
        ("\\.hh\\'" . c++-mode)
        ("\\.hpp\\'" . c++-mode)
        ("\\.C\\'" . c++-mode)
        ("\\.H\\'" . c++-mode)
        ("\\.cpp\\'" . c++-mode)
        ("\\.[cC][xX][xX]\\'" . c++-mode)
        ("\\.hxx\\'" . c++-mode)
        ("\\.c\\+\\+\\'" . c++-mode)
        ("\\.h\\+\\+\\'" . c++-mode)
        ("\\.m\\'" . objc-mode)
        ("\\.java\\'" . java-mode)
        ("\\.ma?k\\'" . makefile-mode)
        ("\\(M\\|m\\|GNUm\\)akefile\\(\\.in\\)?" . makefile-mode)
        ("\\.am\\'" . makefile-mode)
        ("\\.mms\\'" . makefile-mode)
        ("\\.texinfo\\'" . texinfo-mode)
        ("\\.te?xi\\'" . texinfo-mode)
        ("\\.s\\'" . asm-mode)
        ("\\.S\\'" . asm-mode)
        ("\\.asm\\'" . asm-mode)
        ("ChangeLog\\'" . change-log-mode)
        ("change\\.log\\'" . change-log-mode)
        ("changelo\\'" . change-log-mode)
        ("ChangeLog\\.[0-9]+\\'" . change-log-mode)
        ("changelog\\'" . change-log-mode)
        ("changelog\\.[0-9]+\\'" . change-log-mode)
        ("\\$CHANGE_LOG\\$\\.TXT" . change-log-mode)
        ("\\.scm\\.[0-9]*\\'" . scheme-mode)
        ("\\.[ck]?sh\\'\\|\\.shar\\'\\|/\\.z?profile\\'" . sh-mode)
        ("\\(/\\|\\`\\)\\.\\(bash_profile\\|z?login\\|bash_login\\|z?logout\\)\\'" . sh-mode)
        ("\\(/\\|\\`\\)\\.\\(bash_logout\\|[kz]shrc\\|bashrc\\|t?cshrc\\|esrc\\)\\'" . sh-mode)
        ("\\(/\\|\\`\\)\\.\\([kz]shenv\\|xinitrc\\|startxrc\\|xsession\\)\\'" . sh-mode)
        ("\\.mm\\'" . nroff-mode)
        ("\\.me\\'" . nroff-mode)
        ("\\.ms\\'" . nroff-mode)
        ("\\.man\\'" . nroff-mode)
        ("\\.[12345678]\\'" . nroff-mode)
        ("\\.TeX\\'" . TeX-mode)
        ("\\.sty\\'" . LaTeX-mode)
        ("\\.cls\\'" . LaTeX-mode)
        ("\\.clo\\'" . LaTeX-mode)
        ("\\.bbl\\'" . LaTeX-mode)
        ("\\.bib\\'" . BibTeX-mode)
        ("\\.m4\\'" . m4-mode)
        ("\\.mc\\'" . m4-mode)
        ("\\.mf\\'" . metafont-mode)
        ("\\.mp\\'" . metapost-mode)
        ("\\.vhdl?\\'" . vhdl-mode)
        ("\\.article\\'" . text-mode)
        ("\\.letter\\'" . text-mode)
        ("\\.tcl\\'" . tcl-mode)
        ("\\.exp\\'" . tcl-mode)
        ("\\.itcl\\'" . tcl-mode)
        ("\\.itk\\'" . tcl-mode)
        ("\\.icn\\'" . icon-mode)
        ("\\.sim\\'" . simula-mode)
        ("\\.mss\\'" . scribe-mode)
        ("\\.f90\\'" . f90-mode)
        ("\\.lsp\\'" . lisp-mode)
        ("\\.awk\\'" . awk-mode)
        ("\\.prolog\\'" . prolog-mode)
        ("\\.tar\\'" . tar-mode)
        ("\\.\\(arc\\|zip\\|lzh\\|zoo\\|jar\\)\\'" . archive-mode)
        ("\\.\\(ARC\\|ZIP\\|LZH\\|ZOO\\|JAR\\)\\'" . archive-mode)
        ("\\`/tmp/Re" . text-mode)
        ("/Message[0-9]*\\'" . text-mode)
        ("/drafts/[0-9]+\\'" . mh-letter-mode)
        ("\\.zone\\'" . zone-mode)
        ("\\`/tmp/fol/" . text-mode)
        ("\\.y\\'" . c-mode)
        ("\\.lex\\'" . c-mode)
        ("\\.oak\\'" . scheme-mode)
        ("\\.sgml?\\'" . sgml-mode)
        ("\\.xml\\'" . sgml-mode)
        ("\\.dtd\\'" . sgml-mode)
        ("\\.ds\\(ss\\)?l\\'" . dsssl-mode)
        ("\\.idl\\'" . c++-mode)
        ("[]>:/\\]\\..*emacs\\'" . emacs-lisp-mode)
        ("\\`\\..*emacs\\'" . emacs-lisp-mode)
        ("[:/]_emacs\\'" . emacs-lisp-mode)
        ("\\.ml\\'" . lisp-mode)))

;; Stuff from M-x customize
 '(font-lock-comment-face ((((class color)) (:foreground "firebrick" :italic t))))
 '(font-lock-reference-face ((((class color)) (:foreground "Purple"))))
 '(font-lock-string-face ((((class color)) (:foreground "DarkGreen"))))
 '(region ((((class color)) (:background "burlywood"))))
 '(font-lock-keyword-face ((((class color)) (:foreground "Blue"))))
 '(font-lock-constant-face ((((class color)) (:foreground "Blue"))))
 '(font-lock-type-face ((((class color)) (:foreground "Red"))))
 '(modeline ((((class color)) (:foreground "floral white" :background "PlumDesktop"))))
 '(show-paren-match-face ((((class color)) (:background "burlywood4"))))
 '(font-lock-function-name-face ((((class color)) (:foreground "DarkGoldenrod"))))
 '(font-lock-builtin-face ((((class color)) (:foreground "Blue")))))

;; Enable some functions
(put 'downcase-region 'disabled nil)
(put 'upcase-region 'disabled 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