Split up configuration in five files. I wrote a nice commit message explaining this, but I wrote it in vi and it died on me.

This commit is contained in:
Vincent Ambo 2013-07-08 01:15:05 +02:00
parent 90f95a6a3d
commit 0d133eceb3
7 changed files with 340 additions and 220 deletions

19
emacs.d/init-custom.el Normal file
View file

@ -0,0 +1,19 @@
(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.
'(custom-safe-themes
(quote
("ea0c5df0f067d2e3c0f048c1f8795af7b873f5014837feb0a7c8317f34417b04" "a234f91f9be6ed40f6ce0e94dce5cea1b9f1ccec2b9ccd42bb71c499867a3fcc" "fc5fcb6f1f1c1bc01305694c59a1a861b008c534cae8d0e48e4d5e81ad718bc6" "1e7e097ec8cb1f8c3a912d7e1e0331caeed49fef6cff220be63bd2a6ba4cc365" "d6a00ef5e53adf9b6fe417d2b4404895f26210c52bb8716971be106550cea257" default)))
'(erc-modules
(quote
(autojoin button completion dcc irccontrols list log match menu move-to-prompt netsplit networks noncommands notifications readonly ring scrolltobottom stamp track)))
'(ns-alternate-modifier (quote none))
'(ns-command-modifier (quote meta)))
(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.
)

53
emacs.d/init-functions.el Normal file
View file

@ -0,0 +1,53 @@
;; A few handy functions I use in init.el (or not, but they're nice to
;; have)
;; Ensure that the themes folder exists
(defun custom-download-theme (url filename)
"Downloads a theme through HTTP and places it in ~/.emacs.d/themes"
;; Ensure the directory exists
(unless (file-exists-p "~/.emacs.d/themes")
(make-directory "~/.emacs.d/themes"))
;; Adds the themes folder to the theme load path (if not already
;; there)
(unless (member "~/.emacs.d/themes" custom-theme-load-path)
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes"))
;; Download file if it doesn't exist.
(let ((file
(concat "~/.emacs.d/themes/" filename)))
(unless (file-exists-p file)
(url-copy-file url file))))
;; These come from the emacs starter kit
(defun esk-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))))))
(defun esk-add-watchwords ()
(font-lock-add-keywords
nil '(("\\<\\(FIX\\(ME\\)?\\|TODO\\|HACK\\|REFACTOR\\|NOCOMMIT\\)"
1 font-lock-warning-face t))))
(defun esk-sudo-edit (&optional arg)
(interactive "p")
(if (or arg (not buffer-file-name))
(find-file (concat "/sudo:root@localhost:" (ido-read-file-name "File: ")))
(find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name))))
(defun esk-suck-it (suckee)
"Insert a comment of appropriate length about what can suck it."
(interactive "MWhat can suck it? ")
(let ((prefix (concat ";; " suckee " can s"))
(postfix "ck it!")
(col (current-column)))
(insert prefix)
(dotimes (_ (- 80 col (length prefix) (length postfix))) (insert "u"))
(insert postfix)))

38
emacs.d/init-modes.el Normal file
View file

