[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/multiple-cursors 0ee76bf 214/434: Add mc/add-cursor-on-cli
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/multiple-cursors 0ee76bf 214/434: Add mc/add-cursor-on-click |
Date: |
Sat, 7 Aug 2021 09:20:28 -0400 (EDT) |
branch: elpa/multiple-cursors
commit 0ee76bfad1cf368762e231484c2a0de974cc4797
Author: Magnar Sveen <magnars@gmail.com>
Commit: Magnar Sveen <magnars@gmail.com>
Add mc/add-cursor-on-click
---
README.md | 13 +++++++++++++
mc-mark-more.el | 17 +++++++++++++++++
multiple-cursors.el | 13 +++++++++++++
3 files changed, 43 insertions(+)
diff --git a/README.md b/README.md
index 2c2f24f..fea5eaf 100644
--- a/README.md
+++ b/README.md
@@ -46,6 +46,7 @@ You can [watch an intro to multiple-cursors at Emacs
Rocks](http://emacsrocks.co
- `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/add-cursor-on-click`: Bind to a mouse event to add cursors by clicking.
See tips-section.
### Mark many occurrences
@@ -98,6 +99,18 @@ You can [watch an intro to multiple-cursors at Emacs
Rocks](http://emacsrocks.co
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`.
+### Binding mouse events
+
+To override a mouse event, you will likely have to also unbind the
+`down-mouse` part of the event. Like this:
+
+ (global-unset-key (kbd "M-<down-mouse-1>"))
+ (global-set-key (kbd "M-<mouse-1>") 'mc/add-cursor-on-click)
+
+Or you can do like me and find an unused, but less convenient, binding:
+
+ (global-set-key (kbd "C-S-<mouse-1>") 'mc/add-cursor-on-click)
+
## Unknown commands
Multiple-cursors uses two lists of commands to know what to do: the run-once
list
diff --git a/mc-mark-more.el b/mc-mark-more.el
index 6dffeb5..ca239e0 100644
--- a/mc-mark-more.el
+++ b/mc-mark-more.el
@@ -399,6 +399,23 @@ With prefix, it behaves the same as original
`mc/mark-all-like-this'"
(<= (point) end))))
;;;###autoload
+(defun mc/add-cursor-on-click (event)
+ "Add a cursor where you click."
+ (interactive "e")
+ (mouse-minibuffer-check event)
+ ;; Use event-end in case called from mouse-drag-region.
+ ;; If EVENT is a click, event-end and event-start give same value.
+ (let ((position (event-end event)))
+ (if (not (windowp (posn-window position)))
+ (error "Position not in text area of window"))
+ (select-window (posn-window position))
+ (if (numberp (posn-point position))
+ (save-excursion
+ (goto-char (posn-point position))
+ (mc/create-fake-cursor-at-point)))
+ (mc/maybe-multiple-cursors-mode)))
+
+;;;###autoload
(defun mc/mark-sgml-tag-pair ()
"Mark the tag we're in and its pair for renaming."
(interactive)
diff --git a/multiple-cursors.el b/multiple-cursors.el
index 7ea861a..518855c 100644
--- a/multiple-cursors.el
+++ b/multiple-cursors.el
@@ -66,6 +66,7 @@
;; - `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/add-cursor-on-click`: Bind to a mouse event to add cursors by
clicking. See tips-section.
;; ### Mark many occurrences
@@ -115,6 +116,18 @@
;; 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`.
+;; ### Binding mouse events
+
+;; To override a mouse event, you will likely have to also unbind the
+;; `down-mouse` part of the event. Like this:
+;;
+;; (global-unset-key (kbd "M-<down-mouse-1>"))
+;; (global-set-key (kbd "M-<mouse-1>") 'mc/add-cursor-on-click)
+;;
+;; Or you can do like me and find an unused, but less convenient, binding:
+;;
+;; (global-set-key (kbd "C-S-<mouse-1>") 'mc/add-cursor-on-click)
+
;; ## Unknown commands
;; Multiple-cursors uses two lists of commands to know what to do: the
run-once list
- [nongnu] elpa/multiple-cursors f7d393d 128/434: Don't use next-line and previous-line in non-interactive ways., (continued)
- [nongnu] elpa/multiple-cursors f7d393d 128/434: Don't use next-line and previous-line in non-interactive ways., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors fc59b63 131/434: Fix typo, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors d98b85b 138/434: Bump to 1.1.2, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 6e9ea1a 149/434: Merge pull request #20 from tkf/diff-friendly-save-lists, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 6d4979d 144/434: Bump to 1.1.3, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors b3ca408 171/434: Have to require 'cl for now, because of count-if., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors a6984a1 203/434: Merge pull request #53 from oneself/master, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors a37e02b 177/434: Add new mc-commands to default run-once list., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 6339657 192/434: Fix byte-compilation warnings, and avoid unnecessary use of "eval", ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 641eb68 212/434: Can use mc/reverse-regions w/o region or cursors, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 0ee76bf 214/434: Add mc/add-cursor-on-click,
ELPA Syncer <=
- [nongnu] elpa/multiple-cursors 16589a5 224/434: Update README.md, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 5c60757 216/434: export ECUKES_EMACS in run-travis-ci.sh, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 6467fe2 277/434: Add mc/mark-all-dwim to autoloads, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors c69be0e 282/434: Travis CI: Update location of cask install, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 4da58ea 302/434: Merge pull request #146 from bling/master, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors f0dcd06 323/434: Merge pull request #175 from lexa/master, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 2d6ffce 330/434: Support unmarking with no region. Change mc/mark-lines to preserve point., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 36b7025 348/434: Add alternative to mc/mark-next-like-this, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors a393384 353/434: Merge pull request #227 from jtamagnan/insert_letters, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors e17851e 359/434: Fix click-toggling and make it robust (address all PR #239 comments), ELPA Syncer, 2021/08/07