2011-06-03 17:44:54 +00:00
|
|
|
;; Date: Aug 19, 2010
|
|
|
|
;; Author: Collin J. Doering
|
|
|
|
;; Description: Emacs configuration file (in emacs lisp)
|
|
|
|
|
2011-06-06 04:37:41 +00:00
|
|
|
;; stop renaming of saved files to filename~ which ends up breaking hardlinks
|
|
|
|
(setq backup-by-copying-when-linked t)
|
|
|
|
|
2011-06-03 17:44:54 +00:00
|
|
|
;; fixes color output issues; see: http://wiki.archlinux.org/index.php/Emacs#Colored_output_issues
|
|
|
|
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
|
|
|
|
|
|
|
|
;; bind M-g to M-x goto-line
|
|
|
|
(global-set-key "\M-g" 'goto-line)
|
|
|
|
|
2011-07-09 23:27:51 +00:00
|
|
|
;; Make C-x O cycle backwards a pane (oposite to C-x o)
|
|
|
|
(global-set-key "\C-xO" #'(lambda ()
|
|
|
|
(interactive)
|
|
|
|
(other-window -1)))
|
|
|
|
|
|
|
|
;; Thanks to lauren michelle for this one
|
|
|
|
(defun pretty-lambdas ()
|
|
|
|
(font-lock-add-keywords
|
|
|
|
nil `(("(\\(lambda\\>\\)"
|
|
|
|
(0 (progn (compose-region (match-beginning 1) (match-end 1)
|
|
|
|
,(make-char 'greek-iso8859-7 107))
|
|
|
|
nil))))))
|
|
|
|
|
|
|
|
;; Make lambda appear as the greek character
|
|
|
|
(add-hook 'scheme-mode-hook 'pretty-lambdas)
|
|
|
|
(add-hook 'lisp-mode-hook 'pretty-lambdas)
|
|
|
|
(add-hook 'lisp-interaction-mode-hook 'pretty-lambdas)
|
|
|
|
(add-hook 'geiser-repl-mode-hook 'pretty-lambdas)
|
|
|
|
|
2011-06-03 17:44:54 +00:00
|
|
|
;; adds the given function mode to each element of the given-hooks
|
|
|
|
(defun activate-mode-with-hooks (mode given-hooks)
|
|
|
|
(while given-hooks
|
|
|
|
(add-hook (car given-hooks)
|
|
|
|
mode)
|
|
|
|
(setq given-hooks (cdr given-hooks))))
|
|
|
|
|
|
|
|
;; linum mode for pretty line numbering
|
|
|
|
(require 'linum)
|
|
|
|
|
|
|
|
;; right justify the numbers and add a space between them and the text in the given buffer
|
|
|
|
(setq linum-format
|
|
|
|
(lambda (line)
|
|
|
|
(propertize (format
|
|
|
|
(let ((w (length (number-to-string
|
|
|
|
(count-lines (point-min) (point-max))))))
|
|
|
|
(concat "%" (number-to-string w) "d "))
|
|
|
|
line)
|
|
|
|
'face 'linum)))
|
|
|
|
|
|
|
|
;; linum-modes is a list of mode hooks to instantiate linum-mode on
|
|
|
|
(defvar linum-modes '(scheme-mode-hook emacs-lisp-mode-hook c-mode-hook c++-mode-hook python-mode-hook lua-mode-hook haskell-mode-hook php-mode-hook perl-mode-hook lisp-mode-hook ruby-mode-hook sh-mode-hook))
|
|
|
|
(activate-mode-with-hooks (lambda () (linum-mode 1)) linum-modes)
|
|
|
|
|
|
|
|
;; load color-theme and initialize
|
|
|
|
(require 'color-theme)
|
|
|
|
(color-theme-initialize)
|
|
|
|
|
|
|
|
;; use a global color theme
|
|
|
|
(color-theme-tty-dark)
|
|
|
|
|
|
|
|
;; make color-theme not applied globally and not cumunitive
|
|
|
|
;;(setq color-theme-is-cumulative nil)
|
|
|
|
;;(setq color-theme-is-global nil)
|
|
|
|
|
|
|
|
;; given a frame colorizes the frame
|
|
|
|
;; if its window-system is X Windows the tty-dark theme will be applied otherwise it will be colorized tty-dark
|
|
|
|
;;(defun apply-color-theme (frame)
|
|
|
|
;; (select-frame frame)
|
|
|
|
;; (if (eq (window-system frame) 'x)
|
|
|
|
;; (color-theme-tty-dark)
|
|
|
|
;; (color-theme-tty-dark)))
|
|
|
|
|
|
|
|
;; add the apply-color-theme function (hook) to be executed on the creation of a new frame
|
|
|
|
;;(add-hook 'after-make-frame-functions 'apply-color-theme)
|
|
|
|
|
|
|
|
;; Set default tramp method to ssh (for security purposes)
|
|
|
|
(setq tramp-default-method "ssh")
|
|
|
|
|
|
|
|
;; Setup ibuffer (interactive buffer)
|
|
|
|
(global-set-key "\C-x\C-b" 'ibuffer)
|
|
|
|
(autoload 'ibuffer "ibuffer" "List buffers." t)
|
|
|
|
|
|
|
|
;; Require ibuffer extentions (used for ibuffer-never-show-predicates)
|
|
|
|
(require 'ibuf-ext)
|
|
|
|
(add-to-list 'ibuffer-never-show-predicates "^\\*slime-events\\*$")
|
|
|
|
(add-to-list 'ibuffer-never-show-predicates "^\\*Completions\\*$")
|
|
|
|
(add-to-list 'ibuffer-never-show-predicates "^\\*tramp/.*\\*$")
|
|
|
|
|
|
|
|
;; Filter ibuffers (similar to gnus)
|
|
|
|
(setq ibuffer-saved-filter-groups
|
|
|
|
(quote (("default"
|
|
|
|
("dired" (mode . dired-mode))
|
|
|
|
("config" (or
|
|
|
|
(name . "^\\.xinitrc$")
|
|
|
|
(name . "^\\.bashrc$")
|
|
|
|
(name . "^\\.bash_profile$")
|
|
|
|
(name . "^\\.zshrc$")
|
|
|
|
(name . "^xmonad\\.hs$")
|
|
|
|
(name . "^\\.emacs$")
|
|
|
|
(name . "^\\.gnus$")
|
|
|
|
(name . "^\\.xmobarrc")
|
|
|
|
(name . "^\\.Xdefaults$")
|
|
|
|
(name . "^\\.screenrc$")
|
|
|
|
(name . "^\\.xbindkeysrc$")))
|
|
|
|
("code" (or
|
|
|
|
(mode . c-mode)
|
|
|
|
(mode . c++-mode)
|
|
|
|
(mode . perl-mode)
|
|
|
|
(mode . python-mode)
|
|
|
|
(mode . ruby-mode)
|
|
|
|
(mode . emacs-lisp-mode)
|
|
|
|
(mode . lisp-mode)
|
|
|
|
(mode . sh-mode)
|
|
|
|
(mode . scheme-mode)
|
|
|
|
(mode . php-mode)
|
|
|
|
(mode . xml-mode)))
|
|
|
|
("REPL" (or
|
|
|
|
(mode . geiser-mode)
|
|
|
|
(mode . slime-repl-mode)
|
|
|
|
(name . "^\\*inferior-lisp\\*$")
|
|
|
|
(name . "^\\* Racket REPL \\*$")))
|
|
|
|
("planner" (or
|
|
|
|
(name . "^\\*Calendar\\*$")
|
|
|
|
(name . "^diary$")
|
|
|
|
(mode . muse-mode)))
|
|
|
|
("emacs" (or
|
|
|
|
(name . "^\\*scratch\\*$")
|
|
|
|
(name . "^\\*Messages\\*$")))
|
|
|
|
("gnus" (or
|
|
|
|
(mode . message-mode)
|
|
|
|
(mode . bbdb-mode)
|
|
|
|
(mode . mail-mode)
|
|
|
|
(mode . gnus-group-mode)
|
|
|
|
(mode . gnus-summary-mode)
|
|
|
|
(mode . gnus-article-mode)
|
|
|
|
(name . "^\\.bbdb$")
|
|
|
|
(name . "^\\.newsrc-dribble")))))))
|
|
|
|
|
|
|
|
(add-hook 'ibuffer-mode-hook
|
|
|
|
(lambda ()
|
|
|
|
(ibuffer-switch-to-saved-filter-groups "default")))
|
|
|
|
|
|
|
|
;; setup html renderer w3m
|
|
|
|
(require 'w3m-load)
|
|
|
|
(setq browse-url-browser-function 'w3m-browse-url)
|
|
|
|
(autoload 'w3m-browse-url "w3m" "Ask a WWW browser to show a URL." t)
|
|
|
|
|
|
|
|
;; setup php-mode
|
|
|
|
(autoload 'php-mode "php-mode.el" "Php mode." t)
|
|
|
|
(setq auto-mode-alist (append '(("/*.\.php[345]?$" . php-mode)) auto-mode-alist))
|
|
|
|
|
|
|
|
;; Set default lisp program
|
|
|
|
(setq inferior-lisp-program "/usr/bin/sbcl")
|
|
|
|
|
2011-07-09 23:27:51 +00:00
|
|
|
;; Since there is no support for the kawa implementation of scheme
|
|
|
|
(defun run-kawa ()
|
|
|
|
"Run Kawa Scheme in an Emacs buffer."
|
|
|
|
(interactive)
|
|
|
|
(require 'cmuscheme)
|
|
|
|
(let ((scheme-program-name "/usr/bin/kawa"))
|
|
|
|
(run-scheme scheme-program-name)))
|
|
|
|
|
2011-06-03 17:44:54 +00:00
|
|
|
;; Set usable lisp implementations
|
|
|
|
(setq slime-lisp-implementations
|
|
|
|
'((sbcl ("/usr/bin/sbcl" ""))
|
2011-06-21 00:55:55 +00:00
|
|
|
(clisp ("/usr/bin/clisp" "-K base"))
|
|
|
|
(clojure ("/usr/bin/clj" ""))))
|
2011-06-03 17:44:54 +00:00
|
|
|
|
|
|
|
;; Function to start and/or connect to slime
|
|
|
|
(defun start-slime ()
|
|
|
|
(unless (slime-connected-p)
|
|
|
|
(save-excursion (slime))))
|
|
|
|
|
|
|
|
;; Setup slime mode
|
|
|
|
(add-to-list 'load-path "/usr/share/emacs/site-lisp/slime/")
|
|
|
|
(require 'slime)
|
|
|
|
(slime-setup '(slime-fancy))
|
|
|
|
|
2011-06-21 00:55:55 +00:00
|
|
|
;; Setup clojure mode
|
|
|
|
(add-to-list 'load-path "/usr/share/emacs/site-lisp/clojure-mode")
|
|
|
|
(require 'clojure-mode)
|
|
|
|
|
|
|
|
;; Setup swank-clojure-mode
|
|
|
|
(add-to-list 'load-path "/usr/share/emacs/site-lisp/swank-clojure")
|
|
|
|
(require 'swank-clojure)
|
|
|
|
|
|
|
|
(add-hook 'clojure-mode-hook
|
|
|
|
'(lambda ()
|
|
|
|
(define-key clojure-mode-map "\C-c\C-e" 'lisp-eval-last-sexp)
|
|
|
|
(define-key clojure-mode-map "\C-x\C-e" 'lisp-eval-last-sexp)))
|
|
|
|
(eval-after-load "slime"
|
|
|
|
`(progn
|
|
|
|
(require 'assoc)
|
|
|
|
(setq swank-clojure-classpath
|
|
|
|
(list "/usr/share/clojure/clojure.jar"
|
|
|
|
"/usr/share/clojure/clojure-contrib.jar"
|
|
|
|
"/usr/share/emacs/site-lisp/swank-clojure/src"))
|
|
|
|
(aput 'slime-lisp-implementations 'clojure
|
|
|
|
(list (swank-clojure-cmd) :init 'swank-clojure-init))))
|
|
|
|
|
2011-06-03 17:44:54 +00:00
|
|
|
;; Setup emacs-org-mode
|
|
|
|
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
|
|
|
|
(add-hook 'org-mode-hook 'turn-on-font-lock) ; not needed when global-font-lock-mode is on
|
|
|
|
(global-set-key "\C-cl" 'org-store-link)
|
|
|
|
(global-set-key "\C-ca" 'org-agenda)
|
|
|
|
(global-set-key "\C-cb" 'org-iswitchb)
|
|
|
|
|
|
|
|
;; Setup emacs-haskell-mode
|
|
|
|
(load "/usr/share/emacs/site-lisp/haskell-mode/haskell-site-file")
|
|
|
|
(add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode)
|
|
|
|
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
|
|
|
|
;;(add-hook 'haskell-mode-hook 'turn-on-haskell-indent)
|
|
|
|
;;(add-hook 'haskell-mode-hook 'turn-on-haskell-simple-indent)
|
|
|
|
|
|
|
|
;; Setup emacs-python-mode
|
|
|
|
(autoload 'python-mode "/usr/share/emacs/site-lisp/python-mode.el" "Python mode." t)
|
|
|
|
(setq auto-mode-alist (append '(("/*.\.py$" . python-mode)) auto-mode-alist))
|
|
|
|
|
|
|
|
;; Setup emacs-lua-mode
|
|
|
|
(setq auto-mode-alist (cons '("\.lua$" . lua-mode) auto-mode-alist))
|
|
|
|
(autoload 'lua-mode "lua-mode" "Lua editing mode." t)
|
|
|
|
|
|
|
|
;; Setup emacs-erlang-mode
|
|
|
|
(setq erlang-root-dir "/usr/lib/erlang")
|
|
|
|
(setq exec-path (cons "/usr/lib/erlang/bin" exec-path))
|
|
|
|
(require 'erlang-start)
|
|
|
|
|
|
|
|
;; Setup enhanced scheme/racket mode consisting of geiser, quack and paredit
|
|
|
|
(require 'geiser-install)
|
|
|
|
;(require 'quack)
|
|
|
|
(require 'paredit)
|
|
|
|
(defvar paredit-hooks '(lisp-mode-hook lisp-interaction-mode-hook scheme-mode-hook c-mode-hook c++-mode-hook python-mode-hook))
|
|
|
|
(activate-mode-with-hooks (lambda () (paredit-mode 1)) paredit-hooks)
|
|
|
|
|
2011-06-21 00:55:55 +00:00
|
|
|
;; Highlight paren's in given modes [to apply globally do (show-paren-mode 1)]
|
|
|
|
(activate-mode-with-hooks (lambda () (show-paren-mode 1)) paredit-hooks)
|
|
|
|
|
2011-06-03 17:44:54 +00:00
|
|
|
;; upcomming functionallity: toggle paredit-mode due to annoying things like wrapping parens when a mistake is made
|
|
|
|
;; known issue..if paredit-mode is turned on when there are unbalanced parens an error is reported
|
|
|
|
(defun toggle-paredit-mode ()
|
|
|
|
(let ((active-minor-modes (list)))
|
|
|
|
(mapatoms (lambda (sym)
|
|
|
|
(when (and (symbolp sym) (assq sym minor-mode-alist) (symbol-value sym))
|
|
|
|
(push sym active-minor-modes))))
|
|
|
|
(if (member 'paredit-mode active-minor-modes) (paredit-mode -1) (paredit-mode 1))))
|
|
|
|
|
|
|
|
(setq geiser-repl-use-other-window nil)
|
|
|
|
(setq geiser-active-implementations '(racket))
|
|
|
|
|
|
|
|
;; Make hs-minor-mode act like org-mode for code folding
|
|
|
|
;;(add-to-list 'load-path "/usr/share/emacs/site-lisp/hideshow-org")
|
|
|
|
(require 'hideshow-org)
|
|
|
|
(global-set-key "\C-ch" 'hs-org/minor-mode)
|
|
|
|
|
|
|
|
;; Add automatic activation of hs-org/minor-mode in the below major-modes
|
|
|
|
(add-hook 'c-mode-common-hook 'hs-org/minor-mode)
|
|
|
|
(add-hook 'emacs-lisp-mode-hook 'hs-org/minor-mode)
|
|
|
|
(add-hook 'java-mode-hook 'hs-org/minor-mode)
|
|
|
|
(add-hook 'lisp-mode-hook 'hs-org/minor-mode)
|
|
|
|
(add-hook 'sh-mode-hook 'hs-org/minor-mode)
|
|
|
|
(add-hook 'python-mode-hook 'hs-org/minor-mode)
|
|
|
|
(add-hook 'scheme-mode-hook 'hs-org/minor-mode)
|
|
|
|
|
2011-06-05 14:42:52 +00:00
|
|
|
;; Enable autoinsert feature to automagically insert
|
|
|
|
(require 'autoinsert)
|
|
|
|
(auto-insert-mode) ;;; Adds hook to find-files-hook
|
|
|
|
(setq auto-insert-directory "~/.emacs.d/templates/") ;;; Or use custom, *NOTE* Trailing slash important
|
|
|
|
(setq auto-insert-query nil) ;;; If you don't want to be prompted before insertion
|
|
|
|
|
|
|
|
;; auto-insert options template and auto-completion
|
|
|
|
(add-hook 'find-file-hooks 'auto-insert)
|
|
|
|
(setq auto-insert-directory (concat (getenv "HOME") "/.emacs.d/templates/"))
|
|
|
|
(setq auto-insert-alist
|
|
|
|
'(("\\.c$" . ["c-template.c" auto-update-generic-template])
|
|
|
|
("\\.\(cc\|cpp\)$" . ["cpp-template.c" auto-update-generic-template])
|
|
|
|
("\\.sh$" . ["shell-template.sh" auto-update-generic-template])
|
|
|
|
("\\.rkt$" . ["racket-template.rkt" auto-update-generic-template])
|
2011-06-27 16:21:08 +00:00
|
|
|
("\\.scm$" . ["scheme-template.scm" auto-update-generic-template])
|
2011-06-27 20:49:11 +00:00
|
|
|
("\\.clj$" . ["clojure-template.clj" auto-update-generic-template])
|
2011-08-11 06:00:52 +00:00
|
|
|
("\\.lisp$" . ["lisp-template.lisp" auto-update-generic-template])
|
2011-08-10 03:04:59 +00:00
|
|
|
("\\.hs$" . ["haskell-template.hs" auto-update-generic-template])
|
2011-06-05 14:42:52 +00:00
|
|
|
("\\.py$" . ["python-template.py" auto-update-generic-template])))
|
|
|
|
(setq auto-insert 'other)
|
|
|
|
|
|
|
|
(defun auto-update-generic-template ()
|
|
|
|
(save-excursion
|
|
|
|
;; Replace @!@FILENAME@!@ with file name sans suffix
|
|
|
|
(while (search-forward "@!@FILENAME@!@" nil t)
|
|
|
|
(save-restriction
|
|
|
|
(narrow-to-region (match-beginning 0) (match-end 0))
|
|
|
|
(replace-match (file-name-sans-extension (file-name-nondirectory buffer-file-name)) t))))
|
|
|
|
(save-excursion
|
|
|
|
;; Replace @!@FILE@!@ with file name
|
|
|
|
(while (search-forward "@!@FILE@!@" nil t)
|
|
|
|
(save-restriction
|
|
|
|
(narrow-to-region (match-beginning 0) (match-end 0))
|
|
|
|
(replace-match (file-name-nondirectory buffer-file-name) t))))
|
|
|
|
(save-excursion
|
|
|
|
;; replace @!@DATE@!@ with today's date
|
|
|
|
(while (search-forward "@!@DATE@!@" nil t)
|
|
|
|
(save-restriction
|
|
|
|
(narrow-to-region (match-beginning 0) (match-end 0))
|
|
|
|
(replace-match "")
|
|
|
|
(insert-date))))
|
|
|
|
(save-excursion
|
|
|
|
;; Replace @!@YEAR@!@ with the current year
|
|
|
|
(while (search-forward "@!@YEAR@!@" nil t)
|
|
|
|
(save-restriction
|
|
|
|
(narrow-to-region (match-beginning 0) (match-end 0))
|
|
|
|
(replace-match (format-time-string "%Y" (current-time)))))))
|
|
|
|
|
2011-06-03 17:44:54 +00:00
|
|
|
;; Insert current date at cursor in the currently active buffer
|
|
|
|
(defun insert-date ()
|
|
|
|
"Insert today's date into buffer"
|
|
|
|
(interactive)
|
|
|
|
(insert (format-time-string "%b %e, %Y" (current-time))))
|
|
|
|
|
|
|
|
;; Force ediff sessions to run in the same frame
|
|
|
|
(setq ediff-window-setup-function 'ediff-setup-windows-plain)
|
|
|
|
|
|
|
|
;; Remove menu-bar
|
|
|
|
(menu-bar-mode -1)
|
|
|
|
|
|
|
|
;; Remove tool-bar
|
|
|
|
(tool-bar-mode -1)
|
2011-06-21 00:55:55 +00:00
|
|
|
|
|
|
|
;; Remove scroll bars
|
|
|
|
(scroll-bar-mode -1)
|
2011-06-21 03:26:45 +00:00
|
|
|
|
|
|
|
(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.
|
|
|
|
'(org-agenda-files (quote ("~/.org/todo/center-todo.org" "~/.org/todo/oh-mega-todo.org" "~/.org/todo/network-todo.org" "~/.org/todo/rekahsoft-todo.org" "~/.org/todo/alpha-todo.org" "~/.org/todo/rekahsoft-mini-todo.org")))
|
|
|
|
'(quack-default-program "racket")
|
|
|
|
'(quack-fontify-style (quote plt))
|
|
|
|
'(quack-programs (quote ("mzscheme" "bigloo" "csi" "csi -hygienic" "gosh" "gracket" "gsi" "gsi ~~/syntax-case.scm -" "guile" "kawa" "mit-scheme" "racket" "racket -il typed/racket" "rs" "scheme" "scheme48" "scsh" "sisc" "stklos" "sxi")))
|
|
|
|
'(scroll-bar-mode nil)
|
|
|
|
'(show-paren-mode t))
|
|
|
|
(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.
|
|
|
|
)
|