@ -0,0 +1,38 @@
;; Initializes modes I use.
(add-hook 'prog-mode-hook 'esk-pretty-lambdas)
(add-hook 'prog-mode-hook 'esk-add-watchwords)
(add-hook 'prog-mode-hook 'idle-highlight-mode)
;; Configure markdown-mode
(autoload 'markdown-mode "markdown-mode"
"Major mode for editing Markdown files" t)
(add-to-list 'auto-mode-alist '("\\.txt\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
;; Configure haskell-mode
;; Enable semi-automatic indentation and font-locking
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
(add-hook 'haskell-mode-hook 'font-lock-mode)
;; Add keybindings to move nested blocks with C-, rsp. C-.
(define-key haskell-mode-map (kbd "C-,") 'haskell-move-nested-left)
(define-key haskell-mode-map (kbd "C-.") 'haskell-move-nested-right)
;; Configure nrepl (Clojure REPL) and clojure-mode
;; Paredit in clojure
(add-hook 'clojure-mode-hook 'paredit-mode)
;; eldoc in clojure
(add-hook 'nrepl-interaction-mode-hook
'nrepl-turn-on-eldoc-mode)
;; Don't annoy me
(setq nrepl-hide-special-buffers t)
(setq nrepl-popup-stacktraces nil)
;; Paredit in nrepl
(add-hook 'nrepl-mode-hook 'paredit-mode)
(add-hook 'nrepl-mode-hook 'rainbow-delimiters-mode)

180
emacs.d/init-settings.el Normal file
View file

@ -0,0 +1,180 @@
;; ## Generic settings ##
(tool-bar-mode -1)
(scroll-bar-mode -1)
;;; Code:
(when window-system
(setq frame-title-format '(buffer-file-name "%f" ("%b")))
(tooltip-mode -1)
(mouse-wheel-mode t)
(blink-cursor-mode -1))
;; can't do it at launch or emacsclient won't always honor it
(add-hook 'before-make-frame-hook 'esk-turn-off-tool-bar)
(setq visible-bell t
inhibit-startup-message t
color-theme-is-global t
sentence-end-double-space nil
shift-select-mode nil
mouse-yank-at-point t
uniquify-buffer-name-style 'forward
whitespace-style '(face trailing lines-tail tabs)
whitespace-line-column 80
ediff-window-setup-function 'ediff-setup-windows-plain
oddmuse-directory (concat user-emacs-directory "oddmuse")
save-place-file (concat user-emacs-directory "places")
backup-directory-alist `(("." . ,(concat user-emacs-directory "backups")))
diff-switches "-u")
(setq smex-save-file (concat user-emacs-directory ".smex-items"))
(smex-initialize)
(global-set-key (kbd "M-x") 'smex)
(add-to-list 'safe-local-variable-values '(lexical-binding . t))
(add-to-list 'safe-local-variable-values '(whitespace-line-column . 80))
;; ido-mode is like magic pixie dust!
(ido-mode t)
(ido-ubiquitous t)
(setq ido-enable-prefix nil
ido-enable-flex-matching t
ido-auto-merge-work-directories-length nil
ido-create-new-buffer 'always
ido-use-filename-at-point 'guess
ido-use-virtual-buffers t
ido-handle-duplicate-virtual-buffers 2
ido-max-prospects 10)
;; Swedish!
(set-language-environment 'Swedish)
(require 'ffap)
(defvar ffap-c-commment-regexp "^/\\*+"
"Matches an opening C-style comment, like \"/***\".")
(defadvice ffap-file-at-point (after avoid-c-comments activate)
"Don't return paths like \"/******\" unless they actually exist.
This fixes the bug where ido would try to suggest a C-style
comment as a filename."
(ignore-errors
(when (and ad-return-value
(string-match-p ffap-c-commment-regexp
ad-return-value)
(not (ffap-file-exists-string ad-return-value)))
(setq ad-return-value nil))))
(defalias 'yes-or-no-p 'y-or-n-p)
(defalias 'auto-tail-revert-mode 'tail-mode)
;; Hippie expand: at times perhaps too hip
(eval-after-load 'hippie-exp
'(progn
(dolist (f '(try-expand-line try-expand-list try-complete-file-name-partially))
(delete f hippie-expand-try-functions-list))
;; Add this back in at the end of the list.
(add-to-list 'hippie-expand-try-functions-list 'try-complete-file-name-partially t)))
;; ## Look and feel ##
;; Theme!
(custom-download-theme "https://raw.github.com/owainlewis/emacs-color-themes/master/themes/hickey-theme.el"
"hickey-theme.el")
(load-theme 'hickey t)
;; Hiding JOIN, QUIT, PART
(setq erc-hide-list '("JOIN" "PART" "QUIT"))
;; Enable projectile for all things programming
(add-hook 'prog-mode-hook 'projectile-on)
;; Enable rainbow-delimiters for all things programming
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
;; Enable paredit in all Lisps
(add-hook 'lisp-mode-hook 'paredit-mode)
(eval-after-load 'diff-mode
'(progn
(set-face-foreground 'diff-added "green4")
(set-face-foreground 'diff-removed "red3")))
(eval-after-load 'magit
'(progn
(set-face-foreground 'magit-diff-add "green4")
(set-face-foreground 'magit-diff-del "red3")))
;; ## Mac specific settings ##
(setq browse-url-browser-function 'browse-default-macosx-browser)
;; Enable mouse support on OS X
(unless window-system
(require 'mouse)
(xterm-mouse-mode t)
(global-set-key [mouse-4] '(lambda ()
(interactive)
(scroll-down 1)))
(global-set-key [mouse-5] '(lambda ()
(interactive)
(scroll-up 1)))
(defun track-mouse (e))
(setq mouse-sel-mode t)
)
;; Use clipboard properly
(setq x-select-enable-clipboard t)
;; Settings for Emacs.app (Cocoa Emacs)
;; Menu bar doesn't take up additional space, so lets use it.
(menu-bar-mode 1)
;; Don't use Apple's native fullscreen (FIXME: Change with Mavericks)
(setq ns-use-native-fullscreen nil)
;; ... and then enable fullscreen. (This requires a nightly build of
;; Emacs for OS X)
;;(toggle-frame-fullscreen)
;; ## Navigation and key bindings ##
;; Navigate windows with M-<arrows>
(windmove-default-keybindings 'meta)
(setq windmove-wrap-around t)
;; Load ace-jump-mode
(autoload
'ace-jump-mode
"ace-jump-mode"
"Emacs quick move minor mode"
)
(define-key global-map [?] 'ace-jump-mode)
;; Quick jump back
(autoload
'ace-jump-mode-pop-mark
"ace-jump-mode"
"Ace jump back:-)"
)
(eval-after-load "ace-jump-mode"
'(ace-jump-mode-enable-mark-sync))
(define-key global-map (kbd "C-x ö") 'ace-jump-mode-pop-mark)
;; Eshell
;; Start/join
(global-set-key (kbd "C-x m") 'eshell)
;; Always start
(global-set-key (kbd "C-x M") (lambda () (interactive) (eshell t)))
;; Git
(global-set-key (kbd "C-c g") 'magit-status)
(remove-hook 'kill-buffer-query-functions 'server-kill-buffer-query-function)

50
emacs.d/init.el Normal file
View file

@ -0,0 +1,50 @@
;; Configure package manager
(require 'package)
;; Add Marmalade repo
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))
;; ... and melpa. Melpa packages that exist on marmalade will have
;; precendence.
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents))
;; Important packages
(defvar my-pkgs '(starter-kit-bindings
haskell-mode
markdown-mode
magit
leuven-theme
projectile
rainbow-delimiters
nrepl
clojure-mode
ace-jump-mode
switch-window)
"A list of packages to install at launch.")
(dolist (p my-pkgs)
(when (not (package-installed-p p))
(package-install p)))
(load "~/.emacs.d/init-functions.el")
(load "~/.emacs.d/init-settings.el")
(setq custom-file "~/.emacs.d/init-custom.el")
(load custom-file)
;; IRC configuration (erc)
;; Actual servers and such are loaded from irc.el
(require 'erc)
(load "~/.emacs.d/irc")
;; Seed RNG
(random t)
;; Start server for emacsclient
(server-start)

View file

@ -1,23 +0,0 @@
;; A few handy functions I use in init.el (or not, but they're nice to
;; have)
;; Ensure that the themes folder exists
(defun custom-download-theme (url filename)
"Downloads a theme through HTTP and places it in ~/.emacs.d/themes"
;; Ensure the directory exists
(unless (file-exists-p "~/.emacs.d/themes")
(make-directory "~/.emacs.d/themes"))
;; Adds the themes folder to the theme load path (if not already
;; there)
(unless (member "~/.emacs.d/themes" custom-theme-load-path)
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes"))
;; Download file if it doesn't exist.
(let ((file
(concat "~/.emacs.d/themes/" filename)))
(unless (file-exists-p file)
(url-copy-file url file))))

197
init.el
View file

@ -1,197 +0,0 @@
;; Configure package manager
(require 'package)
;; Add Marmalade repo
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))
;; ... and melpa. Melpa packages that exist on marmalade will have
;; precendence.
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents))
;; Important packages
(defvar my-pkgs '(starter-kit
starter-kit-bindings
haskell-mode
markdown-mode
magit
leuven-theme
projectile
rainbow-delimiters
nrepl
clojure-mode
ace-jump-mode)
"A list of packages to install at launch.")
(dolist (p my-pkgs)
(when (not (package-installed-p p))
(package-install p)))
;; Configure el-get
(require 'cl)
(add-to-list 'load-path "~/.emacs.d/el-get/el-get")
;; Install el-get if not already present
(unless (require 'el-get nil t)
(url-retrieve
"https://github.com/dimitri/el-get/raw/master/el-get-install.el"
(lambda (s)
(end-of-buffer)
(eval-print-last-sexp))))
;; el-get recipes
(setq
my:el-get-packages
'(el-get
switch-window))
(el-get 'sync my:el-get-packages)
;; Set solarized theme
(load-theme 'leuven t)
;; Other general settings
;; Swedish!
(set-language-environment 'Swedish)
;; Enable mouse support on OS X
(unless window-system
(require 'mouse)
(xterm-mouse-mode t)
(global-set-key [mouse-4] '(lambda ()
(interactive)
(scroll-down 1)))
(global-set-key [mouse-5] '(lambda ()
(interactive)
(scroll-up 1)))
(defun track-mouse (e))
(setq mouse-sel-mode t)
)
;; Use clipboard properly
(setq x-select-enable-clipboard t)
;; Settings for Emacs.app (Cocoa Emacs)
;; Menu bar doesn't take up additional space, so lets use it.
(menu-bar-mode 1)
;; Don't use Apple's native fullscreen (FIXME: Change with Mavericks)
(setq ns-use-native-fullscreen nil)
;; ... and then enable fullscreen. (This requires a nightly build of
;; Emacs for OS X)
;;(toggle-frame-fullscreen)
;; Navigate windows with M-<arrows>
(windmove-default-keybindings 'meta)
(setq windmove-wrap-around t)
;; Load ace-jump-mode
(autoload
'ace-jump-mode
"ace-jump-mode"
"Emacs quick move minor mode"
t)
(define-key global-map [?] 'ace-jump-mode)
;; Quick jump back
(autoload
'ace-jump-mode-pop-mark
"ace-jump-mode"
"Ace jump back:-)"
t)
(eval-after-load "ace-jump-mode"
'(ace-jump-mode-enable-mark-sync))
(define-key global-map (kbd "C-x ö") 'ace-jump-mode-pop-mark)
;; Configure markdown-mode
(autoload 'markdown-mode "markdown-mode"
"Major mode for editing Markdown files" t)
(add-to-list 'auto-mode-alist '("\\.txt\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
;; Configure haskell-mode
;; Enable semi-automatic indentation and font-locking
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
(add-hook 'haskell-mode-hook 'font-lock-mode)
;; Add keybindings to move nested blocks with C-, rsp. C-.
(define-key haskell-mode-map (kbd "C-,") 'haskell-move-nested-left)
(define-key haskell-mode-map (kbd "C-.") 'haskell-move-nested-right)
;; Configure nrepl (Clojure REPL) and clojure-mode
;; Paredit in clojure
(add-hook 'clojure-mode-hook 'paredit-mode)
;; eldoc in clojure
(add-hook 'nrepl-interaction-mode-hook
'nrepl-turn-on-eldoc-mode)
;; Don't annoy me
(setq nrepl-hide-special-buffers t)
(setq nrepl-popup-stacktraces nil)
;; Paredit in nrepl
(add-hook 'nrepl-mode-hook 'paredit-mode)
(add-hook 'nrepl-mode-hook 'rainbow-delimiters-mode)
;; IRC configuration (erc)
;; Actual servers and such are loaded from irc.el
(require 'erc)
(load "~/.emacs.d/irc")
;; Hiding JOIN, QUIT, PART
(setq erc-hide-list '("JOIN" "PART" "QUIT"))
;; Eshell
;; Start/join
(global-set-key (kbd "C-x m") 'eshell)
;; Always start
(global-set-key (kbd "C-x M") (lambda () (interactive) (eshell t)))
;; Git
(global-set-key (kbd "C-c g") 'magit-status)
(remove-hook 'kill-buffer-query-functions 'server-kill-buffer-query-function)
;; Enable projectile for all things programming
(require 'projectile)
(add-hook 'prog-mode-hook 'projectile-on)
;; Enable rainbow-delimiters for all things programming
(require 'rainbow-delimiters)
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
;; Start server for emacsclient
(server-start)
(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.
'(custom-safe-themes
(quote
("ea0c5df0f067d2e3c0f048c1f8795af7b873f5014837feb0a7c8317f34417b04" "a234f91f9be6ed40f6ce0e94dce5cea1b9f1ccec2b9ccd42bb71c499867a3fcc" "fc5fcb6f1f1c1bc01305694c59a1a861b008c534cae8d0e48e4d5e81ad718bc6" "1e7e097ec8cb1f8c3a912d7e1e0331caeed49fef6cff220be63bd2a6ba4cc365" "d6a00ef5e53adf9b6fe417d2b4404895f26210c52bb8716971be106550cea257" default)))
'(erc-modules
(quote
(autojoin button completion dcc irccontrols list log match menu move-to-prompt netsplit networks noncommands notifications readonly ring scrolltobottom stamp track)))
'(ns-alternate-modifier (quote none))
'(ns-command-modifier (quote meta)))
(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.
)