;; Brandon's .emacs file. Taken nearly in bulk from Steve Ackermann's perl ;; .emacs file on http://www.dotemacs.de ;; ;; This is very empowering. ;; .emacs file for plaza.301south.net (message "Entering .emacs file") ;; --------------------------------------------------------------------------- ; X Fonts ;; --------------------------------------------------------------------------- ; Remember, for fonts: xfd will display a font; xlsfonts will list available ones ; xlsfonts -fn 'pattern' ;(set-default-font "-*-LucidaTypewriter-medium-r-*-17-*-*-*-*-*-iso8859-*") ;(set-default-font "-*-LucidaTypewriter-medium-r-*-14-*-*-*-*-*-iso8859-*") ; this is best but I think it's just too damn small ;(set-default-font "-misc-fixed-medium-r-semicondensed-*-13-*-*-*-*-*-iso8859-*") ;(set-default-font "-Bitstream-*-medium-r-normal-*-15-*-*-*-m-*-iso8859-*") (set-default-font "-bitstream-courier 10 pitch-medium-r-normal--15-145-75-75-m-0-iso8859-1") ;(set-default-font "-sony-fixed-medium-r-* -*-*-120-*-*-*-*-iso8859-*") ;; --------------------------------------------------------------------------- ; Mode Hooks ;; --------------------------------------------------------------------------- ;; text mode stuff: autofill, ISO accents (add-hook 'text-mode-hook '(lambda () (auto-fill-mode 1))) (add-hook 'text-mode-hook '(lambda () (set-fill-column 75))) ;;(add-hook 'text-mode-hook '(lambda () (iso-accents-mode 1))) ;; note: may not want this on all the time. If not, to enter the mode ;; temporarily, enter ctrl-x 8 ;; asm mode stuff: it does a little too much for me (add-hook 'asm-mode-hook '(lambda() (local-unset-key ";"))) (add-hook 'asm-mode-hook '(lambda () (setq auto-fill-mode t))) (add-hook 'asm-mode-hook '(lambda () (setq fill-column 85))) ;; c-mode stuff (setq c-default-style "bsd") (add-hook 'c-mode-hook '(lambda () (setq c-basic-offset 4))) ;; Default mode: fundamental ;(setq default-major-mode 'text-mode) (setq default-major-mode 'fundamental-mode) ;; --------------------------------------------------------------------------- ; Highlighting ;; --------------------------------------------------------------------------- ;; highlight region between point and mark ;; --------------------------------------------------------------------------- ;; Make the region visible (but only up to the next operation on it) ;; --------------------------------------------------------------------------- (transient-mark-mode t) ;; highlight during query (setq query-replace-highlight t) ;; highlight incremental search (setq search-highlight t) ;; Show matching parenthesis. How can you live without it. (show-paren-mode t) ;; --------------------------------------------------------------------------- ;; user input nuances ;; --------------------------------------------------------------------------- ;;(setq w32-num-mouse-buttons '3) ;; NA for linux machines (setq mouse-yank-at-point t) ;; Don't add new lines to the end of a file when using down-arrow key (setq next-line-add-newlines nil) ;; Windows-like selection and key bindings... (pc-bindings-mode) ;; ... but don't replace marked text when writing ;(pc-selection-mode) (delete-selection-mode nil) ;; Do only one line scrolling. (setq scroll-step 1) ;; Don't wrap long lines. (set-default 'truncate-lines t) ;; Nevertheless I'd like to have the possibility to see what is out of my ;; view. (require 'auto-show) (auto-show-mode 1) (setq-default auto-show-mode t) ;; --------------------------------------------------------------------------- ; Services and Features ;; --------------------------------------------------------------------------- ; emacsclient (server-start) ;; elisp files (add-to-list 'load-path "~/.emacs.d") ;; htmlize (require 'htmlize) ;; matlab mode -- as downloaded from the Mathworks website (autoload 'matlab-mode "~/.emacs.d/matlab.el" "Enter MATLAB mode." t) ;; exec this line to load interactively (autoload 'matlab-shell "matlab" "Interactive MATLAB mode." t) (setq my-author-name (getenv "USER")) (setq user-full-name (getenv "USER")) (setq default-directory (getenv "HOME")) ;; this doesn't do what I want it to do (setq auto-save-directory (expand-file-name "~/.emacs.d/auto-save-dir/")) ; don't make pesky backup files (setq make-backup-files nil) ; don't use version numbers for backup files (setq version-control 'never) (put 'eval-expression 'disabled nil) ; findfile runs dired mode for ambiguous inputs (custom-set-variables '(find-file-run-dired t) ) ;; this looks neat for the future, but I don't use it now ;; In abbrev mode, inserting an abbreviation causes it to expand ;; and be replaced by its expansion. ; (setq-default abbrev-mode t) ; (read-abbrev-file "~/.abbrev_defs") ; (setq save-abbrevs t) ;; --------------------------------------------------------------------------- ; Keybindings and Input Commands ;; --------------------------------------------------------------------------- ;; Enable uppercase or lowercase conversions (put 'downcase-region 'disabled nil) (put 'upcase-region 'disabled nil) (put 'set-goal-column 'disabled nil) (put 'narrow-to-region 'disabled nil) ;; =============== ;; untabify-buffer (defun untabify-buffer nil "Convert all tabs in buffer to spaces" (interactive) (untabify (point-min) (point-max))) (global-set-key (kbd "") 'untabify-buffer) ;; ============= ;; word counting (defun word-count nil "Count words in buffer" (interactive) (shell-command-on-region (point-min) (point-max) "wc -w")) (defun word-count-region nil "Count words in selected region" (interactive) (shell-command-on-region (mark) (point) "wc -w")) (global-set-key "\C-cw" 'word-count) (global-set-key "\C-c\C-w" 'word-count-region) ;; ==================== ;; insert date and time (defvar current-date-time-format "%a %b %d %H:%M:%S %Z %Y" "Format of date to insert with `insert-current-date-time' func See help of `format-time-string' for possible replacements") (defvar current-time-format "%a %H:%M:%S" "Format of date to insert with `insert-current-time' func. Note the weekly scope of the command's precision.") (defun insert-current-date-time () "insert the current date and time into current buffer. Uses `current-date-time-format' for the formatting the date/time." (interactive) (insert "==========\n") ; (insert (let () (comment-start))) (insert (format-time-string current-date-time-format (current-time))) (insert "\n") ) (defun insert-current-time () "insert the current time (1-week scope) into the current buffer." (interactive) (insert (format-time-string current-time-format (current-time))) (insert "\n") ) (global-set-key "\C-c\C-d" 'insert-current-date-time) (global-set-key "\C-c\C-t" 'insert-current-time) ;; ====================== ;; scroll-buffer commands ; I haven't decided if these 'pilot controls' are right or reversed (defun jog-down-buffer nil "Improved scroll-down" (interactive) (scroll-down 1) (forward-line -1)) (defun jog-up-buffer nil "Improved scroll-up" (interactive) (scroll-up 1) (forward-line 1)) (defun jog-down-other-window nil "Improved scroll-down, other window" (interactive) (scroll-other-window -1) ; (forward-line -1)) ; this is not what we want... ) (defun jog-up-other-window nil "Improved scroll-up, other window" (interactive) (scroll-other-window 1) ; (forward-line 1)) ) (global-set-key [(control ,)] 'jog-down-buffer) (global-set-key [(control \.)] 'jog-up-buffer) (global-set-key [(control <)] 'jog-down-other-window) (global-set-key [(control >)] 'jog-up-other-window) ;; ============= ;; newline-above (defun newline-above nil "Insert a new line above current line" (interactive) ; this breaks if user has a current goal column already set (set-goal-column nil) (forward-line 0) (newline) (previous-line 1) (next-line 1) (set-goal-column 1) (message "newline inserted") ) (global-set-key [(control return)] 'newline-above) ;; ============= ;; Miscellaneous (global-set-key "\C-x\C-m" 'shell) (global-set-key "\C-c\C-c" 'comment-region) (global-set-key "\C-cc" 'uncomment-region) (global-set-key "\C-cy" 'clipboard-yank) ;; --------------------------------------------------------------------------- ; Appearance ;; -------------------------------------------------------------------------- ;; Give me colours in major editing modes!!!!! (require 'font-lock) (global-font-lock-mode t) ;; The mode line (bar at the bottom) (add-hook 'font-lock-mode-hook '(lambda () (set-face-background 'modeline "Blue4") (set-face-foreground 'modeline "Gold") ; (set-face-foreground 'secondary-selection "red") ; (set-face-background 'highlight "yellow") )) ;; Current line & column of cursor in the mode line (bar at the bottom) (line-number-mode 1) (setq column-number-mode t) ;; show current function in modeline ;(which-func-mode t) ;; Background (set-background-color "black") (set-foreground-color "ivory") (set-cursor-color "light goldenrod yellow") ;;Comments in italics ;;(setq w32-enable-italics t) ;; not interested ;(make-face-italic 'font-lock-comment-face) ;; Override default text colours (custom-set-faces ; '(font-lock-comment-face ((((class color)) (:foreground "firebrick")))) '(font-lock-comment-face ((((class color)) (:foreground "spring green")))) '(region ((((class color)) (:background "royal blue")))) ; '(highlight ((((class color)) (:background "green1")))) ; '(font-lock-string-face ((((class color)) (:foreground "green4")))) ; '(font-lock-keyword-face ((((class color)) (:foreground "orange")))) '(font-lock-type-face ((((class color)) (:foreground "blue")))) ; '(font-lock-variable-name-face ((((class color)) (:foreground "brown")))) ; '(font-lock-function-name-face ((((class color)) (:foreground "royal blue")))) '(font-lock-function-name-face ((((class color)) (:foreground "red2")))) ) ; This turns off the toolbar at the top of the screen (tool-bar-mode -1) ; this prevents the annoying 'hopping' of the minibuffer when it contains text (setq resize-mini-windows nil) ;; --------------------------------------------------------------------------- ;; Bind major editing modes to certain file extensions ;;---------------------------------------------------------------------------- (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) ("\\.cgi$" . perl-mode) ("\\.s?html?\\'" . html-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\\'" . matlab-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) ("\\.inc\\'" . 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) ("\\.sld\\'" . TeX-mode) ;; "input" presentation slide ("\\.pdslide\\'" . TeX-mode) ;; new powerdot-format slide ("\\.fig\\'" . TeX-mode) ;; "input" graphics ("\\.tbl\\'" . TeX-mode) ;; "input" tabular ("\\.sty\\'" . LaTeX-mode) ("\\.cls\\'" . LaTeX-mode) ("\\.clo\\'" . LaTeX-mode) ("\\.bbl\\'" . LaTeX-mode) ("\\.bib\\'" . BibTeX-mode) ("DIRECTORY" . text-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))) ;; final setup and file loading (split-window-horizontally) (find-file-other-window "~/TeX/doc/texnotes.text") (find-file-other-window "~/.emacs") (message ".emacs successfully loaded")