[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/multiple-cursors 980a880 223/434: Merge pull request #63 f
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/multiple-cursors 980a880 223/434: Merge pull request #63 from tkf/select-thing-at-point |
Date: |
Sat, 7 Aug 2021 09:20:30 -0400 (EDT) |
branch: elpa/multiple-cursors
commit 980a8808ddfc4e48def0cab76782a909a3456029
Merge: ed18fa4 1cdd730
Author: Magnar Sveen <magnars@gmail.com>
Commit: Magnar Sveen <magnars@gmail.com>
Merge pull request #63 from tkf/select-thing-at-point
Automatically select word/symbol
---
features/mark-things.feature | 137 +++++++++++++++++++++
.../step-definitions/multiple-cursors-steps.el | 8 ++
mc-mark-more.el | 15 +++
3 files changed, 160 insertions(+)
diff --git a/features/mark-things.feature b/features/mark-things.feature
new file mode 100644
index 0000000..c99c24f
--- /dev/null
+++ b/features/mark-things.feature
@@ -0,0 +1,137 @@
+Feature: Mark things
+
+ Scenario: Mark all symbols like this with select
+ 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))
+ """
+ When I select "ghi"
+ And I mark all symbols like this
+ And I type "hmm"
+ Then I should see:
+ """
+ (defun abc (hmm) (message hmm))
+ (defun def (hmm) (message some-other-ghi))
+ """
+
+ Scenario: Mark all words like this with select
+ 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))
+ """
+ When I select "ghi"
+ And I mark all words like this
+ And I type "hmm"
+ Then I should see:
+ """
+ (defun abc (hmm) (message hmm))
+ (defun def (hmm) (message some-other-hmm))
+ """
+
+ Scenario: Mark all symbols like this in defun with select
+ 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))
+ """
+ When I select "ghi"
+ And I mark all symbols like this in defun
+ And I type "hmm"
+ Then I should see:
+ """
+ (defun abc (hmm) (message hmm))
+ (defun def (ghi) (message some-other-ghi))
+ """
+
+ Scenario: Mark all words like this in defun with select
+ 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))
+ """
+ When I select "ghi"
+ And I mark all words like this in defun
+ And I type "hmm"
+ Then I should see:
+ """
+ (defun abc (hmm) (message hmm))
+ (defun def (ghi) (message some-other-ghi))
+ """
+
+ Scenario: Mark all symbols like this with no select
+ 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))
+ """
+ When I go to word "ghi"
+ And I mark all symbols like this
+ And I type "hmm"
+ Then I should see:
+ """
+ (defun abc (hmm) (message hmm))
+ (defun def (hmm) (message some-other-ghi))
+ """
+
+ Scenario: Mark all words like this with no select
+ 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))
+ """
+ When I go to word "ghi"
+ And I mark all words like this
+ And I type "hmm"
+ Then I should see:
+ """
+ (defun abc (hmm) (message hmm))
+ (defun def (hmm) (message some-other-hmm))
+ """
+
+ Scenario: Mark all symbols like this in defun with no select
+ 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))
+ """
+ When I go to word "ghi"
+ And I mark all symbols like this in defun
+ And I type "hmm"
+ Then I should see:
+ """
+ (defun abc (hmm) (message hmm))
+ (defun def (ghi) (message some-other-ghi))
+ """
+
+ Scenario: Mark all words like this in defun with no select
+ 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))
+ """
+ When I go to word "ghi"
+ And I mark all words like this in defun
+ And I type "hmm"
+ Then I should see:
+ """
+ (defun abc (hmm) (message hmm))
+ (defun def (ghi) (message some-other-ghi))
+ """
diff --git a/features/step-definitions/multiple-cursors-steps.el
b/features/step-definitions/multiple-cursors-steps.el
index 900eeed..ba25181 100644
--- a/features/step-definitions/multiple-cursors-steps.el
+++ b/features/step-definitions/multiple-cursors-steps.el
@@ -95,3 +95,11 @@
(assert search nil "The text '%s' was not found in the current
buffer." text))
(set-mark (point))
(re-search-forward text)))
+
+(When "^I mark all \\(.+\\)$"
+ (lambda (rest)
+ (let ((func (intern (mapconcat 'identity
+ (cons "mc/mark-all"
+ (split-string rest))
+ "-"))))
+ (call-interactively func))))
diff --git a/mc-mark-more.el b/mc-mark-more.el
index ca239e0..eba7bed 100644
--- a/mc-mark-more.el
+++ b/mc-mark-more.el
@@ -225,15 +225,28 @@ With zero ARG, skip the last one and mark next."
(multiple-cursors-mode 1)
(multiple-cursors-mode 0)))
+(defun mc--select-thing-at-point (thing)
+ (let ((bound (bounds-of-thing-at-point thing)))
+ (when bound
+ (set-mark (car bound))
+ (goto-char (cdr bound))
+ bound)))
+
+(defun mc--select-thing-at-point-or-bark (thing)
+ (unless (or (region-active-p) (mc--select-thing-at-point thing))
+ (error "Mark a region or set cursor on a %s." thing)))
+
;;;###autoload
(defun mc/mark-all-words-like-this ()
(interactive)
+ (mc--select-thing-at-point-or-bark 'word)
(let ((mc/enclose-search-term 'words))
(mc/mark-all-like-this)))
;;;###autoload
(defun mc/mark-all-symbols-like-this ()
(interactive)
+ (mc--select-thing-at-point-or-bark 'symbol)
(let ((mc/enclose-search-term 'symbols))
(mc/mark-all-like-this)))
@@ -355,6 +368,7 @@ With prefix, it behaves the same as original
`mc/mark-all-like-this'"
(defun mc/mark-all-words-like-this-in-defun ()
"Mark all words like this in defun."
(interactive)
+ (mc--select-thing-at-point-or-bark 'word)
(if (mc--in-defun)
(save-restriction
(widen)
@@ -366,6 +380,7 @@ With prefix, it behaves the same as original
`mc/mark-all-like-this'"
(defun mc/mark-all-symbols-like-this-in-defun ()
"Mark all symbols like this in defun."
(interactive)
+ (mc--select-thing-at-point-or-bark 'symbol)
(if (mc--in-defun)
(save-restriction
(widen)
- [nongnu] elpa/multiple-cursors 32213d4 115/434: Make sure we run the right version of Emacs in travis., (continued)
- [nongnu] elpa/multiple-cursors 32213d4 115/434: Make sure we run the right version of Emacs in travis., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 6e61e3d 114/434: Fix travis badge, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 719fe40 119/434: Integrate with rect.el instead of consolidating/splitting on kill-ring, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 5fcc69c 139/434: Skip keyboard macros, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 3f20fc1 154/434: When no region is active mc/mark-next-like-this and mc/mark-previous-like-this should create a cursor one like up (or down)., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 038c9a7 161/434: Added stop as a possible value for mc/cycle-looping-behaviour., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors e4adefc 158/434: Fix issues with mc/cycle-(backward|forward) where the cycling was dependent on not having an active mark., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 1cdd730 221/434: Automatically select word/symbol, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 72ba43a 225/434: add .nosearch to directory with bundled libraries, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 6a5969e 202/434: Adding support for using mc/edit-lines without transient mark mode., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 980a880 223/434: Merge pull request #63 from tkf/select-thing-at-point,
ELPA Syncer <=
- [nongnu] elpa/multiple-cursors dce6c00 174/434: Add mc/cursor-specific-vars to handle vars that need to be tracked per cursor., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 0a081a7 184/434: Move mc/maybe-multiple-cursors-mode to core., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 9a376a6 201/434: Add note about yank-rectangle, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors e7605bb 194/434: Merge pull request #42 from purcell/cleanup, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors d24ddc5 217/434: Default ECUKES_EMACS to $EMACS, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 94af074 240/434: Add some readability enhancing step definitions, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 66ceb0b 246/434: Revert cursor specific pre- & post-command-hooks, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 725369c 253/434: Merge pull request #97 from knu/fix-mc-mark-pop-doc, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors bbbe90d 349/434: Minor changes mark-next-like-this-word and readme, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors dd07bc5 351/434: Merge pull request #228 from jtamagnan/mark-next-like-this-word, ELPA Syncer, 2021/08/07