(custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(TeX-output-view-style (quote (("^dvi$" ("^landscape$" "^pstricks$\\|^pst-\\|^psfrag$") "%(o?)dvips -t landscape %d -o && gv %f") ("^dvi$" "^pstricks$\\|^pst-\\|^psfrag$" "%(o?)dvips %d -o && gv %f") ("^dvi$" ("^a4\\(?:dutch\\|paper\\|wide\\)\\|sem-a4$" "^landscape$") "%(o?)xdvi %dS -paper a4r -s 0 %d") ("^dvi$" "^a4\\(?:dutch\\|paper\\|wide\\)\\|sem-a4$" "%(o?)xdvi %dS -paper a4 %d") ("^dvi$" ("^a5\\(?:comb\\|paper\\)$" "^landscape$") "%(o?)xdvi %dS -paper a5r -s 0 %d") ("^dvi$" "^a5\\(?:comb\\|paper\\)$" "%(o?)xdvi %dS -paper a5 %d") ("^dvi$" "^b5paper$" "%(o?)xdvi %dS -paper b5 %d") ("^dvi$" "^letterpaper$" "%(o?)xdvi %dS -paper us %d") ("^dvi$" "^legalpaper$" "%(o?)xdvi %dS -paper legal %d") ("^dvi$" "^executivepaper$" "%(o?)xdvi %dS -paper 7.25x10.5in %d") ("^dvi$" "." "%(o?)xdvi %dS %d") ("^pdf$" "." "open %o") ("^html?$" "." "netscape %o")))) '(blink-cursor-mode nil) '(case-fold-search t) '(current-language-environment "English") '(display-battery-mode t) '(display-time-day-and-date t) '(display-time-mode t) '(global-font-lock-mode t nil (font-lock)) '(show-paren-mode t) '(transient-mark-mode (quote identity)) '(truncate-partial-width-windows nil)) (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(default ((t (:stipple nil :background "black" :foreground "grey98" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 120 :width extra-expanded :family "apple-monaco"))))) (add-to-list 'load-path "~/emacs-stuff") ;; bind return to do same as C-j (global-set-key (kbd "RET") 'newline-and-indent) ;;when running in split-window mode, stop text from running off the screen (setq truncate-partial-width-windows nil) ;; Python mode (add-to-list 'load-path "~/emacs-stuff/python-mode") (setq auto-mode-alist (cons '("\\.py$" . python-mode) auto-mode-alist)) (setq interpreter-mode-alist (cons '("python" . python-mode) interpreter-mode-alist)) (autoload 'python-mode "python-mode" "Python editing mode." t) ;; paredit-beta, for bracket-matching ;; various hooks for various modes (autoload 'paredit-mode "paredit-beta" "Minor mode for pseudo-structurally editing Lisp code." t) (mapc (lambda (mode-hook) (add-hook mode-hook (lambda () (paredit-mode 1)))) '(lisp-mode-hook emacs-lisp-mode-hook slime-mode-hook slime-repl-mode-hook)) ;; (add-hook 'slime-repl-mode-hook (lambda () (paredit-mode +1))) ;; Slime stuff for Lisp (add-to-list 'load-path "~/emacs-stuff/slime/") (setq inferior-lisp-program "/usr/local/bin/openmcl") (require 'slime) (slime-setup) (autoload 'slime-init-command "slime" "Return a string to initialise OpenMCL running under SLIME.") ;; Slime stuff for Scheme48 (add-to-list 'load-path "~/emacs-stuff/slime48/") (autoload 'slime "slime" "Start an inferior Lisp and connect to its Swank server" t) (autoload 'slime-mode "slime" "SLIME: Superior Lisp Interaction Mode for Emacs (minor-mode)." t) (add-hook 'scheme-mode-hook (lambda () (slime-mode +1))) (eval-after-load 'slime '(progn (slime-setup :autodoc t) (setq slime-lisp-implementations `((s48 ("scheme48") :init slime48-init-command) (openmcl ("openmcl") :init slime-init-command) (sbcl ("sbcl") :init slime-init-command) ,@slime-lisp-implementations)))) (autoload 'slime48-init-command "slime48" "Return a string to initialise Scheme48 running under SLIME.") ;; Lets me specify a scheme48-package local variable in a file's ;; -*- line or local variables section, and have SLIME48 ;; automatically evaluate code in the right package. For example, ;; all Scheme48 source files can start with: ;; ;;; -*- Mode: Scheme; scheme48-package: ... -*- (eval-after-load "slime48" '(add-hook 'slime-mode-hook (lambda () (if (and (boundp 'scheme48-package) scheme48-package) (setq slime-buffer-package scheme48-package))))) ;; This disables some hmar zift in SLIME that makes space throw an exception (setq slime-space-information-p nil) ;; SICP exercises header macro (fset 'sicp-ex [?\; ?\; ?\; ?\; ?\; ?\; ?\; ?\; ?\; return ?\; ?\; return ?\; ?\; ?\; ?\; ?\; ?\; ?\; ?\; ?\; up ?4 ?.]) ;; lisp commenting mode (defvar commenting-mode-map (let ((map (make-sparse-keymap "Commenting mode"))) (define-key map [return] (lambda () (interactive) (insert "\n;; "))) map)) (define-minor-mode commenting-mode "Foo" nil nil commenting-mode-map (if commenting-mode (auto-fill-mode 1) (auto-fill-mode 0))) ;; turn on word-wrap (setq default-major-mode 'text-mode) (add-hook 'text-mode-hook 'turn-on-auto-fill) ;; set default frame width, height, and position on desktop (set-frame-size (selected-frame) 77 51) (set-frame-position (selected-frame) 440 0) ;; cursor colour (set-cursor-color "white") ;; Erlang mode (setq load-path (cons "/usr/local/lib/erlang/lib/tools-2.6.2/emacs" load-path)) (setq erlang-root-dir "/usr/local/lib/erlang") (setq exec-path (cons "/usr/local/lib/erlang/bin" exec-path)) (require 'erlang-start) ;; Distel (add-to-list 'load-path "/Users/ghalib/emacs-stuff/distel-4.0/elisp") (require 'distel) (distel-setup) ;; Turn on all electric commands (erlang-electric-newline is not on by ;; default, for some reason). (setq erlang-electric-commands t) ;; Give our Erlang node the name "emacs" (setq inferior-erlang-machine-options '("-sname" "emacs")) ;; Swap buffers in split-window-mode (defun gms-swap-buffers () (interactive) (let ((curr-buffer (current-buffer))) (other-window 1) (let ((other-buffer (current-buffer))) (switch-to-buffer curr-buffer) (other-window -1) (switch-to-buffer other-buffer)))) ;; SLIME48 stuff that helps C-c C-c work. ?? DOESN'T WORK (defalias 'slime-repl-read-break 'slime-interrupt) ;; flyspell mode (autoload 'flyspell-mode "flyspell" "On-the-fly spelling checker." t) (autoload 'flyspell-delay-command "flyspell" "Delay on command." t) (autoload 'tex-mode-flyspell-verify "flyspell" "" t) (put 'LeTex-mode 'flyspell-mode-predicate 'tex-mode-flyspell-verify) (add-hook 'LaTeX-mode-hook 'flyspell-mode) ;; set web browser to be emacs-w3m for Lisp docs, default OS X browser for ;; everything else ;; (require 'w3m-load) ;; (setq browse-url-browser-function '(("hyperspec" . w3m-browse-url) ;; ("weitz" . w3m-browse-url) ;; ("." . browse-url-default-macosx-browser))) ;; easier to type y/n instead of yes/no (fset 'yes-or-no-p 'y-or-n-p) ;; nice mode to use when switching buffers (require 'iswitchb) (iswitchb-mode 1) ;; Bind M-RET to iswitchb-buffer (global-set-key (kbd "M-RET") (lambda () (interactive) (iswitchb-buffer))) ;; iswitchb ignores (add-to-list 'iswitchb-buffer-ignore "*Messages*") (add-to-list 'iswitchb-buffer-ignore "*Completions*") (add-to-list 'iswitchb-buffer-ignore "*inferior-lisp*") (add-to-list 'iswitchb-buffer-ignore "*slime-events*") ;; woman (man page reader) should launch in existing frame, not new (setq-default woman-use-own-frame nil) ;; Keybindings for writing Lisp. Swap '(' and '[' (eval-after-load "paredit-beta.el" '(progn (define-key paredit-mode-map (kbd "[") 'paredit-open-parenthesis) (define-key paredit-mode-map (kbd "]") 'paredit-close-parenthesis-and-newline) (define-key paredit-mode-map (kbd "(") 'paredit-open-bracket) (define-key paredit-mode-map (kbd ")") 'paredit-close-bracket))) ;; Compile .emacs to make things a little bit faster (defun byte-compile-user-init-file () (let ((byte-compile-warnings '(unresolved))) ;; in case compilation fails, don't leave the old .elc around: (delete-file (concat user-init-file ".elc")) (byte-compile-file user-init-file) ;; (message "%s compiled" user-init-file) )) (defun my-emacs-lisp-mode-hook () (when (equal buffer-file-name user-init-file) (add-hook 'after-save-hook 'byte-compile-user-init-file t t))) (add-hook 'emacs-lisp-mode-hook 'my-emacs-lisp-mode-hook) ;;;; rcirc (rcirc-track-minor-mode 1) (setq global-mode-string '("" rcirc-activity-string)) ;; Join these channels on startup. (setq rcirc-startup-channels-alist '(("freenode" "#emacs" "#math" "#lisp" "#scheme" "#erlang" "##c++" "#python") ("choopa" "#math" "#c++" "#Python" "#compsci"))) (setq rcirc-default-nick "Cowmoo") (setq rcirc-default-user-name "Cowmoo") (setq rcirc-default-user-full-name "Cowmoo") (setq rcirc-default-server "kornbluth.freenode.net") ;; authentication info on freenode (setq rcirc-authinfo `(("freenode" nickserv ,rcirc-default-nick *CENSORED-PASSWORD*))) ;; Connect to these servers and channels on startup (setq rcirc-server-alist '(("kornbluth.freenode.net" :channels ("#emacs" "#math" "#lisp" "#scheme" "#erlang" "#algos" "##c++" "#python")) ("irc.choopa.net" :channels ("#math" "#c++" "#Python" "#compsci")))) ;; Truncate channel buffer after it reaches this number of lines (setq rcirc-buffer-maximum-lines 15000) ;;;; end rcirc ;; TRAMP (setq tramp-default-method "ssh") ;;; Default Emacs behaviour for zap-to-char is to include the char ;;; when killing. Not exactly intuitive. (defun gms-zap-to-char (arg char) "Kill up to but not including ARG'th occurrence of CHAR. Case is ignored if `case-fold-search' is non-nil in the current buffer. Goes backward if ARG is negative; error if CHAR not found." (interactive "p\ncZap to char: ") (if (char-table-p translation-table-for-input) (setq char (or (aref translation-table-for-input char) char))) (kill-region (point) (progn (search-forward (char-to-string char) nil nil arg) (- (point) 1)))) (global-set-key (kbd "M-z") 'gms-zap-to-char) (defun rcirc-quit () (interactive) (dolist (b (buffer-list)) (when (eq (buffer-local-value 'major-mode b) 'rcirc-mode) (kill-buffer b)))) ;;; Steve Yegge's js2-mode (autoload 'js2-mode "js2" nil t) (add-to-list 'auto-mode-alist '("\\.js$" . js2-mode)) ;;; Windmove package -- move to window by hitting SHIFT-arrow ;;; instead of C-x o repeatedly (windmove-default-keybindings) ;;; After compiling mochiweb app, close the *compilation* buffer if ;;; compilation was successful. Otherwise, go to first error in source. (defun gms-mochi-compile-finish (compilation-buffer finish-msg) (if (string= finish-msg "finished\n") (kill-buffer compilation-buffer) (next-error))) (setq compilation-finish-functions '(gms-mochi-compile-finish)) ;;; Mochiweb app compile command. Just runs 'make'. (defun gms-mochi-compile () (interactive) (compile "make")) ;;; Bind this to C-C C-b when erlang-mode is invoked (add-hook 'erlang-mode-hook (lambda () (define-key erlang-mode-map "\C-c\C-b" 'gms-mochi-compile)))