Created
November 23, 2014 00:30
-
-
Save lpand/16099bf0f7abb7d8f880 to your computer and use it in GitHub Desktop.
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
(add-to-list 'load-path "~/.emacs.d/auto-complete/") | |
(add-to-list 'load-path "~/.emacs.d/elisp/") | |
(load-library "mac-keyboard") | |
(load-library "auto-complete") | |
(add-to-list 'load-path "~/.emacs.d/elpa/yasnippet-0.8.0") | |
(add-to-list 'load-path "~/.emacs.d/multiple-cursors/") | |
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes") | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(setq | |
backup-by-copying t ; don't clobber symlinks | |
backup-directory-alist | |
'(("." . "~/.saves")) ; don't litter my fs tree | |
delete-old-versions t | |
kept-new-versions 10 | |
kept-old-versions 10 | |
version-control t) ; use versioned backups | |
;; packages | |
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/") | |
("marmalade" . "https://marmalade-repo.org/packages/") | |
("melpa" . "http://melpa.milkbox.net/packages/"))) | |
;; save and restore session | |
(desktop-save-mode 1) | |
;; font size | |
(set-face-attribute 'default nil :height 150) | |
(global-auto-complete-mode t) | |
;; turn on automatic bracket insertion by pairs. New in emacs 24 | |
(electric-pair-mode 1) | |
;; shows cursor position | |
(setq line-number-mode t) | |
(setq column-number-mode t) | |
;; move regions | |
(defun move-region (start end n) | |
"Move the current region up or down by N lines." | |
(interactive "r\np") | |
(let ((line-text (delete-and-extract-region start end))) | |
(forward-line n) | |
(let ((start (point))) | |
(insert line-text) | |
(setq deactivate-mark nil) | |
(set-mark start)))) | |
(defun move-region-up (start end n) | |
"Move the current line up by N lines." | |
(interactive "r\np") | |
(move-region start end (if (null n) -1 (- n)))) | |
(defun move-region-down (start end n) | |
"Move the current line down by N lines." | |
(interactive "r\np") | |
(move-region start end (if (null n) 1 n))) | |
(global-set-key (kbd "M-p") 'move-region-up) | |
(global-set-key (kbd "M-n") 'move-region-down) | |
;; 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) | |
;; fuzzy file search | |
(require 'ido) | |
(ido-mode t) | |
(global-linum-mode t) | |
;; moving between windows | |
(when (fboundp 'windmove-default-keybindings) | |
(windmove-default-keybindings)) | |
;; tabs | |
(defun how-many-region (begin end regexp &optional interactive) | |
"Print number of non-trivial matches for REGEXP in region. | |
Non-interactive arguments are Begin End Regexp" | |
(interactive "r\nsHow many matches for (regexp): \np") | |
(let ((count 0) opoint) | |
(save-excursion | |
(setq end (or end (point-max))) | |
(goto-char (or begin (point))) | |
(while (and (< (setq opoint (point)) end) | |
(re-search-forward regexp end t)) | |
(if (= opoint (point)) | |
(forward-char 1) | |
(setq count (1+ count)))) | |
(if interactive (message "%d occurrences" count)) | |
count))) | |
(defun infer-indentation-style () | |
;; if our source file uses tabs, we use tabs, if spaces spaces, and if | |
;; neither, we use the current indent-tabs-mode | |
(let ((space-count (how-many-region (point-min) (point-max) "^ ")) | |
(tab-count (how-many-region (point-min) (point-max) "^\t"))) | |
(if (> space-count tab-count) (setq indent-tabs-mode nil)) | |
(if (> tab-count space-count) (setq indent-tabs-mode t)))) | |
(setq-default tab-width 2) | |
(setq js-indent-level 2) | |
(setq css-indent-level 2) | |
(setq python-indent-level 2) | |
(setq ruby-indent-level 2) | |
(setq css-indent-level 2) | |
(setq-default indent-tabs-mode nil) | |
(infer-indentation-style) | |
;; snippets (doesn't work) | |
(require 'yasnippet) | |
(setq yas-mode t) | |
;;; use popup menu for yas-choose-value | |
(require 'popup) | |
;; add some shotcuts in popup menu mode | |
(define-key popup-menu-keymap (kbd "M-n") 'popup-next) | |
(define-key popup-menu-keymap (kbd "TAB") 'popup-next) | |
(define-key popup-menu-keymap (kbd "<tab>") 'popup-next) | |
(define-key popup-menu-keymap (kbd "<backtab>") 'popup-previous) | |
(define-key popup-menu-keymap (kbd "M-p") 'popup-previous) | |
(defun yas-popup-isearch-prompt (prompt choices &optional display-fn) | |
(when (featurep 'popup) | |
(popup-menu* | |
(mapcar | |
(lambda (choice) | |
(popup-make-item | |
(or (and display-fn (funcall display-fn choice)) | |
choice) | |
:value choice)) | |
choices) | |
:prompt prompt | |
;; start isearch mode immediately | |
:isearch t | |
))) | |
(setq yas-prompt-functions '(yas-popup-isearch-prompt yas-ido-prompt yas-no-prompt)) | |
(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 default default italic underline success warning error]) | |
'(ansi-color-names-vector | |
["#242424" "#e5786d" "#95e454" "#cae682" "#8ac6f2" "#333366" "#ccaa8f" "#f6f3e8"]) | |
'(custom-enabled-themes (quote (spacegray))) | |
'(custom-safe-themes | |
(quote | |
("7f14fad67d7ac8d0555bd5a1fd1a429ce2dd37162c4e2dc7ae501f54bad1273a" "7a00b0710bb2e400d33a925f94b1cd8cfa2281f864ac9506b9046703e0045d66" "57d7e8b7b7e0a22dc07357f0c30d18b33ffcbb7bcd9013ab2c9f70748cfa4838" "6ecfc451f545459728a4a8b1d44ac4cdcc5d93465536807d0cb0647ef2bb12c4" "0ae977e603e99d89c80d679377bfed4a904317968bd885ee063455cee01728d3" default))) | |
'(fci-rule-color "#383838")) | |
(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. | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment