Skip to content

Instantly share code, notes, and snippets.

@mrmagooey
Last active November 30, 2015 03:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrmagooey/3791747 to your computer and use it in GitHub Desktop.
Save mrmagooey/3791747 to your computer and use it in GitHub Desktop.
.emacs file
;; increase gc threshold for startup
(setq gc-cons-threshold 100000000)
;;;;;;;;;;;;
;; el-get ;;
;;;;;;;;;;;;
(add-to-list 'load-path "~/.emacs.d/el-get/el-get")
(unless (require 'el-get nil 'noerror)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.github.com/dimitri/el-get/master/el-get-install.el")
(let (el-get-master-branch)
(goto-char (point-max))
(eval-print-last-sexp))))
(el-get 'sync)
(setq
my:el-get-packages
'(el-get
helm
jedi))
(condition-case nil
(el-get 'sync my:el-get-packages)
(error nil))
;;;;;;;;;;;;;;;;;;;;;;;;
;; Package management ;;
;;;;;;;;;;;;;;;;;;;;;;;;
(require 'package)
(setq package-archives
'(("gnu" . "http://elpa.gnu.org/packages/")
("melpa" . "http://melpa.milkbox.net/packages/")))
(package-initialize)
(defvar custom-packages
'(color-theme-sanityinc-solarized
color-theme-sanityinc-tomorrow
yaml-mode
yasnippet
less-css-mode
js2-mode
rainbow-mode
deft
handlebars-mode
markdown-mode
web-mode
smartparens
keyfreq
multiple-cursors
coffee-mode
zencoding-mode
auto-complete
multi-term
exec-path-from-shell
graphviz-dot-mode
flymake-cursor
jade-mode
ace-jump-mode
json-mode
ido-ubiquitous
smex
virtualenvwrapper
flycheck
magit
cider
paredit
exec-path-from-shell
rainbow-delimiters
scss-mode
projectile
extempore-mode
)
)
(dolist (p custom-packages)
(when (not (package-installed-p p))
(package-refresh-contents)
(dolist (p custom-packages)
(when (not (package-installed-p p))
(package-install p)
))))
;;;;;;;;;;;
;; Theme ;;
;;;;;;;;;;;
(require 'color-theme-sanityinc-tomorrow)
(load-theme 'sanityinc-tomorrow-eighties t)
;;;;;;;;;;;;;
;; Startup ;;
;;;;;;;;;;;;;
(setq initial-scratch-message "")
(setq inhibit-startup-message t)
(when window-system
(tool-bar-mode -1)
(menu-bar-mode -1)
(scroll-bar-mode -1))
(blink-cursor-mode -1)
(column-number-mode 1)
(exec-path-from-shell-initialize)
;;;;;;;;;
;; ido ;;
;;;;;;;;;
(ido-mode 1)
(ido-everywhere 1)
;;;;;;;;;;;;;;;;
;; projectile ;;
;;;;;;;;;;;;;;;;
(projectile-global-mode)
;;;;;;;;;;
;; smex ;;
;;;;;;;;;;
(smex-initialize)
(global-set-key (kbd "M-x") 'smex)
;;;;;;;;;;;;;
;; paredit ;;
;;;;;;;;;;;;;
(require 'paredit)
(autoload 'enable-paredit-mode "paredit" "Turn on pseudo-structural editing of Lisp code." t)
;; (add-hook 'emacs-lisp-mode-hook #'enable-paredit-mode)
(add-hook 'lisp-mode-hook #'enable-paredit-mode)
(add-hook 'cider-repl-mode-hook 'paredit-mode)
;; (add-hook 'lisp-interaction-mode-hook #'enable-paredit-mode)
;; (add-hook 'scheme-mode-hook #'enable-paredit-mode)
;; (paredit-skip-whitespace)
;;;;;;;;;;;
;; elisp ;;
;;;;;;;;;;;
(add-hook 'lisp-mode-hook
(lambda ()
(turn-off-smartparens-mode)))
(add-hook 'lisp-mode-hook 'paredit-mode)
;;;;;;;;;;;;;
;; clojure ;;
;;;;;;;;;;;;;
(add-hook 'cider-mode-hook #'eldoc-mode)
(add-hook 'clojure-mode-hook 'paredit-mode)
(add-hook 'clojure-mode-hook
'(lambda ()
(local-set-key (kbd "C-a") 'beginning-of-line-or-indentation)))
(defun figwheel-repl ()
(interactive)
(run-clojure "lein figwheel"))
(add-hook 'clojure-mode-hook #'inf-clojure-minor-mode)
;;;;;;;;;;;;;;;
;; extempore ;;
;;;;;;;;;;;;;;;
(add-hook 'extempore-mode-hook
(lambda ()
(turn-off-smartparens-mode)))
(add-hook 'extempore-mode-hook #'enable-paredit-mode)
(defun extempore-autorun ()
"Starts extempore with default args, doesn't ask user for input"
(interactive)
(if (not (comint-check-proc "*extempore*"))
(let* ((default-directory (file-name-as-directory
(expand-file-name user-extempore-directory)))
(runtime-directory (concat default-directory "runtime"))
(full-args (concat "--runtime=" runtime-directory)))
(message (concat "Running extempore with: " full-args))
(set-buffer (apply #'make-comint "extempore" (concat default-directory "extempore") nil
(split-string-and-unquote full-args)))
(inferior-extempore-mode))
(message "extempore is already running in *extempore* buffer.")))
(defun extempore-autokill ()
(interactive)
(delete-process "*extempore*")
(extempore-sync-connections))
(defun extempore-autoconnect ()
(interactive)
(extempore-sync-connections)
(if (extempore-get-connection "127.0.0.1" 7099)
(message "already connected")
(let ((proc (open-network-stream "extempore" nil "127.0.0.1" 7099)))
(if proc
(progn
(set-process-coding-system proc 'iso-latin-1-unix 'iso-latin-1-unix)
(set-process-filter proc #'extempore-minibuffer-echo-filter)
(add-to-list 'extempore-connection-list proc t)
(extempore-update-mode-line))))))
(defun extempore-autodisconnect ()
(interactive)
(let ((proc (extempore-get-connection "localhost" 7099)))
(if proc
(progn (delete-process proc)
(extempore-sync-connections))
(message "No current connections to %s on port %d" "localhost" 7099))))
(defun extempore-autorestart ()
(interactive)
(condition-case nil
(extempore-autokill)
(error nil))
(extempore-autorun)
(sit-for 3) ;; let the extempore process startup
;;(extempore-autoconnect)
)
(add-hook 'extempore-mode-hook
'(lambda ()
(local-set-key (kbd "C-c C-p") 'extempore-autorestart)))
(add-hook 'extempore-mode-hook
'(lambda ()
(local-set-key (kbd "C-c C-;") 'extempore-autoconnect)))
;;;;;;;;;;;;;;;
;; yasnippet ;;
;;;;;;;;;;;;;;;
(require 'yasnippet)
(exec-path-from-shell-copy-env "EMACS_YASNIPPET_DIRS")
(if (stringp (getenv "EMACS_YASNIPPET_DIRS"))
(dolist (dir (split-string (getenv "EMACS_YASNIPPET_DIRS")))
(add-to-list 'yas-snippet-dirs dir))
(message "Couldn't find EMACS_YASNIPPET_DIRS in shell environment, not loading additional yasnippet directories"))
(yas-global-mode 1)
;; remove x-prompt from dropdown possibilities
(if (member 'yas/x-prompt yas/prompt-functions)
(setq yas/prompt-functions (remove 'yas/x-prompt yas/prompt-functions)))
;;;;;;;;;;;;;;
;; ido-mode ;;
;;;;;;;;;;;;;;
(setq ido-enable-flex-matching t)
(setq ido-everywhere t)
(setq ido-auto-merge-work-directories-length -1)
(ido-mode 1)
;;;;;;;;;;;;;;;
;; smex-mode ;;
;;;;;;;;;;;;;;;
(global-set-key (kbd "M-x") 'smex)
(global-set-key (kbd "M-X") 'smex-major-mode-commands)
;;;;;;;;;;;;;;;;;
;; smartparens ;;
;;;;;;;;;;;;;;;;;
(require 'smartparens)
(require 'smartparens-config)
(smartparens-global-mode t)
(setq sp-autoescape-string-quote nil)
;; (sp-pair "<" ">")
;;;;;;;;;;;;;;;
;; scss-mode ;;
;;;;;;;;;;;;;;;
(require 'scss-mode)
(autoload 'scss-mode "scss-mode")
(add-to-list 'auto-mode-alist '("\\.scss\\'" . scss-mode))
;;;;;;;;;;;;;;;
;; auto-save ;;
;;;;;;;;;;;;;;;
;;; This stops emacs from creating symlink lock files, and crashing various build systems
(setq create-lockfiles nil)
(setq auto-save-default nil)
(setq backup-directory-alist
`((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms
`((".*" ,temporary-file-directory t)))
;;;;;;;;;;;;;;;
;; HTML Mode ;;
;;;;;;;;;;;;;;;
(add-hook 'html-mode-hook
'(lambda ()
(local-set-key (kbd "C-a") 'beginning-of-line-or-indentation)))
(add-hook 'html-mode-hook
'(lambda ()
(flyspell-mode 0)))
(add-hook 'html-mode-hook
'(lambda ()
(toggle-truncate-lines 1)))
(add-hook 'html-mode-hook
'(lambda ()
(auto-fill-mode -1)))
(add-hook 'html-mode-hook
'(lambda ()
(visual-line-mode -1)))
(add-to-list 'auto-mode-alist '("\\.ejs$" . html-mode))
(add-to-list 'auto-mode-alist '("\\.dust$" . html-mode))
(sp-local-pair 'html-mode "%" "%")
;;;;;;;;;;;;;;;;;;
;; tagedit-mode ;;
;;;;;;;;;;;;;;;;;;
(add-hook 'html-mode-hook
'(lambda ()
(local-set-key (kbd "C-)") 'tagedit-forward-slurp-tag)))
(add-hook 'html-mode-hook
'(lambda ()
(local-set-key (kbd "C-}") 'tagedit-forward-barf-tag)))
;; (define-key html-mode-map (kbd "C-)") 'tagedit-forward-slurp-tag)
;; (define-key html-mode-map (kbd "C-}") 'tagedit-forward-barf-tag)
;; (define-key html-mode-map (kbd "M-r") 'tagedit-raise-tag)
;; (define-key html-mode-map (kbd "M-s") 'tagedit-splice-tag)
;; (define-key html-mode-map (kbd "M-J") 'tagedit-join-tags)
;; (define-key html-mode-map (kbd "M-S") 'tagedit-split-tag)
;; (define-key html-mode-map (kbd "M-?") 'tagedit-convolute-tags)
;; (define-key html-mode-map (kbd "C-k") 'tagedit-kill)
;; (define-key html-mode-map (kbd "s-k") 'tagedit-kill-attribute)
;;;;;;;;;;;;;;;;;
;; coffee-mode ;;
;;;;;;;;;;;;;;;;;
(require 'coffee-mode)
(add-to-list 'auto-mode-alist '("\\.coffee$" . coffee-mode))
(setq coffee-tab-width 4) ;; coffee-mode specific indenting
(add-hook 'coffee-mode-hook
'(lambda ()
(auto-complete-mode 1)))
(add-hook 'coffee-mode-hook
'(lambda ()
(toggle-truncate-lines 1)))
(add-hook 'coffee-mode-hook
'(lambda ()
(local-set-key (kbd "C-a") 'beginning-of-line-or-indentation)))
;;;;;;;;;;;;;;
;; js2-mode ;;
;;;;;;;;;;;;;;
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
(add-to-list 'auto-mode-alist '("\\.jsx\\'" . js2-mode))
(setq js2-basic-offset 2)
(add-hook 'js2-mode-hook
'(lambda ()
(local-set-key (kbd "C-a") 'beginning-of-line-or-indentation)))
(add-hook 'js2-mode-hook
'(lambda ()
(auto-fill-mode -1)))
(add-hook 'js2-mode-hook
'(lambda ()
(toggle-truncate-lines nil)))
(add-hook 'js2-mode-hook
'(lambda ()
(electric-indent-mode nil)))
(defcustom js2-strict-trailing-comma-warning nil
"..."
:type 'boolean
:group 'js2-mode
)
;; (defun js-newline-and-indent ()
;; "Custom version that doesn't delete horizontal space on previous line.
;; Insert a newline, then indent according to major mode.
;; Indentation is done using the value of `indent-line-function'.
;; In programming language modes, this is the same as TAB.
;; In some text modes, where TAB inserts a tab, this command indents to the
;; column specified by the function `current-left-margin'."
;; (interactive "*")
;; ;; (delete-horizontal-space t)
;; (newline)
;; (js-indent-line))
;; (add-hook 'js2-mode-hook
;; '(lambda ()
;; (local-set-key (kbd "C-j") 'js-newline-and-indent)))
;;;;;;;;;;;;;
;; node-js ;;
;;;;;;;;;;;;;
;; the worlds shittest inferior mode for node
;; m-x node-repl
(defun node-repl ()
(interactive)
(pop-to-buffer (make-comint "node-repl" "node" nil "--interactive")))
;;;;;;;;;;;;;;;
;; jade mode ;;
;;;;;;;;;;;;;;;
(require 'jade-mode)
(add-hook 'jade-mode-hook
'(lambda ()
(local-set-key (kbd "C-a") 'beginning-of-line-or-indentation)))
(sp-local-pair 'jade-mode "<" ">")
;;;;;;;;;;;;;;
;; jsx-mode ;;
;;;;;;;;;;;;;;
;; (add-to-list 'auto-mode-alist '("\\.jsx\\'" . jsx-mode))
;; (autoload 'jsx-mode "jsx-mode" "JSX mode" t)
;;;;;;;;;;;;;;;
;; text mode ;;
;;;;;;;;;;;;;;;
(add-hook 'text-mode-hook
'(lambda ()
(auto-fill-mode -1)))
(add-hook 'text-mode-hook
'(lambda ()
(visual-line-mode 1)))
(remove-hook 'text-mode-hook 'turn-on-auto-fill)
;;;;;;;;;;;;
;; python ;;
;;;;;;;;;;;;
(add-hook 'python-mode-hook
#'(lambda ()
(toggle-truncate-lines 1)))
(add-hook 'python-mode-hook
'(lambda ()
(local-set-key (kbd "C-a") 'beginning-of-line-or-indentation)))
(add-hook 'python-mode-hook
'(lambda ()
(electric-pair-mode -1)))
(add-hook 'python-mode-hook
'(lambda ()
(setq python-indent 4)))
(add-hook 'python-mode-hook
'(lambda ()
(setq python-indent 4)))
(add-hook 'python-mode-hook
'(lambda ()
(flycheck-mode 1)))
(defun virtualenv-pylint ()
"Checks if a virtualenv is active and warns if it isn't.
If a virtualenv is active, checks if pylint is installed and warns if it isn't.
Otherwise uses the virtualenv pylint to lint code"
(if python-shell-virtualenv-path
(if (file-exists-p (concat python-shell-virtualenv-path "bin/pylint"))
(setq-default flycheck-pylint-executable (concat python-shell-virtualenv-path "bin/pylint"))
(run-with-idle-timer 4 nil (message "WARNING -- Pylint not found in virtualenv"))
)
(message "WARNING -- No Virtualenv Set")
)
)
(add-hook 'python-mode-hook 'virtualenv-pylint)
(defun python-shell-clear ()
(interactive)
(let ((comint-buffer-maximum-size 0))
(comint-truncate-buffer)))
;;;;;;;;;;;;;;;
;; less mode ;;
;;;;;;;;;;;;;;;
(add-hook 'less-css-mode-hook
'(lambda ()
(auto-fill-mode -1)))
(add-hook 'less-css-mode-hook
'(lambda ()
(auto-complete-mode 1)))
(add-hook 'less-css-mode-hook
'(lambda ()
(toggle-truncate-lines 1)))
(add-hook 'less-css-mode-hook
'(lambda ()
(local-set-key (kbd "C-a") 'beginning-of-line-or-indentation)))
;;;;;;;;;;;;;;
;; org mode ;;
;;;;;;;;;;;;;;
(add-hook 'org-mode-hook
'(lambda ()
(flyspell-mode 0)))
(add-hook 'org-mode-hook
'(lambda ()
(auto-fill-mode -1)))
(add-hook 'org-mode-hook
'(lambda ()
(visual-line-mode 1)))
;;;;;;;;;;;;;;
;; markdown ;;
;;;;;;;;;;;;;;
(add-to-list 'auto-mode-alist '("\\.md" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.markdown" . markdown-mode))
(setq markdown-css-path "~/.emacs.d/markdown-css/style.css")
(add-hook 'markdown-mode-hook
'(lambda ()
visual-line-mode 1))
(add-hook 'markdown-mode-hook
'(lambda ()
(local-set-key (kbd "M-n") 'forward-paragraph)))
(add-hook 'markdown-mode-hook
'(lambda ()
(local-set-key (kbd "M-p") 'backward-paragraph)))
;;;;;;;;;;
;; yaml ;;
;;;;;;;;;;
(add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))
;;;;;;;;;;;;;;;;;;
;; rainbow-mode ;;
;;;;;;;;;;;;;;;;;;
(add-hook 'less-css-mode-hook
'(lambda ()
(rainbow-mode 1)))
(add-hook 'css-mode-hook
'(lambda ()
(rainbow-mode 1)))
;;;;;;;;;;;;;;;;;;;
;; ispell/aspell ;;
;;;;;;;;;;;;;;;;;;;
;; helps emacs find homebrew installed aspell on osx
(setenv "PATH" (concat (getenv "PATH") ":/usr/local/bin"))
(setq exec-path (append exec-path '("/usr/local/bin")))
(setq ispell-program-name "aspell")
(setq ispell-dictionary "british")
(setq ispell-extra-args '("--sug-mode=ultra"))
(setq flyspell-issue-message-flag nil)
(defun fly-on-off-buffer-checked ()
"Flips buffer between having flyspell enabled and disabled whilst running flyspell
on the buffer. Spell check slows emacs down considerably."
(interactive)
(if (and (boundp 'flyspell-mode) flyspell-mode)
(flyspell-mode-off)
(progn (flyspell-mode 1) (flyspell-buffer)))
)
(global-set-key (kbd "<f7>") 'fly-on-off-buffer-checked)
(global-set-key (kbd "<f8>") 'ispell-word)
;;;;;;;;;;;;;;;;;;;;;;
;; skeleton pairing ;;
;;;;;;;;;;;;;;;;;;;;;;
(setq skeleton-pair nil) ;; skeleton-pair off
;;;;;;;;;;
;; deft ;;
;;;;;;;;;;
;; This is notational velocity for emacs
(require 'deft)
(setq deft-text-mode 'markdown-mode)
;;;;;;;;;;;;;;;;;;;;;;
;; electric-indent ;;
;;;;;;;;;;;;;;;;;;;;;;
(setq electric-indent-mode nil)
;;;;;;;;;
;; tex ;;
;;;;;;;;;
(setq TeX-auto-save t)
(setq-default TeX-master nil)
(setq TeX-parse-self t)
(setq TeX-PDF-mode t)
(setq latex-run-command "pdflatex")
;;;;;;;;;;;
;; tramp ;;
;;;;;;;;;;;
(setq tramp-default-method "ssh")
;;;;;;;;;
;; tex ;;
;;;;;;;;;
(setq TeX-auto-save t)
(setq-default TeX-master nil)
(setq TeX-parse-self t)
(setq TeX-PDF-mode t)
(setq latex-run-command "pdflatex")
;;;;;;;;;;;;;;;;
;; emacs-lisp ;;
;;;;;;;;;;;;;;;;
(add-hook 'lisp-mode 'autocomplete-mode)
(add-hook 'emacs-lisp-mode-hook
'(lambda ()
(auto-fill-mode -1)))
;;;;;;;;;;;;;;;;;;;;;;
;; multiple cursors ;;
;;;;;;;;;;;;;;;;;;;;;;
(require 'multiple-cursors)
(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
(global-set-key (kbd "C->") 'mc/mark-next-like-this)
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this)
;;;;;;;;;;;;;
;; go mode ;;
;;;;;;;;;;;;;
(add-to-list 'auto-mode-alist '("\\.go$" . go-mode))
;;;;;;;;;;;;;;
;; rst mode ;;
;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;
;; zencoding ;;
;;;;;;;;;;;;;;;
;; (require 'zencoding-mode)
;; (add-hook 'sgml-mode-hook 'zencoding-mode)
;; (add-hook 'sgml-mode-hook
;; '(lambda ()
;; (local-set-key (kbd "Enter") 'zencoding-expand-line)))
;; (define-key zencoding-mode-keymap (kbd "C-j") 'newline-and-indent)
;; (add-hook 'sgml-mode-hook
;; '(lambda ()
;; (local-set-key (kbd "C-j") 'newline-and-indent)))
;;;;;;;;;;;;;;;
;; jedi-mode ;;
;;;;;;;;;;;;;;;
(add-hook 'python-mode-hook 'jedi:setup)
(setq jedi:setup-keys t)
(setq jedi:complete-on-dot t)
;;;;;;;;;;;;
;; shells ;;
;;;;;;;;;;;;
(setq system-uses-terminfo 1)
;;;;;;;;;;
;; helm ;;
;;;;;;;;;;
(require 'helm-config)
;;;;;;;;;;;;;;;;;;
;; autocomplete ;;
;;;;;;;;;;;;;;;;;;
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict")
(ac-config-default)
(global-auto-complete-mode t)
;;;;;;;;;;;;;
;; arduino ;;
;;;;;;;;;;;;;
(add-to-list 'auto-mode-alist '("\\.pde$" . c-mode))
(add-to-list 'auto-mode-alist '("\\.ino$" . c-mode))
;;;;;;;;;;;
;; magit ;;
;;;;;;;;;;;
(setq magit-push-always-verify nil)
;; this can be used by calling checkout on
;; /refs/pull/origin/<number>
(defun endless/add-PR-fetch ()
"If refs/pull is not defined on a GH repo, define it."
(let ((fetch-address
"+refs/pull/*/head:refs/pull/origin/*")
(magit-remotes
(magit-get-all "remote" "origin" "fetch")))
(unless (or (not magit-remotes)
(member fetch-address magit-remotes))
(when (string-match
"github" (magit-get "remote" "origin" "url"))
(magit-git-string
"config" "--add" "remote.origin.fetch"
fetch-address)))))
(add-hook 'magit-mode-hook #'endless/add-PR-fetch)
;;;;;;;;;;;;
;; c-mode ;;
;;;;;;;;;;;;
(add-hook 'c-mode
'(lambda ()
(toggle-truncate-lines 1)))
;;;;;;;;;;;;;;
;; c++-mode ;;
;;;;;;;;;;;;;;
(add-hook 'c++-mode
'(lambda ()
(toggle-truncate-lines 1)))
(add-hook 'c++-mode
'(lambda ()
(local-set-key (kbd "C-a") 'beginning-of-line-or-indentation)))
;;;;;;;;;;;;;;;;;;;
;; ace-jump-mode ;;
;;;;;;;;;;;;;;;;;;;
(require 'ace-jump-mode)
(define-key global-map (kbd "C-;") 'ace-jump-mode)
;;;;;;;;;;;;;;;;;;;;;;
;; tabs and indents ;;
;;;;;;;;;;;;;;;;;;;;;;
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(setq indent-line-function 'nil)
(defun beginning-of-line-or-indentation ()
"Move to beginning of line, or indentation"
(interactive)
(if (bolp)
(back-to-indentation)
(beginning-of-line)))
;;;;;;;;;;;;;;;;;;;;;;;;
;; change window size ;;
;;;;;;;;;;;;;;;;;;;;;;;;
(global-set-key (kbd "S-C-<left>") 'shrink-window-horizontally)
(global-set-key (kbd "S-C-<right>") 'enlarge-window-horizontally)
(global-set-key (kbd "S-C-<down>") 'shrink-window)
(global-set-key (kbd "S-C-<up>") 'enlarge-window)
(when (fboundp 'windmove-default-keybindings)
(windmove-default-keybindings))
;;;;;;;;;;;;;;;;;;;;
;; text encoding ;;
;;;;;;;;;;;;;;;;;;;;
(defun dos2unix (buffer)
"Automate M-% C-q C-m RET C-q C-j RET"
(interactive "*b")
(save-excursion
(goto-char (point-min))
(while (search-forward (string ?\C-m) nil t)
(replace-match (string ?\C-j) nil t))))
(defun do-not-show-dos-eol ()
"Do not show ^M in files containing mixed UNIX and DOS line endings."
(interactive)
(setq buffer-display-table (make-display-table))
(aset buffer-display-table ?\^M []))
;;;;;;;;;;
;; evil ;;
;;;;;;;;;;
;; (require 'evil)
;; (evil-mode 1)
;;;;;;;;;;;;;;;
;; graphviz ;;
;;;;;;;;;;;;;;;
(setq graphviz-dot-auto-indent-on-semi nil)
;;;;;;;;;;;;;;;
;; uniquify ;;
;;;;;;;;;;;;;;;
(require 'uniquify)
;;;;;;;;;
;; erc ;;
;;;;;;;;;
(erc-match-mode 1)
(if (eq system-type 'darwin)
(progn
(defun erc-make-noise (match-type nickuserhost message)
(start-process-shell-command "afplay" nil "afplay /System/Library/Sounds/Bottle.aiff"))
(add-hook 'erc-text-matched-hook 'erc-make-noise)))
;;;;;;;;;;;;;;;;;;
;; rainbow-mode ;;
;;;;;;;;;;;;;;;;;;
(require 'rainbow-delimiters)
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
;;;;;;;;;;;;;;;;;;;;;;
;; visual-line-mode ;;
;;;;;;;;;;;;;;;;;;;;;;
(add-hook 'visual-line-mode-hook '(lambda ()
(local-set-key (kbd "C-a") 'beginning-of-visual-line)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; global bits and pieces ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(show-paren-mode 1)
(desktop-save-mode 1)
(global-set-key (kbd "C-a") 'beginning-of-line-or-indentation)
(global-set-key (kbd "M-n") 'forward-paragraph)
(global-set-key (kbd "M-p") 'backward-paragraph)
(global-set-key (kbd "C-j") 'newline-and-indent)
;; remove the default list-directory behaviour of C-x C-d, I always actually want dired
(global-set-key (kbd "C-x C-d") 'dired)
(defun comment-dwim-line (&optional arg)
"Replacement for the `comment-dwim' command.
If no region is selected and current line is not blank and we are not at the end of the line,then comment current line.
Replaces default behaviour of `comment-dwim', when it inserts comment at the end of the line."
(interactive "*P")
(comment-normalize-vars)
(if (and (not (region-active-p)) (not (looking-at "[ \t]*$")))
(comment-or-uncomment-region (line-beginning-position) (line-end-position))
(comment-dwim arg)))
(global-set-key (kbd "M-;") 'comment-dwim-line)
;; use 'a' in dired mode
(put 'dired-find-alternate-file 'disabled nil)
(defun revert-all-buffers ()
"Refreshes all open buffers from their respective files."
(interactive)
(dolist (buf (buffer-list))
(with-current-buffer buf
(when (and (buffer-file-name) (file-exists-p (buffer-file-name)) (not (buffer-modified-p)))
(revert-buffer t t t) )))
(message "Refreshed open files.") )
;; stop the warning bell
(setq ring-bell-function 'ignore)
(defun newline-and-indent ()
"Custom version that doesn't delete horizontal space on previous line.
Insert a newline, then indent according to major mode.
Indentation is done using the value of `indent-line-function'.
In programming language modes, this is the same as TAB.
In some text modes, where TAB inserts a tab, this command indents to the
column specified by the function `current-left-margin'."
(interactive "*")
;; (delete-horizontal-space t)
(newline)
(indent-according-to-mode))
;;;;;;;;;;;;;;;;;;;
;; emacs config ;;
;;;;;;;;;;;;;;;;;;;
(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.
'(ansi-color-faces-vector
[default bold shadow italic underline bold bold-italic bold])
'(ansi-color-names-vector
(vector "#4d4d4c" "#c82829" "#718c00" "#eab700" "#4271ae" "#8959a8" "#3e999f" "#ffffff"))
'(custom-safe-themes
(quote
("06f0b439b62164c6f8f84fdda32b62fb50b6d00e8b01c2208e55543a6337433a" "bb08c73af94ee74453c90422485b29e5643b73b05e8de029a6909af6a3fb3f58" "1b8d67b43ff1723960eb5e0cba512a2c7a2ad544ddb2533a90101fd1852b426e" "82d2cac368ccdec2fcc7573f24c3f79654b78bf133096f9b40c20d97ec1d8016" "4aee8551b53a43a883cb0b7f3255d6859d766b6c5e14bcb01bed572fcbef4328" default)))
'(erc-default-sound "")
'(erc-sound-mode t)
'(fci-rule-color "#efefef")
'(fill-column 90)
'(flymake-run-in-place nil)
'(js2-bounce-indent-p nil)
'(rst-level-face-base-color "red")
'(rst-level-face-base-light 20)
'(safe-local-variable-values
(quote
((eval font-lock-add-keywords nil
(\`
(((\,
(concat "("
(regexp-opt
(quote
("sp-do-move-op" "sp-do-move-cl" "sp-do-put-op" "sp-do-put-cl" "sp-do-del-op" "sp-do-del-cl"))
t)
"\\_>"))
1
(quote font-lock-variable-name-face))))))))
'(uniquify-buffer-name-style (quote forward) nil (uniquify))
'(warning-minimum-level :error))
(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.
)
(put 'downcase-region 'disabled nil)
(put 'upcase-region 'disabled nil)
;;;;;;;;;;;;;;;;;
;; os specific ;;
;;;;;;;;;;;;;;;;;
(if (eq system-type 'windows-nt)
(progn
;; This should be c:/Documents and Settings/ if < vista
(setq default-directory (concat "c:/Users/" user-login-name))
)
)
(if (eq system-type 'gnu/linux)
(progn
(set-face-attribute 'default nil :height 120) ; ubuntu has oddly large font
)
)
(if (eq system-type 'darwin)
(progn
(set-variable 'magit-emacsclient-executable "/usr/local/bin/emacsclient") ; magit will open a separate window otherwise
(setq default-directory (getenv "HOME"))
)
)
;; reduce gc threshold now that startup is done
(setq gc-cons-threshold 800000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment