;;
;; Written by William Braynen
;; Last modified: Nov 23, 2002
;;
;;
;; Latest version of Emacs's port to Windows available from
;; ftp://ftp.gnu.org/gnu/windows/emacs/
;; See http://www.gnu.org/software/emacs/windows/ntemacs.html
;;
;; This .emacs file was optimized for the Windows port of
;; GNU Emacs 21.2 on Win2k, so it might not work with other
;; (older) versions of Emacs and on other platforms.
;;
;; Under Windows 2000, this file must either be located in the root
;; C:\ directory or in the HOME directory, as defined by the HOME
;; environment variable (see Control Panel -> System -> Advanced)
;; e.g. "C:\Documents and Settings\Administrator"
;;
(setq debug-on-error t)
;;
On Windows, use "cmdproxy.exe"
;; On UNIX, use "/bin/csh" or the like
(setq shell-file-name "cmdproxy.exe")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Set default appearance
;;
(blink-cursor-mode 0) ; No blinking cursors please
(cond (window-system
;;
Set up the font support and turn on the fontifying.
(setq font-lock-support-mode 'fast-lock-mode)
(setq font-lock-maximum-decoration t)
(global-font-lock-mode t)
(setq default-frame-alist
'((top . 0) (left . 0)
(width . 80) (height . 43) ; Use 80 x 43 at resolution 1024 x 768
(cursor-color . "Yellow")
(cursor-type . box)
(foreground-color . "White")
(background-color . "Black")
(vertical-scroll-bars . right)))
;;
Set the frame's title. %b is the name of the buffer. %+ indicates the
;; state of the buffer: * if modified, % if read only, or - otherwise.
;; Two of them to emulate the mode line. %f for the file name
;; (absolute path actually).
(setq frame-title-format "Emacs: %b %+%+ %f")
(transient-mark-mode t) ; Highlight region between set mark and cursor
(delete-selection-mode t) ; Delete typed over highlighted selections
;(tool-bar-mode
nil) ; toolbar not available on the Win32 port yet...
;(menu-bar-mode nil) ; turn off the menus
(scroll-bar-mode nil) ; turn off the scroll bar
;(set-border-color
"white")
;(set-face-background 'region "darkblue")
;(set-face-foreground 'region "lightgrey")
;(set-face-background 'highlight "red")
;(set-face-foreground 'highlight "black")
(set-face-background 'modeline "LightSteelBlue2")
(set-face-foreground 'modeline "Black")
;;
Colors in my code
(set-face-foreground 'font-lock-comment-face "Light Green")
(set-face-foreground 'font-lock-string-face "Salmon")
;(set-face-foreground
'font-lock-constant-face "Aqua Marine")
(set-face-foreground 'font-lock-keyword-face "light sky blue")
(set-face-foreground 'font-lock-type-face "light sky blue")
(set-face-foreground 'font-lock-function-name-face "Black")
(set-face-background 'font-lock-function-name-face "Cornflower
Blue");
(set-face-foreground 'font-lock-variable-name-face "moccasin")
;(set-face-foreground
'font-lock-reference-face "Magenta")
;(set-face-foreground 'font-lock-my-type-face "Salmon")
))
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
Load libraries
(load-library "redo.el") ; Kyle
Jones's library written for xemacs -
;
maybe compiling it would be a good idea
;;
Make the screen scroll one line when the cursor moves past the edge
(setq scroll-step 1)
;;
Do not create backup files ending in ~
(setq make-backup-files nil)
(setq ;display-time-24hr-format t
display-tme-mail-file t
display-time-form-list (list 'time 'load)
display-time-day-and-date t)
(display-time)
;;
If at beginning of a line, don't make me C-k twice.
(setq kill-whole-line t)
;;
Turn on auto-fill
(setq-default auto-fill-function 'do-auto-fill)
(setq auto-fill-mode t)
;;
Use only spaces for indentation (default is tab mixed with spaces)
(setq-default indent-tabs-mode nil)
;;
Highlight matching parenthesis (useful when coding)
(show-paren-mode 0)
;;
Set up font hooks
;(add-hook 'c-mode-hook 'turn-on-font-lock)
;(add-hook 'c++-mode-hook 'turn-on-font-lock)
;(add-hook 'lisp-mode-hook 'turn-on-font-lock)
;; Make sure the modes are loaded automatically
;(setq auto-mode-alist
; (append '(("\\.C$" . c++-mode)
; ("\\.cpp$" . c++-mode)
; ("\\.c$" . c-mode) ; to edit C code
; ("\\.h$" . c-mode) ; to edit C code
; ("\\.emacs$" . emacs-lisp-mode)
; ) auto-mode-alist))
;; Yes yes, use 'compile-command' - don't make me confirm "use make
-k"
(setq compilation-read-command nil)
(setq compile-command "make -k")
(setq compilation-window-height 10)
(defun word-after (&optional position)
"Return
word in current buffer at specified position."
(interactive)
;;
set default value of pos to (point)
(if (not position)
(setq position (point)))
(setq word "")
(while (and (> (char-after
position) 32)
(< (char-after position) 127))
(setq char (char-after position))
(setq word (concat word (list char)))
(setq position (1+ position)))
(eval word))
(defun bin-to-dec (number)
"Convert
binary number to base 10."
(setq result 0)
(setq i 0)
(while (not (equal number 0))
(setq bit (mod number 10))
(setq number (/ number 10))
(setq result (+ result (* bit (expt 2 i))))
(setq i (1+ i)))
(eval result))
(defun bin-to-hex (number)
"Convert
binary number to hex."
(format "0x%02x" (bin-to-dec number)))
(defun insert-bin-to-hex-atpoint ()
"Insert
hex value of a binary number at current position."
(interactive)
(setq hex (bin-to-hex (string-to-number (word-after))))
(forward-word 1)
(insert (concat " " hex)))
;;
;; SOME KEYBOARD/SHORTCUT IMPROVEMENTS
;;
;;;;;;;;;;;;; Split Windows ;;;;;;;;;;;;;
;;
;; Easier way to change size of split windows
(global-set-key [C-down] 'shrink-window)
(global-set-key [C-up] 'enlarge-window)
;;
Jump between windows
(defun other-window-backward (&optional n)
"Select
Nth previous window."
(interactive "P")
(other-window (- (prefix-numeric-value n))))
(global-set-key "\C-x\C-n" 'other-window)
(global-set-key "\C-x\C-p" 'other-window-backward)
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; It would be great to have context-sensitive tab, meaning it should
;; indent only if it's at the beginning or end of file, otherwise it
;; should auto-complete [M-tab]. But I'll settle for ctrl-tab
;; completing function names.
;;
(global-set-key [C-tab] [M-tab])
;;
Make Emacs use "newline-and-indent" when you hit the Enter key so
;; that you don't need to keep using TAB to align yourself when coding.
;; This is akin to setting autoindent in vi.
(global-set-key "\C-m" 'newline-and-indent)
(global-set-key [f2] 'apropos)
(global-set-key [f7] (lambda () (interactive) (compile compile-command)))
(global-set-key [f8] 'next-error) ; no, I don't like pressing
"\C-x `"
(global-set-key [f12] "\C-xe") ; execute kdb macro
(global-set-key "\M-g" (goto-line 5))
(global-set-key "\C-z" 'undo)
(global-set-key "\C-q" 'redo)
(global-set-key "\C-x\C-a" 'mark-whole-buffer) ; "Select All" in
MS Windows
(global-set-key "\C-xa" 'mark-whole-buffer) ; (Ctrl-a jumps to end of line)
;;
Show empty lines at the end of the buffer
;(setq default-indicate-empty-lines t)