mirror of
https://github.com/magnars/multiple-cursors.el.git
synced 2025-10-13 21:03:05 +00:00
Add mc/add-cursor-on-click
This commit is contained in:
parent
e7a5fe61c4
commit
0ee76bfad1
13
README.md
13
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-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-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 occurances.
|
||||||
|
- `mc/add-cursor-on-click`: Bind to a mouse event to add cursors by clicking. See tips-section.
|
||||||
|
|
||||||
### Mark many occurrences
|
### 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
|
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`.
|
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
|
## Unknown commands
|
||||||
|
|
||||||
Multiple-cursors uses two lists of commands to know what to do: the run-once list
|
Multiple-cursors uses two lists of commands to know what to do: the run-once list
|
||||||
|
@ -398,6 +398,23 @@ With prefix, it behaves the same as original `mc/mark-all-like-this'"
|
|||||||
(>= (point) beg)
|
(>= (point) beg)
|
||||||
(<= (point) end))))
|
(<= (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
|
;;;###autoload
|
||||||
(defun mc/mark-sgml-tag-pair ()
|
(defun mc/mark-sgml-tag-pair ()
|
||||||
"Mark the tag we're in and its pair for renaming."
|
"Mark the tag we're in and its pair for renaming."
|
||||||
|
@ -66,6 +66,7 @@
|
|||||||
;; - `mc/mark-previous-word-like-this`: Like `mc/mark-previous-like-this` but only for whole words.
|
;; - `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-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 occurances.
|
||||||
|
;; - `mc/add-cursor-on-click`: Bind to a mouse event to add cursors by clicking. See tips-section.
|
||||||
|
|
||||||
;; ### Mark many occurrences
|
;; ### Mark many occurrences
|
||||||
|
|
||||||
@ -115,6 +116,18 @@
|
|||||||
;; BTW, I highly recommend adding `mc/mark-next-like-this` to a key binding that's
|
;; 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`.
|
;; 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
|
;; ## Unknown commands
|
||||||
|
|
||||||
;; Multiple-cursors uses two lists of commands to know what to do: the run-once list
|
;; Multiple-cursors uses two lists of commands to know what to do: the run-once list
|
||||||
|
Loading…
x
Reference in New Issue
Block a user