1. Fuco
  2. .emacs.d

Commits

Fuco  committed 7260145

Multiple cursors are now a package in elpa.

  • Participants
  • Parent commits 1825d53
  • Branches default

Comments (0)

Files changed (13)

File autoinstall.el

View file
  • Ignore whitespace
     markdown-mode
     markdown-mode+
     multi-web-mode
+    multiple-cursors
     parenface
     php-mode
     rainbow-mode

File files/defuns-edit.el

View file
  • Ignore whitespace
       (if (= (point) eoc)
           (end-of-line-lov)
         (goto-char eoc)))))
-
-(defun mc/mark-all-like-this-dwim (arg)
-  "Uses some sane defaults to guess what the user want to do:
-
-- If inside a defun, find and mark all the parts of current defun matchign
-the currently active region. If no region is active, activate the word
-under cursor.
-- If in SGML/HTML mode and inside a tag, select the tag and its pair
-
-With prefix, it behaves the same as original `mc/mark-all-like-this'"
-  (interactive "P")
-  (if arg
-      (mc/mark-all-like-this)
-    (let ((mode (with-current-buffer (current-buffer) major-mode)))
-      (cond ((and (member mode '(sgml-mode html-mode))
-                  (mc/mark-tags)) t)
-            ((bounds-of-thing-at-point 'defun)
-             (mc/select-under-cursor)
-             (save-restriction
-               (widen)
-               (narrow-to-defun)
-               (mc/mark-all-like-this)))
-            (t (mc/select-under-cursor) (mc/mark-all-like-this))))))
-
-(defun mc/select-under-cursor ()
-  "Select the word under cursor"
-  (interactive)
-  (when (not (use-region-p))
-    (let ((b (bounds-of-thing-at-point 'word)))
-      (goto-char (car b))
-      (set-mark (cdr b)))))
-
-(defun mc/mark-tags ()
-  "Mark the tag we're in and its pair for renaming."
-  (interactive)
-  (let ((context (car (last (save-excursion (sgml-get-context))))))
-    (when (and context
-               (> (point) (aref context 2))
-               (< (point) (aref context 3)))
-      (let* ((tag-position (aref context 1))
-             (tag-length (length (aref context 4)))
-             (main-start (- (aref context 3) 1 tag-length))
-             (mirror-start (save-excursion
-                             (if (eq tag-position 'open)
-                                 (sgml-skip-tag-forward 1)
-                               (sgml-skip-tag-backward 1)
-                               (forward-sexp))
-                             (- (point) 1 tag-length))))
-        (goto-char main-start)
-        (set-mark (+ main-start tag-length))
-        (mc/save-excursion (goto-char mirror-start)
-                           (push-mark (+ mirror-start tag-length))
-                           (mc/create-fake-cursor-at-point))
-        (mc/maybe-multiple-cursors-mode)))))
-
-;; not finished!
-(defun mc/tex-get-pair ()
-  "Get the pair of the currently selected begin/end tag"
-  (interactive)
-  ;;  (save-excursion
-  (skip-chars-backward "{A-Za-z0-9")
-  (forward-char -1)
-  (cond ((looking-at "\\\\begin{.*?}")
-         (forward-char 1)
-         (skip-chars-forward "A-Za-z0-9")
-         (forward-char)
-         (set-mark (point))
-         (skip-chars-forward "A-Za-z0-9"))
-        (t
-         (error "Not inside \\begin{...}"))
-
-        ;;   )
-        ))

File files/keys.el

View file
  • Ignore whitespace
 (global-set-key (kbd "C-<i-key>") 'backward-kill-word)
 (global-set-key (kbd "C-<backspace>") 'my-kill-whitespace)
 
+;;;;; multiple cursors
+(global-set-key (kbd "C-c C-S-c") 'mc/edit-lines)
+(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-dwim)
+(global-set-key (kbd "H-SPC") 'set-rectangular-region-anchor)
+
 ;; keys for specific modes
 (defun add-html-binding ()
   (define-key (current-local-map) (kbd "C-c <deletechar>") 'sgml-delete-tag))

File files/multiple-cursors.el

  • Ignore whitespace
-(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-dwim)
-
-
-;; 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 init.el

View file
  • Ignore whitespace
 (vendor 'revbufs 'revbufs)
 (vendor 'shell-pop 'shell-pop)
 (vendor 'golden-ratio)
-(vendor 'multiple-cursors)
 (vendor 'iy-go-to-char 'iy-go-to-char 'iy-go-to-char-backward)
 (vendor 'sunrise-commander)
 (vendor 'smart-forward 'smart-forward 'smart-backward 'smart-up 'smart-down)

File vendor/multiple-cursors/README.md

  • Ignore whitespace
-# 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

  • Ignore whitespace
-;;; 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

  • Ignore whitespace
-;;; 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

  • Ignore whitespace
-;;; 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

  • Ignore whitespace
-;;; 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
-  `(" mc:" (:eval (format ,(propertize "%d" 'face 'font-lock-warning-face)
-                          (mc/num-cursors))))
-  "What to display in the mode line while multiple-cursors-mode is active."
-  :group 'multiple-cursors)
-(put 'mc/mode-line 'risky-local-variable t)
-
-(define-minor-mode multiple-cursors-mode
-  "Mode while multiple cursors are active."
-  nil mc/mode-line mc/keymap
-  (if multiple-cursors-mode
-      (progn
-        (mc/temporarily-disable-unsupported-minor-modes)
-        (add-hook 'pre-command-hook 'mc/make-a-note-of-the-command-being-run nil t)
-        (add-hook 'post-command-hook 'mc/execute-this-command-for-all-cursors t t)
-        (run-hooks 'multiple-cursors-mode-enabled-hook))
-    (remove-hook 'post-command-hook 'mc/execute-this-command-for-all-cursors t)
-    (remove-hook 'pre-command-hook 'mc/make-a-note-of-the-command-being-run t)
-    (setq mc--this-command nil)
-    (mc--maybe-set-killed-rectangle)
-    (mc/remove-fake-cursors)
-    (mc/enable-temporarily-disabled-minor-modes)
-    (run-hooks 'multiple-cursors-mode-disabled-hook)))
-
-(add-hook 'after-revert-hook #'(lambda () (multiple-cursors-mode 0)))
-
-(defmacro unsupported-cmd (cmd msg)
-  "Adds command to list of unsupported commands and prevents it
-from being executed if in multiple-cursors-mode."
-  `(progn
-     (put (quote ,cmd) 'mc--unsupported ,msg)
-     (defadvice ,cmd (around unsupported-advice activate)
-       "command isn't supported with multiple cursors"
-       (unless (and multiple-cursors-mode (called-interactively-p 'any))
-         ad-do-it))))
-
-;; Commands that does not work with multiple-cursors
-(unsupported-cmd isearch-forward ". Feel free to add a compatible version.")
-(unsupported-cmd isearch-backward ". Feel free to add a compatible version.")
-
-;; Make sure pastes from other programs are added to all kill-rings when yanking
-(defadvice current-kill (before interprogram-paste-for-all-cursors activate)
-  (let ((interprogram-paste (and (= n 0)
-                                 interprogram-paste-function
-                                 (funcall interprogram-paste-function))))
-    (when interprogram-paste
-      ;; Add interprogram-paste to normal kill ring, just
-      ;; like current-kill usually does for itself.
-      ;; We have to do the work for it tho, since the funcall only returns
-      ;; something once. It is not a pure function.
-      (let ((interprogram-cut-function nil))
-        (if (listp interprogram-paste)
-            (mapc 'kill-new (nreverse interprogram-paste))
-          (kill-new interprogram-paste))
-        ;; And then add interprogram-paste to the kill-rings
-        ;; of all the other cursors too.
-        (mc/for-each-fake-cursor
-         (let ((kill-ring (overlay-get cursor 'kill-ring))
-               (kill-ring-yank-pointer (overlay-get cursor 'kill-ring-yank-pointer)))
-           (if (listp interprogram-paste)
-               (mapc 'kill-new (nreverse interprogram-paste))
-             (kill-new interprogram-paste))
-           (overlay-put cursor 'kill-ring kill-ring)
-           (overlay-put cursor 'kill-ring-yank-pointer kill-ring-yank-pointer)))))))
-
-(defvar mc/list-file "~/.emacs.d/.mc-lists.el"
-  "The position of the file that keeps track of your preferences
-for running commands with multiple cursors.")
-
-(defun mc/dump-list (list-symbol)
-  "Insert (setq 'LIST-SYMBOL LIST-VALUE) to current buffer."
-  (let ((value (symbol-value list-symbol)))
-    (insert "(setq " (symbol-name list-symbol) "\n"
-            "      '(")
-    (newline-and-indent)
-    (mapc #'(lambda (cmd) (insert (format "%S" cmd)) (newline-and-indent))
-          (sort value (lambda (x y) (string-lessp (symbol-name x)
-                                                  (symbol-name y)))))
-    (insert "))")
-    (newline)))
-
-(defun mc/save-lists ()
-  "Saves preferences for running commands with multiple cursors to `mc/list-file'"
-  (with-temp-file mc/list-file
-    (emacs-lisp-mode)
-    (insert ";; This file is automatically generated by the multiple-cursors extension.")
-    (newline)
-    (insert ";; It keeps track of your preferences for running commands with multiple cursors.")
-    (newline)
-    (newline)
-    (mc/dump-list 'mc/cmds-to-run-for-all)
-    (newline)
-    (mc/dump-list 'mc/cmds-to-run-once)))
-
-(defvar mc/cmds-to-run-once nil
-  "Commands to run only once in multiple-cursors-mode.")
-
-(defvar mc--default-cmds-to-run-once nil
-  "Default set of commands to run only once in multiple-cursors-mode.")
-
-(setq mc--default-cmds-to-run-once '(mc/edit-lines
-                                     mc/edit-ends-of-lines
-                                     mc/edit-beginnings-of-lines
-                                     mc/mark-next-like-this
-                                     mc/mark-previous-like-this
-                                     mc/mark-more-like-this-extended
-                                     mc/mark-all-like-this
-                                     mc/cycle-forward
-                                     mc/cycle-backward
-                                     rrm/switch-to-multiple-cursors
-                                     save-buffer
-                                     ido-exit-minibuffer
-                                     exit-minibuffer
-                                     minibuffer-complete-and-exit
-                                     execute-extended-command
-                                     undo
-                                     redo
-                                     undo-tree-undo
-                                     undo-tree-redo
-                                     universal-argument
-                                     universal-argument-more
-                                     universal-argument-other-key
-                                     negative-argument
-                                     digit-argument
-                                     top-level
-                                     recenter-top-bottom
-                                     describe-mode
-                                     describe-key-1
-                                     describe-function
-                                     describe-bindings
-                                     describe-prefix-bindings
-                                     other-window
-                                     kill-buffer-and-window
-                                     split-window-right
-                                     split-window-below
-                                     delete-other-windows
-                                     toggle-window-split
-                                     mwheel-scroll
-                                     mouse-set-point
-                                     mouse-drag-region
-                                     quit-window
-                                     toggle-read-only
-                                     windmove-left
-                                     windmove-right
-                                     windmove-up
-                                     windmove-down))
-
-(defvar mc--default-cmds-to-run-for-all nil
-  "Default set of commands that should be mirrored by all cursors")
-
-(setq mc--default-cmds-to-run-for-all '(mc/keyboard-quit
-                                        self-insert-command
-                                        quoted-insert
-                                        previous-line
-                                        next-line
-                                        newline
-                                        newline-and-indent
-                                        open-line
-                                        delete-blank-lines
-                                        transpose-chars
-                                        transpose-lines
-                                        transpose-paragraphs
-                                        transpose-regions
-                                        join-line
-                                        right-char
-                                        right-word
-                                        forward-char
-                                        forward-word
-                                        left-char
-                                        left-word
-                                        backward-char
-                                        backward-word
-                                        forward-paragraph
-                                        backward-paragraph
-                                        upcase-word
-                                        downcase-word
-                                        capitalize-word
-                                        forward-list
-                                        backward-list
-                                        hippie-expand
-                                        hippie-expand-lines
-                                        yank
-                                        yank-pop
-                                        append-next-kill
-                                        kill-word
-                                        kill-line
-                                        kill-whole-line
-                                        backward-kill-word
-                                        backward-delete-char-untabify
-                                        delete-char delete-forward-char
-                                        delete-backward-char
-                                        just-one-space
-                                        zap-to-char
-                                        end-of-line
-                                        set-mark-command
-                                        exchange-point-and-mark
-                                        cua-set-mark
-                                        cua-replace-region
-                                        move-end-of-line
-                                        beginning-of-line
-                                        move-beginning-of-line
-                                        kill-ring-save
-                                        back-to-indentation
-                                        subword-forward
-                                        subword-backward
-                                        subword-mark
-                                        subword-kill
-                                        subword-backward-kill
-                                        subword-transpose
-                                        subword-capitalize
-                                        subword-upcase
-                                        subword-downcase
-                                        er/expand-region
-                                        er/contract-region
-                                        smart-forward
-                                        smart-backward
-                                        smart-up
-                                        smart-down))
-
-(defvar mc/cmds-to-run-for-all nil
-  "Commands to run for all cursors in multiple-cursors-mode")
-
-(load mc/list-file t) ;; load, but no errors if it does not exist yet please
-
-(provide 'multiple-cursors-core)
-
-;;; multiple-cursors-core.el ends here

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

  • Ignore whitespace
-(define-package "multiple-cursors" "1.1.3"
-                "Multiple cursors for Emacs.")

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

  • Ignore whitespace
-;;; multiple-cursors.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:
-
-;; 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)
-;;
-;; 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`.
-;;
-;;
-;; ## 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.
-;;
-;; 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`.
-;;
-;;
-;; ## 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
-;;
-;;; Code:
-
-(require 'mc-edit-lines)
-(require 'mc-cycle-cursors)
-(require 'mc-mark-more)
-(require 'rectangular-region-mode)
-
-(provide 'multiple-cursors)
-
-;;; multiple-cursors.el ends here

File vendor/multiple-cursors/rectangular-region-mode.el

  • Ignore whitespace
-;;; rectangular-region-mode.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:
-
-;; (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.
-
-;;; Code:
-
-(require 'multiple-cursors-core)
-
-(defvar rrm/anchor (make-marker)
-  "The position in the buffer that anchors the rectangular region.")
-
-(defvar rectangular-region-mode-map (make-sparse-keymap)
-  "Keymap for rectangular region is mainly for rebinding C-g")
-
-(define-key rectangular-region-mode-map (kbd "C-g") 'rrm/keyboard-quit)
-(define-key rectangular-region-mode-map (kbd "<return>") 'rrm/switch-to-multiple-cursors)
-
-(defun rrm/keyboard-quit ()
-  "Exit rectangular-region-mode."
-  (interactive)
-  (rectangular-region-mode 0)
-  (rrm/remove-rectangular-region-overlays)
-  (deactivate-mark))
-
-;; Bind this to a key (for instance H-SPC) to start rectangular-region-mode
-;;;###autoload
-(defun set-rectangular-region-anchor ()
-  "Anchors the rectangular region at point.
-
-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."
-  (interactive)
-  (set-marker rrm/anchor (point))
-  (push-mark (point))
-  (rectangular-region-mode 1))
-
-(defun rrm/remove-rectangular-region-overlays ()
-  "Remove all rectangular-region overlays."
-  (mc/remove-fake-cursors)
-  (mapc #'(lambda (o)
-            (when (eq (overlay-get o 'type) 'additional-region)
-              (delete-overlay o)))
-        (overlays-in (point-min) (point-max))))
-
-(defun rrm/repaint ()
-  "Start from the anchor and draw a rectangle between it and point."
-  (rrm/remove-rectangular-region-overlays)
-  (let* ((annoying-arrows-mode nil)
-         (point-column (current-column))
-         (point-line (line-number-at-pos))
-         (anchor-column (save-excursion (goto-char rrm/anchor) (current-column)))
-         (anchor-line (save-excursion (goto-char rrm/anchor) (line-number-at-pos)))
-         (left-column (if (< point-column anchor-column) point-column anchor-column))
-         (right-column (if (> point-column anchor-column) point-column anchor-column))
-         (navigation-step (if (< point-line anchor-line) 1 -1)))
-    (move-to-column anchor-column)
-    (set-mark (point))
-    (move-to-column point-column)
-    (mc/save-excursion
-     (while (not (= anchor-line (line-number-at-pos)))
-       (forward-line navigation-step)
-       (move-to-column anchor-column)
-       (when (= anchor-column (current-column))
-         (set-mark (point))
-         (move-to-column point-column)
-         (when (= point-column (current-column))
-           (mc/create-fake-cursor-at-point)))))))
-
-(defun rrm/switch-to-multiple-cursors (&rest forms)
-  "Switch from rectangular-region-mode to multiple-cursors-mode."
-  (interactive)
-  (rectangular-region-mode 0)
-  (multiple-cursors-mode 1))
-
-(defadvice er/expand-region (before switch-from-rrm-to-mc activate)
-  (when rectangular-region-mode
-    (rrm/switch-to-multiple-cursors)))
-
-(defadvice kill-ring-save (before switch-from-rrm-to-mc activate)
-  (when rectangular-region-mode
-    (rrm/switch-to-multiple-cursors)))
-
-(define-minor-mode rectangular-region-mode
-  "A mode for creating a rectangular region to edit"
-  nil " rr" rectangular-region-mode-map
-  (if rectangular-region-mode
-      (progn
-        (add-hook 'after-change-functions 'rrm/switch-to-multiple-cursors t t)
-        (add-hook 'post-command-hook 'rrm/repaint t t))
-    (remove-hook 'after-change-functions 'rrm/switch-to-multiple-cursors t)
-    (remove-hook 'post-command-hook 'rrm/repaint t)
-    (set-marker rrm/anchor nil)))
-
-(provide 'rectangular-region-mode)
-
-;;; rectangular-region-mode.el ends here