Browse Source

Scrub emacs files to get them more minimal for development

Taylor Bockman 7 years ago
parent
commit
60f0a22254
  1. 248
      dotfiles/emacs.d/init.el
  2. 29
      dotfiles/emacs.d/package.el
  3. 32
      dotfiles/emacs.d/sample-private.el
  4. 38
      dotfiles/emacs.d/urxvt-bindings.el

248
dotfiles/emacs.d/init.el

@ -1,13 +1,6 @@
;;-------------------------------------------------------------------------------------- ;;--------------------------------------------------------------------------------------
;; ;;
;; Emacs Configuration file ;; EMACS Configuration file
;;
;; NOTES:
;; - For stuff that requires privacy (such as ERC, Circe, or Email) place them in
;; a .private.el file in your home directory. This script will load that file.
;; This is the best way I could think of protecting sensitive data without making
;; it incredibly inconvenient for you. Take a look at the sample private.el in
;; the emacs.d folder (currently a work in progress).
;; ;;
;;-------------------------------------------------------------------------------------- ;;--------------------------------------------------------------------------------------
@ -52,11 +45,11 @@
;; Disable Splash Screen ;; Disable Splash Screen
;;-------------------------------------------------------------------------------------- ;;--------------------------------------------------------------------------------------
(defvar inhibit-splash-screen) (defvar Inhibit-Splash-Screen)
(setq inhibit-splash-screen t) (setq Inhibit-Splash-Screen t)
;;-------------------------------------------------------------------------------------- ;;--------------------------------------------------------------------------------------
;; Prefer UTF-8 for buffers ;; Prefer Utf-8 For Buffers
;;-------------------------------------------------------------------------------------- ;;--------------------------------------------------------------------------------------
(prefer-coding-system 'utf-8) (prefer-coding-system 'utf-8)
@ -87,20 +80,6 @@ setq org-log-done t)
(set-buffer-file-coding-system 'unix) (set-buffer-file-coding-system 'unix)
;;-------------------------------------------------------------------------------------- ;;--------------------------------------------------------------------------------------
;; Conditionally load urxvt files to fix weird bindings
;;--------------------------------------------------------------------------------------
;; This code doesn't fix anything related to emacs -nw not allowing C-) in terminal
;; mode. Currently looking for solutions so I don't have to keep using C-<left>
;; and C-<right>
;;
;; (when (string= (getenv "TERM") "rxvt")
;; (load "term/rxvt")
;; (terminal-init-rxvt)
;; (load "~/.emacs.d/urxvt-bindings.el")
;; )
;;--------------------------------------------------------------------------------------
;; Enable auto-refresh to keep buffers up to date when git or another program ;; Enable auto-refresh to keep buffers up to date when git or another program
;; modifies them ;; modifies them
;;-------------------------------------------------------------------------------------- ;;--------------------------------------------------------------------------------------
@ -111,8 +90,6 @@ setq org-log-done t)
;; IBuffer configurations (C-x C-b) ;; IBuffer configurations (C-x C-b)
;;-------------------------------------------------------------------------------------- ;;--------------------------------------------------------------------------------------
;; Filter Groups - ***** Circe filtering currently doesnt work *****
(setq ibuffer-saved-filter-groups (setq ibuffer-saved-filter-groups
'(("default" '(("default"
("Emacs Configuration" (or (filename . ".emacs.d") ("Emacs Configuration" (or (filename . ".emacs.d")
@ -123,21 +100,12 @@ setq org-log-done t)
("Org" (or (mode . org-mode) ("Org" (or (mode . org-mode)
(filename . "OrgMode"))) (filename . "OrgMode")))
("Magit" (name . "\*magit")) ("Magit" (name . "\*magit"))
("IRC" (or (mode . "Circe*")
(mode . erc-mode)))
("Help" (or (name . "\*Help\*") ("Help" (or (name . "\*Help\*")
(name . "\*Apropos\*") (name . "\*Apropos\*")
(name . "\*info\*"))) (name . "\*info\*")))
("Dired" (mode . dired-mode)) ("Dired" (mode . dired-mode))
;; Dev has groups for all languages you program in ;; Dev has groups for all languages you program in
("Dev" (or (mode . haskell-mode) ("Dev" (or (mode . cc-mode))
(mode . coffee-mode)
(mode . js2-mode)
(mode . clojure-mode)
(mode . cc-mode)
(mode . stylus-mode)
(mode . scheme-mode)
(mode . lisp-mode))
) )
("Emacs" (or (name . "^\\*scratch\\*$") ("Emacs" (or (name . "^\\*scratch\\*$")
(name . "^\\*Messages\\*$"))) (name . "^\\*Messages\\*$")))
@ -179,9 +147,9 @@ setq org-log-done t)
(let ((trailnewlines (abs (skip-chars-backward "\n\t")))) (let ((trailnewlines (abs (skip-chars-backward "\n\t"))))
(if (> trailnewlines 0) (if (> trailnewlines 0)
(progn (progn
(delete-char trailnewlines))))))) (delete-char trailnewlines))))))
(add-hook 'before-save-hook 'delete-trailing-whitespace) (add-hook 'before-save-hook 'delete-trailing-whitespace))
;; Comment this if you dont mind git diffs complaining about missing ending newlines. ;; Comment this if you dont mind git diffs complaining about missing ending newlines.
(setq require-final-newline t) (setq require-final-newline t)
@ -215,51 +183,6 @@ setq org-log-done t)
(load-file "~/.emacs.d/package.el") (load-file "~/.emacs.d/package.el")
;;-------------------------------------------------------------------------------------- ;;--------------------------------------------------------------------------------------
;; Load private file
;;--------------------------------------------------------------------------------------
(if (file-exists-p "~/.private.el")
(load-file "~/.private.el")
(setq irc-servers nil
irc-username nil
irc-password nil
default-realname nil
)
)
;;--------------------------------------------------------------------------------------
;; Configure Circe
;;--------------------------------------------------------------------------------------
(setq circe-network-options irc-servers)
(setq circe-use-cycle-completion t)
(setq helm-mode-no-completion-in-region-in-modes
'(circe-channel-mode
circe-query-mode
circe-server-mode
)
)
(setq circe-reduce-lurker-spam t)
;; (circe-set-display-handler "JOIN" (lambda (&rest ignored) nil)) ;; Hide JOIN spam
(add-hook 'circe-chat-mode-hook 'my-circe-prompt)
(defun my-circe-prompt ()
(lui-set-prompt
(concat (propertize (concat (buffer-name) ">")
'face 'circe-prompt-face)
" ")))
;;--------------------------------------------------------------------------------------
;; Coffee mode specific settings
;;--------------------------------------------------------------------------------------
(custom-set-variables
'(coffee-tab-width 2)
'(coffee-indent-like-python-mode t)
)
;;--------------------------------------------------------------------------------------
;; Enable ParEdit for Emacs lisp modes ;; Enable ParEdit for Emacs lisp modes
;;-------------------------------------------------------------------------------------- ;;--------------------------------------------------------------------------------------
@ -278,7 +201,7 @@ setq org-log-done t)
(require 'fill-column-indicator) (require 'fill-column-indicator)
(setq fci-rule-color "black") (setq fci-rule-color "red")
(setq fci-rule-column 120) (setq fci-rule-column 120)
(setq fci-rule-width 1) (setq fci-rule-width 1)
(setq fci-rule-character ?\u2503) ; Solid line unicode character (setq fci-rule-character ?\u2503) ; Solid line unicode character
@ -294,11 +217,11 @@ setq org-log-done t)
;;-------------------------------------------------------------------------------------- ;;--------------------------------------------------------------------------------------
;; If python.el is loaded, change the rule column to 80 characters. ;; If python.el is loaded, change the rule column to 80 characters.
;;-------------------------------------------------------------------------------------- ;;--------------------------------------------------------------------------------------
(eval-after-load "python" (eval-after-load "python"
'(progn '(progn
(setq fci-rule-column 80))) (setq fci-rule-column 80)))
;;-------------------------------------------------------------------------------------- ;;--------------------------------------------------------------------------------------
;; Expand region settings ;; Expand region settings
;;-------------------------------------------------------------------------------------- ;;--------------------------------------------------------------------------------------
@ -307,6 +230,18 @@ setq org-log-done t)
(pending-delete-mode t) ; Selected region contents are replaced on typing (pending-delete-mode t) ; Selected region contents are replaced on typing
;;-------------------------------------------------------------------------------------- ;;--------------------------------------------------------------------------------------
;; CC-Mode Settings
;;-------------------------------------------------------------------------------------
;; Keep character limit to 80
(eval-after-load "c"
'(progn
(setq fci-rule-column 80)))
(setq-default c-basic-offset 4) ;; NASA Style Guide says 4 spaces is optimal
(setq-default c-default-style "linux") ;; Use Linux code style
;;--------------------------------------------------------------------------------------
;; Line Numbering - Note: Might not look good with files with 10,000 or more lines ;; Line Numbering - Note: Might not look good with files with 10,000 or more lines
;;-------------------------------------------------------------------------------------- ;;--------------------------------------------------------------------------------------
@ -330,13 +265,6 @@ setq org-log-done t)
(show-paren-mode 1) (show-paren-mode 1)
;;-------------------------------------------------------------------------------------- ;;--------------------------------------------------------------------------------------
;; JSX Mode
;;--------------------------------------------------------------------------------------
(add-to-list 'auto-mode-alist '("\\.jsx\\'" . jsx-mode))
(autoload 'jsx-mode "jsx-mode" "JSX mode" t)
;;--------------------------------------------------------------------------------------
;; Ivy Configuration ;; Ivy Configuration
;;-------------------------------------------------------------------------------------- ;;--------------------------------------------------------------------------------------
@ -346,14 +274,12 @@ setq org-log-done t)
(setq magit-complete-read-function 'ivy-completing-read) (setq magit-complete-read-function 'ivy-completing-read)
(setq ivy-use-virtual-buffers t) (setq ivy-use-virtual-buffers t)
;;------------------------------------------------------------------------------------- ;;-------------------------------------------------------------------------------------
;; Use Grizzl with Projectile ;; Use Grizzl with Projectile
;;------------------------------------------------------------------------------------- ;;-------------------------------------------------------------------------------------
(setq projectile-completion-system 'grizzl) (setq projectile-completion-system 'grizzl)
;;------------------------------------------------------------------------------------- ;;-------------------------------------------------------------------------------------
;; Enable Autocomplete ;; Enable Autocomplete
;; ;;
@ -375,77 +301,6 @@ setq org-log-done t)
(sh-set-shell "zsh")))) (sh-set-shell "zsh"))))
;;------------------------------------------------------------------------------------- ;;-------------------------------------------------------------------------------------
;; EShell Configuration
;;-------------------------------------------------------------------------------------
;; Enable ANSI colors in EShell
(ansi-color-for-comint-mode-on)
(defun eshell-handle-ansi-color ()
(ansi-color-apply-on-region eshell-last-output-start eshell-last-output-end)
)
(add-hook 'eshell-mode-hook
'(lambda ()
(add-to-list
'eshell-output-filter-functions
'eshell-handle-ansi-color))
)
;; Disable line numbers for EShell
(add-hook 'eshell-mode-hook 'nolinum)
;;Save EShell history on exit
(setq eshell-save-history-on-exit t)
;; History size
(setq eshell-history-size 1024)
;; Emulate Bash history save
(setq eshell-hist-ignoreups t)
;; Ignore dupes in history
(setq eshell-hist-ignoredups t)
;; Scroll to bottom on output
(setq eshell-scroll-to-bottom-on-output t)
;;; Below this section I'm defining convenience commands for EShell so it acts
;;; a little more like a terminal you might be used to.
;; Define the clear function
(defun eshell/clear ()
(interactive)
(let ((inhibit-read-only t))
(erase-buffer))
)
;; Info
(defun eshell/info ()
(info)
)
;; Remove strange characters that don't seem to correspond to anything
(defvar ansi-escape-re
(rx (or ?\233 (and ?\e ?\[))
(zero-or-more (char (?0 . ?\?)))
(zero-or-more (char ?\s ?- ?\/))
(char (?@ . ?~))))
(defun nuke-ansi-escapes (beg end)
(save-excursion
(goto-char beg)
(while (re-search-forward ansi-escape-re end t)
(replace-match ""))))
(defun eshell-nuke-ansi-escapes ()
(nuke-ansi-escapes eshell-last-output-start eshell-last-output-end))
(add-hook 'eshell-output-filter-functions 'eshell-nuke-ansi-escapes t)
;; Correct the path
(setenv "PATH" (concat "/usr/local/bin:/usr/local/sbin:" (getenv "PATH")))
;;-------------------------------------------------------------------------------------
;; Alignment ;; Alignment
;;------------------------------------------------------------------------------------- ;;-------------------------------------------------------------------------------------
@ -501,25 +356,19 @@ setq org-log-done t)
(self-insert-command N))) (self-insert-command N)))
;;------------------------------------------------------------------------------------- ;;-------------------------------------------------------------------------------------
;; JS Mode 2 Space Indenting
;;-------------------------------------------------------------------------------------
(setq js-indent-level 2)
;;-------------------------------------------------------------------------------------
;; Key Bindings ;; Key Bindings
;;------------------------------------------------------------------------------------- ;;-------------------------------------------------------------------------------------
;; Unbind C-t from transpose ;; Try to force alt to be the meta key
(global-set-key (kbd "C-t") nil) (setq x-alt-keysym 'meta)
;; Neotree
(global-set-key [f8] 'neotree-toggle)
(global-set-key (kbd "C-d") nil) (global-set-key (kbd "C-d") nil)
(global-set-key (kbd "C-m") nil) (global-set-key (kbd "C-m") nil)
(global-set-key (kbd "RET") nil) (global-set-key (kbd "RET") nil)
;; Unbind C-c p f from projectile
;(global-set-key (kbd "C-c p f") nil)
;; Unbind C-s from Isearch to make room for swiper ;; Unbind C-s from Isearch to make room for swiper
(global-set-key (kbd "C-s") nil) (global-set-key (kbd "C-s") nil)
@ -533,13 +382,6 @@ setq org-log-done t)
(global-set-key (kbd "C-h C-k") nil) (global-set-key (kbd "C-h C-k") nil)
;; Neotree binds are prefixed by C-t
(global-set-key (kbd "C-t t") 'neotree-toggle)
(global-set-key (kbd "C-t n") 'neotree-create-node)
(global-set-key (kbd "C-t d") 'neotree-delete-node)
(global-set-key (kbd "C-t r") 'neotree-rename-node)
(global-set-key (kbd "C-t h") 'neotree-hidden-file-toggle)
;; Pane navigation ;; Pane navigation
(global-set-key (kbd "M-h") 'windmove-left) (global-set-key (kbd "M-h") 'windmove-left)
(global-set-key (kbd "M-j") 'windmove-down) (global-set-key (kbd "M-j") 'windmove-down)
@ -549,9 +391,6 @@ setq org-log-done t)
;; Delete surrounding ;; Delete surrounding
(global-set-key (kbd "C-d s") 'delete-pair) (global-set-key (kbd "C-d s") 'delete-pair)
;; Kill whole line
(global-set-key (kbd "C-d d") 'kill-whole-line)
;; Git utility ;; Git utility
(global-set-key (kbd "C-x g s") 'magit-status) (global-set-key (kbd "C-x g s") 'magit-status)
(global-set-key (kbd "C-x g b") 'magit-blame-popup) (global-set-key (kbd "C-x g b") 'magit-blame-popup)
@ -559,19 +398,14 @@ setq org-log-done t)
(global-set-key (kbd "C-x g f") 'magit-file-popup) (global-set-key (kbd "C-x g f") 'magit-file-popup)
;; Fix RET ;; Fix RET
(global-set-key (kbd "RET") 'electric-newline-and-maybe-indent) (global-set-key (kbd "RET") 'newline-and-indent)
;; Helm ;; Ivy Bindings
;(global-set-key (kbd "C-c p f") 'helm-projectile-find-file) (global-set-key (kbd "C-x C-f") 'counsel-find-file)
;(global-set-key (kbd "C-x C-f") 'helm-find-files)
;(global-set-key (kbd "C-s") 'helm-do-ag-this-file)
;; Swiper ;; Swiper
(global-set-key (kbd "C-s") 'swiper) (global-set-key (kbd "C-s") 'swiper)
;; Ivy find file
(global-set-key (kbd "C-x C-f") 'counsel-find-file)
;; Better M-x ;; Better M-x
;;(global-set-key (kbd "M-x") 'counsel-M-x) ;;(global-set-key (kbd "M-x") 'counsel-M-x)
@ -601,7 +435,7 @@ setq org-log-done t)
(set-frame-parameter nil 'background-mode 'dark) (set-frame-parameter nil 'background-mode 'dark)
(set-terminal-parameter nil 'background-mode 'dark) (set-terminal-parameter nil 'background-mode 'dark)
(load-theme 'solarized t) (load-theme 'zenburn t)
;; 10 pt font ;; 10 pt font
(set-frame-font "inconsolata") (set-frame-font "inconsolata")
@ -609,13 +443,29 @@ setq org-log-done t)
(powerline-center-theme) (powerline-center-theme)
;;-------------------------------------------------------------------------------------
(custom-set-variables (custom-set-variables
;; custom-set-variables was added by Custom. ;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful. ;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance. ;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right. ;; If there is more than one, they won't work right.
'(custom-safe-themes '(package-selected-packages
(quote (quote
("8db4b03b9ae654d4a57804286eb3e332725c84d7cdab38463cb6b97d5762ad26" default)))) (counsel zenburn-theme wrap-region swiper stylus-mode smex slim-mode scss-mode sass-mode rust-mode rspec-mode robe rainbow-delimiters projectile powerline paredit neotree magit livescript-mode linum-relative less-css-mode jsx-mode js2-mode jade-mode grizzl golden-ratio gitignore-mode flymake-ruby flycheck-rust flycheck-pos-tip flycheck-haskell flycheck-clojure fill-column-indicator feature-mode expand-region esh-help enh-ruby-mode coffee-mode circe ag ac-inf-ruby))))
(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.
)

29
dotfiles/emacs.d/package.el

@ -1,12 +1,27 @@
(require 'cl) (require 'cl)
(defvar my-packages '(ag auto-complete clojure-mode coffee-mode css-mode circe expand-region framemove flycheck (defvar my-packages '(ag auto-complete
grizzl esh-help enh-ruby-mode flymake-ruby ruby-block robe inf-ruby ac-inf-ruby rspec-mode cc-mode
fill-column-indicator flycheck-clojure flycheck-haskell flycheck-rust slim-mode feature-mode counsel
flycheck-pos-tip gitignore-mode golden-ratio haskell-mode swiper sass-mode linum-relative expand-region
js2-mode less-css-mode magit neotree paredit scala-mode2 scss-mode smex powerline toml-mode flycheck
projectile rust-mode color-theme-solarized wrap-region stylus-mode rainbow-delimiters grizzl
livescript-mode jade-mode jsx-mode) fill-column-indicator
feature-mode
flycheck-pos-tip
gitignore-mode
golden-ratio
swiper
linum-relative
magit
neotree
paredit
smex
powerline
projectile
wrap-region
rainbow-delimiters
zenburn-theme)
"Packages to make sure are installed") "Packages to make sure are installed")
(defun my-packages-installed-p () (defun my-packages-installed-p ()

32
dotfiles/emacs.d/sample-private.el

@ -1,32 +0,0 @@
;;-------------------------------------------------------------------
;; Sample private.el
;;
;; Base your private.el off of this if you want an easier time
;; setting things up.
;;
;;-------------------------------------------------------------------
;; Circe Configuration
(defvar irc-servers '(
(
"Freenode"
:nick "Your nick"
:host "ircserver.whatever.com"
:channels ("channel1" "channel2")
:port port
:realname "Your name"
:use-tls t
:nickserv-nick "auth nick"
:nickserv-password "auth password"
)
)
)
;; Email Configuration
;; Usenet Configuration

38
dotfiles/emacs.d/urxvt-bindings.el

@ -1,38 +0,0 @@
;; This file adds the missing escape sequences for urxvt so emacs -nw
;; will work with Ctrl+Shift, Ctrl+Meta, etc sequences.
;;
;; Credit for the original code goes to Gilles on emacs.stackexchange.com
;;
(defun character-apply-modifiers (c &rest modifiers)
"Apply modifiers to the character C.
MODIFIERS must be a list of symbols amongst (meta control shift).
Return an event vector."
(if (memq 'control modifiers) (setq c (if (or (and (<= ?@ c) (<= c ?_))
(and (<= ?a c) (<= c ?z)))
(logand c ?\x1f)
(logior (lsh 1 26) c))))
(if (memq 'meta modifiers) (setq c (logior (lsh 1 27) c)))
(if (memq 'shift modifiers) (setq c (logior (lsh 1 25) c)))
(vector c))
(defun eval-after-load-urxvt ()
(when (and (boundp 'rxvt-alternatives-map) (boundp 'rxvt-function-map))
(let ((c 32))
(while (<= c 126)
(mapc (lambda (x)
(define-key rxvt-function-map (format (car x) c)
(apply 'character-apply-modifiers c (cdr x))))
'(
("\e\[27;3;%d~" meta)
("\e\[27;5;%d~" control)
("\e\[27;6;%d~" control shift)
("\e\[27;7;%d~" control meta)
("\e\[27;8;%d~" control meta shift)
("\e\[%d;3~" meta)
("\e\[%d;5~" control)
("\e\[%d;6~" control shift)
("\e\[%d;7~" control meta)
("\e\[%d;8~" control meta shift)))
(setq c (1+ c))))))
(eval-after-load "rxvt" '(eval-after-load-urxvt))
Loading…
Cancel
Save