122 lines
		
	
	
		
			4.2 KiB
		
	
	
	
		
			EmacsLisp
		
	
	
	
	
	
		
		
			
		
	
	
			122 lines
		
	
	
		
			4.2 KiB
		
	
	
	
		
			EmacsLisp
		
	
	
	
	
	
|  | ;;; starter-kit-bindings.el --- Saner defaults and goodies: bindings | ||
|  | ;; | ||
|  | ;; Copyright (c) 2008-2010 Phil Hagelberg and contributors | ||
|  | ;; | ||
|  | ;; Author: Phil Hagelberg <technomancy@gmail.com> | ||
|  | ;; URL: http://www.emacswiki.org/cgi-bin/wiki/StarterKit | ||
|  | ;; Version: 2.0.2 | ||
|  | ;; Keywords: convenience | ||
|  | ;; Package-Requires: ((starter-kit "2.0.2")) | ||
|  | 
 | ||
|  | ;; This file is not part of GNU Emacs. | ||
|  | 
 | ||
|  | ;;; Commentary: | ||
|  | 
 | ||
|  | ;; "Emacs outshines all other editing software in approximately the | ||
|  | ;; same way that the noonday sun does the stars. It is not just bigger | ||
|  | ;; and brighter; it simply makes everything else vanish." | ||
|  | ;; -Neal Stephenson, "In the Beginning was the Command Line" | ||
|  | 
 | ||
|  | ;; This file just contains key bindings. | ||
|  | 
 | ||
|  | ;;; License: | ||
|  | 
 | ||
|  | ;; This program is free software; you can redistribute it and/or | ||
|  | ;; modify it under the terms of the GNU General Public License | ||
|  | ;; as published by the Free Software Foundation; either version 3 | ||
|  | ;; of the License, or (at your option) any later version. | ||
|  | ;; | ||
|  | ;; This program is distributed in the hope that it will be useful, | ||
|  | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
|  | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||
|  | ;; GNU General Public License for more details. | ||
|  | ;; | ||
|  | ;; You should have received a copy of the GNU General Public License | ||
|  | ;; along with GNU Emacs; see the file COPYING.  If not, write to the | ||
|  | ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
|  | ;; Boston, MA 02110-1301, USA. | ||
|  | 
 | ||
|  | ;;; Code: | ||
|  | 
 | ||
|  | ;;;###autoload | ||
|  | (progn | ||
|  |   ;; It's all about the project. | ||
|  |   (global-set-key (kbd "C-c f") 'find-file-in-project) | ||
|  | 
 | ||
|  |   ;; You know, like Readline. | ||
|  |   (global-set-key (kbd "C-M-h") 'backward-kill-word) | ||
|  | 
 | ||
|  |   ;; Completion that uses many different methods to find options. | ||
|  |   (global-set-key (kbd "M-/") 'hippie-expand) | ||
|  | 
 | ||
|  |   ;; Perform general cleanup. | ||
|  |   (global-set-key (kbd "C-c n") 'esk-cleanup-buffer) | ||
|  | 
 | ||
|  |   ;; Turn on the menu bar for exploring new modes | ||
|  |   (global-set-key (kbd "C-<f10>") 'menu-bar-mode) | ||
|  | 
 | ||
|  |   ;; Font size | ||
|  |   (define-key global-map (kbd "C-+") 'text-scale-increase) | ||
|  |   (define-key global-map (kbd "C--") 'text-scale-decrease) | ||
|  | 
 | ||
|  |   ;; Use regex searches by default. | ||
|  |   (global-set-key (kbd "C-s") 'isearch-forward-regexp) | ||
|  |   (global-set-key (kbd "\C-r") 'isearch-backward-regexp) | ||
|  |   (global-set-key (kbd "C-M-s") 'isearch-forward) | ||
|  |   (global-set-key (kbd "C-M-r") 'isearch-backward) | ||
|  | 
 | ||
|  |   ;; Jump to a definition in the current file. (Protip: this is awesome.) | ||
|  |   (global-set-key (kbd "C-x C-i") 'imenu) | ||
|  | 
 | ||
|  |   ;; File finding | ||
|  |   (global-set-key (kbd "C-x M-f") 'ido-find-file-other-window) | ||
|  |   (global-set-key (kbd "C-c y") 'bury-buffer) | ||
|  |   (global-set-key (kbd "C-c r") 'revert-buffer) | ||
|  | 
 | ||
|  |   ;; Window switching. (C-x o goes to the next window) | ||
|  |   (windmove-default-keybindings) ;; Shift+direction | ||
|  |   (global-set-key (kbd "C-x O") (lambda () (interactive) (other-window -1))) ;; back one | ||
|  |   (global-set-key (kbd "C-x C-o") (lambda () (interactive) (other-window 2))) ;; forward two | ||
|  | 
 | ||
|  |   ;; Start eshell or switch to it if it's active. | ||
|  |   (global-set-key (kbd "C-x m") 'eshell) | ||
|  | 
 | ||
|  |   ;; Start a new eshell even if one is active. | ||
|  |   (global-set-key (kbd "C-x M") (lambda () (interactive) (eshell t))) | ||
|  | 
 | ||
|  |   ;; Start a regular shell if you prefer that. | ||
|  |   (global-set-key (kbd "C-x C-m") 'shell) | ||
|  | 
 | ||
|  |   ;; If you want to be able to M-x without meta (phones, etc) | ||
|  |   (global-set-key (kbd "C-c x") 'execute-extended-command) | ||
|  | 
 | ||
|  |   ;; Help should search more than just commands | ||
|  |   (global-set-key (kbd "C-h a") 'apropos) | ||
|  | 
 | ||
|  |   ;; Should be able to eval-and-replace anywhere. | ||
|  |   (global-set-key (kbd "C-c e") 'esk-eval-and-replace) | ||
|  | 
 | ||
|  |   ;; M-S-6 is awkward | ||
|  |   (global-set-key (kbd "C-c q") 'join-line) | ||
|  | 
 | ||
|  |   ;; So good! | ||
|  |   (global-set-key (kbd "C-c g") 'magit-status) | ||
|  | 
 | ||
|  |   ;; This is a little hacky since VC doesn't support git add internally | ||
|  |   (eval-after-load 'vc | ||
|  |     (define-key vc-prefix-map "i" | ||
|  |       '(lambda () (interactive) | ||
|  |          (if (not (eq 'Git (vc-backend buffer-file-name))) | ||
|  |              (vc-register) | ||
|  |            (shell-command (format "git add %s" buffer-file-name)) | ||
|  |            (message "Staged changes."))))) | ||
|  | 
 | ||
|  |   ;; Activate occur easily inside isearch | ||
|  |   (define-key isearch-mode-map (kbd "C-o") | ||
|  |     (lambda () (interactive) | ||
|  |       (let ((case-fold-search isearch-case-fold-search)) | ||
|  |         (occur (if isearch-regexp isearch-string (regexp-quote isearch-string))))))) | ||
|  | 
 | ||
|  | (provide 'starter-kit-bindings) | ||
|  | ;;; starter-kit-bindings.el ends here |