;;; ;;; default.el ;;; EE dept. site-specific customizations for emacs ;;; (Most of this stuff has been moved from my .emacs) -elf ;;; June 2001: updates for Emacs21 ;;; GLOBAL VARIABLE SETTINGS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; (and (string-match "GNU" (emacs-version)) ;; (>= emacs-major-version 21) ;; ;; Emacs21 specific code here ;; ) ;;; Set default language (set-language-environment "latin-1") (set-keyboard-coding-system 'latin-1) ;;;LOOK AND FEEL (setq default-frame-alist '((top . 80) (left . 64) (width . 80) (height . 40) (cursor-color . "red") (cursor-type . box) (foreground-color . "lightcyan") (background-color . "black") (font . "-*-Lucida Console-normal-r-*-*-15-*-*-*-c-*-iso8859-1"))) ;; ascii 32 - 255 can be displayed on windowed systems ;; values for window system can be 'x, 'w32 or "nil" (console mode) (if (and window-system (x-display-color-p)) (progn (standard-display-8bit 32 255))) ;;; modeline config-- display envelope in modeline for "Mail" (setq display-time-use-mail-icon t) (setq display-time-day-and-date t) (setq line-number-mode t) ;show line-numbers in the mode-line (column-number-mode t) ;show column-number in the mode line (display-time) ;show date and time in modeline (setq-default case-fold-search nil ;case sensitive searches by default search-highlight t) ;hilit matches when searching (delete-selection-mode) ; hilighted text is deleted ; and replaced with text being ; typed (windows behaviour) (setq mark-even-if-inactive t) ; keep region hilited after marking (global-set-key [?\C-2] 'set-mark-command) ; make C-2 eqv. to C-@ ;; make C-h delete (not Help) in ttys Wed Aug 15 14:41:56 2001 (global-set-key [?\C-h] 'backward-delete-char) ;;Del will delete forward and Backspace will delete backwards ;; Jun 5, 2003 (normal-erase-is-backspace-mode) ;; Help is now M-? instead of C-h (global-set-key "\M-\?" 'help-command) ;;;Sun keyboard L-key definitions (global-set-key [cut] 'kill-region) (global-set-key [paste] 'hilit-yank) (global-set-key [copy] 'kill-ring-save) (global-set-key [find] 'isearch-forward) (global-set-key [open] 'find-file) (global-set-key [f14] 'undo) ;;; Undo (global-set-key [f19] 'isearch-forward) ;;; Find (global-set-key [S-f19] 'isearch-forward-regexp) ;;; Shift-Find (global-set-key [M-f19] 'replace-regexp) ;;; Meta-Find ;;; For calendar (or use M-x sunrise-sunset) (setq calendar-latitude 43.40 calendar-longitude -79.24 ;west of GMT calendar-location-name "Toronto, Ont. CANADA") ;;; handy stuff for C mode (setq c-auto-newline t) ;;;Version-control and backups (setq version-control t kept-old-versions 2 ;keep only 2 backup files delete-old-versions t) ; old var: trim-versions-without-asking ;;; GNUS definitions (setq gnus-default-nntp-server "news.acs.ryerson.ca" gnus-local-domain "ee.ryerson.ca" gnus-local-organization "Ryerson Polytechnic University" gnus-distribution-list '("local" "rye" "tor" "ont" "can" "na" "world")) ;;;Users without a ~/.newsrc file will get the following groups subscribe ;;;by default if they use (ding) (setq gnus-default-subscribed-newsgroups '("news.answers" "news.newusers.questions" "rye.ee.general" "rye.general" "sci.eletronics" "rec.humor.funny")) ;;; CRYPT++ options ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; on-the-fly encryption and decryption of files (setq crypt-encryption-type 'des crypt-encryption-file-extension "\\(\\.e\\)$" crypt-confirm-password t crypt-auto-write-buffer t ;encode as file-extension suggests crypt-freeze-vs-fortran nil ;; crypt-ignored-filenames '("INBOX$" "RMAIL$" "/Mail/") crypt-bind-insert-file t) (require 'crypt++) ;;; MAIL options ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; where to save outgoing mail (setq mail-archive-file-name (expand-file-name "~/Mail/outbox")) ;;; in text mode, auto-fill at column 69 (setq text-mode-hook '(lambda () (auto-fill-mode 1) (set-fill-column 69))) ;;; VM options ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq vm-startup-with-summary t vm-preview-read-messages t vm-strip-reply-headers t vm-folder-directory "~/Mail/" vm-follow-summary-cursor t vm-confirm-mail-send t) ;; VM Fontification (require 'u-vm-color) (add-hook 'vm-mode-hook 'u-vm-color-presentation-mode) (add-hook 'vm-presentation-mode-hook 'u-vm-color-presentation-mode) (add-hook 'vm-summary-mode-hook 'u-vm-color-summary-mode) ;;; Support for auto-detecting file-extensions and entering a ;;; specific mode. (nconc auto-mode-alist '( ("\\.asm\\'" . asm-mode) ("\\.fvwm2rc\\'" . fvwm-mode) ("\\.ps\\'" . ps-mode) ("\\.vhdl?\\'" . vhdl-mode) ("\\.htaccess$" . apache-mode) ("httpd\\.conf$" . apache-mode) ("zshrc$" . shell-script-mode) ("\\.pl\\'" . perl-mode))) ;;; need to add .m to the start of the alist else Obj/C mode is ;;; associated with .m files. Wed Sep 18 00:22:14 2002 -elf (setq auto-mode-alist (cons '("\\.m\\'" . matlab-mode) auto-mode-alist)) (autoload 'fvwm-mode "fvwm-mode" "Mode for editing fvwm's config files." t) (autoload 'matlab-mode "matlab" "Mode for editing Matlab m files." t) (autoload 'matlab-shell "matlab" "Interactive Matlab mode." t) (autoload 'ps-mode "ps-mode" "Mode for editing PostScript files." t) (autoload 'vhdl-mode "vhdl-mode" "VHDL Mode" t) (autoload 'apache-mode "apache-mode" "autoloaded" t) ;;; show whitespace mode Thu Nov 14 07:38:07 2002 (autoload 'show-whitespace-mode "show-whitespace-mode" "Show tabs and whitespaces in the current buffer." t) ;;; force emacs to use a specific encoding by default based on file extension ;;; bojohan Feb 21 2004 ; (modify-coding-system-alist 'file "\\.txt\\'" 'china-iso-8bit) ;;; cperl-mode is preferred to perl-mode ;;; "Brevity is the soul of wit" (defalias 'perl-mode 'cperl-mode) ;;; enable all the bells and whistles of cperl-mode Sun Jul 07 11:18:06 2002 ;; removed Sun Sep 08 13:22:48 2002-- too buggy and annoying ;;(setq cperl-hairy t) ;;; If 1st line begins with #!, make the file executable when saving ;;; Glenn Morris Sun Jul 07 11:11:51 2002 (if (fboundp 'executable-make-buffer-file-executable-if-script-p) (add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)) ;;; in an empty file, when shell-script-mode is enabled, add the #! line ;;; retroj on #emacs Sun Dec 13 12:14:52 2009 (add-hook 'sh-mode-hook (lambda () (if (eq (buffer-size) 0) (executable-set-magic "bash")))) ;;;Handy MACROS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; insert current date into the buffer at point (defun insert-date() "Insert a time-stamp according to locale's date and time format." (interactive) (insert (format-time-string "%c" (current-time)))) (global-set-key "\C-cd" 'insert-date) ;;; init of AUC TeX (require 'tex-site) ;;; package for handling aliases in VM (from the ~/.rmail aliases) (load-library "mailabbrev") (add-hook 'mail-setup-hook 'mail-abbrevs-setup) ;;;Fontification ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; colorize buffers (setq font-lock-maximum-decoration t) (global-font-lock-mode 1) (set-face-foreground (quote font-lock-comment-face) "lightcyan") (eval-after-load "font-lock" '(setq c-font-lock-keywords c-font-lock-keywords-2 lisp-font-lock-keywords lisp-font-lock-keywords-2 search-highlight t)) ;hilight all visible ;occurences of keyword being searched ;;; fontify the minibuffer prompt Tue Jan 08 14:48:45 2002 (load-library "minicolor") ;;;;;;;;;;;;MODES;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; smart-fill of paragraphs: a great help for citations in gnus & vm (require 'filladapt) (setq filladapt-mode t) ;;; Support for attaching to an already running emacs ;;; xemacs has better support for gnuclient, until then we wait ;(load-library "gnuserv"); 21.x only ;;; flash parens la al Zmacs (load-library "flashparen") (setq flash-matching-mode 1) ;;; and also hilite them (show-paren-mode) ;;; HANDY FUNCTIONS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Stefan Monnier . It is the opposite of fill-paragraph ;;; Takes a multi-line paragraph and makes it into a single line of text. (defun unfill-paragraph () (interactive) (let ((fill-column (point-max))) (fill-paragraph nil))) ;;; ;;;Check for empty subject-header before sending mail ;;;Author: elf at ee.ryerson.ca ;;; (add-hook 'mail-send-hook (function (lambda () (interactive) (beginning-of-buffer) (cond ((search-forward "Subject: \n" nil t) (error "Subject-line is empty!")))))) ;;; Use TAB to move from field-to-filed when composing mail ;;; friedman at splode.com (Noah Friedman) May 1997 (require 'sendmail) (define-key mail-mode-map "\C-i" 'mail-goto-next-header-or-insert) (defun mail-goto-next-header-or-insert (&optional count) "If in header area, go to beginning of next header. If point is not in the header area, just insert the character which invoked this command. With numeric prefix arg, skip forward that many headers. If prefix arg is negative, skip backward that many headers. If either the head or tail of the headers are reached, wrap around to the other end and continue." (interactive "p") (let* ((headers-end (save-excursion (goto-char (point-min)) (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$")) (match-beginning 0))) (forwardp (or (null count) (> count 0))) (fn (if forwardp 're-search-forward 're-search-backward)) (la (if forwardp 2 1)) (nla (if forwardp 1 2)) (re "^[^:\n\t ]+:") (i (abs count))) (cond ((>= (point) headers-end) ;; I haven't really tested to see if this does ;; the right thing. (call-interactively 'self-insert-command)) (t (save-restriction (narrow-to-region (point-min) headers-end) (while (not (zerop i)) (cond ((funcall fn re nil t (if (looking-at re) la nla))) (t (goto-char (point-min)) (funcall fn re nil t))) (setq i (1- i))) (goto-char (match-end 0)) (and (looking-at "[ \t]") (forward-char 1))))))) ;;; Insert text at point rather than at mouse-pointer ;;; emacs 19 only, [mouse-2] has to be re-defined ;;; khera at cs.duke.edu (Vivek Khera) (global-set-key [mouse-2] 'mouse-yank-at-point) (defun mouse-yank-at-point (click arg) "Insert the last stretch of killed text at the current point. Prefix arguments are interpreted as with \\[yank]." (interactive "e\nP") (yank arg)) ;;; Use Backspace(^H) to delete, Help=Delete(^?) ;;; moved from my .emacs file here on Wed Feb 28 05:42:58 EST 2001 (load-library "keyswap") ;;; ;;; STRIPS ^M's FROM BUFFER ;;; Usage: M-x dos2unix ;;; (defun dos2unix nil "Convert this entire buffer from MS-DOS text file format to UNIX." (interactive) (save-excursion (goto-char (point-min)) (replace-regexp "\r$" "" nil) (goto-char (1- (point-max))) (if (looking-at "\C-z") (delete-char 1)))) ;;;VM auto-loads ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (autoload 'vm "vm" "Start VM on your primary inbox." t) (autoload 'vm-visit-folder "vm" "Start VM on an arbitrary folder." t) (autoload 'vm-visit-virtual-folder "vm" "Visit a VM virtual folder." t) (autoload 'vm-mode "vm" "Run VM major mode on a buffer" t) (autoload 'vm-mail "vm" "Send a mail message using VM." t) (autoload 'vm-submit-bug-report "vm" "Send a bug report about VM." t) ;;; In praise of Emacs, The One True Editor ;;; 1.0 Aug 19, 1994 ;;; 2.0 Aug 28, 1994 ;;; Rather ecclesiastical, though. ;;; -elf (defun praise-emacs() "In praise of emacs" (interactive) (message "Praise Emacs...") (sit-for 2) (message "Amen.")) ;;; slight re-definition, similar to w in vi (defun next-word () (interactive) (forward-word 2) (backward-word 1)) (global-set-key "\M-f" 'next-word) ;;;show recently opened files in the File menu (recentf-mode 1) ;; Mouse-wheel support (load-library "mwheel") (mwheel-install) ;;; erc is the emacs irc chat client-- waste time productively (setq erc-server "irc.freenode.net" erc-port 6667 erc-nick "e1f" erc-user-full-name "luis fernandes" erc-public-away-p t;lets ppl know how long you were away erc-prompt-for-password nil) ;; automatically join channels when we start-up (require 'erc-autojoin) (erc-autojoin-mode 1) (setq erc-autojoin-channels-alist '(("freenode.net" "#zsh" "#emacs" "#perl" "#web"))) ;; timestamp the conversations (erc-timestamp-mode 1) ;;; function that returns a random element when passed a list ;;; Thanks to Riastradh (defun random-choose (list) (nth (random (length list)) list)) (defun erc-cmd-LATER (&rest ignore) (interactive) (erc-cmd-QUIT (random-choose '("...and miles to go before i sleep." "adieu..." "another long day's journey into night.")))) ;;; when erc buffer gets to 23,000 lines it's time to flush ;;; kensanata (defun erc-cmd-FLUSH (&rest ignore) "Erase the current buffer. When the ERC buffer has 23,000 lines it's time to flush!" (let ((inhibit-read-only t)) (erase-buffer) t)) ;;; hilite occurences of my nick in the emacs modeline (erc-match-mode 1) (setq erc-keywords '("\\be1f\\b")) ;(setq erc-current-nick-highlight-type 'nick) ;;don't flood buffer with quit/joins when a netsplit happens (require 'erc-netsplit) (erc-netsplit-mode 1) ;; split the window when we get a privmsg (setq erc-auto-query 'window-noselect) ;;; switch to next ERC buffer -kensanata (defun switch-to-irc () "Switch to an IRC buffer, or run `erc-select'. When called repeatedly, cycle through the buffers." (interactive) (let ((buffers (and (fboundp 'erc-buffer-list) (erc-buffer-list)))) (when (eq (current-buffer) (car buffers)) (bury-buffer) (setq buffers (cdr buffers))) (if buffers (switch-to-buffer (car buffers)) (erc-select)))) (global-set-key (kbd "C-c b") 'switch-to-irc)