[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/multiple-cursors fe211c0 176/434: Add word/symbol limiting
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/multiple-cursors fe211c0 176/434: Add word/symbol limiting mark-more functions: |
Date: |
Sat, 7 Aug 2021 09:20:20 -0400 (EDT) |
branch: elpa/multiple-cursors
commit fe211c018ce85e80e9ef133f4ca4cb7bb609eff5
Author: Magnar Sveen <magnars@gmail.com>
Commit: Magnar Sveen <magnars@gmail.com>
Add word/symbol limiting mark-more functions:
- mc/mark-next-word-like-this
- mc/mark-next-symbol-like-this
- mc/mark-previous-word-like-this
- mc/mark-previous-symbol-like-this
- mc/mark-all-words-like-this
- mc/mark-all-symbols-like-this
Fixes #24
---
mc-mark-more.el | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 50 insertions(+), 5 deletions(-)
diff --git a/mc-mark-more.el b/mc-mark-more.el
index 7d722b0..d5fe4a7 100644
--- a/mc-mark-more.el
+++ b/mc-mark-more.el
@@ -85,9 +85,18 @@
(multiple-cursors-mode 1)
(multiple-cursors-mode 0)))
+(defvar mc/enclose-search-term nil
+ "How should mc/mark-more-* search for more matches?
+
+Match everything: nil
+Match only whole words: 'words
+Match only whole symbols: 'symbols
+
+Use like case-fold-search, don't recommend setting it globally.")
+
(defun mc/mark-more-like-this (skip-last direction)
(let ((case-fold-search nil)
- (re (regexp-opt (mc/region-strings)))
+ (re (regexp-opt (mc/region-strings) mc/enclose-search-term))
(point-out-of-order (ecase direction
(forwards (< (point) (mark)))
(backwards (not (< (point) (mark))))))
@@ -107,7 +116,7 @@
(goto-char start-char)
(when skip-last
(mc/remove-fake-cursor furthest-cursor))
- (if (funcall search-function re nil t)
+ (if (funcall search-function re nil t)
(progn
(push-mark (funcall match-point-getter 0))
(when point-out-of-order
@@ -129,6 +138,18 @@ With zero ARG, skip the last one and mark next."
(mc/maybe-multiple-cursors-mode))
;;;###autoload
+(defun mc/mark-next-word-like-this (arg)
+ (interactive "p")
+ (let ((mc/enclose-search-term 'words))
+ (mc/mark-next-like-this arg)))
+
+;;;###autoload
+(defun mc/mark-next-symbol-like-this (arg)
+ (interactive "p")
+ (let ((mc/enclose-search-term 'symbols))
+ (mc/mark-next-like-this arg)))
+
+;;;###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.
@@ -141,13 +162,25 @@ With zero ARG, skip the last one and mark next."
(mc/mark-lines arg 'backwards))
(mc/maybe-multiple-cursors-mode))
+;;;###autoload
+(defun mc/mark-previous-word-like-this (arg)
+ (interactive "p")
+ (let ((mc/enclose-search-term 'words))
+ (mc/mark-previous-like-this arg)))
+
+;;;###autoload
+(defun mc/mark-previous-symbol-like-this (arg)
+ (interactive "p")
+ (let ((mc/enclose-search-term 'symbols))
+ (mc/mark-previous-like-this arg)))
+
(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)
+ (forwards (loop do (next-line 1 nil)
while (mc/all-fake-cursors (point) (1+ (point)))))
- (backwards (loop do (previous-line 1 nil)
+ (backwards (loop do (previous-line 1 nil)
while (mc/all-fake-cursors (point) (1+ (point))))))))
;;;###autoload
@@ -184,7 +217,7 @@ With zero ARG, skip the last one and mark next."
(let ((master (point))
(case-fold-search nil)
(point-first (< (point) (mark)))
- (re (regexp-opt (mc/region-strings))))
+ (re (regexp-opt (mc/region-strings) mc/enclose-search-term)))
(mc/save-excursion
(goto-char 0)
(while (search-forward-regexp re nil t)
@@ -198,6 +231,18 @@ With zero ARG, skip the last one and mark next."
(multiple-cursors-mode 0)))
;;;###autoload
+(defun mc/mark-all-words-like-this ()
+ (interactive)
+ (let ((mc/enclose-search-term 'words))
+ (mc/mark-all-like-this)))
+
+;;;###autoload
+(defun mc/mark-all-symbols-like-this ()
+ (interactive)
+ (let ((mc/enclose-search-term 'symbols))
+ (mc/mark-all-like-this)))
+
+;;;###autoload
(defun mc/mark-all-in-region (beg end)
"Find and mark all the parts in the region matching the given search"
(interactive "r")
- [nongnu] elpa/multiple-cursors b99d54a 047/434: Fix error message., (continued)
- [nongnu] elpa/multiple-cursors b99d54a 047/434: Fix error message., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 4c56cb8 065/434: Tests for white-list prompt., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 4078570 066/434: Switch to multiple-cursors-mode from rectangular-region with <return>, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors b2906bb 097/434: Don't forget to autoload, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 16563e3 104/434: Add hooks when mc-mode is enabled and disabled., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 6926ca3 105/434: Avoid strange smooth-scrolling behavior., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 059ee6b 109/434: Merge pull request #7 from Mon-Ouie/fix/macro-expansion, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 35921b5 130/434: Clarify that you need to set up own keybindings, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 37a89a6 129/434: Remove mark-multiple-integration feature test, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors d7263f2 136/434: A more rubust way of finding the command currently being invoked., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors fe211c0 176/434: Add word/symbol limiting mark-more functions:,
ELPA Syncer <=
- [nongnu] elpa/multiple-cursors bc8af45 186/434: Use derived-mode-p to check for sgml-mode-ishness., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 1afbb93 175/434: Add mc/cycle-looping-behaviour to multiple-cursors custom group., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors ed18fa4 222/434: Merge pull request #62 from tkf/export-ECUKES_EMACS, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 424e066 198/434: 1.1.5, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 374244b 232/434: Add support for C-s and C-r when phi-search is installed, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 53db250 237/434: Added a mark-pop.feature file., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 69c9961 234/434: Use Carton for dev dependencies, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 75df47f 236/434: Added mention of mc/mark-pop to README.md, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 1cb894d 242/434: Add more mc-specific commands to the run-once list, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 47e03d5 249/434: Release 1.2.2, ELPA Syncer, 2021/08/07