├── .emacs ├── .emacs.d ├── settings │ ├── auto-complete-settings.el │ ├── camelcase-settings.el │ ├── custom-functions.el │ ├── custom.el │ ├── el-get-settings.el │ ├── general-settings.el │ ├── helm-settings.el │ ├── js-settings.el │ ├── latex-settings.el │ ├── markdown-settings.el │ ├── matlab-settings.el │ ├── mumamo-settings.el │ ├── python-settings.el │ ├── scss-settings.el │ ├── yaml-settings.el │ └── yasnippet-settings.el └── snippets │ └── js-mode │ └── doc ├── .gitignore ├── README.md └── bootstrap.sh /.emacs: -------------------------------------------------------------------------------- 1 | ;; path where settings files are kept 2 | (add-to-list 'load-path "~/.emacs.d/settings") 3 | ;; path to where plugins are kept 4 | (setq plugin-path "~/.emacs.d/el-get/") 5 | 6 | ;; define various custom functions 7 | (require 'custom-functions) 8 | 9 | ;; configure general settings 10 | (require 'general-settings) 11 | 12 | ;; install dependencies with el-get 13 | (require 'el-get-settings) 14 | 15 | ;---------------; 16 | ;;; Utilities ;;; 17 | ;---------------; 18 | 19 | ;; Git 20 | (include-plugin "magit") 21 | (require 'magit) 22 | 23 | ;; Popup 24 | (include-elget-plugin "popup") 25 | (require 'popup) 26 | 27 | ;; Websocket 28 | (include-plugin "websocket") 29 | (require 'websocket) 30 | 31 | ;; Request 32 | (include-plugin "request") 33 | (require 'request) 34 | 35 | ;; yasnippet 36 | (require 'yasnippet-settings) 37 | 38 | ;; Auto complete 39 | (require 'auto-complete-settings) 40 | 41 | ;; Camelcase functions 42 | (require 'camelcase-settings) 43 | 44 | ;; Helm 45 | (require 'helm-settings) 46 | 47 | 48 | ;-----------; 49 | ;;; Modes ;;; 50 | ;-----------; 51 | 52 | ;; Ido mode 53 | (require 'ido) 54 | (ido-mode 1) 55 | 56 | ;; MuMaMo 57 | (require 'mumamo-settings) 58 | 59 | ;; Markdown mode 60 | (require 'markdown-settings) 61 | 62 | ;; Python mode 63 | (require 'python-settings) 64 | 65 | ;; LaTeX and Auctex 66 | (require 'latex-settings) 67 | 68 | ;; SCSS Mode 69 | (require 'scss-settings) 70 | 71 | ;; Matlab mode 72 | (require 'matlab-settings) 73 | 74 | ;; Javascript 75 | (require 'js-settings) 76 | 77 | ;; YAML mode 78 | (require 'yaml-settings) 79 | 80 | ;; Nyancat mode! 81 | (nyan-mode 1) 82 | 83 | 84 | ;--------------------------------------------------------------------- 85 | ;; Put auto 'custom' changes in a separate file (this is stuff like 86 | ;; custom-set-faces and custom-set-variables) 87 | (load 88 | (setq custom-file (expand-file-name "settings/custom.el" user-emacs-directory)) 89 | 'noerror) 90 | -------------------------------------------------------------------------------- /.emacs.d/settings/auto-complete-settings.el: -------------------------------------------------------------------------------- 1 | ;-------------------; 2 | ;;; Auto-Complete ;;; 3 | ;-------------------; 4 | 5 | (setq ac-directory (make-elget-path "auto-complete")) 6 | (add-to-list 'load-path ac-directory) 7 | (require 'auto-complete) 8 | 9 | (require 'auto-complete-config) 10 | (ac-config-default) 11 | (global-auto-complete-mode 1) 12 | (setq-default ac-sources '(ac-source-yasnippet 13 | ac-source-abbrev 14 | ac-source-dictionary 15 | ac-source-words-in-same-mode-buffers)) 16 | 17 | ; hack to fix ac-sources after pycomplete.el breaks it 18 | (add-hook 'python-mode-hook 19 | '(lambda () 20 | (setq ac-sources '(ac-source-pycomplete 21 | ac-source-yasnippet 22 | ac-source-abbrev 23 | ac-source-dictionary 24 | ac-source-words-in-same-mode-buffers)))) 25 | 26 | ;; from http://truongtx.me/2013/01/06/config-yasnippet-and-autocomplete-on-emacs/ 27 | ; set the trigger key so that it can work together with yasnippet on 28 | ; tab key, if the word exists in yasnippet, pressing tab will cause 29 | ; yasnippet to activate, otherwise, auto-complete will 30 | (ac-set-trigger-key "TAB") 31 | (ac-set-trigger-key "") 32 | 33 | ;; from http://blog.deadpansincerity.com/2011/05/setting-up-emacs-as-a-javascript-editing-environment-for-fun-and-profit/ 34 | ; Start auto-completion after 2 characters of a word 35 | (setq ac-auto-start 2) 36 | ; case sensitivity is important when finding matches 37 | (setq ac-ignore-case nil) 38 | 39 | (provide 'auto-complete-settings) 40 | -------------------------------------------------------------------------------- /.emacs.d/settings/camelcase-settings.el: -------------------------------------------------------------------------------- 1 | ;; The following functions were written by dbrady, see 2 | ;; https://gist.github.com/846766 3 | 4 | ;; Grateful thanks are given to Brian Marick (@marick) for helping me 5 | ;; write these. I got the original idea while reading through 6 | ;; http://xahlee.org/emacs/elisp_idioms.html, but couldn't work out 7 | ;; the elisp regexes. Brian Marick (@marick) stepped in and helped. He 8 | ;; took my tortured and broken camelcase-region and turned it into 9 | ;; something that actually worked. I then created 10 | ;; camelcase-word-or-region. I then wrote the snakecase versions but I 11 | ;; see now that all I did was copy the camelcase defuns over and, 12 | ;; meaning to go back and finish them Real Soon Now, forgot all about 13 | ;; them. I've had a quick look (2011-02-27) but elisp regexes are 14 | ;; still pretty slippery to me, so I have decided to err on the side 15 | ;; of "Showing This To Jim Weirich" (beacuse he expressed interest in 16 | ;; the camelcase defun) and have just marked the offending code and 17 | ;; left it unfixed. 18 | 19 | ;; camelcase-region Given a region of text in snake_case format, 20 | ;; changes it to camelCase. 21 | (defun camelcase-region (start end) 22 | "Changes region from snake_case to camelCase" 23 | (interactive "r") 24 | (save-restriction (narrow-to-region start end) 25 | (goto-char (point-min)) 26 | (while (re-search-forward "_\\(.\\)" nil t) 27 | (replace-match (upcase (match-string 1)))))) 28 | 29 | ;; cadged largely from http://xahlee.org/emacs/elisp_idioms.html: 30 | ;; 31 | (defun camelcase-word-or-region () 32 | "Changes word or region from snake_case to camelCase" 33 | (interactive) 34 | (let (pos1 pos2 bds) 35 | (if (and transient-mark-mode mark-active) 36 | (setq pos1 (region-beginning) pos2 (region-end)) 37 | (progn 38 | (setq bds (bounds-of-thing-at-point 'symbol)) 39 | (setq pos1 (car bds) pos2 (cdr bds)))) 40 | (camelcase-region pos1 pos2))) 41 | 42 | ;; snakecase-region Given a region of text in camelCase format, 43 | ;; changes it to snake_case. 44 | ;; 45 | ;; BUG: This is actually just a repeat of camelcase-region! 46 | (defun snakecase-region (start end) 47 | "Changes region from camelCase to snake_case" 48 | (interactive "r") 49 | (save-restriction (narrow-to-region start end) 50 | (goto-char (point-min)) 51 | (while (re-search-forward "_\\(.\\)" nil t) 52 | (replace-match (upcase (match-string 1)))))) 53 | 54 | ;; Given a region of text in camelCase format, changes it to 55 | ;; snake_case. 56 | (defun snakecase-word-or-region () 57 | "Changes word or region from camelCase to snake_case" 58 | (interactive) 59 | (let (pos1 pos2 bds) 60 | (if (and transient-mark-mode mark-active) 61 | (setq pos1 (region-beginning) pos2 (region-end)) 62 | (progn 63 | (setq bds (bounds-of-thing-at-point 'symbol)) 64 | (setq pos1 (car bds) pos2 (cdr bds)))) 65 | (snakecase-region pos1 pos2))) 66 | 67 | ; camelcase and snakecase 68 | (global-set-key (kbd "C-c C--") 'camelcase-word-or-region) 69 | (global-set-key (kbd "C-c C-_") 'snakecase-word-or-region) 70 | 71 | (provide 'camelcase-settings) 72 | -------------------------------------------------------------------------------- /.emacs.d/settings/custom-functions.el: -------------------------------------------------------------------------------- 1 | ;----------------------; 2 | ;;; Custom Functions ;;; 3 | ;----------------------; 4 | 5 | ; unfill a paragraph, i.e., make it so the text does not wrap in the 6 | ; paragraph where the cursor is 7 | (defun unfill-paragraph () 8 | (interactive) 9 | (let ((fill-column (point-max))) 10 | (fill-paragraph nil))) 11 | 12 | ; unfill a region, i.e., make is so the text in that region does not 13 | ; wrap 14 | (defun unfill-region () 15 | (interactive) 16 | (let ((fill-column (point-max))) 17 | (fill-region (region-beginning) (region-end) nil))) 18 | 19 | (defun system-is-mac () 20 | (interactive) 21 | (string-equal system-type "darwin")) 22 | 23 | (defun system-is-linux () 24 | (interactive) 25 | (string-equal system-type "gnu/linux")) 26 | 27 | (defun make-plugin-path (plugin) 28 | (expand-file-name 29 | (concat plugin-path plugin))) 30 | 31 | (defun include-plugin (plugin) 32 | (add-to-list 'load-path (make-plugin-path plugin))) 33 | 34 | (defun make-elget-path (plugin) 35 | (expand-file-name 36 | (concat elget-path plugin))) 37 | 38 | (defun include-elget-plugin (plugin) 39 | (add-to-list 'load-path (make-elget-path plugin))) 40 | 41 | (provide 'custom-functions) 42 | -------------------------------------------------------------------------------- /.emacs.d/settings/custom.el: -------------------------------------------------------------------------------- 1 | 2 | (custom-set-variables 3 | ;; custom-set-variables was added by Custom. 4 | ;; If you edit it by hand, you could mess it up, so be careful. 5 | ;; Your init file should contain only one such instance. 6 | ;; If there is more than one, they won't work right. 7 | ) 8 | 9 | ; color theme 10 | (add-to-list 'custom-theme-load-path (make-plugin-path "color-theme-solarized")) 11 | (load-theme 'solarized 1) 12 | (setq solarized-termcolors 256) 13 | 14 | (require 'faces) 15 | (if (system-is-mac) 16 | (set-face-attribute 'default nil 17 | :foundry "apple" 18 | :family "DejaVu_Sans_Mono")) 19 | 20 | (custom-set-faces 21 | ;; custom-set-faces was added by Custom. 22 | ;; If you edit it by hand, you could mess it up, so be careful. 23 | ;; Your init file should contain only one such instance. 24 | ;; If there is more than one, they won't work right. 25 | (if (window-system) 26 | (if (system-is-mac) 27 | '(default ((t (:inherit nil :stipple nil :background "#002b35" :foreground "#839496" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 130 :width normal :foundry "apple" :family "DejaVu_Sans_Mono")))) 28 | '(default ((t (:inherit nil :stipple nil :background "#002b35" :foreground "#839496" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 130 :width normal :family "Ubuntu Mono")))))) 29 | '(ein:cell-input-area ((t (:background "#042028")))) 30 | '(ein:cell-input-prompt ((t (:inherit header-line :background "#002b35" :foreground "#859900" :inverse-video nil :weight bold)))) 31 | '(ein:cell-output-prompt ((t (:inherit header-line :background "#002b35" :foreground "#dc322f" :inverse-video nil :weight bold)))) 32 | '(font-lock-comment-face ((t (:foreground "#6171c4" :inverse-video nil :underline nil :slant italic :weight normal)))) 33 | '(font-lock-function-name-face ((t (:foreground "#2075c7" :inverse-video nil :underline nil :slant normal :weight bold)))) 34 | '(font-lock-keyword-face ((t (:foreground "#cb4b16" :inverse-video nil :underline nil :slant normal :weight normal)))) 35 | '(font-lock-type-face ((t (:foreground "#d33682" :inverse-video nil :underline nil :slant normal :weight normal)))) 36 | '(fringe ((t (:background "#002b35" :foreground "#465a61")))) 37 | (if (window-system) 38 | '(magit-item-highlight ((t (:inherit highlight :background "#042028")))) 39 | '(magit-item-highlight ((t (:background "white" :foreground "black"))))) 40 | '(markdown-header-face-1 ((t (:inherit markdown-header-face :height 210)))) 41 | '(markdown-header-face-2 ((t (:inherit markdown-header-face :height 190)))) 42 | '(markdown-header-face-3 ((t (:inherit markdown-header-face :height 170)))) 43 | '(markdown-header-face-4 ((t (:inherit markdown-header-face :height 150)))) 44 | '(markdown-header-face-5 ((t (:inherit markdown-header-face :slant italic :weight bold)))) 45 | '(markdown-header-face-6 ((t (:inherit markdown-header-face :slant italic :weight normal)))) 46 | '(markdown-math-face ((t (:inherit font-lock-string-face :foreground "#cb4b16" :slant italic)))) 47 | (if (window-system) 48 | '(mode-line ((t (:background "#0a2832" :foreground "#eee8d4" :inverse-video t :box nil :underline nil :slant normal :weight normal))))) 49 | '(mumamo-background-chunk-major ((t (:background "#002b36")))) 50 | '(py-variable-name-face ((t (:inherit default :foreground "#268bd2"))))) 51 | 52 | -------------------------------------------------------------------------------- /.emacs.d/settings/el-get-settings.el: -------------------------------------------------------------------------------- 1 | ; set the el-get path, and create it if it doesn't exist 2 | (setq elget-path plugin-path) 3 | (unless (file-exists-p elget-path) 4 | (make-directory elget-path)) 5 | 6 | ; add el-get to the load path, and install it if it doesn't exist 7 | (add-to-list 'load-path "~/.emacs.d/el-get/el-get") 8 | (unless (require 'el-get nil 'noerror) 9 | (with-current-buffer 10 | (url-retrieve-synchronously 11 | "https://raw.github.com/dimitri/el-get/master/el-get-install.el") 12 | (goto-char (point-max)) 13 | (eval-print-last-sexp))) 14 | 15 | ; packages to install 16 | (setq 17 | my-packages '(auctex 18 | auto-complete 19 | color-theme-solarized 20 | ein 21 | magit 22 | markdown-mode 23 | matlab-mode 24 | nxhtml 25 | pydoc-info 26 | scss-mode 27 | popup 28 | jedi 29 | nyan-mode 30 | helm 31 | helm-descbinds 32 | js2-mode 33 | yasnippet 34 | yaml-mode 35 | )) 36 | 37 | ; first enable shallow clone, so we don't need to clone the entire 38 | ; history of every project 39 | (setq el-get-git-shallow-clone t) 40 | 41 | ; then intsall! 42 | (el-get 'sync my-packages) 43 | 44 | (provide 'el-get-settings) 45 | 46 | -------------------------------------------------------------------------------- /.emacs.d/settings/general-settings.el: -------------------------------------------------------------------------------- 1 | ;--------------------------------; 2 | ;;; General or Global Settings ;;; 3 | ;--------------------------------; 4 | 5 | ; set PATH, because we don't load .bashrc 6 | ; function from https://gist.github.com/jakemcc/3887459 7 | (defun set-exec-path-from-shell-PATH () 8 | (setenv "PATH" (concat "/usr/local/bin:" (getenv "PATH"))) 9 | (let ((path-from-shell (shell-command-to-string "$SHELL -i -c 'echo -n $PATH'"))) 10 | (setenv "PATH" path-from-shell) 11 | (setq exec-path (split-string path-from-shell path-separator)))) 12 | 13 | (if window-system (set-exec-path-from-shell-PATH)) 14 | 15 | ; language 16 | (setq current-language-environment "English") 17 | 18 | ; don't show the startup screen 19 | (setq inhibit-startup-screen 1) 20 | ; don't show the menu bar 21 | (menu-bar-mode 0) 22 | ; don't show the tool bar 23 | (require 'tool-bar) 24 | (tool-bar-mode 0) 25 | ; don't show the scroll bar 26 | (if window-system (scroll-bar-mode 0)) 27 | 28 | ; turn on mouse wheel support for scrolling 29 | (require 'mwheel) 30 | (mouse-wheel-mode 1) 31 | 32 | ; set command key to be meta instead of option 33 | (if (system-is-mac) 34 | (setq ns-command-modifier 'meta)) 35 | 36 | ; number of characters until the fill column 37 | (setq-default fill-column 70) 38 | 39 | ; each line of text gets one line on the screen (i.e., text will run 40 | ; off the left instead of wrapping around onto a new line) 41 | (setq-default truncate-lines 1) 42 | ; truncate lines even in partial-width windows 43 | (setq truncate-partial-width-windows 1) 44 | 45 | ; default window width and height 46 | (defun custom-set-frame-size () 47 | (add-to-list 'default-frame-alist '(height . 50)) 48 | (add-to-list 'default-frame-alist '(width . 178))) 49 | (custom-set-frame-size) 50 | (add-hook 'before-make-frame-hook 'custom-set-frame-size) 51 | 52 | ; window modifications 53 | ;; (global-set-key (kbd "S-C-") 'shrink-window-horizontally) 54 | ;; (global-set-key (kbd "S-C-") 'enlarge-window-horizontally) 55 | ;; (global-set-key (kbd "S-C-") 'shrink-window) 56 | ;; (global-set-key (kbd "S-C-") 'enlarge-window) 57 | 58 | ; make end and home keys go to the start/end of buffers 59 | (global-set-key (kbd "") 'end-of-buffer) 60 | (global-set-key (kbd "") 'beginning-of-buffer) 61 | (define-key input-decode-map "\e[1;5A" [C-up]) 62 | (define-key input-decode-map "\e[1;5B" [C-down]) 63 | 64 | ; always use spaces, not tabs, when indenting 65 | (setq-default indent-tabs-mode nil) 66 | ; indentation styles 67 | (setq c-basic-offset 8) 68 | (setq c-default-style (quote ( 69 | (c-mode . "bsd") 70 | (java-mode . "java") 71 | (awk-mode . "awk") 72 | (other . "gnu")))) 73 | 74 | ; ignore case when searching 75 | (setq-default case-fold-search 1) 76 | 77 | ; set the keybinding so that you can use f4 for goto line 78 | (global-set-key [f4] 'goto-line) 79 | 80 | ; require final newlines in files when they are saved 81 | (setq require-final-newline 1) 82 | ; add a new line when going to the next line 83 | (setq next-line-add-newlines t) 84 | 85 | ; show the current line and column numbers in the stats bar as well 86 | (line-number-mode 1) 87 | (column-number-mode 1) 88 | 89 | ; don't blink the cursor 90 | (blink-cursor-mode 0) 91 | 92 | ; make sure transient mark mode is enabled (it should be by default, 93 | ; but just in case) 94 | (transient-mark-mode 1) 95 | 96 | ; highlight parentheses when the cursor is next to them 97 | (require 'paren) 98 | (show-paren-mode 1) 99 | 100 | ; text decoration 101 | (require 'font-lock) 102 | ;(setq font-lock-maximum-decoration 1) 103 | (global-font-lock-mode 1) 104 | (global-hi-lock-mode nil) 105 | (setq jit-lock-contextually 1) 106 | (setq jit-lock-stealth-verbose 1) 107 | 108 | ; if there is size information associated with text, change the text 109 | ; size to reflect it 110 | (size-indication-mode 1) 111 | 112 | ; disable backup 113 | (setq backup-inhibited t) 114 | ; disable auto save 115 | (setq auto-save-default nil) 116 | 117 | (provide 'general-settings) 118 | -------------------------------------------------------------------------------- /.emacs.d/settings/helm-settings.el: -------------------------------------------------------------------------------- 1 | (require 'helm) 2 | (require 'helm-descbinds) 3 | 4 | (fset 'describe-bindings 'helm-descbinds) 5 | (helm-mode 1) 6 | 7 | (global-set-key (kbd "C-c h") 'helm-mini) 8 | 9 | (provide 'helm-settings) 10 | -------------------------------------------------------------------------------- /.emacs.d/settings/js-settings.el: -------------------------------------------------------------------------------- 1 | ;----------------; 2 | ;;; Javascript ;;; 3 | ;----------------; 4 | 5 | (add-to-list 'auto-mode-alist '("\\.js$" . js2-mode)) 6 | (setq-default js2-basic-offset 4) 7 | 8 | (provide 'js-settings) 9 | -------------------------------------------------------------------------------- /.emacs.d/settings/latex-settings.el: -------------------------------------------------------------------------------- 1 | ;-----------; 2 | ;;; LaTeX ;;; 3 | ;-----------; 4 | 5 | (add-to-list 'load-path "/usr/local/share/emacs/site-lisp") 6 | (include-plugin "auctex") 7 | (load "auctex.el" -1 1 1) 8 | (load "preview-latex.el" -1 1 1) 9 | 10 | (if (system-is-mac) 11 | (progn 12 | (require 'tex-site) 13 | (require 'font-latex) 14 | (setq TeX-view-program-list 15 | (quote 16 | (("Skim" 17 | (concat "/Applications/Skim.app/Contents/SharedSupport/displayline" 18 | " %n %o %b"))))) 19 | (setq TeX-view-program-selection 20 | (quote (((output-dvi style-pstricks) "dvips and gv") 21 | (output-dvi "xdvi") 22 | (output-pdf "Skim") 23 | (output-html "xdg-open"))))) 24 | 25 | (if (system-is-linux) 26 | (setq TeX-view-program-selection 27 | (quote (((output-dvi style-pstricks) "dvips and gv") 28 | (output-dvi "xdvi") 29 | (output-pdf "evince") 30 | (output-html "xdg-open")))))) 31 | 32 | ; always start the server for inverse search 33 | (setq-default TeX-source-correlate-start-server 0) 34 | 35 | (add-hook 'LaTeX-mode-hook 36 | (lambda () 37 | (tex-pdf-mode 1) 38 | (TeX-source-correlate-mode 1))) 39 | 40 | (provide 'latex-settings) 41 | -------------------------------------------------------------------------------- /.emacs.d/settings/markdown-settings.el: -------------------------------------------------------------------------------- 1 | ;-------------------; 2 | ;;; Markdown mode ;;; 3 | ;-------------------; 4 | 5 | (include-plugin "markdown-mode") 6 | (autoload 'markdown-mode "markdown-mode.el" 7 | "Major mode for editing Markdown files" t) 8 | (setq auto-mode-alist 9 | (append 10 | (list '("\\.text" . markdown-mode) 11 | '("\\.md" . markdown-mode) 12 | '("\\.markdown" . markdown-mode) 13 | ) 14 | auto-mode-alist)) 15 | 16 | (provide 'markdown-settings) 17 | -------------------------------------------------------------------------------- /.emacs.d/settings/matlab-settings.el: -------------------------------------------------------------------------------- 1 | ;---------------------; 2 | ;;; Matlab settings ;;; 3 | ;---------------------; 4 | 5 | (include-plugin "matlab") 6 | (autoload 'matlab-mode "matlab" "Matlab Editing Mode" t) 7 | (add-to-list 8 | 'auto-mode-alist 9 | '("\\.m$" . matlab-mode)) 10 | (setq matlab-indent-function t) 11 | (setq matlab-shell-command "matlab") 12 | 13 | (provide 'matlab-settings) 14 | -------------------------------------------------------------------------------- /.emacs.d/settings/mumamo-settings.el: -------------------------------------------------------------------------------- 1 | ;---------------------; 2 | ;;; MuMaMo / nxhtml ;;; 3 | ;---------------------; 4 | 5 | (load (make-plugin-path "nxhtml/elisp/autostart.el")) 6 | ;; Workaround the annoying warnings: 7 | ;; Warning (mumamo-per-buffer-local-vars): 8 | ;; Already 'permanent-local t: buffer-file-name 9 | (when (and (equal emacs-major-version 24) 10 | (equal emacs-minor-version 3)) 11 | (eval-after-load "mumamo" 12 | '(setq mumamo-per-buffer-local-vars 13 | (delq 'buffer-file-name mumamo-per-buffer-local-vars)))) 14 | 15 | (provide 'mumamo-settings) 16 | -------------------------------------------------------------------------------- /.emacs.d/settings/python-settings.el: -------------------------------------------------------------------------------- 1 | ;------------------------; 2 | ;;; Python Programming ;;; 3 | ;------------------------; 4 | 5 | ;; ----------------------- 6 | ;; python.el configuration 7 | ;; ----------------------- 8 | 9 | ; from python.el 10 | (require 'python) 11 | 12 | (setq 13 | python-shell-interpreter "ipython" 14 | python-shell-interpreter-args (if (system-is-mac) 15 | "--matplotlib=osx --colors=Linux" 16 | (if (system-is-linux) 17 | "--gui=wx --matplotlib=wx --colors=Linux")) 18 | python-shell-prompt-regexp "In \\[[0-9]+\\]: " 19 | python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: " 20 | python-shell-completion-setup-code 21 | "from IPython.core.completerlib import module_completion" 22 | python-shell-completion-module-string-code 23 | "';'.join(module_completion('''%s'''))\n" 24 | python-shell-completion-string-code 25 | "';'.join(get_ipython().Completer.all_completions('''%s'''))\n") 26 | 27 | 28 | ;; ----------------------------- 29 | ;; emacs IPython notebook config 30 | ;; ----------------------------- 31 | 32 | ; use autocompletion, but don't start to autocomplete after a dot 33 | (setq ein:complete-on-dot -1) 34 | (setq ein:use-auto-complete 1) 35 | 36 | ; set python console args 37 | (setq ein:console-args 38 | (if (system-is-mac) 39 | '("--gui=osx" "--matplotlib=osx" "--colors=Linux") 40 | (if (system-is-linux) 41 | '("--gui=wx" "--matplotlib=wx" "--colors=Linux")))) 42 | 43 | ; timeout settings 44 | (setq ein:query-timeout 1000) 45 | 46 | ; IPython notebook 47 | (include-plugin "emacs-ipython-notebook/lisp") 48 | (require 'ein) 49 | 50 | ; shortcut function to load notebooklist 51 | (defun load-ein () 52 | (ein:notebooklist-load) 53 | (interactive) 54 | (ein:notebooklist-open)) 55 | 56 | 57 | ;; ------------------ 58 | ;; misc python config 59 | ;; ------------------ 60 | 61 | ; pydoc info 62 | (include-plugin "pydoc-info-0.2") 63 | (require 'pydoc-info) 64 | 65 | ;; ; jedi python completion 66 | ;; (include-elget-plugin "ctable") ; required for epc 67 | ;; (include-elget-plugin "deferred") ; required for epc 68 | ;; (include-elget-plugin "epc") ; required for jedi 69 | ;; (include-elget-plugin "jedi") 70 | ;; (require 'jedi) 71 | ;; (setq jedi:setup-keys t) 72 | ;; (autoload 'jedi:setup "jedi" nil t) 73 | ;; (add-hook 'python-mode-hook 'jedi:setup) 74 | 75 | ;; pyflakes flymake integration 76 | ;; http://stackoverflow.com/a/1257306/347942 77 | (when (load "flymake" t) 78 | (defun flymake-pyflakes-init () 79 | (let* ((temp-file (flymake-init-create-temp-buffer-copy 80 | 'flymake-create-temp-inplace)) 81 | (local-file (file-relative-name 82 | temp-file 83 | (file-name-directory buffer-file-name)))) 84 | (list "pycheckers" (list local-file)))) 85 | (add-to-list 'flymake-allowed-file-name-masks 86 | '("\\.py\\'" flymake-pyflakes-init))) 87 | (add-hook 'python-mode-hook 88 | (lambda () 89 | (unless (eq buffer-file-name nil) (flymake-mode 1)))) 90 | 91 | ; Set PYTHONPATH, because we don't load .bashrc 92 | (defun set-python-path-from-shell-PYTHONPATH () 93 | (let ((path-from-shell (shell-command-to-string "$SHELL -i -c 'echo $PYTHONPATH'"))) 94 | (setenv "PYTHONPATH" path-from-shell))) 95 | 96 | (if window-system (set-python-path-from-shell-PYTHONPATH)) 97 | 98 | (setq auto-mode-alist 99 | (append 100 | (list '("\\.pyx" . python-mode) 101 | '("SConstruct" . python-mode)) 102 | auto-mode-alist)) 103 | 104 | ; keybindings 105 | (eval-after-load 'python 106 | '(define-key python-mode-map (kbd "C-c !") 'python-shell-switch-to-shell)) 107 | (eval-after-load 'python 108 | '(define-key python-mode-map (kbd "C-c |") 'python-shell-send-region)) 109 | 110 | (provide 'python-settings) 111 | 112 | -------------------------------------------------------------------------------- /.emacs.d/settings/scss-settings.el: -------------------------------------------------------------------------------- 1 | ;-----------------; 2 | ;;; SCSS / SASS ;;; 3 | ;-----------------; 4 | 5 | (include-plugin "scss-mode") 6 | (autoload 'scss-mode "scss-mode") 7 | (add-to-list 'auto-mode-alist '("\\.scss\\'" . scss-mode)) 8 | (setq scss-sass-command (expand-file-name "~/.rvm/gems/ruby-1.9.3-p392/bin/sass")) 9 | (setq scss-compile-at-save nil) 10 | 11 | (provide 'scss-settings) 12 | -------------------------------------------------------------------------------- /.emacs.d/settings/yaml-settings.el: -------------------------------------------------------------------------------- 1 | ;-------------------; 2 | ;;; YAML Mode ;;; 3 | ;-------------------; 4 | 5 | (require 'yaml-mode) 6 | 7 | (add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode)) 8 | 9 | (add-hook 'yaml-mode-hook 10 | '(lambda () 11 | (define-key yaml-mode-map "\C-m" 'newline-and-indent))) 12 | 13 | (provide 'yaml-settings) 14 | -------------------------------------------------------------------------------- /.emacs.d/settings/yasnippet-settings.el: -------------------------------------------------------------------------------- 1 | ;---------------; 2 | ;;; yasnippet ;;; 3 | ;---------------; 4 | 5 | (require 'yasnippet) 6 | (yas-global-mode 1) 7 | 8 | (provide 'yasnippet-settings) 9 | -------------------------------------------------------------------------------- /.emacs.d/snippets/js-mode/doc: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | #name : jsdoc 3 | # -- 4 | /** 5 | * $0 6 | */ -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.elc 3 | .emacs.d/plugins/color-theme-* 4 | .emacs.d/plugins/python-mode* 5 | .emacs.d/plugins/auctex 6 | .emacs.d/plugins/pydoc-info-* 7 | .emacs.d/plugins/matlab/ 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Emacs Configuration 2 | 3 | > **Please note**: I no longer use emacs regularly and am unable to support issues on this configuration. I will leave it up for people in case it is useful, but I have disabled issues on the repository and will not respond to emails asking for help -- I receive too many emails as it is, and unfortunately I cannot respond to every one. 4 | 5 | **Tested on versions:** 6 | * GNU Emacs 24.3.1 (x86_64-apple-darwin13.1.0, NS apple-appkit-1265.19) of 2014-04-06 7 | * GNU Emacs 24.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.4.2) of 2014-02-22 8 | 9 | ## Installing 10 | 11 | Clone this repository, and then run the `bootstrap.sh` script. This 12 | will copy all of the necessary files to `~/.emacs` and 13 | `~/.emacs.d`. Note that if these files exist for you already, **this 14 | will overwrite those files**. 15 | 16 | Once you have run the bootstrap script, start Emacs (make sure you are 17 | connected to the internet when you do this for the first time). It 18 | will install [`el-get`](https://github.com/dimitri/el-get) and all of 19 | the other plugins listed in the next section. This initial 20 | installation may take a while, so be patient. 21 | 22 | ## Dependencies 23 | 24 | For some of the plugins to work, you will need to have some external 25 | dependencies installed, such as Python, IPython, git, etc. If the 26 | installation gives you an error, it might mean you are missing a 27 | required dependency that el-get doesn't install. 28 | 29 | ## Emacs plugins 30 | 31 | This configuration installs several plugins using 32 | [`el-get`](https://github.com/dimitri/el-get). These plugins are 33 | specified in `.emacs.d/settings/el-get-settings.el`, and are also 34 | listed below: 35 | 36 | * `auctex` -- LaTeX plugin 37 | * `ein` -- [IPython notebook](http://ipython.org/notebook) plugin 38 | * `jedi` -- general Python support 39 | * `pydoc-info` -- Python documentation 40 | * `auto-complete` -- auto completion 41 | * `popup` -- visual popup (e.g., for auto completion) 42 | * `color-theme-solarized` -- the [solarized](http://ethanschoonover.com/solarized) color theme 43 | * `magit` -- git plugin 44 | * `markdown-mode` -- support for [Markdown](http://daringfireball.net/projects/markdown/) files 45 | * `matlab-mode` -- support Matlab files 46 | * `nxhtml` (MuMaMo) 47 | * `scss-mode` -- support for [SCSS](http://sass-lang.com/) files 48 | * `nyan-mode` -- silly mode that renders a nyan cat to display how far 49 | you are through a file 50 | * `helm` -- [completion and selection](https://github.com/emacs-helm/helm) narrowing framework 51 | * `helm-descbinds` -- describe keybindings using helm 52 | * `yaml-mode` -- support [YAML](https://github.com/yoshiki/yaml-mode) files 53 | 54 | ## Gotchas 55 | 56 | Here are some issues I or others have run into when installing this configuration. 57 | 58 | ### Version control systems 59 | 60 | To install all the plugins above, you need to have several different version control systems installed, including `hg`, `git`, `bzr`, and `cvs`. 61 | 62 | ### Trouble building AUCTeX 63 | 64 | If you get the following error: 65 | 66 | `error: el-get: ./autogen.sh el-get could not build auctex [./autogen.sh]` 67 | 68 | There are a few possible causes. Try these steps: 69 | 70 | 1. Make sure you have `automake` and `texlive-full` installed (if you are on Ubuntu) or MacTeX (if you are on Mac). 71 | 2. Try running emacs from the command line (it could be an issue with not finding the right path). 72 | 3. If that doesn't work, run emacs from the command line with the `--debug-init` flag. This will give you more information about the error, and possibly point you towards the solution. 73 | 74 | ### No such file or directory: pycheckers 75 | 76 | `pycheckers` is a little script to check that your Python code 77 | conforms to the 78 | [PEP8 style guide](http://legacy.python.org/dev/peps/pep-0008/) using 79 | the [pep8](https://pypi.python.org/pypi/pep8) and 80 | [pyflakes](https://pypi.python.org/pypi/pyflakes/0.8.1) Python 81 | packages. 82 | 83 | If you do not want this functionality, you can comment out the block 84 | of code in `python-settings.el` that starts with "pyflakes flymake 85 | integration". Otherwise, read on. 86 | 87 | 1. In your `~/.bashrc`, add `$HOME/bin` to your `$PATH` environment variable like so: 88 | 89 | ``` 90 | export PATH="$HOME/bin:$PATH" 91 | ``` 92 | 93 | 2. Create a file in `~/bin/pycheckers` with the following contents: 94 | 95 | ``` 96 | #!/bin/bash 97 | 98 | pyflakes "$1" 99 | pep8 --ignore=E261 --repeat "$1" 100 | true 101 | ``` 102 | 103 | 3. Make it executable with `chmod +x ~/bin/pycheckers`. 104 | 105 | 4. Make sure you have `pep8` and `pyflakes` installed (run `pip 106 | install pep8 pyflakes`). 107 | 108 | 5. Now it should work! If not, please submit a bug report and let me 109 | know. 110 | 111 | ### Tramp is timing out 112 | 113 | If you get the error `tramp ssh: connect to host c port 22: Operation timed out` and you are running OS X Mavericks with Emacs installed using Homebrew, then this is probably due to the Mavericks upgrade. Try reinstalling Emacs through Homebrew and remove the folder `~/.emacs.d/el-get` (note: this will remove all your el-get plugins, and they will need to be reinstalled). 114 | 115 | ### Auto-complete disappears from python mode 116 | The python mode needs to have the `jedi`, `epc`, and `pylint` packages added to your Python installation. Run this command: 117 | 118 | ``` 119 | pip install jedi epc pylint 120 | ``` 121 | 122 | Hint provided by Andrea Crotti's EuroPython 2013 Conference talk, [Emacs and shell as your best friends](https://www.youtube.com/watch?v=0cZ7szFuz18), and the [minimal Emacs configuration](https://github.com/AndreaCrotti/minimal-emacs-configuration) used in the talk. 123 | -------------------------------------------------------------------------------- /bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Based on bootstrap.sh by Mathias Bynens, retrieved 04/28/2013: 4 | # https://github.com/mathiasbynens/dotfiles/blob/5d1850e041f955c48f5a2241faabddd7af895b58/bootstrap.sh 5 | 6 | cd "$(dirname "${BASH_SOURCE}")" 7 | git pull origin master 8 | 9 | gitExitCode=$? 10 | if [[ $gitExitCode != 0 ]]; then 11 | exit $gitExitCode 12 | fi 13 | 14 | function clean() { 15 | git clean -nx 16 | read -p "Clean the above files? (y/n) " -n 1 17 | echo 18 | if [[ $REPLY =~ ^[Yy]$ ]]; then 19 | git clean -fx 20 | fi 21 | } 22 | 23 | function doIt() { 24 | for i in $(ls -a); do 25 | if [ $i != '.' -a $i != '..' -a $i != '.git' -a $i != '.DS_Store' -a $i != 'bootstrap.sh' -a $i != 'README.md' -a $i != '.gitignore' -a $i != '.gitmodules' ]; then 26 | if [ $(uname) == "Darwin" ]; then 27 | echo "$i" 28 | gcp -alrf "$i" "$HOME/" 29 | else 30 | echo "$i" 31 | cp -alrf "$i" "$HOME/" 32 | fi 33 | fi 34 | done 35 | } 36 | 37 | clean 38 | if [ "$1" == "--force" -o "$1" == "-f" ]; then 39 | doIt 40 | else 41 | read -p "This may overwrite existing files in your home directory. Are you sure? (y/n) " -n 1 42 | echo 43 | if [[ $REPLY =~ ^[Yy]$ ]]; then 44 | doIt 45 | fi 46 | fi 47 | unset clean 48 | unset doIt 49 | --------------------------------------------------------------------------------