dotfiles / dot.emacs

The default branch has multiple heads

;; We need mouse wheel!
(mouse-wheel-mode t)
(setq scroll-step 1)
;; I hate auto save and auto backup files scattered all over the file system
;; so we turn them off...
; (setq make-backup-files nil)
; (setq auto-save-default nil)
;; ... or make them all in ONE place
;; autosave files (ie #foo#)
(defvar autosave-dir "~/.emacs.d/.auto-save-files/")

(defun auto-save-file-name-p (filename)
  (string-match "^#.*#$" (file-name-nondirectory filename)))

(defun make-auto-save-file-name ()
  (concat autosave-dir
    (if buffer-file-name
      (concat "#" (file-name-nondirectory buffer-file-name) "#")
      (expand-file-name
        (concat "#%" (buffer-name) "#")))))
;; backup files (ie foo~) - backup-directory-alist list contains regexp=>directory mappings
;; filenames matching a regexp are backed up in the corresponding directory
(defvar backup-dir "~/.emacs.d/.backup-files/")
(setq backup-directory-alist (list (cons "." backup-dir)))

;; My elips load-path
(add-to-list 'load-path "~/.emacs.d/")

;; Disable abbrev save to prevent weird annoying
(setq abbrev-file-name "~/.emacs.d/abbrev_defs")
(setq save-abbrevs nil)

;; Load slime and swank-clojure
(add-to-list 'load-path "/usr/share/emacs/site-lisp/slime/")
(require 'slime-autoloads)

;;(setq slime-lisp-implementations `(
;;	(sbcl ("/usr/bin/sbcl"))
	;; (clisp ("/opt/local/bin/clisp"))
;;	))

(add-hook 'lisp-mode-hook
	(lambda ()
	(cond ((not (featurep 'slime))
	  (require 'slime) 
		(normal-mode)))))

(eval-after-load "slime"
	'(slime-setup '(slime-fancy slime-banner)))

(global-set-key (kbd "<f5>") 'slime-selector)

; Load clojure stuff
(add-to-list 'load-path "~/.emacs.d/clojure-mode")
(require 'clojure-auto)

(add-to-list 'load-path "~/.emacs.d/swank-clojure")
(require 'swank-clojure-autoload)       
(swank-clojure-config
	(setq swank-clojure-jar-path (expand-file-name "/usr/share/clojure/clojure.jar"))
  (setq swank-clojure-extra-classpaths (list (expand-file-name "~/src/git/clojure-contrib/src"))))

;; Load paredit-mode
(autoload 'paredit-mode "paredit" 
	"Minor mode for pseudo-structurally editing Lisp code." t)
	
(mapc 
	(lambda (mode)
		(let ((hook (intern (concat (symbol-name mode) "-mode-hook"))))
			(add-hook hook (lambda () (paredit-mode +1)))))
	'(emacs-lisp lisp inferior-lisp))

;; Keyboard customization for slime
(eval-after-load 'slime
	'(progn
		; * Using built-in functions or paredit-mode functions
		; (define-key slime-mode-map (kbd "[") 'insert-parentheses)
		; (define-key slime-mode-map (kbd "]") 'move-past-close-and-reindent)
		; (define-key slime-mode-map (kbd "(") (lambda () (interactive) (insert "[")))
		; (define-key slime-mode-map (kbd ")") (lambda () (interactive) (insert "]")))
		(define-key slime-mode-map (kbd "[") 'paredit-open-parenthesis)
		(define-key slime-mode-map (kbd "]") 'paredit-close-parenthesis-and-newline)
		(define-key slime-mode-map (kbd "(") 'paredit-open-bracket)
		(define-key slime-mode-map (kbd ")") 'paredit-close-bracket)
		(define-key slime-mode-map [(return)] 'paredit-newline)
		(define-key slime-mode-map [(control ?\=)] (lambda () (interactive) (insert "(")))
		(define-key slime-mode-map [(control ?\\)] (lambda () (interactive) (insert ")")))
		(define-key slime-mode-map (kbd "C-t") 'transpose-sexps)
		(define-key slime-mode-map (kbd "C-M-t") 'transpose-chars)
		(define-key slime-mode-map (kbd "C-b") 'backward-sexp)
		(define-key slime-mode-map (kbd "C-M-b") 'backward-char)
		(define-key slime-mode-map (kbd "C-f") 'forward-sexp)
		(define-key slime-mode-map (kbd "C-M-f") 'forward-char)
		))


;; Function to run tidy on buffer
(defun tidy-buffer ()
  "Run Tidy HTML parser on current buffer."
  (interactive)
  (if (get-buffer "tidy-errs") (kill-buffer "tidy-errs"))
  (shell-command-on-region (point-min) (point-max)
    "tidy -asxhtml -n -q -i -c -wrap 72 -f /tmp/tidy-errs" t)
  (find-file-other-window "/tmp/tidy-errs")
  (other-window 1)
  (delete-file "/tmp/tidy-errs")
  (message "buffer tidy'ed"))
(global-set-key (kbd "C-x t") 'tidy-buffer)

;; The following lines are always needed.  Choose your own keys.
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cb" 'org-iswitchb)

(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 ("agenda.bruce" "todo.bruce"))))
(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.
 )
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.