Created
October 11, 2013 02:37
-
-
Save clvrobj/6928781 to your computer and use it in GitHub Desktop.
My Emacs config
This file contains hidden or 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
(menu-bar-mode 0) | |
(tool-bar-mode 0) | |
;; (scroll-bar-mode 0) | |
(blink-cursor-mode 0) | |
(set-default-font "Source Code Pro 13") | |
;; format title bar to show full path of current file | |
(setq-default frame-title-format | |
(list '((buffer-file-name " %f" | |
(dired-directory | |
dired-directory | |
(revert-buffer-function " %b" | |
("%b - Dir: " default-directory))))))) | |
(global-set-key (kbd "M-3") 'grep-find) | |
(setq grep-find-command | |
"find . '(' -path '*/.svn' -o -path '*/.hg' -o -path '*/.git' ')' -prune -o -type f -print0 | xargs -0 grep -in ") | |
;;;; tab to spaces | |
(setq c-basic-offset 4) | |
(setq-default indent-tabs-mode nil) | |
(setq default-tab-width 4) | |
(setq tab-stop-list nil) | |
(add-hook 'html-mode-hook | |
(lambda () | |
;; Default indentation is usually 2 spaces, changing to 4. | |
(set (make-local-variable 'sgml-basic-offset) 4))) | |
;; store the emacs state | |
(desktop-save-mode 1) | |
(setq auto-save-timeout 1800) | |
;; scoll just 3 lines not all the screen | |
(setq scroll-margin 3 | |
scroll-conservatively 10000) | |
;; high light the match parentheses but not auto move the cursor | |
(show-paren-mode t) | |
(setq show-paren-style 'parentheses) | |
(show-paren-mode 1) | |
(column-number-mode 1) | |
(global-set-key "\C-xg" 'goto-line) | |
(global-set-key "\C-x\C-r" 'revert-buffer) ;; reload buffer | |
(fset 'yes-or-no-p 'y-or-n-p) ;; Make all yes-or-no questions as y-or-n | |
;; duplicate current line insert to next line | |
(defun dup-line-down() | |
(interactive) | |
(move-beginning-of-line 1) | |
(kill-line) | |
(yank) | |
(open-line 1) | |
(next-line 1) | |
(yank) | |
) | |
(global-set-key (kbd "<C-M-down>") 'dup-line-down) | |
(defun add-py-header () | |
"check and add # -*- coding: utf-8 -*-" | |
(interactive) | |
(let ((pyheader "# -*- coding: utf-8 -*-")) | |
(if (not (equal pyheader (buffer-substring-no-properties 1 (1+ (length pyheader))))) | |
(progn (goto-char 1) | |
(insert (concat pyheader "\n\n")))))) | |
(defun kill-other-buffers () | |
"Kill all other buffers." | |
(interactive) | |
(mapc 'kill-buffer | |
(delq (current-buffer) | |
(remove-if-not 'buffer-file-name (buffer-list))))) | |
(global-set-key (kbd "C-c k") 'kill-other-buffers) | |
(mapc (lambda (hook) | |
(add-hook hook (lambda () | |
(setq show-trailing-whitespace t)))) | |
'(text-mode-hook | |
emacs-lisp-mode-hook | |
python-mode-hook | |
js2-mode-hook | |
css-mode-hook | |
)) | |
;; duplicate current line insert to next line | |
(defun dup-line-down() | |
(interactive) | |
(move-beginning-of-line 1) | |
(kill-line) | |
(yank) | |
(open-line 1) | |
(next-line 1) | |
(yank) | |
) | |
(global-set-key (kbd "<C-M-down>") 'dup-line-down) | |
(global-set-key (kbd "C-x <up>") 'windmove-up) | |
(global-set-key (kbd "C-x <down>") 'windmove-down) | |
(global-set-key (kbd "C-x <right>") 'windmove-right) | |
(global-set-key (kbd "C-x <left>") 'windmove-left) | |
;; Moving lines up & down with <M-up> & <M-down> | |
(defun move-line (&optional n) | |
"Move current line N (1) lines up/down leaving point in place." | |
(interactive "p") | |
(when (null n) | |
(setq n 1)) | |
(let ((col (current-column))) | |
(beginning-of-line) | |
(forward-line) | |
(transpose-lines n) | |
(forward-line -1) | |
(forward-char col)) | |
(indent-according-to-mode)) | |
(defun move-line-up (n) | |
"Moves current line N (1) lines up leaving point in place." | |
(interactive "p") | |
(move-line (if (null n) -1 (- n)))) | |
(defun move-line-down (n) | |
"Moves current line N (1) lines down leaving point in place." | |
(interactive "p") | |
(move-line (if (null n) 1 n))) | |
(global-set-key [(meta p)] 'move-line-up) | |
(global-set-key [(meta n)] 'move-line-down) | |
(setq make-backup-files nil) | |
(defun google () | |
"Google the selected region if any, display a query prompt otherwise." | |
(interactive) | |
(browse-url | |
(concat | |
"http://www.google.com/search?ie=utf-8&oe=utf-8&q=" | |
(url-hexify-string (if mark-active | |
(buffer-substring (region-beginning) (region-end)) | |
(read-string "Google: ")))))) | |
(global-set-key (kbd "C-c g") 'google) | |
(defun copy-file-name-to-clipboard () | |
"Copy the current buffer file name to the clipboard." | |
(interactive) | |
(let ((filename (if (equal major-mode 'dired-mode) | |
default-directory | |
(buffer-file-name)))) | |
(when filename | |
(kill-new filename) | |
(message "Copied buffer file name '%s' to the clipboard." filename)))) | |
;; end of programing, require some mode below | |
(ido-mode t) | |
(setq ido-enable-flex-matching t) | |
(setq ido-auto-merge-work-directories-length -1) | |
(add-to-list 'custom-theme-load-path "~/.emacs.d/plugins/emacs-color-theme-solarized/") | |
(load-theme 'solarized-dark t) | |
(make-face-unitalic 'font-lock-comment-face) ;; solve italic Chinese problem | |
(add-to-list 'load-path "~/.emacs.d/plugins/") | |
(add-to-list 'load-path (expand-file-name "~/.emacs.d/plugins/emacs-goodies-el")) | |
(require 'emacs-goodies-el) | |
(add-to-list 'load-path (expand-file-name "~/.emacs.d/plugins/emacs-color-theme-solarized")) | |
(require 'color-theme-solarized) | |
;;(require 'color-theme) | |
;(color-theme-calm-forest) | |
;;(color-theme-resolve) | |
(require 'tramp) | |
(setq tramp-default-method "ssh") | |
;; for remember the pwd of vagrant | |
(setq password-cache-expiry nil) | |
;; bash | |
(setq added-path "/usr/local/share/python/:/usr/local/bin:/usr/bin/:") | |
(setq original-path (getenv "PATH")) | |
(setenv "PATH" (message "%s%s" added-path original-path)) | |
;; auto complete [{ pair | |
;; (require 'autopair) | |
;; (autopair-global-mode) ;; enable autopair in all buffers | |
;; (add-hook 'js2-mode-hook #'(lambda () (setq autopair-dont-activate t))) | |
;; (add-hook 'python-mode-hook | |
;; #'(lambda () (push '(?' . ?') | |
;; (getf autopair-extra-pairs :code)) | |
;; (setq autopair-handle-action-fns | |
;; (list #'autopair-default-handle-action | |
;; #'autopair-python-triple-quote-action)))) | |
;; using this instead of pair, pair always hang my emacs | |
(electric-pair-mode +1) | |
(require 'auto-complete) | |
(global-auto-complete-mode t) | |
(define-key ac-complete-mode-map "\C-n" 'ac-next) | |
(define-key ac-complete-mode-map "\C-p" 'ac-previous) | |
(setq ac-dwim t) | |
(add-to-list 'load-path "~/.emacs.d/plugins/js2.el") | |
(autoload 'js2-mode "js2" nil t) | |
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode)) | |
(require 'zencoding-mode) | |
(add-hook 'sgml-mode-hook 'zencoding-mode) ;; Auto-start on any markup modes | |
(require 'golden-ratio) | |
(golden-ratio-enable) | |
(require 'workgroups) | |
(setq wg-prefix-key (kbd "C-c w")) | |
(workgroups-mode 1) | |
(wg-load "~/.workgroups") | |
(setq wg-morph-on nil) ;; no morphing please | |
(require 'python-pep8) | |
(require 'python-pylint) | |
;; (add-hook 'before-save-hook 'delete-trailing-whitespace) | |
(require 'package) | |
(add-to-list 'package-archives | |
'("marmalade" . | |
"http://marmalade-repo.org/packages/")) | |
(package-initialize) | |
(add-to-list 'load-path (expand-file-name "~/.emacs.d/plugins/gh.el")) | |
(require 'gist) | |
(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) | |
(add-to-list 'load-path (expand-file-name "~/.emacs.d/plugins/expand-region.el")) | |
(require 'expand-region) | |
(global-set-key (kbd "C-=") 'er/expand-region) | |
;; 防止字体设置窗口弹出 | |
(setq mac-command-modifier 'super) | |
(global-unset-key [(super t)]) | |
;; 使两边窗口显示相同的buffer并切换到另一个窗口 | |
(defun switch-same-buffer-other-window() | |
"Open same buffer and switch to the other window." | |
(interactive) | |
(let ((cur-buf (current-buffer))) | |
(other-window 1) | |
(switch-to-buffer cur-buf))) | |
(global-set-key "\C-x\C-o" 'switch-same-buffer-other-window) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment