Commits

Anonymous committed 23d780c

* too many changes to keep track of :D

  • Participants
  • Parent commits 1151c03

Comments (0)

Files changed (23)

 bookmarks
 org-clock-save.el
 commit.bat
-url/*
+url/*
+overlay.el
+mark-multiple.el

File .mc-lists.el

+;; This file is automatically generated by the multiple-cursors extension.
+;; It keeps track of your preferences for running commands with multiple cursors.
+
+(setq mc/cmds-to-run-for-all
+      '(
+        ignore
+        kill-region
+        ))
+
+(setq mc/cmds-to-run-once
+      '(
+        typopunct-insert-mp
+        ))

File autoinstall.el

+;; autoinstall packages
+(require 'cl)
+
+(defvar prelude-packages
+  '(undo-tree helm expand-region)
+  "A list of packages to ensure are installed at launch.")
+
+(defun prelude-packages-installed-p ()
+  (loop for p in prelude-packages
+        when (not (package-installed-p p)) do (return nil)
+        finally (return t)))
+
+(unless (prelude-packages-installed-p)
+  ;; check for new packages (package versions)
+  (message "%s" "Emacs Prelude is now refreshing its package database...")
+  (package-refresh-contents)
+  (message "%s" " done.")
+  ;; install the missing packages
+  (dolist (p prelude-packages)
+    (when (not (package-installed-p p))
+      (package-install p))))
+
+(provide 'autoinstall)

File files/defuns.el

   (beginning-of-buffer)
   (replace-regexp "^[[:space:]]" "")
   (beginning-of-buffer)
+  (replace-string "}\\emph{" "")
+  (beginning-of-buffer)
+  (replace-string "\\emph{}" "")
+  (beginning-of-buffer)
+  (query-replace-regexp "\\\\emph{ }" "")
+  (beginning-of-buffer)
   (replace-regexp "
 
 

File files/global.el

 ;; Small fringes
 (set-fringe-mode '(1 . 1))
 
-;; Emacs gurus don't need no stinking scroll bars
-(when (fboundp 'toggle-scroll-bar)
-    (toggle-scroll-bar -1))
-
 ;; Explicitly show the end of a buffer
 (set-default 'indicate-empty-lines t)
 
 
 (setq calendar-week-start-day 1)
 
+;; pending deletion. Replace active region with input
+(pending-delete-mode t)
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Some text-mode settings
 
                   (filename . ".tex")))
             ("Web"
              (or (mode . html-mode)
-                 (mode . CSS-mode)
+                 (mode . css-mode)
                  (mode . PHP-mode)))
             ("Programming" ;; prog stuff not already in MyProjectX
               (or
                 (mode . perl-mode)
                 (mode . python-mode)
                 (mode . cc-mode)
+                (mode . js-mode)
                 ;; etc
                 ))))))
 

File files/key-chord.el

+(key-chord-mode 1)
+
+(defun add-tex-key-chords ()
+  (key-chord-define tex-mode-map "''" "`\C-q'\C-b")
+  (key-chord-define tex-mode-map "$$" "$$\C-b"))
+(add-hook 'tex-mode-hook 'add-tex-key-chords)
+
+(defun add-programming-chords ()
+  (key-chord-define-local ";;" "\C-e;")
+  (key-chord-define-local ",," "\C-e,"))
+(dolist (hook '(c++-mode-hook
+                c-mode-hook
+                js-mode-hook
+                java-mode-hook))
+  (add-hook hook 'add-programming-chords))

File files/keys.el

 ;; How to Define Keyboard Shortcuts in Emacs
 ;; http://xahlee.org/emacs/keyboard_shortcuts.html
 
+;; setting the PC keyboard's various keys to
+;; Super or Hyper, for emacs running on Windows.
+(setq w32-pass-lwindow-to-system nil
+      w32-pass-rwindow-to-system nil
+      w32-pass-apps-to-system nil
+      w32-lwindow-modifier 'super ; Left Windows key
+      w32-rwindow-modifier 'super ; Right Windows key
+      w32-apps-modifier 'hyper) ; Menu key
+
+;; Url & Browsing
+(global-set-key (kbd "C-c C-w") 'browse-url-at-point)
+(global-set-key (kbd "C-c w") 'browse-url)
+
 ;; Window manipulation
 (global-set-key [(control kp-6)] 'enlarge-window-horizontally)
 (global-set-key [(control kp-4)] 'shrink-window-horizontally)
 
 (global-set-key (kbd "M-O") 'rotate-windows)
 
+;; Move windows, even in org-mode (doesn't work on windows :( )
+(global-set-key (kbd "<s-right>") 'windmove-right)
+(global-set-key (kbd "<s-left>") 'windmove-left)
+(global-set-key (kbd "<s-up>") 'windmove-up)
+(global-set-key (kbd "<s-down>") 'windmove-down)
+
 ;; Replace dired's M-o
 (add-hook 'dired-mode-hook (lambda () (define-key dired-mode-map (kbd "M-o") 'other-window))) ; was dired-omit-mode
 ;; Replace ibuffer's M-o
 ;; Window navigation
 (windmove-default-keybindings 'meta)
 
-;; Find matching parens
-(global-set-key (kbd "C-'") 'match-paren)
-
 ;; Easier buffer killing
 (global-unset-key (kbd "M-k"))
 (global-set-key (kbd "M-k") 'kill-this-buffer)
+(global-set-key (kbd "M-K") (lambda () (interactive) (kill-buffer (window-buffer (next-window)))))
 
 ;; imenu
 (global-unset-key (kbd "M-.")) ;; was Find tag
   (beginning-of-line))
 
 (global-set-key (kbd "C-x a") 'select-to-the-beginning-of-line)
+;; swap C-a and M-m
+(global-unset-key (kbd "M-m"))
+(global-unset-key (kbd "C-a"))
+(global-set-key (kbd "M-m") 'beginning-of-line)
+(global-set-key (kbd "C-a") 'back-to-indentation)
+
+(defun vi-open-next-line (arg)
+  "Move to the next line (like vi) and then opens a line."
+  (interactive "p")
+  (if (looking-at "^")
+      (open-line arg)
+    (end-of-line)
+    (open-line arg)
+    (next-line 1)
+    (indent-according-to-mode)))
+(global-set-key (kbd "C-o") 'vi-open-next-line)
 
 (defun copy-line ()
   (interactive)
 (global-set-key (kbd "C-M-e") 'forward-sexp)
 
 (global-set-key (kbd "M-y") 'helm-show-kill-ring)
+
+(defun open-next-line ()
+  (interactive)
+  (newline)
+  (indent-according-to-mode))
+
+(global-set-key (kbd "RET") 'open-next-line)
+
+(defun eval-and-replace ()
+  "Replace the preceding sexp with its value."
+  (interactive)
+  (backward-kill-sexp)
+  (condition-case nil
+      (prin1 (eval (read (current-kill 0)))
+             (current-buffer))
+    (error (message "Invalid expression")
+           (insert (current-kill 0)))))
+
+(global-set-key (kbd "C-c C-e") 'eval-and-replace)
+
+(global-set-key (kbd "C-c f") 'iy-go-to-char)
+(global-set-key (kbd "C-c F") 'iy-go-to-char-backward)
+(global-set-key (kbd "C-c ;") 'iy-go-to-char-continue)
+(global-set-key (kbd "C-c ,") 'iy-go-to-char-continue-backward)
+
+
+;; 0 = previous, 2 = next
+;; but we map it to +/-1 to be more intuitive
+;; +1 -> 2
+;; -1 -> 0
+(defun copy-line-with-offset (offset)
+  (kill-ring-save (line-beginning-position (+ offset 1))
+                  (line-end-position (+ offset 1)))
+  (let ((pos (point))
+        (line (buffer-substring-no-properties (line-beginning-position) (line-end-position))))
+    (beginning-of-line)
+    (when (or (and (string-match "[:space:]" line)
+                    (> offset 0))
+              (< offset 0))
+      (newline)
+      (forward-line -1))
+    (beginning-of-line)
+    (insert (car kill-ring))
+    (goto-char pos)))
+
+(defun copy-previous-line ()
+  (interactive)
+  (copy-line-with-offset -1))
+
+(defun copy-next-line ()
+  (interactive)
+  (copy-line-with-offset 1))
+
+(global-set-key (kbd "C-c <up>") 'copy-previous-line)
+(global-set-key (kbd "C-c <down>") 'copy-next-line)

File files/multiple-cursors.el

+(global-set-key (kbd "s-c") 'mc/edit-lines)
+
+;; When you want to add multiple cursors not based on continuous lines, but based on keywords in the buffer, use:
+(global-set-key (kbd "s-.") 'mc/mark-next-like-this)
+(global-set-key (kbd "s-,") 'mc/mark-previous-like-this)
+(global-set-key (kbd "s-?") 'mc/mark-more-like-this-extended)
+(global-set-key (kbd "s-/") 'mc/mark-all-like-this)
+
+
+;; From active region to multiple cursors:
+(global-set-key (kbd "s-e") 'mc/edit-ends-of-lines)
+(global-set-key (kbd "s-a") 'mc/edit-beginnings-of-lines)
+
+;; Rectangular region mode
+(global-set-key (kbd "H-SPC") 'set-rectangular-region-anchor)

File files/tabs.el

 ;; Hippie expand.  Groovy vans with tie-dyes.
 
 (setq hippie-expand-try-functions-list
-	  '(yas/hippie-try-expand
-		try-expand-dabbrev
-		try-expand-dabbrev-all-buffers
-		try-expand-dabbrev-from-kill
-		try-complete-file-name
-		try-complete-lisp-symbol))
+      '(yas/hippie-try-expand
+        try-expand-dabbrev
+        try-expand-dabbrev-all-buffers
+        try-expand-dabbrev-from-kill
+        try-complete-file-name
+        try-complete-lisp-symbol))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Smart Tab
   expands it. Else calls `smart-indent'."
   (interactive "P")
   (labels ((smart-tab-must-expand (&optional prefix)
-								  (unless (or (consp prefix)
-											  mark-active)
-									(looking-at "\\_>"))))
-	(cond ((minibufferp)
-		   (minibuffer-complete))
-		  ((smart-tab-must-expand prefix)
-		   (if smart-tab-using-hippie-expand
-			   (hippie-expand prefix)
-			 (dabbrev-expand prefix)))
-		  ((smart-indent)))))
+                                  (unless (or (consp prefix)
+                                              mark-active)
+                                    (looking-at "\\_>"))))
+    (cond ((minibufferp)
+           (minibuffer-complete))
+          ((smart-tab-must-expand prefix)
+           (if smart-tab-using-hippie-expand
+               (hippie-expand prefix)
+             (dabbrev-expand prefix)))
+          ((smart-indent)))))
 
 (defun smart-indent ()
   "Indents region if mark is active, or current line otherwise."
   (interactive)
   (if mark-active
-	  (indent-region (region-beginning)
-					 (region-end))
-	(indent-for-tab-command)))
+      (indent-region (region-beginning)
+                     (region-end))
+    (indent-for-tab-command)))
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (global-set-key (kbd "TAB") 'smart-tab)

File files/wrap-region.el

+;; enable wrap region mode
+(wrap-region-global-mode t)
+
+;; begin, end, trigger, mode
+(wrap-region-add-wrapper "`" "'")                  ; hit ` then region -> `region'
+(wrap-region-add-wrapper "/*" "*/" "/")            ; hit / then region -> /*region*/
+(wrap-region-add-wrapper "$" "$" nil 'latex-mode)  ; hit $ then region -> $region$ in latex-mode
 (server-start)
 
+;; Emacs gurus don't need no stinking scroll bars & widgets
+(scroll-bar-mode -1)
+(menu-bar-mode -1)
+(tool-bar-mode -1)
+(tooltip-mode -1)
+
 ;; add load paths
 (add-to-list 'load-path "~/.emacs.d")
 (add-to-list 'load-path "~/.emacs.d/vendor")
 (setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
                          ("marmalade" . "http://marmalade-repo.org/packages/")
                          ("melpa" . "http://melpa.milkbox.net/packages/")))
+(package-initialize)
+(require 'autoinstall)
 
 ;; load config files
+(load "files/org-mode")
+(load "files/global")
 (load "files/defuns")
 (load "files/macros")
-(load "files/org-mode")
 (load "files/tabs")
-(load "files/global")
 (load "files/keys")
 (load "files/ido")
+(load "files/ispell")
+
 (load "files/undo-tree")
-(load "files/ispell")
+
 
 ;; vendor
 (vendor 'smex)
 (vendor 'revbufs)
 (vendor 'shell-pop)
 (vendor 'golden-ratio)
+(vendor 'multiple-cursors)
+(vendor 'iy-go-to-char)
+(vendor 'key-chord)
+(vendor 'wrap-region)
 
 ;; TEX
 (require 'tildify)

File vendor/iy-go-to-char/iy-go-to-char.el

+;;; iy-go-to-char.el -- Go to next CHAR which is similar to "f" in vim
+
+;; Copyright (C) 2009 Ian Yang
+
+;; Author: Ian Yang <doit dot ian (at) gmail dot com>
+;; Keywords: navigation, search
+;; Filename: iy-go-to-char.el
+;; Description: Go to char
+;; Created: 2009-08-23 01:27:34
+;; Version: 1.1
+;; Last-Updated: 2012-04-16 08:42:00
+;; URL: http://www.emacswiki.org/emacs/download/iy-go-to-char.el
+;; Compatibility: GNU Emacs 23.1.1
+
+;; 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 2, 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 this program; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+
+;; This package defines the function `iy-go-to-char' which behaves
+;; like "f" in vim. It reads a char and go the next Nth occurence of
+;; the char. User can continue such search using that char key.
+
+;; To use, make sure this file is on your `load-path' and put the
+;; following in your .emacs file:
+;;
+;; (require 'iy-go-to-char)
+;;
+;; Then you can bind functions like:
+;;
+;; (global-set-key (kbd "C-c f") 'iy-go-to-char)
+;; (global-set-key (kbd "C-c F") 'iy-go-to-char-backward)
+;; (global-set-key (kbd "C-c ;") 'iy-go-to-char-continue)
+;; (global-set-key (kbd "C-c ,") 'iy-go-to-char-continue-backward)
+
+;; Except repeating the char key, followings keys are defined before
+;; quitting the search:
+;;
+;;    ;   -- search forward the char, customizable:
+;;           `iy-go-to-char-key-forward'
+;;
+;;    ,   -- search backward the char, customizable:
+;;           `iy-go-to-char-key-backward'
+;;
+;;    C-g -- quit
+;;
+;;    C-s -- start `isearch-forward' using char as initial search
+;;           string
+;;
+;;    C-r -- start `isearch-backward' using char as initial search
+;;           string
+;;
+;;    C-w -- quit and kill region between start and current point. If region is
+;;           activated before search, then use the original mark instead of the
+;;           start position.
+;;
+;;    M-w -- quit and save region between start and current point. If region is
+;;           activated before search, use the mark instead of start position.
+;;
+;; All other keys will quit the search. Then the key event is
+;; intepreted in the original environment before search.
+;;
+;; if the search quits because of error or using "C-g", point is set
+;; back to the start position. Otherwise, point is not change and the
+;; start position is set as marker. So you can use "C-x C-x" back to
+;; that position.
+
+;; `iy-go-to-char-backward' search backward by default. Not like in
+;; "vim", ";" is always searching forward and "," is searching
+;; backward, whether the search is started forward or backward. It
+;; does be the same even when the search char is ";" or ",". Also the
+;; search can cross lines. To continue search last char, use
+;; `iy-go-to-char-continue' and `iy-go-to-char-continue-backward'.
+
+;;; Change Log:
+;; 2012-04-16 (1.1)
+;;    fix C-s/C-r to enter isearch
+
+;;; Code:
+
+(defgroup iy-go-to-char nil
+  "go to char like f in vim."
+  :link '(emacs-commentary-link "iy-go-to-char")
+  :prefix "iy-go-to-char-"
+  :group 'matching)
+
+(defcustom iy-go-to-char-key-forward ?\;
+  "Default key used to go to next occurence of the char"
+  :type 'character
+  :group 'iy-go-to-char)
+(defcustom iy-go-to-char-key-backward ?\,
+  "Default key used to go to previous occurence of the char"
+  :type 'character
+  :group 'iy-go-to-char)
+
+(defvar iy-go-to-char-last-char nil
+  "last char used in iy-go-to-char"
+  )
+
+(defun iy-go-to-char-isearch-setup ()
+  (remove-hook 'isearch-mode-hook 'iy-go-to-char-isearch-setup)
+  (setq isearch-string (if iy-go-to-char-last-char (string iy-go-to-char-last-char) ""))
+  (isearch-search-and-update))
+
+;;;###autoload
+(defun iy-go-to-char (n char)
+  "Move forward to Nth occurence of CHAR.
+
+Typing key of CHAR will move to the next occurence of CHAR.
+Typing ; will move to the next occurence of CHAR.
+Typing , will move to the previous occurence of CHAR.
+Typing C-g will quit and return to the original point.
+Typing C-s or C-r will start `isearch` using CHAR.
+Typing C-w or M-w will kill/copy between current point and the start point.
+Unless quit using C-g or the region is activated before searching, the start
+ point is set as mark.
+"
+  (interactive "p\ncGo to char: ")
+  (let ((count (if (zerop n) 1 n))
+        (cont t)
+        (orig (if (region-active-p) (mark) (point)))
+        (dir (if (< n 0) -1 1))
+        ev pt)
+    (when (and (= char ?\C-z) iy-go-to-char-last-char)
+      (setq char iy-go-to-char-last-char))
+    (save-excursion
+      (search-forward (string char) nil nil count)
+      (setq pt (match-end 0))
+      (setq iy-go-to-char-last-char char) ;; save char only if success
+      (while cont
+        (setq ev (read-event))
+        (cond ((eq ev iy-go-to-char-key-forward)
+               (search-forward (string char) nil nil 1)
+               (setq pt (match-end 0)))
+              ((eq ev iy-go-to-char-key-backward)
+               (search-forward (string char) nil nil -1)
+               (setq pt (match-end 0)))
+              ((eq ev char)
+               (search-forward (string char) nil nil dir)
+               (setq pt (match-end 0)))
+              ((eq ev ?\C-z)
+               (search-forward (string char) nil nil dir)
+               (setq pt (match-end 0)))
+              (t
+               (setq cont nil)))))
+    (if (not pt)
+        (push ev unread-command-events)
+      (goto-char pt)
+      (push-mark orig t)
+      (cond
+       ((or (eq ev ?\C-s) (eq ev ?\C-r))
+        (add-hook 'isearch-mode-hook 'iy-go-to-char-isearch-setup)
+        (if (eq ev ?\C-s) (isearch-forward) (isearch-backward)))
+       ((eq ev ?\C-w)
+        (goto-char pt)
+        (push-mark orig t)
+        (kill-region orig pt))
+       ((eq ev ?\M-w)
+        (goto-char pt)
+           (push-mark orig t)
+           (kill-ring-save orig pt))
+       (t
+        (push ev unread-command-events)
+        (goto-char pt)
+        (push-mark orig t))))))
+
+;;;###autoload
+(defun iy-go-to-char-backward (n char)
+  "Move backward to Nth occurence of CHAR.
+Typing key of CHAR will move to the previous occurence of CHAR.
+Typing ; will move to the next occurence of CHAR.
+Typing , will move to the previous occurence of CHAR.
+Typing C-g will quit and return to the original point.
+Typing C-s or C-r will start `isearch` using CHAR"
+  (interactive "p\ncGo to char: ")
+  (iy-go-to-char (- n) char))
+
+;;;###autoload
+(defun iy-go-to-char-continue (n)
+  "Continue last `iy-go-to-char` or `iy-go-to-char-backward`"
+  (interactive "p")
+  (when iy-go-to-char-last-char
+    (iy-go-to-char n iy-go-to-char-last-char)))
+
+;;;###autoload
+(defun iy-go-to-char-continue-backward (n)
+  "Continue last `iy-go-to-char` or `iy-go-to-char-backward`"
+  (interactive "p")
+  (when iy-go-to-char-last-char
+    (iy-go-to-char (- n) iy-go-to-char-last-char)))
+
+
+
+(provide 'iy-go-to-char)

File vendor/key-chord/key-chord.el

+;;; key-chord.el --- map pairs of simultaneously pressed keys to commands
+;;-------------------------------------------------------------------
+;;
+;; Copyright (C) 2003,2005,2008 David Andersson
+;;
+;; This file is NOT part of Emacs.
+;;
+;; 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 2 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 this program; if not, write to the Free
+;; Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+;; MA 02111-1307 USA
+;;
+;;-------------------------------------------------------------------
+
+;; Author: David Andersson <l.david.andersson(at)sverige.nu>
+;; Created: 27 April 2003
+;; Version: 0.5 (2008-09-15)
+;; Keywords: keyboard chord input
+
+;;; Commentary:
+
+;; ########   Compatibility   ########################################
+;;
+;; Works with Emacs-20.3, 20.6, 20.7, 21.2, 21.4 and 22.1.
+;; Does not work with Emacs-19.31 nor XEmacs-20.4 and 21.4.
+
+;; ########   Quick start   ########################################
+;;
+;; Add to your ~/.emacs
+;;
+;;	(require 'key-chord)
+;;	(key-chord-mode 1)
+;;
+;; and some chords, for example
+;;
+;;      (key-chord-define-global "hj"     'undo)
+;;      (key-chord-define-global ",."     "<>\C-b")
+
+;; ########   Terminology   ########################################
+;;
+;; In this package, a "key chord" is two keys pressed simultaneously,
+;; or a single key quickly pressed twice.
+;;
+;; (Sometimes pressing SHIFT and/or META plus another key is call a chord,
+;; but not here. However SHIFT plus two normal keys can be a "key chord".)
+
+;; ########   Description   ########################################
+;;
+;; Key chord mode acts like a global minor mode controlled by the function
+;; `key-chord-mode'.
+;;
+;; Key chord definitions are stored in ordinary key-maps.
+;; The function `key-chord-define-global' defines a chord in the global
+;; key-map and `key-chord-define' defines a chord in a specified key-map,
+;; for example for a specific mode.
+;;
+;; A TWO-key chord is two distinct keys pressed simultaneously (within
+;; one tenth of a second, or so).
+;;
+;; Examples:
+;;
+;;      (key-chord-define-global ",."     "<>\C-b")
+;;      (key-chord-define-global "hj"     'undo)
+;;      (key-chord-define-global [?h ?j]  'undo)  ; the same
+;;      (key-chord-define-global "jk"     'dabbrev-expand)
+;;      (key-chord-define-global "cv"     'reindent-then-newline-and-indent)
+;;      (key-chord-define-global "4r"     "$")
+;;
+;; Comma and dot pressed together insert a pair of angle brackets.
+;; `h' and `j' pressed together invoke the undo command.
+;; `j' and `k' pressed together invoke the dabbrev-expand command.
+;; 'c' and 'v' pressed together insert a newline.
+;; `4' and `r' pressed together insert a dollar sign.
+;;
+;; A ONE-key chord is a single key quickly pressed twice (within one third
+;; of a second or so).
+;;
+;; Examples:
+;;
+;;      (key-chord-define-global "''"     "`'\C-b")
+;;      (key-chord-define-global ",,"     'indent-for-comment)
+;;      (key-chord-define-global "qq"     "the ")
+;;      (key-chord-define-global "QQ"     "The ")
+;;
+;; Tick (') pressed twice inserts a back-tick and a tick (`').
+;; Comma (,) pressed twice indents for and/or inserts a comment.
+;; `q' pressed twice inserts the word "the ".
+;;
+;; Examples: Mode specific chords
+;;
+;;      (key-chord-define c++-mode-map ";;"  "\C-e;")
+;;      (key-chord-define c++-mode-map "{}"  "{\n\n}\C-p\t")
+;;
+;; The command `key-chord-describe' lists currently defined key chords.
+;; The standard command `describe-bindings' (C-h b) will also show key chords.
+;;
+;; The standard command `describe-key' (C-h k) will accept a key chord and
+;; show its definition. (Isn't that amazing. There is no explicit code to
+;; carry out this functionality.)
+
+;; ########   Tips   ########################################
+;;
+;; Don't chord key combinations that exists in the languages you typically
+;; write. Otherwise, if you are typing fast, two key intended to be separate
+;; letters might instead trig a chord.
+;; E.g. "uu" would be a good chord in spanish but not in finnish, and
+;; "hj" would be a good chord in english but not in swedish.
+;;
+;; Don't rely solely on /usr/dict/words to find unusual combination.
+;; For example "cv" or "fg" can be quite common in certain kinds of
+;; programming. Grep your own texts to verify that a combination is unusual.
+;; And don't forget to check both permutations: "fg" and "gf".
+;;
+;; Choose two keys that are close to each other on the keyboard, so they
+;; can be quickly typed without effort. Chords involving two hands (as
+;; opposed to two fingers on one hand) are harder to type (quickly).
+;; The idea is that key chords are to replace function keys for functions
+;; that are frequently performed while the hands are in writing position.
+;;
+;; Key chords might not work well over a slow network.
+
+;; ########   Limitations   ########################################
+;;
+;; When recording keyboard macros, the time between keyboard inputs are not
+;; recorded. Thus, the key-chord-input-method cannot know for sure if two keys
+;; in a macro was a chord or not. The current solution remembers the first key
+;; of the chords typed during macro recording, and keys that match those (and
+;; are defined as chords) are considered key-chords during macro execution.
+;; This knowledge is not saved with `name-last-kbd-macro', so they may
+;; execute wrong if they contain pair of keys that match defined chords.
+;;
+;; Emacs will not call input-method-function for keys that have non numeric
+;; codes or whos code is outside the range 32..126. Thus you cannot define
+;; key chords involving function keys, control keys, or even your non-english
+;; letters (on national keyboards) that otherwise are well positioned for
+;; chording on your keyboard.
+;; (I think chording left and right arrow keys would be useful, but cannot do.
+;; I consider this a bug in Emacs. Input methods could happily return
+;; unmodified *any* key they don't know about.)
+;;
+;; Key chords longer that 2 keys are not supported. It could be done, but I
+;; don't think it is worth the trubbel since most keyboards will not reliably
+;; send all key codes when 3 or more keys are pressed simultaneously.
+;; It might also be a bit trickier to maintain performance.
+;;
+;; Key chord mode uses input-method-function. And so do internationalisation
+;; packages (mule, quail, etc). Do not expect them to work well together.
+;; The last one that gets the input-method-function rules.
+
+;; ########   Implementation   ########################################
+;;
+;; Key chords piggy back in ordinary key maps, so they can be defined
+;; per mode without having to add hooks to all modes.
+;;
+;; Key chord key codes are vectors beginning with the atom `key-chord'.
+;; A two key chord, e.g. "hj", will add two entries in the key-map.
+;; E.g. [key-chord ?h ?j] and [key-chord ?h ?j].
+;;
+;; When key-chord-mode is enabled input-method-function is set to
+;; key-chord-input-method.
+
+;; ########   To do   ########################################
+;;
+;; * Find a way to save key-chord info in keyboard macros.
+;;
+;; * Save previous value of input-method-function? And call it?
+;;
+;; * input-method-function is reset in *info* buffers! What to do?
+;;
+;; * How to enter interactively command OR string in key-chord-define-global?
+;;
+;; * Customize public vars (defcustom).
+
+;; ########   History   ########################################
+;;
+;; 0.5 (2008-09-15) l.david.andersson(at)sverige.nu
+;;      Bugfix sit-for; Improved examples; New E-mail in comment
+;; 0.4 (2005-05-07) david(at)symsoft.se
+;;  Slightly better macro heuristics; Added option key-chord-in-macros
+;; 0.3 (2005-04-14) david(at)symsoft.se
+;;  Require advice; More examples
+;; 0.2 (2003-09-13) david(at)symsoft.se
+;;  Quick and dirty fix for keyboard macros
+;; 0.1 (2003-04-27) david(at)symsoft.se
+;;	First release
+
+;;; Code:
+
+(defvar key-chord-two-keys-delay 0.1	; 0.05 or 0.1
+  "Max time delay between two key press to be considered a key chord.")
+
+(defvar key-chord-one-key-delay 0.2	; 0.2 or 0.3 to avoid first autorepeat
+  "Max time delay between two press of the same key to be considered a key chord.
+This should normally be a little longer than `key-chord-two-keys-delay'.")
+
+(defvar key-chord-in-macros t
+  "If nil, don't expand key chords when executing keyboard macros.
+If non-nil, expand chord sequenses in macros, but only if a similar chord was
+entered during the last interactive macro recording. (This carries a bit of
+guesswork. We can't know for sure when executing whether two keys were
+typed quickly or slowly when recorded.)")
+
+;; Internal vars
+(defvar key-chord-mode nil)
+
+;; Shortcut for key-chord-input-method: no need to test a key again if it
+;; didn't matched a chord the last time. Improves feedback during autorepeat.
+(defvar key-chord-last-unmatched nil)
+
+;; Macro heuristics: Keep track of which chords was used when the last macro
+;; was defined. Or rather, only the first-char of the chords. Only expand
+;; matching chords during macro execution.
+(defvar key-chord-in-last-kbd-macro nil)
+(defvar key-chord-defining-kbd-macro nil)
+
+;;;###autoload
+(defun key-chord-mode (arg)
+  "Toggle key chord mode.
+With positive ARG enable the mode. With zero or negative arg disable the mode.
+A key chord is two keys that are pressed simultaneously, or one key quickly
+pressed twice.
+See functions `key-chord-define-global' or `key-chord-define'
+and variables `key-chord-two-keys-delay' and `key-chord-one-key-delay'."
+  (interactive "P")
+  (setq key-chord-mode (if arg
+               (> (prefix-numeric-value arg) 0)
+             (not key-chord-mode)))
+  (cond (key-chord-mode
+     (setq input-method-function 'key-chord-input-method)
+     (message "Key Chord mode on"))
+    (t
+     (setq input-method-function nil)
+     (message "Key Chord mode off"))))
+
+;;;###autoload
+(defun key-chord-define-global (keys command)
+  "Define a key-chord of two keys in KEYS starting a COMMAND.
+\nKEYS can be a string or a vector of two elements. Currently only elements
+that corresponds to ascii codes in the range 32 to 126 can be used.
+\nCOMMAND can be an interactive function, a string, or nil.
+If COMMAND is nil, the key-chord is removed."
+  (interactive "sSet key chord globally (2 keys): \nCSet chord \"%s\" to command: ")
+  (key-chord-define (current-global-map) keys command))
+
+(defun key-chord-define-local (keys command)
+  (interactive "sSet key chord globally (2 keys): \nCSet chord \"%s\" to command: ")
+  (key-chord-define (current-local-map) keys command))
+
+;;;###autoload
+(defun key-chord-define (keymap keys command)
+  "Define in KEYMAP, a key-chord of two keys in KEYS starting a COMMAND.
+\nKEYS can be a string or a vector of two elements. Currently only elements
+that corresponds to ascii codes in the range 32 to 126 can be used.
+\nCOMMAND can be an interactive function, a string, or nil.
+If COMMAND is nil, the key-chord is removed."
+  (if (/= 2 (length keys))
+      (error "Key-chord keys must have two elements"))
+  ;; Exotic chars in a string are >255 but define-key wants 128..255 for those
+  (let ((key1 (logand 255 (aref keys 0)))
+    (key2 (logand 255 (aref keys 1))))
+    (if (eq key1 key2)
+    (define-key keymap (vector 'key-chord key1 key2) command)
+      ;; else
+      (define-key keymap (vector 'key-chord key1 key2) command)
+      (define-key keymap (vector 'key-chord key2 key1) command))))
+
+(defun key-chord-lookup-key1 (keymap key)
+  "Like lookup-key but no third arg and no numeric return value."
+  (let ((res (lookup-key keymap key)))
+    (if (numberp res)
+    nil
+      ;; else
+      res)))
+
+(defun key-chord-lookup-key (key)
+  "Lookup KEY in all current key maps."
+  (let ((maps (current-minor-mode-maps))
+    res)
+    (while (and maps (not res))
+      (setq res (key-chord-lookup-key1 (car maps) key)
+        maps (cdr maps)))
+    (or res
+    (if (current-local-map)
+        (key-chord-lookup-key1 (current-local-map) key))
+    (key-chord-lookup-key1 (current-global-map) key))))
+
+(defun key-chord-describe ()
+  "List key chord bindings in a help buffer.
+\nTwo key chords will be listed twice and there will be Prefix Commands.
+Please ignore that."
+  (interactive)
+  (describe-bindings [key-chord]))
+
+(defun key-chord-input-method (first-char)
+  "Input method controlled by key bindings with the prefix `key-chord'."
+  (if (and (not (eq first-char key-chord-last-unmatched))
+       (key-chord-lookup-key (vector 'key-chord first-char)))
+      (let ((delay (if (key-chord-lookup-key (vector 'key-chord first-char first-char))
+               key-chord-one-key-delay
+             ;; else
+             key-chord-two-keys-delay)))
+    (if (if executing-kbd-macro
+        (not (memq first-char key-chord-in-last-kbd-macro))
+          (sit-for delay 0 'no-redisplay))
+        (progn
+          (setq key-chord-last-unmatched nil)
+          (list first-char))
+      ;; else input-pending-p
+      (let* ((input-method-function nil)
+         (next-char (read-event))
+         (res (vector 'key-chord first-char next-char)))
+        (if (key-chord-lookup-key res)
+        (progn
+          (setq key-chord-defining-kbd-macro
+            (cons first-char key-chord-defining-kbd-macro))
+          (list 'key-chord first-char next-char))
+          ;; else put back next-char and return first-char
+          (setq unread-command-events (cons next-char unread-command-events))
+          (if (eq first-char next-char)
+          (setq key-chord-last-unmatched first-char))
+          (list first-char)))))
+    ;; else no key-chord keymap
+    (setq key-chord-last-unmatched first-char)
+    (list first-char)))
+
+(require 'advice)
+
+(defadvice start-kbd-macro (after key-chord activate)
+  (setq key-chord-defining-kbd-macro nil))
+
+(defadvice end-kbd-macro (after key-chord activate)
+  (setq key-chord-in-last-kbd-macro key-chord-defining-kbd-macro))
+
+(provide 'key-chord)
+
+;;; key-chord.el ends here

File vendor/multiple-cursors/README.md

+# multiple-cursors.el [![Build Status](https://secure.travis-ci.org/magnars/multiple-cursors.el.png)](http://travis-ci.org/magnars/multiple-cursors.el)
+
+Multiple cursors for Emacs. This is some pretty crazy functionality, so yes,
+there are kinks. Don't be afraid tho, I've been using it since 2011 with
+great success and much merriment.
+
+## Basic usage
+
+Start out with:
+
+    (require 'multiple-cursors)
+
+Then you have to set up your keybindings - multiple-cursors doesn't presume to
+know how you'd like them laid out. Here are some examples:
+
+When you have an active region that spans multiple lines, the following will
+add a cursor to each line:
+
+    (global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
+
+When you want to add multiple cursors not based on continuous lines, but based on
+keywords in the buffer, use:
+
+    (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)
+
+First mark the word, then add more cursors.
+
+To get out of multiple-cursors-mode, press `<return>` or `C-g`. The latter will
+first disable multiple regions before disabling multiple cursors. If you want to
+insert a newline in multiple-cursors-mode, use `C-j`.
+
+## Video
+
+You can [watch an intro to multiple-cursors at Emacs Rocks](http://emacsrocks.com/e13.html).
+
+## More commands to play around with
+
+I've set up my key-bindings like so:
+
+    ;; From active region to multiple cursors:
+    (global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
+    (global-set-key (kbd "C-S-c C-e") 'mc/edit-ends-of-lines)
+    (global-set-key (kbd "C-S-c C-a") 'mc/edit-beginnings-of-lines)
+
+When you have an active region that spans multiple lines, the preceeding three
+commands will add one cursor to each line.
+
+    ;; Rectangular region mode
+    (global-set-key (kbd "H-SPC") 'set-rectangular-region-anchor)
+
+Think of this one as `set-mark` except you're marking a rectangular region. It is
+an exceedingly quick way of adding multiple cursors to multiple lines.
+
+    ;; Mark more like this
+    (global-set-key (kbd "M-æ") 'mc/mark-all-like-this)
+    (global-set-key (kbd "C-å") 'mc/mark-previous-like-this)
+    (global-set-key (kbd "C-æ") 'mc/mark-next-like-this)
+    (global-set-key (kbd "C-Æ") 'mc/mark-more-like-this-extended)
+    (global-set-key (kbd "M-å") 'mc/mark-all-in-region)
+
+Okay, yes, I have a crazy norwegian keyboard. Regardless, these will look at
+whatever you've got selected at the moment, and mark more places like that in
+the buffer.
+
+If you would like to keep the global bindings clean, and get custom keybindings
+when the region is active, you can try [region-bindings-mode](https://github.com/fgallina/region-bindings-mode).
+
+BTW, I highly recommend adding `mc/mark-next-like-this` to a key binding that's
+right next to the key for `er/expand-region`.
+
+## Scrolling
+
+Sometimes you end up with cursors outside of your view. You can scroll the
+screen to center on each cursor with `C-v` and `M-v`.
+
+## Unknown commands
+
+Multiple-cursors uses two lists of commands to know what to do: the run-once list
+and the run-for-all list. It comes with a set of defaults, but it would be beyond silly
+to try and include all the known Emacs commands.
+
+So that's why multiple-cursors occasionally asks what to do about a command. It will
+then remember your choice by saving it in `~/.emacs.d/.mc-lists.el`. You can change
+the location with:
+
+    (setq mc/list-file "/my/preferred/file")
+
+
+## Known limitations
+
+* isearch-forward and isearch-backward aren't supported with multiple cursors.
+  You should feel free to add a simplified version that can work with it.
+* Commands run with `M-x` won't be repeated for all cursors.
+* All key bindings that refer to lambdas are always run for all cursors. If you
+  need to limit it, you will have to give it a name.
+* Redo might screw with your cursors. Undo works very well.
+
+
+## Contribute
+
+Yes, please do. There's a suite of tests, so remember to add tests for your
+specific feature, or I might break it later.
+
+You'll find the repo at:
+
+    https://github.com/magnars/multiple-cursors.el
+
+To fetch the test dependencies:
+
+    $ cd /path/to/multiple-cursors
+    $ git submodule update --init
+
+Run the tests with:
+
+    $ ./util/ecukes/ecukes --graphical
+
+## Contributors
+
+* [Takafumi Arakaki](https://github.com/tkf) made .mc-lists.el diff friendly
+* [Marco Baringer](https://github.com/segv) contributed looping to mc/cycle and adding cursors without region for mark-more.
+* [Ivan Andrus](https://github.com/gvol) added showing number of cursors in mode-line
+
+Thanks!
+
+## License
+
+Copyright (C) 2012 Magnar Sveen
+
+Author: Magnar Sveen <magnars@gmail.com>
+Keywords: editing cursors
+
+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 this program.  If not, see <http://www.gnu.org/licenses/>.

File vendor/multiple-cursors/mc-cycle-cursors.el

+;;; mc-cycle-cursors.el
+
+;; Copyright (C) 2012 Magnar Sveen
+
+;; Author: Magnar Sveen <magnars@gmail.com>
+;; Keywords: editing cursors
+
+;; 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This scrolls the buffer to center each cursor in turn.
+;; Scroll down with C-v, scroll up with M-v
+;; This is nice when you have cursors that's outside of your view.
+
+;;; Code:
+
+(require 'multiple-cursors-core)
+
+(eval-when-compile (require 'cl))
+
+(defun mc/next-fake-cursor-after-point ()
+  (let ((pos (point))
+        (next-pos (point-max))
+        next)
+    (mc/for-each-fake-cursor
+     (let ((cursor-pos (overlay-get cursor 'point)))
+       (when (and (< pos cursor-pos)
+                  (< cursor-pos next-pos))
+         (setq next-pos cursor-pos)
+         (setq next cursor))))
+    next))
+
+(defun mc/prev-fake-cursor-before-point ()
+  (let ((pos (point))
+        (prev-pos (point-min))
+        prev)
+    (mc/for-each-fake-cursor
+     (let ((cursor-pos (overlay-get cursor 'point)))
+       (when (and (> pos cursor-pos)
+                  (> cursor-pos prev-pos))
+         (setq prev-pos cursor-pos)
+         (setq prev cursor))))
+    prev))
+
+(defcustom mc/cycle-looping-behaviour 'continue
+  "What to do if asked to cycle beyond the last cursor or before the first cursor."
+  :type '(radio (const :tag "Loop around to beginning/end of document." continue)
+                (const :tag "Warn and then loop around." warn)
+                (const :tag "Signal an error." error)
+                (const :tag "Don't loop." stop)))
+
+(defun mc/handle-loop-condition (error-message)
+  (ecase mc/cycle-looping-behaviour
+    (error (error error-message))
+    (warn  (message error-message))
+    (continue 'continue)
+    (stop 'stop)))
+
+(defun mc/first-fake-cursor-after (point)
+  "Very similar to mc/furthest-cursor-before-point, but ignores (mark) and (point)."
+  (let* ((cursors (mc/all-fake-cursors))
+         (cursors-after-point (remove-if (lambda (cursor)
+                                           (< (mc/cursor-beg cursor) point))
+                                         cursors))
+         (cursors-in-order (sort* cursors-after-point '< :key 'mc/cursor-beg)))
+    (first cursors-in-order)))
+
+(defun mc/last-fake-cursor-before (point)
+  "Very similar to mc/furthest-cursor-before-point, but ignores (mark) and (point)."
+  (let* ((cursors (mc/all-fake-cursors))
+         (cursors-before-point (remove-if (lambda (cursor)
+                                            (> (mc/cursor-end cursor) point))
+                                          cursors))
+         (cursors-in-order (sort* cursors-before-point '> :key 'mc/cursor-end)))
+    (first cursors-in-order)))
+
+(defun* mc/cycle (next-cursor fallback-cursor loop-message)
+  (when (null next-cursor)
+    (when (eql 'stop (mc/handle-loop-condition loop-message))
+      (return-from mc/cycle nil))
+    (setf next-cursor fallback-cursor))
+  (mc/create-fake-cursor-at-point)
+  (mc/pop-state-from-overlay next-cursor)
+  (recenter))
+
+(defun mc/cycle-forward ()
+  (interactive)
+  (mc/cycle (mc/next-fake-cursor-after-point)
+            (mc/first-fake-cursor-after (point-min))
+             "We're already at the last cursor."))
+
+(defun mc/cycle-backward ()
+  (interactive)
+  (mc/cycle (mc/prev-fake-cursor-before-point)
+            (mc/last-fake-cursor-before (point-max))
+            "We're already at the last cursor"))
+
+(define-key mc/keymap (kbd "C-v") 'mc/cycle-forward)
+(define-key mc/keymap (kbd "M-v") 'mc/cycle-backward)
+
+(provide 'mc-cycle-cursors)
+
+;;; mc-cycle-cursors.el ends here

File vendor/multiple-cursors/mc-edit-lines.el

+;;; mc-edit-lines.el
+
+;; Copyright (C) 2012 Magnar Sveen
+
+;; Author: Magnar Sveen <magnars@gmail.com>
+;; Keywords: editing cursors
+
+;; 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This file contains functions to add multiple cursors to consecutive lines
+;; given an active region.
+
+;; Please see multiple-cursors.el for more commentary.
+
+;;; Code:
+
+(require 'multiple-cursors-core)
+
+;;;###autoload
+(defun mc/edit-lines ()
+  "Add one cursor to each line of the active region.
+Starts from mark and moves in straight down or up towards the
+line point is on."
+  (interactive)
+  (when (not (use-region-p))
+    (error "Mark a set of lines first."))
+  (mc/remove-fake-cursors)
+  (let* ((col (current-column))
+         (point-line (line-number-at-pos))
+         (mark-line (progn (exchange-point-and-mark) (line-number-at-pos)))
+         (direction (if (< point-line mark-line) :up :down)))
+    (deactivate-mark)
+    (when (and (eq direction :up) (bolp))
+      (forward-line -1)
+      (move-to-column col))
+    (while (not (eq (line-number-at-pos) point-line))
+      (mc/create-fake-cursor-at-point)
+      (if (eq direction :up) (forward-line -1) (forward-line 1))
+      (move-to-column col))
+    (multiple-cursors-mode)))
+
+;;;###autoload
+(defun mc/edit-ends-of-lines ()
+  "Add one cursor to the end of each line in the active region."
+  (interactive)
+  (mc/edit-lines)
+  (mc/execute-command-for-all-fake-cursors 'end-of-line)
+  (end-of-line))
+
+;;;###autoload
+(defun mc/edit-beginnings-of-lines ()
+  "Add one cursor to the beginning of each line in the active region."
+  (interactive)
+  (mc/edit-lines)
+  (mc/execute-command-for-all-fake-cursors 'beginning-of-line)
+  (beginning-of-line))
+
+(provide 'mc-edit-lines)
+
+;;; mc-edit-lines.el ends here

File vendor/multiple-cursors/mc-mark-more.el

+;;; mc-mark-more.el
+
+;; Copyright (C) 2012 Magnar Sveen
+
+;; Author: Magnar Sveen <magnars@gmail.com>
+;; Keywords: editing cursors
+
+;; 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This file contains functions to mark more parts of the buffer.
+;; See ./features/mark-more.feature for examples.
+
+;; Please see multiple-cursors.el for more commentary.
+
+;;; Code:
+
+(require 'multiple-cursors-core)
+
+(defun mc/cursor-end (cursor)
+  (if (overlay-get cursor 'mark-active)
+      (max (overlay-get cursor 'point)
+           (overlay-get cursor 'mark))
+    (overlay-get cursor 'point)))
+
+(defun mc/cursor-beg (cursor)
+  (if (overlay-get cursor 'mark-active)
+      (min (overlay-get cursor 'point)
+           (overlay-get cursor 'mark))
+    (overlay-get cursor 'point)))
+
+(defun mc/furthest-region-end ()
+  (let ((end (max (mark) (point))))
+    (mc/for-each-fake-cursor
+     (setq end (max end (mc/cursor-end cursor))))
+    end))
+
+(defun mc/first-region-start ()
+  (let ((beg (min (mark) (point))))
+    (mc/for-each-fake-cursor
+     (setq beg (min beg (mc/cursor-beg cursor))))
+    beg))
+
+(defun mc/furthest-cursor-before-point ()
+  (let ((beg (min (mark) (point)))
+        furthest)
+    (mc/for-each-fake-cursor
+     (when (< (mc/cursor-beg cursor) beg)
+       (setq beg (mc/cursor-beg cursor))
+       (setq furthest cursor)))
+    furthest))
+
+(defun mc/furthest-cursor-after-point ()
+  (let ((end (max (mark) (point)))
+        furthest)
+    (mc/for-each-fake-cursor
+     (when (> (mc/cursor-end cursor) end)
+       (setq end (mc/cursor-end cursor))
+       (setq furthest cursor)))
+    furthest))
+
+(defun mc/region-strings ()
+  (let ((strings (list (buffer-substring-no-properties (point) (mark)))))
+    (mc/for-each-fake-cursor
+     (add-to-list 'strings (buffer-substring-no-properties
+                            (mc/cursor-beg cursor)
+                            (mc/cursor-end cursor))))
+    strings))
+
+(defun mc/maybe-multiple-cursors-mode ()
+  "Enable multiple-cursors-mode if there is more than one currently active cursor."
+  (if (> (mc/num-cursors) 1)
+      (multiple-cursors-mode 1)
+    (multiple-cursors-mode 0)))
+
+(defun mc/mark-more-like-this (skip-last direction)
+  (let ((case-fold-search nil)
+        (re (regexp-opt (mc/region-strings)))
+        (point-out-of-order (ecase direction
+                              (forwards       (< (point) (mark)))
+                              (backwards (not (< (point) (mark))))))
+        (furthest-cursor (ecase direction
+                           (forwards  (mc/furthest-cursor-after-point))
+                           (backwards (mc/furthest-cursor-before-point))))
+        (start-char (ecase direction
+                      (forwards  (mc/furthest-region-end))
+                      (backwards (mc/first-region-start))))
+        (search-function (ecase direction
+                           (forwards  'search-forward-regexp)
+                           (backwards 'search-backward-regexp)))
+        (match-point-getter (ecase direction
+                              (forwards 'match-beginning)
+                              (backwards 'match-end))))
+    (mc/save-excursion
+     (goto-char start-char)
+     (when skip-last
+       (mc/remove-fake-cursor furthest-cursor))
+     (if (funcall search-function re nil t) 
+         (progn
+           (push-mark (funcall match-point-getter 0))
+           (when point-out-of-order
+             (exchange-point-and-mark))
+           (mc/create-fake-cursor-at-point))
+       (error "no more matches found.")))))
+
+;;;###autoload
+(defun mc/mark-next-like-this (arg)
+  "Find and mark the next part of the buffer matching the currently active region
+With negative ARG, delete the last one instead.
+With zero ARG, skip the last one and mark next."
+  (interactive "p")
+  (if (region-active-p)
+      (if (< arg 0)
+          (mc/remove-fake-cursor (mc/furthest-cursor-after-point))
+        (mc/mark-more-like-this (= arg 0) 'forwards))
+    (mc/mark-lines arg 'forwards))
+  (mc/maybe-multiple-cursors-mode))
+
+;;;###autoload
+(defun mc/mark-previous-like-this (arg)
+  "Find and mark the previous part of the buffer matching the currently active region
+With negative ARG, delete the last one instead.
+With zero ARG, skip the last one and mark next."
+  (interactive "p")
+  (if (region-active-p)
+      (if (< arg 0)
+          (mc/remove-fake-cursor (mc/furthest-cursor-before-point))
+        (mc/mark-more-like-this (= arg 0) 'backwards))
+    (mc/mark-lines arg 'backwards))
+  (mc/maybe-multiple-cursors-mode))
+
+(defun mc/mark-lines (num-lines direction)
+  (dotimes (i num-lines)
+    (mc/create-fake-cursor-at-point)
+    (ecase direction
+      (forwards (loop do (next-line 1 nil) 
+                      while (mc/all-fake-cursors (point) (1+ (point)))))
+      (backwards (loop do (previous-line 1 nil) 
+                       while (mc/all-fake-cursors (point) (1+ (point))))))))
+
+;;;###autoload
+(defun mc/mark-next-lines (arg)
+  (interactive "p")
+  (mc/mark-lines arg 'forwards)
+  (mc/maybe-multiple-cursors-mode))
+
+;;;###autoload
+(defun mc/mark-previous-lines (arg)
+  (interactive "p")
+  (mc/mark-lines arg 'backwards)
+  (mc/maybe-multiple-cursors-mode))
+
+;;;###autoload
+(defun mc/unmark-next-like-this (arg)
+  "Deselect next part of the buffer matching the currently active region."
+  (interactive)
+  (mc/mark-next-like-this -1))
+
+;;;###autoload
+(defun mc/unmark-previous-like-this (arg)
+  "Deselect prev part of the buffer matching the currently active region."
+  (interactive)
+  (mc/mark-previous-like-this -1))
+
+;;;###autoload
+(defun mc/mark-all-like-this ()
+  "Find and mark all the parts of the buffer matching the currently active region"
+  (interactive)
+  (unless (region-active-p)
+    (error "Mark a region to match first."))
+  (mc/remove-fake-cursors)
+  (let ((master (point))
+        (case-fold-search nil)
+        (point-first (< (point) (mark)))
+        (re (regexp-opt (mc/region-strings))))
+    (mc/save-excursion
+     (goto-char 0)
+     (while (search-forward-regexp re nil t)
+       (push-mark (match-beginning 0))
+       (when point-first (exchange-point-and-mark))
+       (unless (= master (point))
+         (mc/create-fake-cursor-at-point))
+       (when point-first (exchange-point-and-mark)))))
+  (if (> (mc/num-cursors) 1)
+      (multiple-cursors-mode 1)
+    (multiple-cursors-mode 0)))
+
+;;;###autoload
+(defun mc/mark-all-in-region (beg end)
+  "Find and mark all the parts in the region matching the given search"
+  (interactive "r")
+  (let ((search (read-from-minibuffer "Mark all in region: "))
+        (case-fold-search nil))
+    (mc/remove-fake-cursors)
+    (goto-char beg)
+    (while (search-forward search end t)
+      (push-mark (match-beginning 0))
+      (mc/create-fake-cursor-at-point))
+    (let ((first (mc/furthest-cursor-before-point)))
+      (if (not first)
+          (error "Search failed for %S" search)
+        (mc/pop-state-from-overlay first))))
+  (if (> (mc/num-cursors) 1)
+      (multiple-cursors-mode 1)
+    (multiple-cursors-mode 0)))
+
+;;;###autoload
+(defun mc/mark-more-like-this-extended ()
+  "Like mark-more-like-this, but then lets you adjust with arrows key.
+The actual adjustment made depends on the final component of the
+key-binding used to invoke the command, with all modifiers removed:
+
+   <up>    Mark previous like this
+   <down>  Mark next like this
+   <left>  If last was previous, skip it
+           If last was next, remove it
+   <right> If last was next, skip it
+           If last was previous, remove it
+
+Then, continue to read input events and further add or move marks
+as long as the input event read (with all modifiers removed)
+is one of the above."
+  (interactive)
+  (let ((first t)
+        (ev last-command-event)
+        (cmd 'mc/mark-next-like-this)
+        (arg 1)
+        last echo-keystrokes)
+    (while cmd
+      (let ((base (event-basic-type ev)))
+        (cond ((eq base 'left)
+               (if (eq last 'mc/mark-previous-like-this)
+                   (setq cmd last arg 0)
+                 (setq cmd 'mc/mark-next-like-this arg -1)))
+              ((eq base 'up)
+               (setq cmd 'mc/mark-previous-like-this arg 1))
+              ((eq base 'right)
+               (if (eq last 'mc/mark-next-like-this)
+                   (setq cmd last arg 0)
+                 (setq cmd 'mc/mark-previous-like-this arg -1)))
+              ((eq base 'down)
+               (setq cmd 'mc/mark-next-like-this arg 1))
+              (first
+               (setq cmd 'mc/mark-next-like-this arg 1))
+              (t
+               (setq cmd nil))))
+      (when cmd
+        (ignore-errors
+          (funcall cmd arg))
+        (setq first nil last cmd)
+        (setq ev (read-event "Use arrow keys for more marks: "))))
+    (push ev unread-command-events)))
+
+(provide 'mc-mark-more)
+
+;;; mc-mark-more.el ends here

File vendor/multiple-cursors/multiple-cursors-core.el

+;;; multiple-cursors-core.el --- An experiment in multiple cursors for emacs.
+
+;; Copyright (C) 2012 Magnar Sveen
+
+;; Author: Magnar Sveen <magnars@gmail.com>
+;; Keywords: editing cursors
+
+;; 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This file contains the core functionality of multiple-cursors.
+;; Please see multiple-cursors.el for more commentary.
+
+;;; Code:
+
+(eval-when-compile (require 'cl))
+
+(require 'rect)
+
+(defface mc/cursor-face
+  '((t (:inverse-video t)))
+  "The face used for fake cursors"
+  :group 'multiple-cursors)
+
+(defface mc/region-face
+  '((t :inherit region))
+  "The face used for fake regions"
+  :group 'multiple-cursors)
+
+(defmacro mc/add-fake-cursor-to-undo-list (&rest forms)
+  "Make sure point is in the right place when undoing"
+  `(let ((undo-cleaner (cons 'apply (cons 'deactivate-cursor-after-undo (list id)))))
+     (setq buffer-undo-list (cons undo-cleaner buffer-undo-list))
+     ,@forms
+     (if (eq undo-cleaner (car buffer-undo-list)) ;; if nothing has been added to the undo-list
+         (setq buffer-undo-list (cdr buffer-undo-list)) ;; then pop the cleaner right off again
+       (setq buffer-undo-list ;; otherwise add a function to activate this cursor
+             (cons (cons 'apply (cons 'activate-cursor-for-undo (list id))) buffer-undo-list)))))
+
+(defun mc/all-fake-cursors (&optional start end)
+  (remove-if-not 'mc/fake-cursor-p
+                 (overlays-in (or start (point-min))
+                              (or end   (point-max)))))
+
+(defmacro mc/for-each-fake-cursor (&rest forms)
+  "Runs the body for each fake cursor, bound to the name cursor"
+  `(mapc #'(lambda (cursor) ,@forms)
+         (mc/all-fake-cursors)))
+
+(defmacro mc/save-excursion (&rest forms)
+  "Saves and restores all the state that multiple-cursors cares about."
+  `(let ((current-state (mc/store-current-state-in-overlay
+                         (make-overlay (point) (point) nil nil t))))
+     (overlay-put current-state 'type 'original-cursor)
+     (save-excursion ,@forms)
+     (mc/pop-state-from-overlay current-state)))
+
+(defun mc--compare-by-overlay-start (o1 o2)
+  (< (overlay-start o1) (overlay-start o2)))
+
+(defmacro mc/for-each-cursor-ordered (&rest forms)
+  "Runs the body for each cursor, fake and real, bound to the name cursor"
+  `(let ((real-cursor (mc/create-fake-cursor-at-point)))
+     (mapc #'(lambda (cursor)
+               (when (mc/fake-cursor-p cursor)
+                 ,@forms))
+           (sort (overlays-in (point-min) (point-max)) 'mc--compare-by-overlay-start))
+     (mc/pop-state-from-overlay real-cursor)))
+
+(defmacro mc/save-window-scroll (&rest forms)
+  "Saves and restores the window scroll position"
+  `(let ((p (set-marker (make-marker) (point)))
+         (start (set-marker (make-marker) (window-start)))
+         (hscroll (window-hscroll)))
+     ,@forms
+     (goto-char p)
+     (set-window-start nil start)
+     (set-window-hscroll nil hscroll)
+     (set-marker p nil)
+     (set-marker start nil)))
+
+(defun mc/make-cursor-overlay-at-eol (pos)
+  "Create overlay to look like cursor at end of line."
+  (let ((overlay (make-overlay pos pos nil nil nil)))
+    (overlay-put overlay 'after-string (propertize " " 'face 'mc/cursor-face))
+    overlay))
+
+(defun mc/make-cursor-overlay-inline (pos)
+  "Create overlay to look like cursor inside text."
+  (let ((overlay (make-overlay pos (1+ pos) nil nil nil)))
+    (overlay-put overlay 'face 'mc/cursor-face)
+    overlay))
+
+(defun mc/make-cursor-overlay-at-point ()
+  "Create overlay to look like cursor.
+Special case for end of line, because overlay over a newline
+highlights the entire width of the window."
+  (if (eolp)
+      (mc/make-cursor-overlay-at-eol (point))
+    (mc/make-cursor-overlay-inline (point))))
+
+(defun mc/make-region-overlay-between-point-and-mark ()
+  "Create overlay to look like active region."
+  (let ((overlay (make-overlay (mark) (point) nil nil t)))
+    (overlay-put overlay 'face 'mc/region-face)
+    (overlay-put overlay 'type 'additional-region)
+    overlay))
+
+(defun mc/store-current-state-in-overlay (o)
+  "Store relevant info about point and mark in the given overlay."
+  (overlay-put o 'point (set-marker (make-marker) (point)))
+  (overlay-put o 'kill-ring kill-ring)
+  (overlay-put o 'kill-ring-yank-pointer kill-ring-yank-pointer)
+  (overlay-put o 'mark (set-marker (make-marker) (mark)))
+  (overlay-put o 'mark-ring mark-ring)
+  (overlay-put o 'mark-active mark-active)
+  (overlay-put o 'yank-undo-function yank-undo-function)
+  (overlay-put o 'kill-ring-yank-pointer kill-ring-yank-pointer)
+  (when (boundp 'er/history) (overlay-put o 'er/history er/history))
+  o)
+
+(defun mc/restore-state-from-overlay (o)
+  "Restore point and mark from stored info in the given overlay."
+  (goto-char (overlay-get o 'point))
+  (setq kill-ring (overlay-get o 'kill-ring))
+  (setq kill-ring-yank-pointer (overlay-get o 'kill-ring-yank-pointer))
+  (set-marker (mark-marker) (overlay-get o 'mark))
+  (setq mark-ring (overlay-get o 'mark-ring))
+  (setq mark-active (overlay-get o 'mark-active))
+  (setq yank-undo-function (overlay-get o 'yank-undo-function))
+  (setq kill-ring-yank-pointer (overlay-get o 'kill-ring-yank-pointer))
+  (when (boundp 'er/history) (setq er/history (overlay-get o 'er/history))))
+
+(defun mc/remove-fake-cursor (o)
+  "Delete overlay with state, including dependent overlays and markers."
+  (set-marker (overlay-get o 'point) nil)
+  (set-marker (overlay-get o 'mark) nil)
+  (mc/delete-region-overlay o)
+  (delete-overlay o))
+
+(defun mc/pop-state-from-overlay (o)
+  "Restore the state stored in given overlay and then remove the overlay."
+  (mc/restore-state-from-overlay o)
+  (mc/remove-fake-cursor o))
+
+(defun mc/delete-region-overlay (o)
+  "Remove the dependent region overlay for a given cursor overlay."
+  (ignore-errors
+    (delete-overlay (overlay-get o 'region-overlay))))
+
+(defvar mc--current-cursor-id 0
+  "Var to store increasing id of fake cursors, used to keep track of them for undo.")
+
+(defun mc/create-cursor-id ()
+  "Returns a unique cursor id"
+  (incf mc--current-cursor-id))
+
+(defun mc/create-fake-cursor-at-point (&optional id)
+  "Add a fake cursor and possibly a fake active region overlay based on point and mark.
+Saves the current state in the overlay to be restored later."
+  (let ((overlay (mc/make-cursor-overlay-at-point)))
+    (overlay-put overlay 'mc-id (or id (mc/create-cursor-id)))
+    (overlay-put overlay 'type 'fake-cursor)
+    (overlay-put overlay 'priority 100)
+    (mc/store-current-state-in-overlay overlay)
+    (when (use-region-p)
+      (overlay-put overlay 'region-overlay
+                   (mc/make-region-overlay-between-point-and-mark)))
+    overlay))
+
+(defun mc/execute-command (cmd)
+  "Run command, simulating the parts of the command loop that makes sense for fake cursors."
+  (setq this-command cmd)
+  (run-hooks 'pre-command-hook)
+  (unless (eq this-command 'ignore)
+    (call-interactively cmd))
+  (when deactivate-mark (deactivate-mark)))
+
+(defvar mc--executing-command-for-fake-cursor nil)
+
+(defun mc/execute-command-for-all-fake-cursors (cmd)
+  "Calls CMD interactively for each cursor.
+It works by moving point to the fake cursor, setting
+up the proper environment, and then removing the cursor.
+After executing the command, it sets up a new fake
+cursor with updated info."
+  (mc/save-excursion
+   (mc/save-window-scroll
+    (mc/for-each-fake-cursor
+     (save-excursion
+       (let ((mc--executing-command-for-fake-cursor t)
+             (id (overlay-get cursor 'mc-id))
+             (annoying-arrows-mode nil)
+             (smooth-scroll-margin 0))
+         (mc/add-fake-cursor-to-undo-list
+          (mc/pop-state-from-overlay cursor)
+          (ignore-errors
+            (mc/execute-command cmd)
+            (mc/create-fake-cursor-at-point id))))))))
+  (mc--reset-read-prompts))
+
+;; Intercept some reading commands so you won't have to
+;; answer them for every single cursor
+
+(defadvice read-char (around mc-support activate)
+  (if (not multiple-cursors-mode)
+      ad-do-it
+    (unless mc--read-char
+      (setq mc--read-char ad-do-it))
+    (setq ad-return-value mc--read-char)))
+
+(defadvice read-quoted-char (around mc-support activate)
+  (if (not multiple-cursors-mode)
+      ad-do-it
+    (unless mc--read-quoted-char
+      (setq mc--read-quoted-char ad-do-it))
+    (setq ad-return-value mc--read-quoted-char)))
+
+(defun mc--reset-read-prompts ()
+  (setq mc--read-char nil)
+  (setq mc--read-quoted-char nil))
+
+(mc--reset-read-prompts)
+
+(defun mc/fake-cursor-p (o)
+  "Predicate to check if an overlay is a fake cursor"
+  (eq (overlay-get o 'type) 'fake-cursor))
+
+(defun mc/cursor-with-id (id)
+  "Find the first cursor with the given id, or nil"
+  (find-if #'(lambda (o) (and (mc/fake-cursor-p o)
+                              (= id (overlay-get o 'mc-id))))
+           (overlays-in (point-min) (point-max))))
+
+(defvar mc--stored-state-for-undo nil
+  "Variable to keep the state of the real cursor while undoing a fake one")
+
+(defun activate-cursor-for-undo (id)
+  "Called when undoing to temporarily activate the fake cursor which action is being undone."
+  (let ((cursor (mc/cursor-with-id id)))
+    (when cursor
+      (setq mc--stored-state-for-undo (mc/store-current-state-in-overlay
+                                       (make-overlay (point) (point) nil nil t)))
+      (mc/pop-state-from-overlay cursor))))
+
+(defun deactivate-cursor-after-undo (id)
+  "Called when undoing to reinstate the real cursor after undoing a fake one."
+  (when mc--stored-state-for-undo
+    (mc/create-fake-cursor-at-point id)
+    (mc/pop-state-from-overlay mc--stored-state-for-undo)
+    (setq mc--stored-state-for-undo nil)))
+
+(defun mc/prompt-for-inclusion-in-whitelist (original-command)
+  "Asks the user, then adds the command either to the once-list or the all-list."
+  (let ((all-p (y-or-n-p (format "Do %S for all cursors?" original-command))))
+    (if all-p
+        (add-to-list 'mc/cmds-to-run-for-all original-command)
+      (add-to-list 'mc/cmds-to-run-once original-command))
+    (mc/save-lists)
+    all-p))
+
+(defun mc/num-cursors ()
+  "The number of cursors (real and fake) in the buffer."
+  (1+ (count-if 'mc/fake-cursor-p
+                (overlays-in (point-min) (point-max)))))
+
+(defvar mc--this-command nil
+  "Used to store the original command being run.")
+(make-variable-buffer-local 'mc--this-command)
+
+(defun mc/make-a-note-of-the-command-being-run ()
+  "Used with pre-command-hook to store the original command being run.
+Since that cannot be reliably determined in the post-command-hook.
+
+Specifically, this-original-command isn't always right, because it could have
+been remapped. And certain modes (cua comes to mind) will change their
+remapping based on state. So a command that changes the state will afterwards
+not be recognized through the command-remapping lookup."
+  (unless mc--executing-command-for-fake-cursor
+    (setq mc--this-command (or (command-remapping this-original-command)
+                               this-original-command))))
+
+(defun mc/execute-this-command-for-all-cursors ()
+  "Wrap around `mc/execute-this-command-for-all-cursors-1' to protect hook."
+  (condition-case error
+      (mc/execute-this-command-for-all-cursors-1)
+    (error
+     (message "[mc] problem in `mc/execute-this-command-for-all-cursors': %s"
+              (error-message-string error)))))
+
+;; execute-kbd-macro should never be run for fake cursors. The real cursor will
+;; execute the keyboard macro, resulting in new commands in the command loop,
+;; and the fake cursors can pick up on those instead.
+(defadvice execute-kbd-macro (around skip-fake-cursors activate)
+  (unless mc--executing-command-for-fake-cursor
+    ad-do-it))
+
+(defun mc/execute-this-command-for-all-cursors-1 ()
+  "Used with post-command-hook to execute supported commands for all cursors.
+
+It uses two lists of commands to know what to do: the run-once
+list and the run-for-all list. If a command is in neither of these lists,
+it will prompt for the proper action and then save that preference.
+
+Some commands are so unsupported that they are even prevented for
+the original cursor, to inform about the lack of support."
+  (unless mc--executing-command-for-fake-cursor
+
+   (if (eq 1 (mc/num-cursors)) ;; no fake cursors? disable mc-mode
+       (multiple-cursors-mode 0)
+
+     (when this-original-command
+       (let ((original-command (or mc--this-command
+                                   (command-remapping this-original-command)
+                                   this-original-command)))
+
+         ;; skip keyboard macros, since they will generate actual commands that are
+         ;; also run in the command loop - we'll handle those later instead.
+         (when (functionp original-command)
+
+           ;; if it's a lambda, we can't know if it's supported or not
+           ;; - so go ahead and assume it's ok, because we're just optimistic like that
+           (if (not (symbolp original-command))
+               (mc/execute-command-for-all-fake-cursors original-command)
+
+             ;; otherwise it's a symbol, and we can be more thorough
+             (if (get original-command 'mc--unsupported)
+                 (message "%S is not supported with multiple cursors%s"
+                          original-command
+                          (get original-command 'mc--unsupported))
+               (when (and original-command
+                          (not (memq original-command mc--default-cmds-to-run-once))
+                          (not (memq original-command mc/cmds-to-run-once))
+                          (or (memq original-command mc--default-cmds-to-run-for-all)
+                              (memq original-command mc/cmds-to-run-for-all)
+                              (mc/prompt-for-inclusion-in-whitelist original-command)))
+                 (mc/execute-command-for-all-fake-cursors original-command))))))))))
+
+(defun mc/remove-fake-cursors ()
+  "Remove all fake cursors.
+Do not use to conclude editing with multiple cursors. For that
+you should disable multiple-cursors-mode."
+  (mc/for-each-fake-cursor
+   (mc/remove-fake-cursor cursor)))
+
+(defun mc/keyboard-quit ()
+  "Deactivate mark if there are any active, otherwise exit multiple-cursors-mode."
+  (interactive)
+  (if (not (use-region-p))
+      (multiple-cursors-mode 0)
+    (deactivate-mark)))
+
+(defvar mc/keymap nil
+  "Keymap while multiple cursors are active.
+Main goal of the keymap is to rebind C-g and <return> to conclude
+multiple cursors editing.")
+(if mc/keymap
+    nil
+  (setq mc/keymap (make-sparse-keymap))
+  (define-key mc/keymap (kbd "C-g") 'mc/keyboard-quit)
+  (define-key mc/keymap (kbd "<return>") 'multiple-cursors-mode))
+
+(defun mc--all-equal (entries)
+  "Are all these entries equal?"
+  (let ((first (car entries))
+        (all-equal t))
+    (while (and all-equal entries)
+      (setq all-equal (equal first (car entries)))
+      (setq entries (cdr entries)))
+    all-equal))
+
+(defun mc--kill-ring-entries ()
+  "Return the latest kill-ring entry for each cursor.
+The entries are returned in the order they are found in the buffer."
+  (let (entries)
+    (mc/for-each-cursor-ordered
+     (setq entries (cons (car (overlay-get cursor 'kill-ring)) entries)))
+    (reverse entries)))
+
+(defun mc--maybe-set-killed-rectangle ()
+  "Add the latest kill-ring entry for each cursor to killed-rectangle.
+So you can paste it in later with `yank-rectangle'."
+  (let ((entries (mc--kill-ring-entries)))
+    (unless (mc--all-equal entries)
+      (setq killed-rectangle entries))))
+
+(defvar mc/unsupported-minor-modes '(auto-complete-mode)
+  "List of minor-modes that does not play well with multiple-cursors.
+They are temporarily disabled when multiple-cursors are active.")
+
+(defvar mc/temporarily-disabled-minor-modes nil
+  "The list of temporarily disabled minor-modes.")
+(make-variable-buffer-local 'mc/temporarily-disabled-minor-modes)
+
+(defun mc/temporarily-disable-minor-mode (mode)
+  "If MODE is available and turned on, remember that and turn it off."
+  (when (and (boundp mode) (eval mode))
+    (add-to-list 'mc/temporarily-disabled-minor-modes mode)
+    (funcall mode -1)))
+
+(defun mc/temporarily-disable-unsupported-minor-modes ()
+  (mapc 'mc/temporarily-disable-minor-mode mc/unsupported-minor-modes))
+
+(defun mc/enable-minor-mode (mode)
+  (funcall mode 1))
+
+(defun mc/enable-temporarily-disabled-minor-modes ()
+  (mapc 'mc/enable-minor-mode mc/temporarily-disabled-minor-modes)
+  (setq mc/temporarily-disabled-minor-modes nil))
+
+(defcustom mc/mode-line