[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/multiple-cursors 65c0c0c 275/434: Merge pull request #104
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/multiple-cursors 65c0c0c 275/434: Merge pull request #104 from mathrick/mark-all-dwim |
Date: |
Sat, 7 Aug 2021 09:20:41 -0400 (EDT) |
branch: elpa/multiple-cursors
commit 65c0c0c6fe9cd4dd407d4697d656d5963344d138
Merge: 68dfa46 ec47813
Author: Magnar Sveen <magnars@gmail.com>
Commit: Magnar Sveen <magnars@gmail.com>
Merge pull request #104 from mathrick/mark-all-dwim
Add new command, mark-all-dwim
---
README.md | 2 +-
features/mark-all-dwim.feature | 70 ++++++++++++++++++++++++++++++++++++------
features/support/env.el | 1 +
mc-mark-more.el | 21 +++++++++++++
multiple-cursors-core.el | 1 +
5 files changed, 85 insertions(+), 10 deletions(-)
diff --git a/README.md b/README.md
index 8001df3..a6a1189 100644
--- a/README.md
+++ b/README.md
@@ -69,7 +69,7 @@ You can [watch an intro to multiple-cursors at Emacs
Rocks](http://emacsrocks.co
- `mc/mark-all-like-this-in-defun`: Marks all parts of the current defun that
matches the current region.
- `mc/mark-all-words-like-this-in-defun`: Like
`mc/mark-all-like-this-in-defun` but only for whole words.
- `mc/mark-all-symbols-like-this-in-defun`: Like
`mc/mark-all-like-this-in-defun` but only for whole symbols.
- - `mc/mark-all-like-this-dwim`: Tries to be smart about marking everything
you want. Can be pressed multiple times.
+ - `mc/mark-all-dwim`: Tries to be smart about marking everything you want.
Can be pressed multiple times.
### Special
diff --git a/features/mark-all-dwim.feature b/features/mark-all-dwim.feature
index 9eca714..4bb1702 100644
--- a/features/mark-all-dwim.feature
+++ b/features/mark-all-dwim.feature
@@ -1,13 +1,16 @@
Feature: Mark all do-what-I-mean
- Scenario: Mark symbols in defun
+ Background:
Given I turn on emacs-lisp-mode
And I turn on delete-selection-mode
And I insert:
"""
(defun abc (ghi) (message ghi))
(defun def (ghi) (message some-other-ghi))
+
"""
+
+ Scenario: Mark symbols in defun
When I go to the end of the word "abc"
And I press "M-f"
And I press "M-$"
@@ -17,15 +20,17 @@ Feature: Mark all do-what-I-mean
(defun abc (hmm) (message hmm))
(defun def (ghi) (message some-other-ghi))
"""
-
- Scenario: Mark all symbols by pressing twice
- Given I turn on emacs-lisp-mode
- And I turn on delete-selection-mode
- And I insert:
+ When I press "C-g"
+ And I go to the front of the word "hmm"
+ And I press "C-$"
+ And I type "foo"
+ Then I should see:
"""
- (defun abc (ghi) (message ghi))
- (defun def (ghi) (message ghi))
+ (defun abc (foo) (message foo))
+ (defun def (ghi) (message some-other-ghi))
"""
+
+ Scenario: Mark all symbols by pressing twice
When I go to the end of the word "abc"
And I press "M-f"
And I press "M-$"
@@ -34,5 +39,52 @@ Feature: Mark all do-what-I-mean
Then I should see:
"""
(defun abc (hmm) (message hmm))
- (defun def (hmm) (message hmm))
+ (defun def (hmm) (message some-other-hmm))
+ """
+ When I press "C-g"
+ And I press "M->"
+ And I insert:
+ """
+ (defun def (hmm-hmm) (message hmm))
+ """
+ And I go to the front of the word "hmm"
+ And I press "C-$"
+ And I press "C-$"
+ And I type "humm"
+ Then I should see:
+ """
+ (defun abc (humm) (message humm))
+ (defun def (humm) (message some-other-humm))
+ (defun def (humm-humm) (message humm))
+ """
+
+ Scenario: Mark dwim from selection
+ When I press "M-<"
+ And I press "S-M->"
+ And I press "C-$ ghi RET"
+ And I type "xyz"
+ Then I should see:
+ """
+ (defun abc (xyz) (message xyz))
+ (defun def (xyz) (message some-other-xyz))
+ """
+ When I press "C-g"
+ And I go to the front of the word "xyz"
+ And I press "C-M-SPC"
+ And I press "C-$"
+ And I type "foo"
+ Then I should see:
+ """
+ (defun abc (foo) (message foo))
+ (defun def (xyz) (message some-other-xyz))
+ """
+ When I press "C-g"
+ And I press "M-<"
+ And I press "S-M->"
+ And I press "C-u C-$"
+ And I type ";;"
+ Then I should see:
+ """
+ ;;(defun abc (foo) (message foo))
+ ;;(defun def (xyz) (message some-other-xyz))
"""
diff --git a/features/support/env.el b/features/support/env.el
index 4f6af30..3ce7c91 100644
--- a/features/support/env.el
+++ b/features/support/env.el
@@ -24,6 +24,7 @@
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
(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)
(global-set-key (kbd "M-#") 'mc/mark-all-in-region)
(global-set-key (kbd "H-0") 'mc/insert-numbers)
(global-set-key (kbd "H-1") 'mc/reverse-regions)
diff --git a/mc-mark-more.el b/mc-mark-more.el
index 627b401..5b66224 100644
--- a/mc-mark-more.el
+++ b/mc-mark-more.el
@@ -419,6 +419,27 @@ With prefix, it behaves the same as original
`mc/mark-all-like-this'"
(when (<= (mc/num-cursors) before)
(mc/mark-all-like-this))))))
+(defun mc/mark-all-dwim (arg)
+ "Tries even harder to guess what you want to mark all of.
+
+If the region is active and spans multiple lines, it will behave
+as if `mc/mark-all-in-region'. With the prefix ARG, it will call
+`mc/edit-lines' instead.
+
+If the region is inactive or on a single line, it will behave like
+`mc/mark-all-like-this-dwim'."
+ (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)))))
+ (if arg
+ (call-interactively 'mc/edit-lines)
+ (call-interactively 'mc/mark-all-in-region))
+ (progn
+ (setq this-command 'mc/mark-all-like-this-dwim)
+ (mc/mark-all-like-this-dwim arg))))
+
(defun mc--in-defun ()
(bounds-of-thing-at-point 'defun))
diff --git a/multiple-cursors-core.el b/multiple-cursors-core.el
index d073090..4b30cf9 100644
--- a/multiple-cursors-core.el
+++ b/multiple-cursors-core.el
@@ -573,6 +573,7 @@ for running commands with multiple cursors.")
mc/mark-all-words-like-this-in-defun
mc/mark-all-symbols-like-this-in-defun
mc/mark-all-like-this-dwim
+ mc/mark-all-dwim
mc/mark-sgml-tag-pair
mc/insert-numbers
mc/sort-regions
- [nongnu] elpa/multiple-cursors 5190e0c 206/434: Add test case for shift-select-mode, (continued)
- [nongnu] elpa/multiple-cursors 5190e0c 206/434: Add test case for shift-select-mode, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 07b8808 195/434: Merge pull request #43 from purcell/travis-script, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 373dcbe 218/434: Add a scenario for mc/mark-all-symbols-like-this, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 8b91e47 231/434: Add py-electric-backspace to run-for-all list, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 39f1725 248/434: Add support for god-mode, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors a374031 257/434: Add gnu repo to Cask, which is needed for cl-lib on Emacs <24.3, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 5e879f9 261/434: Guard against empty search pattern in 'mc/mark-all-in-region', otherwise it will enter an infinite loop, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors af66635 264/434: Make 'mc/mark-all-dwim' into 'mc/edit-lines' if prefix arg is passed, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 45ed43e 265/434: Test edit-lines functionality in 'mc/mark-all-dwim', ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 68dfa46 271/434: Merge pull request #109 from mathrick/fix-mark-all-in-region-hang, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 65c0c0c 275/434: Merge pull request #104 from mathrick/mark-all-dwim,
ELPA Syncer <=
- [nongnu] elpa/multiple-cursors d17c89e 276/434: Release 1.3.0, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors ad79ad8 273/434: Mention only 'mc/mark-all-dwim' in README to prevent confusing redundancy, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 54e408f 279/434: Update README.md, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors aed5d59 287/434: fix compilation warnings (#66), ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 00aea4c 289/434: Show appropriate error messages on trying skipping/unmarking commands with no fake cursors, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors b3fd49c 306/434: Revert "Change file load timing", ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 38d6013 307/434: Merge pull request #156 from magnars/revert-152-master, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 49fe803 316/434: Merge pull request #163 from Silex/master, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 7cf6374 326/434: Typo fixo., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 142fdd6 337/434: Use locate-user-emacs-file to find directory for .mc-lists.el, ELPA Syncer, 2021/08/07