Created
June 28, 2011 21:28
-
-
Save r-moeritz/1052274 to your computer and use it in GitHub Desktop.
My init.el
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; -*- mode: Lisp; lexical-binding: t; -*- | |
;; ---------------------------------------------------------------------- | |
;; HELPER FUNCTIONS | |
;; ---------------------------------------------------------------------- | |
(defvar electrify-return-match | |
"[\]}\)\"]" | |
"If this regexp matches the text after the cursor, do an \"electric\" | |
return.") | |
(defun electrify-return-if-match (arg) | |
"If the text after the cursor matches `electrify-return-match' then | |
open and indent an empty line between the cursor and the text. Move the | |
cursor to the new line." | |
(interactive "P") | |
(let ((case-fold-search nil)) | |
(if (looking-at electrify-return-match) | |
(save-excursion (newline-and-indent))) | |
(newline arg) | |
(indent-according-to-mode))) | |
(defun global-set-font (font) | |
"Globally sets the font to FONT" | |
(let ((fontify-frame | |
(lambda (frame) | |
(set-frame-parameter frame 'font font)))) | |
(funcall fontify-frame nil) | |
(push 'fontify-frame after-make-frame-functions))) | |
(defun get-buffers-matching-mode (mode) | |
"Returns a list of buffers where their major-mode is equal to MODE" | |
(let ((buffer-mode-matches '())) | |
(dolist (buf (buffer-list)) | |
(with-current-buffer buf | |
(if (eq mode major-mode) | |
(add-to-list 'buffer-mode-matches buf)))) | |
buffer-mode-matches)) | |
(defun multi-occur-in-this-mode () | |
"Show all lines matching REGEXP in buffers with this major mode." | |
(interactive) | |
(multi-occur | |
(get-buffers-matching-mode major-mode) | |
(car (occur-read-primary-args)))) | |
(defun global-set-umlaut-keys () | |
(let ((gen-insert-key | |
(lambda (key) | |
(lambda () | |
(interactive) | |
(ucs-insert key))))) | |
(global-set-key (kbd "\C-co") (funcall gen-insert-key #xf6)) | |
(global-set-key (kbd "\C-cu") (funcall gen-insert-key #xfc)) | |
(global-set-key (kbd "\C-ca") (funcall gen-insert-key #xe4)) | |
(global-set-key (kbd "\C-cs") (funcall gen-insert-key #xdf)))) | |
;; ---------------------------------------------------------------------- | |
;; SETUP FUNCTIONS | |
;; ---------------------------------------------------------------------- | |
(defun setup-paredit () | |
"Enable paredit for Elisp, CL & Clojure." | |
(let ((gen-enable-paredit | |
(lambda () | |
(lambda () | |
(paredit-mode t) | |
(show-paren-mode t) | |
(local-set-key (kbd "RET") 'electrify-return-if-match))))) | |
(add-hook 'emacs-lisp-mode-hook (funcall gen-enable-paredit)) | |
(add-hook 'clojure-mode-hook (funcall gen-enable-paredit)) | |
(add-hook 'lisp-mode-hook (funcall gen-enable-paredit)))) | |
(defun setup-org-mode () | |
"setup org-mode" | |
(add-to-list 'auto-mode-alist | |
'("\\.org$" . org-mode) t) | |
(add-hook 'org-mode-hook | |
(lambda () | |
(local-set-key (kbd "\C-cl") 'org-store-link) | |
(local-set-key (kbd "\C-ca") 'org-agenda) | |
(setq org-log-done t | |
org-src-fontify-natively t)))) | |
(defun setup-server () | |
"start server, suppressing error 'directory ~/.emacs.d/server is unsafe' on windows" | |
(require 'server) | |
(when (equal window-system 'w32) | |
(defun server-ensure-safe-dir (dir) | |
"noop" t)) | |
(server-start)) | |
(defun set-preferences () | |
"misc preferences" | |
(setq inhibit-startup-message t) ;; disable annoying splash screen | |
(setq-default indent-tabs-mode nil) ;; no tabs please | |
(prefer-coding-system 'utf-8) ;; prefer utf-8 | |
(add-hook 'text-mode-hook 'turn-on-auto-fill) ;; enable auto-fill in text-mode | |
(global-set-font "Consolas-11:antialias=natural") ;; global font | |
(put 'erase-buffer 'disabled nil)) ;; enable erase-buffer | |
(defun setup-modeline-posn () | |
"setup modeline-posn" | |
(column-number-mode 1) | |
(size-indication-mode 1)) | |
(defun setup-markdown-mode () | |
"setup markdown-mode" | |
(autoload 'markdown-mode "markdown-mode.el" | |
"Major mode for editing Markdown files" t) | |
(add-to-list 'auto-mode-alist | |
'("\\.md$" . markdown-mode) t)) | |
(defun setup-melpa () | |
"setup melpa" | |
(require 'melpa) | |
(add-to-list 'package-archives | |
'("melpa" . "http://melpa.milkbox.net/packages/") t)) | |
(defun setup-clojure-mode () | |
"setup clojure-mode" | |
(add-to-list 'auto-mode-alist | |
'("\\.cljs$" . clojure-mode) t)) | |
(defun setup-powershell-mode () | |
"setup powershell-mode" | |
(require 'powershell-mode) | |
(add-to-list 'auto-mode-alist | |
'("\\.ps[md]?1$" . powershell-mode) t )) | |
(defun setup-smex () | |
"setup smex" | |
(smex-initialize) | |
(global-set-key (kbd "M-x") 'smex) | |
(global-set-key (kbd "M-X") 'smex-major-mode-commands)) | |
;; ---------------------------------------------------------------------- | |
;; INIT FUNCTIONS | |
;; ---------------------------------------------------------------------- | |
(defun init-vanilla () | |
"startup code that works on vanilla emacs" | |
(set-preferences) | |
(setup-server) | |
(setup-org-mode) | |
;; global keyboard shortcuts | |
(global-set-umlaut-keys) | |
(global-set-key (kbd "C-;") 'comment-or-uncomment-region) | |
(global-set-key (kbd "C-M-z") 'multi-occur-in-this-mode)) | |
(defun init-package () | |
"startup code that relies on package" | |
(package-initialize) | |
(setup-melpa) | |
(setup-paredit) | |
(setup-modeline-posn) | |
(setup-smex) | |
(setup-clojure-mode) | |
(setup-powershell-mode) | |
(setup-markdown-mode) | |
(require 'molokai-theme) | |
(require 'powershell) | |
;; global keyboard shortcuts | |
(global-set-key (kbd "C-=") 'er/expand-region) | |
(global-set-key (kbd "C-@") 'ace-jump-mode)) | |
(defun init-local () | |
"startup code that relies on local customizations" | |
;(load (expand-file-name "~/quicklisp/slime-helper.el")) | |
(setq inferior-lisp-program "wx86cl")) | |
(init-vanilla) | |
(init-package) | |
(init-local) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment