mirror of
https://github.com/magnars/multiple-cursors.el.git
synced 2026-05-10 01:18:19 +00:00
Compare commits
60 Commits
1.4.0
...
cl-tidy-up
| Author | SHA1 | Date | |
|---|---|---|---|
| 48e1d3da5c | |||
| 1f3ccfbcd2 | |||
| 7763f4f9d7 | |||
| 6a04a147ce | |||
| b880554d04 | |||
| b9b851a767 | |||
| b39e9631d6 | |||
| 5ffb19af48 | |||
| a730c414b1 | |||
| fc6a6a7462 | |||
| d27870dff3 | |||
| 5ff2071fac | |||
| 9980faa21f | |||
| 6a7c3c0853 | |||
| 8172edd05a | |||
| 3f382d2c8f | |||
| 9c49874fa4 | |||
| 038815b2b9 | |||
| 75dd6bf83a | |||
| 35ff8b5ef1 | |||
| e419903612 | |||
| 0e49fecc18 | |||
| eba10208fc | |||
| f628df72a1 | |||
| 1075270008 | |||
| e048e04bd8 | |||
| 6f183a1e82 | |||
| f33cdd4935 | |||
| 18f992bff5 | |||
| f6bac949a0 | |||
| e14fdb77a1 | |||
| d2766bc215 | |||
| c94566597a | |||
| 7cb18b8aec | |||
| fa91dfb9bd | |||
| ddbe3ae932 | |||
| 616fd84891 | |||
| 632768113d | |||
| 277aef4f0b | |||
| dfaf6215fc | |||
| 95f2e41fab | |||
| 8e59a8a226 | |||
| 6d8c6fcc83 | |||
| 67d6579eab | |||
| 21e48250ec | |||
| ad95d287c7 | |||
| 60b9ef8347 | |||
| d9a6047d1a | |||
| 8413969a97 | |||
| 2ccfc74bf4 | |||
| d26cecd53a | |||
| 2329611a41 | |||
| fd847ae6e7 | |||
| be149f9121 | |||
| 3112e61824 | |||
| a508978cd9 | |||
| a9daac129a | |||
| 741eec6766 | |||
| be4fbc702e | |||
| 1686630fd6 |
@@ -1,2 +1,3 @@
|
||||
elpa
|
||||
*.elc
|
||||
/.ecukes-failing-scenarios
|
||||
|
||||
@@ -1,14 +1,31 @@
|
||||
# multiple-cursors.el [](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
|
||||
there are kinks. Don't be afraid though, I've been using it since 2011 with
|
||||
great success and much merriment.
|
||||
|
||||
## Maintenance warning
|
||||
|
||||
I use this package every day, and have been doing so for years. It just works.
|
||||
At least, it works for all my use cases. And if it breaks somehow, I fix it.
|
||||
|
||||
However, it has become painfully clear to me that I don't have time to fix
|
||||
problems I don't have. It's been years since I could keep pace with the issues
|
||||
and pull requests. Whenever I try, I keep getting feedback that my fix isn't
|
||||
good enough by some standard I don't particularly care about.
|
||||
|
||||
So, I have closed the issue tracker and the pull requests. I hope you can
|
||||
happily use this package, just like I do. If it doesn't work for you, then I'm
|
||||
sorry. Thankfully Emacs is infinitely malleable, you can probably fix it
|
||||
yourself.
|
||||
|
||||
TLDR: *I am still maintaining this package*, but I am no longer crowdsourcing a list of issues.
|
||||
|
||||
## Installation
|
||||
|
||||
I highly recommend installing multiple-cursors through `package.el`.
|
||||
|
||||
It's available on [melpa](http://melpa.milkbox.net/):
|
||||
It's available on [MELPA](http://melpa.org/) and [MELPA Stable](http://stable.melpa.org):
|
||||
|
||||
M-x package-install multiple-cursors
|
||||
|
||||
@@ -43,6 +60,10 @@ 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`.
|
||||
|
||||
## Important note
|
||||
|
||||
Multiple cursors does not do well when you invoke its commands with `M-x`. It needs to be bound to keys to work properly. Pull request to fix this is welcome.
|
||||
|
||||
## Video
|
||||
|
||||
You can [watch an intro to multiple-cursors at Emacs Rocks](http://emacsrocks.com/e13.html).
|
||||
@@ -57,9 +78,11 @@ You can [watch an intro to multiple-cursors at Emacs Rocks](http://emacsrocks.co
|
||||
- `mc/mark-next-word-like-this`: Like `mc/mark-next-like-this` but only for whole words.
|
||||
- `mc/mark-next-symbol-like-this`: Like `mc/mark-next-like-this` but only for whole symbols.
|
||||
- `mc/mark-previous-like-this`: Adds a cursor and region at the next part of the buffer backwards that matches the current region.
|
||||
- `mc/mark-previous-like-this-word`: Adds a cursor and region at the next part of the buffer backwards that matches the current region, if no region is selected it selects the word at the point.
|
||||
- `mc/mark-previous-like-this-symbol`: Adds a cursor and region at the next part of the buffer backwards that matches the current region, if no region is selected it selects the symbol at the point.
|
||||
- `mc/mark-previous-word-like-this`: Like `mc/mark-previous-like-this` but only for whole words.
|
||||
- `mc/mark-previous-symbol-like-this`: Like `mc/mark-previous-like-this` but only for whole symbols.
|
||||
- `mc/mark-more-like-this-extended`: Use arrow keys to quickly mark/skip next/previous occurances.
|
||||
- `mc/mark-more-like-this-extended`: Use arrow keys to quickly mark/skip next/previous occurrences.
|
||||
- `mc/add-cursor-on-click`: Bind to a mouse event to add cursors by clicking. See tips-section.
|
||||
- `mc/mark-pop`: Set a cursor at the current point and move to the next (different) position on the mark stack. This allows for fine grained control over the placement of cursors.
|
||||
|
||||
@@ -67,9 +90,8 @@ You can [watch an intro to multiple-cursors at Emacs Rocks](http://emacsrocks.co
|
||||
|
||||
- `mc/unmark-next-like-this`: Remove the cursor furthest down in the buffer.
|
||||
- `mc/unmark-previous-like-this`: Remove the cursor furthest up in the buffer.
|
||||
- `mc/skip-to-next-like-this`: Remove the cursor furthest down, marking the next occurance down.
|
||||
- `mc/skip-to-previous-like-this`: Remove the cursor furthest up, marking the next occurance up.
|
||||
- `mc/mark-next-like-this-extended`: Temporarily bind the arrow keys to mark/unmark/skip cursors.
|
||||
- `mc/skip-to-next-like-this`: Remove the cursor furthest down, marking the next occurrence down.
|
||||
- `mc/skip-to-previous-like-this`: Remove the cursor furthest up, marking the next occurrence up.
|
||||
|
||||
### Mark many occurrences
|
||||
|
||||
@@ -100,6 +122,9 @@ You can [watch an intro to multiple-cursors at Emacs Rocks](http://emacsrocks.co
|
||||
first disable multiple regions before disabling multiple cursors. If you want to
|
||||
insert a newline in multiple-cursors-mode, use `C-j`.
|
||||
|
||||
- `(define-key mc/keymap (kbd "<return>") nil)` will make `<return>` insert a
|
||||
newline; multiple-cursors-mode can still be disabled with `C-g`.
|
||||
|
||||
- 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` or you can
|
||||
press `C-'` to hide all lines without a cursor, press `C-'` again to unhide.
|
||||
@@ -109,7 +134,7 @@ You can [watch an intro to multiple-cursors at Emacs Rocks](http://emacsrocks.co
|
||||
|
||||
- Try pressing `mc/mark-next-like-this-word` or
|
||||
`mc/mark-next-like-this-symbol` with no region selected. It will
|
||||
mark the word or symbol and add a cursor at the next occurance
|
||||
mark the word or symbol and add a cursor at the next occurrence
|
||||
|
||||
- Try pressing `mc/mark-all-like-this-dwim` on a tagname in html-mode.
|
||||
|
||||
@@ -157,6 +182,11 @@ the location with:
|
||||
|
||||
NB! Make sure to do so before requiring multiple-cursors.
|
||||
|
||||
It is possible to set multiple-cursors to "run-for-all" for every
|
||||
command except for those that are listed in `mc/cmds-to-run-once`. To
|
||||
enable this set `mc/always-run-for-all` to non-nil. Add commands to be
|
||||
run once to `mc/cmds-to-run-once` in ".mc-lists.el".
|
||||
|
||||
## Known limitations
|
||||
|
||||
* isearch-forward and isearch-backward aren't supported with multiple cursors.
|
||||
@@ -198,12 +228,13 @@ Run the tests with:
|
||||
* [Aleksey Fedotov](https://github.com/lexa) added `mc-hide-unmatched-lines-mode`
|
||||
* [Jules Tamagnan](https://github.com/jtamagnan) added `mc/mark-next-like-this-word` and `mc/mark-next-like-this-symbol`
|
||||
* [Ingo Lohmar](https://github.com/ilohmar) extended `mc/add-cursor-on-click` to toggle cursors.
|
||||
* [Andrea Orru](https://github.com/AndreaOrru) added `mc/mark-previous-like-this-word`/`-symbol`
|
||||
|
||||
Thanks!
|
||||
|
||||
## License
|
||||
|
||||
Copyright (C) 2012 Magnar Sveen
|
||||
Copyright (C) 2012-2016 Magnar Sveen
|
||||
|
||||
Author: Magnar Sveen <magnars@gmail.com>
|
||||
Keywords: editing cursors
|
||||
|
||||
@@ -17,3 +17,24 @@ Feature: Insert increasing numbers
|
||||
When I press "C-u H-0"
|
||||
And I press "SPC"
|
||||
Then I should see "This 4 text contains the word 5 text thrice (6 text)"
|
||||
|
||||
Scenario: Three cursors, 0-1-2, default
|
||||
Given I have cursors at "text" in "This text contains the word text thrice (text)"
|
||||
When I set mc/insert-numbers-default to 1
|
||||
And I press "H-0"
|
||||
And I press "SPC"
|
||||
Then I should see "This 1 text contains the word 2 text thrice (3 text)"
|
||||
|
||||
Scenario: Three cursors, 9-10-11, default
|
||||
Given I have cursors at "text" in "This text contains the word text thrice (text)"
|
||||
When I set mc/insert-numbers-default to 1
|
||||
And I press "C-9 H-0"
|
||||
And I press "SPC"
|
||||
Then I should see "This 9 text contains the word 10 text thrice (11 text)"
|
||||
|
||||
Scenario: Three cursors, 9-10-11, default
|
||||
Given I have cursors at "text" in "This text contains the word text thrice (text)"
|
||||
When I set mc/insert-numbers-default to 1
|
||||
And I press "C-u H-0"
|
||||
And I press "SPC"
|
||||
Then I should see "This 4 text contains the word 5 text thrice (6 text)"
|
||||
|
||||
@@ -14,6 +14,14 @@ Feature: Marking multiple parts of the buffer
|
||||
And I type "sentence"
|
||||
Then I should see "This sentence has the word sentence in it"
|
||||
|
||||
Scenario: Marking next like this, word
|
||||
Given I turn on delete-selection-mode
|
||||
When I insert "This text has the word text in it"
|
||||
And I go to word "text"
|
||||
And I press "C-S-c C->"
|
||||
And I type "sentence"
|
||||
Then I should see "This sentence has the word sentence in it"
|
||||
|
||||
Scenario: Skipping a mark
|
||||
Given I turn on delete-selection-mode
|
||||
When I insert "Here's text, text and text"
|
||||
@@ -54,6 +62,14 @@ Feature: Marking multiple parts of the buffer
|
||||
And I type "sentence"
|
||||
Then I should see "This sentence has the word sentence in it"
|
||||
|
||||
Scenario: Marking prev like this, word
|
||||
Given I turn on delete-selection-mode
|
||||
When I insert "This text has the word text in it"
|
||||
And I go to last word "text"
|
||||
And I press "C-S-c C-<"
|
||||
And I type "sentence"
|
||||
Then I should see "This sentence has the word sentence in it"
|
||||
|
||||
Scenario: Skipping a prev mark
|
||||
Given I turn on delete-selection-mode
|
||||
When I insert "Here's text, text and text"
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
Feature: Repeat last interactive command for fake cursors (mc/repeat-command)
|
||||
|
||||
Scenario: Clone insert-char from M-x
|
||||
Given I have cursors at "text" in "This text contains the word text thrice (text)"
|
||||
When I start an action chain
|
||||
When I press "M-x"
|
||||
And I type "insert-char"
|
||||
And I press "RET"
|
||||
And I type "21"
|
||||
And I press "RET"
|
||||
And I press "C-:"
|
||||
And I press "y"
|
||||
And I execute the action chain
|
||||
Then I should see "This !text contains the word !text thrice (!text)"
|
||||
|
||||
Scenario: Clone insert-char from M-:
|
||||
Given I have cursors at "text" in "This text contains the word text thrice (text)"
|
||||
When I start an action chain
|
||||
When I press "M-:"
|
||||
And I type "(insert-char (+ 40 2))"
|
||||
And I press "RET"
|
||||
And I press "C-:"
|
||||
And I press "y"
|
||||
And I execute the action chain
|
||||
Then I should see "This *text contains the word *text thrice (*text)"
|
||||
|
||||
Scenario: Disable prompt
|
||||
Given I have cursors at "text" in "This text/0000 contains the word text/1111 thrice (text/2222)"
|
||||
When I set mc/always-repeat-command to t
|
||||
When I start an action chain
|
||||
And I press "M-x"
|
||||
And I type "zap-to-char"
|
||||
And I press "RET"
|
||||
And I press "/"
|
||||
And I press "C-:"
|
||||
And I execute the action chain
|
||||
Then I should see "This 0000 contains the word 1111 thrice (2222)"
|
||||
@@ -1,4 +1,4 @@
|
||||
(require 'cl) ;; For lexical-let
|
||||
;; -*- lexical-binding: t -*-
|
||||
|
||||
(When "^I mark next like this$"
|
||||
(lambda () (call-interactively 'mc/mark-next-like-this)))
|
||||
@@ -12,6 +12,12 @@
|
||||
(When "^I mark previous like this$"
|
||||
(lambda () (call-interactively 'mc/mark-previous-like-this)))
|
||||
|
||||
(When "^I mark previous like this word$"
|
||||
(lambda () (call-interactively 'mc/mark-previous-like-this-word)))
|
||||
|
||||
(When "^I mark previous like this symbol$"
|
||||
(lambda () (call-interactively 'mc/mark-previous-like-this-symbol)))
|
||||
|
||||
(When "^I mark all like this$"
|
||||
(lambda () (call-interactively 'mc/mark-all-like-this)))
|
||||
|
||||
@@ -102,27 +108,23 @@
|
||||
|
||||
|
||||
(When "^I copy \"\\(.+\\)\" in another program$"
|
||||
(lambda (text)
|
||||
(lexical-let ((text text))
|
||||
(setq interprogram-paste-function
|
||||
#'(lambda () (let ((r text)) (setq text nil) r))))))
|
||||
(lambda (text)
|
||||
(setq interprogram-paste-function
|
||||
#'(lambda () (let ((r text)) (setq text nil) r)))))
|
||||
|
||||
(Given "^I have bound C-! to a lambda that inserts \"\\(.+\\)\"$"
|
||||
(lambda (ins)
|
||||
(lexical-let ((ins ins))
|
||||
(global-set-key (kbd "C-!") #'(lambda () (interactive) (insert ins))))))
|
||||
(global-set-key (kbd "C-!") #'(lambda () (interactive) (insert ins)))))
|
||||
|
||||
(Given "^I have bound C-! to a new command that inserts \"\\(.+\\)\"$"
|
||||
(lambda (ins)
|
||||
(lexical-let ((ins ins))
|
||||
(defun mc-test-temp-command () (interactive) (insert ins))
|
||||
(global-set-key (kbd "C-!") 'mc-test-temp-command))))
|
||||
(defun mc-test-temp-command () (interactive) (insert ins))
|
||||
(global-set-key (kbd "C-!") 'mc-test-temp-command)))
|
||||
|
||||
(Given "^I have bound C-! to another new command that inserts \"\\(.+\\)\"$"
|
||||
(lambda (ins)
|
||||
(lexical-let ((ins ins))
|
||||
(defun mc-test-temp-command-2 () (interactive) (insert ins))
|
||||
(global-set-key (kbd "C-!") 'mc-test-temp-command-2))))
|
||||
(defun mc-test-temp-command-2 () (interactive) (insert ins))
|
||||
(global-set-key (kbd "C-!") 'mc-test-temp-command-2)))
|
||||
|
||||
(Given "^I have bound C-! to a keyboard macro that insert \"_\"$"
|
||||
(lambda ()
|
||||
@@ -144,6 +146,12 @@
|
||||
(cl-assert search nil message word (espuds-buffer-contents))
|
||||
(if (string-equal "front" pos) (backward-word)))))
|
||||
|
||||
(When "^I go to last word \"\\(.+\\)\"$"
|
||||
(lambda (text)
|
||||
(goto-char (point-max))
|
||||
(let ((search (re-search-backward text nil t)))
|
||||
(cl-assert search nil "The text '%s' was not found in the current buffer." text))))
|
||||
|
||||
(When "^I select the last \"\\(.+\\)\"$"
|
||||
(lambda (text)
|
||||
(goto-char (point-max))
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
(global-set-key (kbd "C-S-c C->") 'mc/mark-next-like-this-word)
|
||||
(global-set-key (kbd "C-S-c M->") 'mc/mark-next-like-this-symbol)
|
||||
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
|
||||
(global-set-key (kbd "C-S-c C-<") 'mc/mark-previous-like-this-word)
|
||||
(global-set-key (kbd "C-S-c M-<") 'mc/mark-previous-like-this-symbol)
|
||||
(global-set-key (kbd "M-!") 'mc/mark-all-like-this)
|
||||
(global-set-key (kbd "M-$") 'mc/mark-all-like-this-dwim)
|
||||
(global-set-key (kbd "C-$") 'mc/mark-all-dwim)
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
;;; mc-cycle-cursors.el
|
||||
|
||||
;; Copyright (C) 2012 Magnar Sveen
|
||||
;; Copyright (C) 2012-2016 Magnar Sveen
|
||||
|
||||
;; Author: Magnar Sveen <magnars@gmail.com>
|
||||
;; Keywords: editing cursors
|
||||
@@ -88,7 +88,7 @@
|
||||
(cl-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))
|
||||
(cl-return-from mc/cycle nil))
|
||||
(setf next-cursor fallback-cursor))
|
||||
(mc/create-fake-cursor-at-point)
|
||||
(mc/pop-state-from-overlay next-cursor)
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
;;; mc-edit-lines.el
|
||||
|
||||
;; Copyright (C) 2012 Magnar Sveen
|
||||
;; Copyright (C) 2012-2016 Magnar Sveen
|
||||
|
||||
;; Author: Magnar Sveen <magnars@gmail.com>
|
||||
;; Keywords: editing cursors
|
||||
@@ -54,8 +54,8 @@ other non-nil value will cause short lines to be padded."
|
||||
(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)))
|
||||
(point-line (mc/line-number-at-pos))
|
||||
(mark-line (progn (exchange-point-and-mark) (mc/line-number-at-pos)))
|
||||
(direction (if (< point-line mark-line) :up :down))
|
||||
(style (cond
|
||||
;; called from lisp
|
||||
@@ -71,7 +71,7 @@ other non-nil value will cause short lines to be padded."
|
||||
(previous-logical-line 1 nil)
|
||||
(move-to-column col))
|
||||
;; Add the cursors
|
||||
(while (not (eq (line-number-at-pos) point-line))
|
||||
(while (not (eq (mc/line-number-at-pos) point-line))
|
||||
;; Pad the line
|
||||
(when (eq style 'pad)
|
||||
(while (< (current-column) col)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
;;; mc-hide-unmatched-lines.el
|
||||
;;; mc-hide-unmatched-lines-mode.el
|
||||
|
||||
;; Copyright (C) 2014 Aleksey Fedotov
|
||||
|
||||
@@ -73,7 +73,7 @@ mode. To leave this mode press <return> or \"C-g\""
|
||||
:group 'multiple-cursors)
|
||||
|
||||
(defcustom hum/placeholder "..."
|
||||
"Placeholder which will be placed insted of hiden text"
|
||||
"Placeholder which will be placed instead of hidden text"
|
||||
:type '(string)
|
||||
:group 'multiple-cursors)
|
||||
|
||||
@@ -103,5 +103,6 @@ mode. To leave this mode press <return> or \"C-g\""
|
||||
(defun hum/unhide-unmatched-lines ()
|
||||
(remove-overlays nil nil hum/invisible-overlay-name t))
|
||||
|
||||
(provide 'mc-hide-unmatched-lines-mode)
|
||||
(define-key mc/keymap (kbd "C-'") 'mc-hide-unmatched-lines-mode)
|
||||
|
||||
(provide 'mc-hide-unmatched-lines-mode)
|
||||
|
||||
+85
-31
@@ -1,6 +1,6 @@
|
||||
;;; mc-mark-more.el
|
||||
|
||||
;; Copyright (C) 2012 Magnar Sveen
|
||||
;; Copyright (C) 2012-2016 Magnar Sveen
|
||||
|
||||
;; Author: Magnar Sveen <magnars@gmail.com>
|
||||
;; Keywords: editing cursors
|
||||
@@ -56,7 +56,7 @@
|
||||
|
||||
(defun mc/furthest-cursor-before-point ()
|
||||
(let ((beg (if mark-active (min (mark) (point)) (point)))
|
||||
furthest)
|
||||
furthest)
|
||||
(mc/for-each-fake-cursor
|
||||
(when (< (mc/cursor-beg cursor) beg)
|
||||
(setq beg (mc/cursor-beg cursor))
|
||||
@@ -65,7 +65,7 @@
|
||||
|
||||
(defun mc/furthest-cursor-after-point ()
|
||||
(let ((end (if mark-active (max (mark) (point)) (point)))
|
||||
furthest)
|
||||
furthest)
|
||||
(mc/for-each-fake-cursor
|
||||
(when (> (mc/cursor-end cursor) end)
|
||||
(setq end (mc/cursor-end cursor))
|
||||
@@ -131,7 +131,7 @@ Use like case-fold-search, don't recommend setting it globally.")
|
||||
(when point-out-of-order
|
||||
(exchange-point-and-mark))
|
||||
(mc/create-fake-cursor-at-point))
|
||||
(error "no more matches found."))))))
|
||||
(user-error "no more matches found."))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun mc/mark-next-like-this (arg)
|
||||
@@ -142,9 +142,9 @@ With zero ARG, skip the last one and mark next."
|
||||
(interactive "p")
|
||||
(if (< arg 0)
|
||||
(let ((cursor (mc/furthest-cursor-after-point)))
|
||||
(if cursor
|
||||
(mc/remove-fake-cursor cursor)
|
||||
(error "No cursors to be unmarked")))
|
||||
(if cursor
|
||||
(mc/remove-fake-cursor cursor)
|
||||
(error "No cursors to be unmarked")))
|
||||
(if (region-active-p)
|
||||
(mc/mark-more-like-this (= arg 0) 'forwards)
|
||||
(mc/mark-lines arg 'forwards)))
|
||||
@@ -159,9 +159,9 @@ With zero ARG, skip the last one and mark next."
|
||||
(interactive "p")
|
||||
(if (< arg 0)
|
||||
(let ((cursor (mc/furthest-cursor-after-point)))
|
||||
(if cursor
|
||||
(mc/remove-fake-cursor cursor)
|
||||
(error "No cursors to be unmarked")))
|
||||
(if cursor
|
||||
(mc/remove-fake-cursor cursor)
|
||||
(error "No cursors to be unmarked")))
|
||||
(if (region-active-p)
|
||||
(mc/mark-more-like-this (= arg 0) 'forwards)
|
||||
(mc--select-thing-at-point 'word)
|
||||
@@ -176,9 +176,9 @@ With zero ARG, skip the last one and mark next."
|
||||
(interactive "p")
|
||||
(if (< arg 0)
|
||||
(let ((cursor (mc/furthest-cursor-after-point)))
|
||||
(if cursor
|
||||
(mc/remove-fake-cursor cursor)
|
||||
(error "No cursors to be unmarked")))
|
||||
(if cursor
|
||||
(mc/remove-fake-cursor cursor)
|
||||
(error "No cursors to be unmarked")))
|
||||
(if (region-active-p)
|
||||
(mc/mark-more-like-this (= arg 0) 'forwards)
|
||||
(mc--select-thing-at-point 'symbol)
|
||||
@@ -188,12 +188,22 @@ With zero ARG, skip the last one and mark next."
|
||||
|
||||
;;;###autoload
|
||||
(defun mc/mark-next-word-like-this (arg)
|
||||
"Find and mark the next word of the buffer matching the currently active region
|
||||
The matching region must be a whole word to be a match
|
||||
If no region is active add a cursor on the next line
|
||||
With negative ARG, delete the last one instead.
|
||||
With zero ARG, skip the last one and mark next."
|
||||
(interactive "p")
|
||||
(let ((mc/enclose-search-term 'words))
|
||||
(mc/mark-next-like-this arg)))
|
||||
|
||||
;;;###autoload
|
||||
(defun mc/mark-next-symbol-like-this (arg)
|
||||
"Find and mark the next symbol of the buffer matching the currently active region
|
||||
The matching region must be a whole symbol to be a match
|
||||
If no region is active add a cursor on the next line
|
||||
With negative ARG, delete the last one instead.
|
||||
With zero ARG, skip the last one and mark next."
|
||||
(interactive "p")
|
||||
(let ((mc/enclose-search-term 'symbols))
|
||||
(mc/mark-next-like-this arg)))
|
||||
@@ -201,27 +211,74 @@ With zero ARG, skip the last one and mark next."
|
||||
;;;###autoload
|
||||
(defun mc/mark-previous-like-this (arg)
|
||||
"Find and mark the previous part of the buffer matching the currently active region
|
||||
If no region is active add a cursor on the previous line
|
||||
With negative ARG, delete the last one instead.
|
||||
With zero ARG, skip the last one and mark next."
|
||||
(interactive "p")
|
||||
(if (< arg 0)
|
||||
(let ((cursor (mc/furthest-cursor-before-point)))
|
||||
(if cursor
|
||||
(mc/remove-fake-cursor cursor)
|
||||
(error "No cursors to be unmarked")))
|
||||
(if cursor
|
||||
(mc/remove-fake-cursor cursor)
|
||||
(error "No cursors to be unmarked")))
|
||||
(if (region-active-p)
|
||||
(mc/mark-more-like-this (= arg 0) 'backwards)
|
||||
(mc/mark-lines arg 'backwards)))
|
||||
(mc/maybe-multiple-cursors-mode))
|
||||
|
||||
;;;###autoload
|
||||
(defun mc/mark-previous-like-this-word (arg)
|
||||
"Find and mark the previous part of the buffer matching the currently active region
|
||||
If no region is active, mark the word at the point and find the previous match
|
||||
With negative ARG, delete the last one instead.
|
||||
With zero ARG, skip the last one and mark previous."
|
||||
(interactive "p")
|
||||
(if (< arg 0)
|
||||
(let ((cursor (mc/furthest-cursor-after-point)))
|
||||
(if cursor
|
||||
(mc/remove-fake-cursor cursor)
|
||||
(error "No cursors to be unmarked")))
|
||||
(if (region-active-p)
|
||||
(mc/mark-more-like-this (= arg 0) 'backwards)
|
||||
(mc--select-thing-at-point 'word)
|
||||
(mc/mark-more-like-this (= arg 0) 'backwards)))
|
||||
(mc/maybe-multiple-cursors-mode))
|
||||
|
||||
(defun mc/mark-previous-like-this-symbol (arg)
|
||||
"Find and mark the previous part of the buffer matching the currently active region
|
||||
If no region is active, mark the symbol at the point and find the previous match
|
||||
With negative ARG, delete the last one instead.
|
||||
With zero ARG, skip the last one and mark previous."
|
||||
(interactive "p")
|
||||
(if (< arg 0)
|
||||
(let ((cursor (mc/furthest-cursor-after-point)))
|
||||
(if cursor
|
||||
(mc/remove-fake-cursor cursor)
|
||||
(error "No cursors to be unmarked")))
|
||||
(if (region-active-p)
|
||||
(mc/mark-more-like-this (= arg 0) 'backwards)
|
||||
(mc--select-thing-at-point 'symbol)
|
||||
(mc/mark-more-like-this (= arg 0) 'backwards)))
|
||||
(mc/maybe-multiple-cursors-mode))
|
||||
|
||||
|
||||
;;;###autoload
|
||||
(defun mc/mark-previous-word-like-this (arg)
|
||||
"Find and mark the previous part of the buffer matching the currently active region
|
||||
The matching region must be a whole word to be a match
|
||||
If no region is active add a cursor on the previous line
|
||||
With negative ARG, delete the last one instead.
|
||||
With zero ARG, skip the last one and mark next."
|
||||
(interactive "p")
|
||||
(let ((mc/enclose-search-term 'words))
|
||||
(mc/mark-previous-like-this arg)))
|
||||
|
||||
;;;###autoload
|
||||
(defun mc/mark-previous-symbol-like-this (arg)
|
||||
"Find and mark the previous part of the buffer matching the currently active region
|
||||
The matching region must be a whole symbol to be a match
|
||||
If no region is active add a cursor on the previous line
|
||||
With negative ARG, delete the last one instead.
|
||||
With zero ARG, skip the last one and mark next."
|
||||
(interactive "p")
|
||||
(let ((mc/enclose-search-term 'symbols))
|
||||
(mc/mark-previous-like-this arg)))
|
||||
@@ -230,8 +287,8 @@ With zero ARG, skip the last one and mark next."
|
||||
(dotimes (i (if (= num-lines 0) 1 num-lines))
|
||||
(mc/save-excursion
|
||||
(let ((furthest-cursor (cl-ecase direction
|
||||
(forwards (mc/furthest-cursor-after-point))
|
||||
(backwards (mc/furthest-cursor-before-point)))))
|
||||
(forwards (mc/furthest-cursor-after-point))
|
||||
(backwards (mc/furthest-cursor-before-point)))))
|
||||
(when (overlayp furthest-cursor)
|
||||
(goto-char (overlay-get furthest-cursor 'point))
|
||||
(when (= num-lines 0)
|
||||
@@ -366,16 +423,13 @@ With zero ARG, skip the last one and mark next."
|
||||
(setq lastmatch (point))
|
||||
(when (= (point) (match-beginning 0))
|
||||
(forward-char)))
|
||||
(when lastmatch (goto-char lastmatch)))
|
||||
(when (> (mc/num-cursors) 0)
|
||||
(goto-char (match-end 0)))
|
||||
(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))))))
|
||||
(unless lastmatch
|
||||
(error "Search failed for %S" search)))
|
||||
(goto-char (match-end 0))
|
||||
(if (< (mc/num-cursors) 3)
|
||||
(multiple-cursors-mode 0)
|
||||
(mc/pop-state-from-overlay (mc/furthest-cursor-before-point))
|
||||
(multiple-cursors-mode 1))))))
|
||||
|
||||
(when (not (fboundp 'set-temporary-overlay-map))
|
||||
;; Backport this function from newer emacs versions
|
||||
@@ -525,11 +579,11 @@ If the region is inactive or on a single line, it will behave like
|
||||
(interactive "P")
|
||||
(if (and (use-region-p)
|
||||
(not (> (mc/num-cursors) 1))
|
||||
(not (= (line-number-at-pos (region-beginning))
|
||||
(line-number-at-pos (region-end)))))
|
||||
(not (= (mc/line-number-at-pos (region-beginning))
|
||||
(mc/line-number-at-pos (region-end)))))
|
||||
(if arg
|
||||
(call-interactively 'mc/edit-lines)
|
||||
(call-interactively 'mc/mark-all-in-region))
|
||||
(call-interactively 'mc/mark-all-in-region))
|
||||
(progn
|
||||
(setq this-command 'mc/mark-all-like-this-dwim)
|
||||
(mc/mark-all-like-this-dwim arg))))
|
||||
|
||||
+26
-24
@@ -1,6 +1,6 @@
|
||||
;;; mc-separate-operations.el - functions that work differently on each cursor
|
||||
|
||||
;; Copyright (C) 2012 Magnar Sveen
|
||||
;; Copyright (C) 2012-2016 Magnar Sveen
|
||||
|
||||
;; Author: Magnar Sveen <magnars@gmail.com>
|
||||
;; Keywords: editing cursors
|
||||
@@ -29,17 +29,24 @@
|
||||
|
||||
(require 'multiple-cursors-core)
|
||||
|
||||
;;;###autoload
|
||||
(defun mc/insert-numbers (arg)
|
||||
"Insert increasing numbers for each cursor, starting at 0 or ARG."
|
||||
(interactive "P")
|
||||
(setq mc--insert-numbers-number (or (and arg (prefix-numeric-value arg))
|
||||
0))
|
||||
(mc/for-each-cursor-ordered
|
||||
(mc/execute-command-for-fake-cursor 'mc--insert-number-and-increase cursor)))
|
||||
(defcustom mc/insert-numbers-default 0
|
||||
"The default number at which to start counting for
|
||||
`mc/insert-numbers'"
|
||||
:type 'integer
|
||||
:group 'multiple-cursors)
|
||||
|
||||
(defvar mc--insert-numbers-number 0)
|
||||
|
||||
;;;###autoload
|
||||
(defun mc/insert-numbers (arg)
|
||||
"Insert increasing numbers for each cursor, starting at
|
||||
`mc/insert-numbers-default' or ARG."
|
||||
(interactive "P")
|
||||
(setq mc--insert-numbers-number (or (and arg (prefix-numeric-value arg))
|
||||
mc/insert-numbers-default))
|
||||
(mc/for-each-cursor-ordered
|
||||
(mc/execute-command-for-fake-cursor 'mc--insert-number-and-increase cursor)))
|
||||
|
||||
(defun mc--insert-number-and-increase ()
|
||||
(interactive)
|
||||
(insert (number-to-string mc--insert-numbers-number))
|
||||
@@ -54,6 +61,8 @@
|
||||
(mc/cursor-end cursor)) strings))))
|
||||
(nreverse strings)))
|
||||
|
||||
(defvar mc--insert-letters-number 0)
|
||||
|
||||
;;;###autoload
|
||||
(defun mc/insert-letters (arg)
|
||||
"Insert increasing letters for each cursor, starting at 0 or ARG.
|
||||
@@ -66,15 +75,13 @@
|
||||
|
||||
(defun mc--number-to-letters (number)
|
||||
(let ((letter
|
||||
(char-to-string
|
||||
(+ (mod number 26) ?a)))
|
||||
(number2 (/ number 26)))
|
||||
(char-to-string
|
||||
(+ (mod number 26) ?a)))
|
||||
(number2 (/ number 26)))
|
||||
(if (> number2 0)
|
||||
(concat (mc--number-to-letters (- number2 1)) letter)
|
||||
(concat (mc--number-to-letters (- number2 1)) letter)
|
||||
letter)))
|
||||
|
||||
(defvar mc--insert-letters-number 0)
|
||||
|
||||
(defun mc--insert-letter-and-increase ()
|
||||
(interactive)
|
||||
(insert (mc--number-to-letters mc--insert-letters-number))
|
||||
@@ -117,7 +124,7 @@
|
||||
;;;###autoload
|
||||
(defun mc/vertical-align (character)
|
||||
"Aligns all cursors vertically with a given CHARACTER to the one with the
|
||||
highest colum number (the rightest).
|
||||
highest column number (the rightest).
|
||||
Might not behave as intended if more than one cursors are on the same line."
|
||||
(interactive "c")
|
||||
(let ((rightest-column (current-column)))
|
||||
@@ -130,19 +137,14 @@ Might not behave as intended if more than one cursors are on the same line."
|
||||
(lambda ()
|
||||
(interactive)
|
||||
(let ((missing-spaces (- rightest-column (current-column))))
|
||||
(save-excursion (insert (make-string missing-spaces character)))
|
||||
(forward-char missing-spaces)
|
||||
)
|
||||
))
|
||||
)
|
||||
)
|
||||
(save-excursion (insert (make-string missing-spaces character)))
|
||||
(forward-char missing-spaces))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun mc/vertical-align-with-space ()
|
||||
"Aligns all cursors with whitespace like `mc/vertical-align' does"
|
||||
(interactive)
|
||||
(mc/vertical-align 32)
|
||||
)
|
||||
(mc/vertical-align 32))
|
||||
|
||||
(provide 'mc-separate-operations)
|
||||
;;; mc-separate-operations.el ends here
|
||||
|
||||
+100
-13
@@ -1,6 +1,6 @@
|
||||
;;; multiple-cursors-core.el --- An experiment in multiple cursors for emacs.
|
||||
|
||||
;; Copyright (C) 2012 Magnar Sveen
|
||||
;; Copyright (C) 2012-2016 Magnar Sveen
|
||||
|
||||
;; Author: Magnar Sveen <magnars@gmail.com>
|
||||
;; Keywords: editing cursors
|
||||
@@ -35,6 +35,11 @@
|
||||
"The face used for fake cursors"
|
||||
:group 'multiple-cursors)
|
||||
|
||||
(defface mc/cursor-bar-face
|
||||
`((t (:height 1 :background ,(face-attribute 'cursor :background))))
|
||||
"The face used for fake cursors if the cursor-type is bar"
|
||||
:group 'multiple-cursors)
|
||||
|
||||
(defface mc/region-face
|
||||
'((t :inherit region))
|
||||
"The face used for fake regions"
|
||||
@@ -98,16 +103,39 @@
|
||||
(set-marker ,p nil)
|
||||
(set-marker ,s nil))))
|
||||
|
||||
(defun mc/cursor-is-bar ()
|
||||
"Return non-nil if the cursor is a bar."
|
||||
(or (eq cursor-type 'bar)
|
||||
(and (listp cursor-type)
|
||||
(eq (car cursor-type) 'bar))))
|
||||
|
||||
(defun mc/line-number-at-pos (&optional pos absolute)
|
||||
"Faster implementation of `line-number-at-pos'."
|
||||
(if pos
|
||||
(save-excursion
|
||||
(if absolute
|
||||
(save-restriction
|
||||
(widen)
|
||||
(goto-char pos)
|
||||
(string-to-number (format-mode-line "%l")))
|
||||
(goto-char pos)
|
||||
(string-to-number (format-mode-line "%l"))))
|
||||
(string-to-number (format-mode-line "%l"))))
|
||||
|
||||
(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))
|
||||
(if (mc/cursor-is-bar)
|
||||
(overlay-put overlay 'before-string (propertize "|" 'face 'mc/cursor-bar-face))
|
||||
(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)
|
||||
(if (mc/cursor-is-bar)
|
||||
(overlay-put overlay 'before-string (propertize "|" 'face 'mc/cursor-bar-face))
|
||||
(overlay-put overlay 'face 'mc/cursor-face))
|
||||
overlay))
|
||||
|
||||
(defun mc/make-cursor-overlay-at-point ()
|
||||
@@ -133,13 +161,27 @@ highlights the entire width of the window."
|
||||
yank-undo-function
|
||||
autopair-action
|
||||
autopair-wrap-action
|
||||
er/history)
|
||||
temporary-goal-column
|
||||
er/history
|
||||
dabbrev--abbrev-char-regexp
|
||||
dabbrev--check-other-buffers
|
||||
dabbrev--friend-buffer-list
|
||||
dabbrev--last-abbrev-location
|
||||
dabbrev--last-abbreviation
|
||||
dabbrev--last-buffer
|
||||
dabbrev--last-buffer-found
|
||||
dabbrev--last-direction
|
||||
dabbrev--last-expansion
|
||||
dabbrev--last-expansion-location
|
||||
dabbrev--last-table)
|
||||
"A list of vars that need to be tracked on a per-cursor basis.")
|
||||
|
||||
(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 'mark (set-marker (make-marker) (mark)))
|
||||
(overlay-put o 'mark (set-marker (make-marker)
|
||||
(let ((mark-even-if-inactive t))
|
||||
(mark))))
|
||||
(dolist (var mc/cursor-specific-vars)
|
||||
(when (boundp var) (overlay-put o var (symbol-value var))))
|
||||
o)
|
||||
@@ -310,6 +352,16 @@ cursor with updated info."
|
||||
(mc/pop-state-from-overlay mc--stored-state-for-undo)
|
||||
(setq mc--stored-state-for-undo nil)))
|
||||
|
||||
(defcustom mc/always-run-for-all nil
|
||||
"Disables whitelisting and always executes commands for every fake cursor."
|
||||
:type '(boolean)
|
||||
:group 'multiple-cursors)
|
||||
|
||||
(defcustom mc/always-repeat-command nil
|
||||
"Disables confirmation for `mc/repeat-command' command."
|
||||
:type '(boolean)
|
||||
:group 'multiple-cursors)
|
||||
|
||||
(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))))
|
||||
@@ -396,10 +448,15 @@ the original cursor, to inform about the lack of support."
|
||||
(message "%S is not supported with multiple cursors%s"
|
||||
original-command
|
||||
(get original-command 'mc--unsupported))
|
||||
|
||||
;; lazy-load the user's list file
|
||||
(mc/load-lists)
|
||||
|
||||
(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)
|
||||
(or mc/always-run-for-all
|
||||
(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))))))))))
|
||||
@@ -421,6 +478,17 @@ you should disable multiple-cursors-mode."
|
||||
(multiple-cursors-mode 0)
|
||||
(deactivate-mark)))
|
||||
|
||||
(defun mc/repeat-command ()
|
||||
"Run last command from `command-history' for every fake cursor."
|
||||
(interactive)
|
||||
(when (or mc/always-repeat-command
|
||||
(y-or-n-p (format "[mc] repeat complex command: %s? " (caar command-history))))
|
||||
(mc/execute-command-for-all-fake-cursors
|
||||
(lambda () (interactive)
|
||||
(cl-letf (((symbol-function 'read-from-minibuffer)
|
||||
(lambda (p &optional i k r h d m) (read i))))
|
||||
(repeat-complex-command 0))))))
|
||||
|
||||
(defvar mc/keymap nil
|
||||
"Keymap while multiple cursors are active.
|
||||
Main goal of the keymap is to rebind C-g and <return> to conclude
|
||||
@@ -429,6 +497,7 @@ multiple cursors editing.")
|
||||
(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)
|
||||
(define-key mc/keymap (kbd "C-:") 'mc/repeat-command)
|
||||
(when (fboundp 'phi-search)
|
||||
(define-key mc/keymap (kbd "C-s") 'phi-search))
|
||||
(when (fboundp 'phi-search-backward)
|
||||
@@ -530,14 +599,15 @@ from being executed if in multiple-cursors-mode."
|
||||
(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)
|
||||
(defadvice current-kill (before interprogram-paste-for-all-cursors
|
||||
(n &optional do-not-move) 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
|
||||
;; We have to do the work for it though, since the funcall only returns
|
||||
;; something once. It is not a pure function.
|
||||
(let ((interprogram-cut-function nil))
|
||||
(if (listp interprogram-paste)
|
||||
@@ -554,9 +624,20 @@ from being executed if in multiple-cursors-mode."
|
||||
(overlay-put cursor 'kill-ring kill-ring)
|
||||
(overlay-put cursor 'kill-ring-yank-pointer kill-ring-yank-pointer)))))))
|
||||
|
||||
(defvar mc/list-file (locate-user-emacs-file ".mc-lists.el")
|
||||
(defcustom mc/list-file (locate-user-emacs-file ".mc-lists.el")
|
||||
"The position of the file that keeps track of your preferences
|
||||
for running commands with multiple cursors.")
|
||||
for running commands with multiple cursors."
|
||||
:type 'file
|
||||
:group 'multiple-cursors)
|
||||
|
||||
(defvar mc--list-file-loaded nil
|
||||
"Whether the list file has already been loaded.")
|
||||
|
||||
(defun mc/load-lists ()
|
||||
"Loads preferences for running commands with multiple cursors from `mc/list-file'"
|
||||
(unless mc--list-file-loaded
|
||||
(load mc/list-file 'noerror 'nomessage)
|
||||
(setq mc--list-file-loaded t)))
|
||||
|
||||
(defun mc/dump-list (list-symbol)
|
||||
"Insert (setq 'LIST-SYMBOL LIST-VALUE) to current buffer."
|
||||
@@ -600,6 +681,8 @@ for running commands with multiple cursors.")
|
||||
mc/mark-next-word-like-this
|
||||
mc/mark-next-symbol-like-this
|
||||
mc/mark-previous-like-this
|
||||
mc/mark-previous-like-this-word
|
||||
mc/mark-previous-like-this-symbol
|
||||
mc/mark-previous-word-like-this
|
||||
mc/mark-previous-symbol-like-this
|
||||
mc/mark-all-like-this
|
||||
@@ -631,13 +714,16 @@ for running commands with multiple cursors.")
|
||||
mc/skip-to-previous-like-this
|
||||
rrm/switch-to-multiple-cursors
|
||||
mc-hide-unmatched-lines-mode
|
||||
mc/repeat-command
|
||||
hum/keyboard-quit
|
||||
hum/unhide-invisible-overlays
|
||||
save-buffer
|
||||
ido-exit-minibuffer
|
||||
ivy-done
|
||||
exit-minibuffer
|
||||
minibuffer-complete-and-exit
|
||||
execute-extended-command
|
||||
eval-expression
|
||||
undo
|
||||
redo
|
||||
undo-tree-undo
|
||||
@@ -671,7 +757,8 @@ for running commands with multiple cursors.")
|
||||
windmove-left
|
||||
windmove-right
|
||||
windmove-up
|
||||
windmove-down))
|
||||
windmove-down
|
||||
repeat-complex-command))
|
||||
|
||||
(defvar mc--default-cmds-to-run-for-all nil
|
||||
"Default set of commands that should be mirrored by all cursors")
|
||||
@@ -756,9 +843,9 @@ for running commands with multiple cursors.")
|
||||
(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)
|
||||
(require 'mc-cycle-cursors)
|
||||
(require 'mc-hide-unmatched-lines-mode)
|
||||
|
||||
;; Local Variables:
|
||||
;; coding: utf-8
|
||||
|
||||
+8
-6
@@ -1,6 +1,6 @@
|
||||
;;; multiple-cursors.el --- Multiple cursors for emacs.
|
||||
|
||||
;; Copyright (C) 2012-2013 Magnar Sveen
|
||||
;; Copyright (C) 2012-2016 Magnar Sveen
|
||||
|
||||
;; Author: Magnar Sveen <magnars@gmail.com>
|
||||
;; Version: 1.4.0
|
||||
@@ -22,7 +22,7 @@
|
||||
;;; 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
|
||||
;; there are kinks. Don't be afraid though, I've been using it since 2011 with
|
||||
;; great success and much merriment.
|
||||
|
||||
;; ## Basic usage
|
||||
@@ -68,7 +68,7 @@
|
||||
;; - `mc/mark-previous-like-this`: Adds a cursor and region at the next part of the buffer backwards that matches the current region.
|
||||
;; - `mc/mark-previous-word-like-this`: Like `mc/mark-previous-like-this` but only for whole words.
|
||||
;; - `mc/mark-previous-symbol-like-this`: Like `mc/mark-previous-like-this` but only for whole symbols.
|
||||
;; - `mc/mark-more-like-this-extended`: Use arrow keys to quickly mark/skip next/previous occurances.
|
||||
;; - `mc/mark-more-like-this-extended`: Use arrow keys to quickly mark/skip next/previous occurrences.
|
||||
;; - `mc/add-cursor-on-click`: Bind to a mouse event to add cursors by clicking. See tips-section.
|
||||
|
||||
;; ### Mark many occurrences
|
||||
@@ -105,7 +105,7 @@
|
||||
;;
|
||||
;; - Try pressing `mc/mark-next-like-this-word` or
|
||||
;; `mc/mark-next-like-this-symbol` with no region selected. It will
|
||||
;; mark the symbol and add a cursor at the next occurance
|
||||
;; mark the symbol and add a cursor at the next occurrence
|
||||
;;
|
||||
;; - Try pressing `mc/mark-all-like-this-dwim` on a tagname in html-mode.
|
||||
;;
|
||||
@@ -186,13 +186,15 @@
|
||||
|
||||
;;; Code:
|
||||
|
||||
(defgroup multiple-cursors nil
|
||||
"Multiple cursors for emacs."
|
||||
:group 'editing)
|
||||
|
||||
(require 'mc-edit-lines)
|
||||
(require 'mc-cycle-cursors)
|
||||
(require 'mc-mark-more)
|
||||
(require 'mc-mark-pop)
|
||||
(require 'rectangular-region-mode)
|
||||
(require 'mc-separate-operations)
|
||||
(require 'mc-hide-unmatched-lines-mode)
|
||||
|
||||
(provide 'multiple-cursors)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
;;; rectangular-region-mode.el
|
||||
|
||||
;; Copyright (C) 2012 Magnar Sveen
|
||||
;; Copyright (C) 2012-2016 Magnar Sveen
|
||||
|
||||
;; Author: Magnar Sveen <magnars@gmail.com>
|
||||
;; Keywords: editing cursors
|
||||
@@ -75,9 +75,9 @@ an exceedingly quick way of adding multiple cursors to multiple lines."
|
||||
(rrm/remove-rectangular-region-overlays)
|
||||
(let* ((annoying-arrows-mode nil)
|
||||
(point-column (current-column))
|
||||
(point-line (line-number-at-pos))
|
||||
(point-line (mc/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)))
|
||||
(anchor-line (save-excursion (goto-char rrm/anchor) (mc/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)))
|
||||
@@ -85,7 +85,7 @@ an exceedingly quick way of adding multiple cursors to multiple lines."
|
||||
(set-mark (point))
|
||||
(move-to-column point-column)
|
||||
(mc/save-excursion
|
||||
(while (not (= anchor-line (line-number-at-pos)))
|
||||
(while (not (= anchor-line (mc/line-number-at-pos)))
|
||||
(forward-line navigation-step)
|
||||
(move-to-column anchor-column)
|
||||
(when (= anchor-column (current-column))
|
||||
|
||||
Reference in New Issue
Block a user