Last active
June 24, 2017 03:15
-
-
Save rwilson/5c0e28ce8c2553e2cd8d to your computer and use it in GitHub Desktop.
My Emacs Live 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
;; User pack init file | |
;; | |
;; Use this file to initiate the pack configuration. | |
;; See README for more information. | |
;; Load bindings config | |
(live-load-config-file "bindings.el") | |
(add-to-list 'load-path "/Users/ryan/.live-packs/ryan-pack/lib/p4.elc") | |
(require 'p4) | |
(menu-bar-mode) | |
;; enable desktop mode, auto-saves, x-session undo history | |
(require 'desktop) | |
(desktop-save-mode 1) | |
(setq history-length 250) | |
(add-to-list 'desktop-globals-to-save 'file-name-history) | |
(add-to-list 'warning-suppress-types '(undo discard-info)) | |
;; Buffer improvements (keep auto-updated, filter groups, etc) | |
(defvar default-exclude-dirs | |
'("." ".." ".DS_Store")) | |
(defun dir-filter-groups (base &optional exclude-dirs) | |
(remove nil | |
(mapcar (lambda (dir) | |
(let ((name (file-name-nondirectory (directory-file-name dir)))) | |
(when (not (member name | |
(append default-exclude-dirs | |
exclude-dirs))) | |
`(,name (filename . ,(expand-file-name (concat base dir))))))) | |
(directory-files base)))) | |
(setq ibuffer-show-empty-filter-groups nil) | |
(setq ibuffer-saved-filter-groups | |
(list (cons "default" | |
(append (dir-filter-groups "~/Dev/outpost/" '("platform")) | |
(dir-filter-groups "~/Dev/outpost/platform/") | |
'(("REPL" (or (mode . cider-repl-mode) | |
(name . "\*nrepl-.*"))) | |
("Emacs Config" (or (filename . ".emacs.d") | |
(filename . "emacs-config") | |
(filename . "init.el"))) | |
("Emacs" (or (name . "\*scratch\*") | |
(name . "\*zone\*") | |
(name . "\*Messages\*") | |
(name . "\*Compile-Log\*") | |
(name . "\*Completions\*")))))))) | |
(add-hook 'ibuffer-mode-hook | |
'(lambda () | |
(ibuffer-auto-mode 1) | |
(ibuffer-switch-to-saved-filter-groups "default"))) | |
(setq ibuffer-formats | |
'((mark modified | |
read-only | |
" " | |
(name 30 30 :left :elide) ; change name chars from 18 -> 30 | |
" " | |
; hide the size column | |
;(size 9 -1 :right) | |
;" " | |
; GIT column would normally be here | |
(mode 16 16 :left :elide) ; default | |
" " | |
filename-and-process) | |
(mark " " | |
(name 16 -1) | |
" " | |
filename))) | |
;; Clojure customizations | |
(require 'clojure-mode) | |
(define-clojure-indent | |
(defroutes 'defun) | |
(GET 2) | |
(POST 2) | |
(PUT 2) | |
(DELETE 2) | |
(HEAD 2) | |
(ANY 2) | |
(context 2) | |
(rfn 1) | |
(when-json 2) | |
(when-authenticated 1) | |
(when-authorized 2) | |
(when-in-role 2) | |
(when-enabled 1) | |
(with-account 3) | |
(with-identity-account 2) | |
(-> 1) | |
(->> 1) | |
(some-> 1) | |
(some->> 1) | |
(cond-> 1) | |
(cond->> 1) | |
(as-> 2) | |
(s/defrecord 1) | |
(on-receive 1) | |
(on-close 1) | |
(do-at 1)) | |
(global-unset-key (kbd "C-z")) | |
(global-unset-key (kbd "C-x C-z")) | |
;; get rid of annoying kill region stuff | |
(put 'delete-region 'disabled t) | |
(put 'downcase-region 'disabled nil) | |
(put 'upcase-region 'disabled nil) | |
(global-unset-key (kbd "C-x C-k")) ;; kill-region | |
(put 'kill-region 'interactive-form | |
'(interactive | |
(if (use-region-p) | |
(list (region-beginning) (region-end)) | |
(list (point) (progn (forward-word) (point)))))) | |
(defun comment-or-uncomment-region-or-line () | |
"Comments or uncomments the region or the current line if there's no active region." | |
(interactive) | |
(let (beg end) | |
(if (region-active-p) | |
(setq beg (region-beginning) end (region-end)) | |
(setq beg (line-beginning-position) end (line-end-position))) | |
(comment-or-uncomment-region beg end))) | |
(global-set-key (kbd "C-;") 'comment-or-uncomment-region-or-line) | |
;; Change return behavior to not change indentation on current line when inserting a newline | |
;; Normal binding id 'reindent-then-newline-and-indent | |
(add-hook 'clojure-mode-hook | |
'(lambda () | |
(local-set-key (kbd "RET") 'newline-and-indent))) | |
(add-hook 'Javascript-IDE-mode-hook | |
'(lambda () | |
(local-set-key (kbd "RET") 'newline-and-indent))) | |
;; Normally, killing the newline between indented lines doesn't remove any extra spaces | |
;; caused by indentation. This accomplishes that: | |
(defadvice kill-line (before check-position activate) | |
(if (and (eolp) (not (bolp))) | |
(progn (forward-char 1) | |
(just-one-space 0) | |
(backward-char 1)))) | |
;; Support for editing LUA files | |
(require 'lua-mode) | |
(add-to-list 'auto-mode-alist '("\\.lua$" . lua-mode)) | |
(add-to-list 'interpreter-mode-alist '("lua" . lua-mode)) | |
;; Support for editing JSX files | |
(require 'web-mode) | |
(add-to-list 'auto-mode-alist '("\\.jsx?$" . web-mode)) | |
(add-to-list 'auto-mode-alist '("\\.mustache$" . web-mode)) | |
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode)) | |
(defadvice web-mode-highlight-part (around tweak-jsx activate) | |
(if (equal web-mode-content-type "jsx") | |
(let ((web-mode-enable-part-face nil)) | |
ad-do-it) | |
ad-do-it)) | |
(add-hook 'web-mode-hook | |
'(lambda () | |
(setq web-mode-code-indent-offset 2) | |
(setq web-mode-css-indent-offset 2) | |
(setq web-mode-markup-indent-offset 2) | |
(setq web-mode-attr-indent-offset 2) | |
(setq web-mode-indent-style 2) | |
(setq web-mode-script-padding 2) | |
(setq web-mode-style-padding 2))) | |
(add-hook 'json-mode-hook | |
'(lambda () | |
(make-local-variable 'js-indent-level) | |
(setq js-indent-level 2))) | |
(add-hook 'css-mode-hook | |
'(lambda () | |
(make-local-variable 'css-indent-offset) | |
(setq css-indent-offset 2))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment