Subject: bug#22873: Can we support multiple Cursors?

From: Keith David Bershatsky <[email-masked]>
Date: Tue, 08 Mar 2016 22:27:02 -0800

The second draft of the proposed feature for multiple fake cursors is attached.  For the record, I'm not a programmer -- just a hobbyist -- and the draft patch is not meant to be a proposed official patch -- it is just a working proof concept.  The patch contains a few extra things that I use for debugging and also for drawing my solid vertical line that tracks the cursor position.  It has been tested to some extent on Emacs built for OSX 10.6.8 and Windows XP (SP-3).  Different colors for each fake cursor have already been implemented on Emacs for OSX, but I haven't yet looked into how to accomplish that objective on Emacs for Windows.  The draft concept patch is for the master branch as of March 8, 2016 bearing commit "e0400b72a24d67b53f71c8b97915cae599e36c37".  After applying the patch, the new feature can be tested as follows:

(defun mc-test (&optional list)
"Draw fake cursors at all POS defined in the `mc-list'."
(interactive)
  (setq mc-list '(
    (3 "hbar" [1.0 0.0 0.0])
    (4 "bar" [0.0 1.0 0.0])
    (5 "box" [0.0 0.0 1.0])
    (6 "hollow" [1.0 1.0 1.0])
    (7 ("hbar" 3) [1.0 0.0 1.0])
    (8 ("bar" 3) [0.0 1.0 1.0]))))

(global-set-key [f1] 'mc-test)

To remove the cursors or change the cursors, just modify the buffer-local variable `mc-list' -- e.g., `(setq mc-list nil)` removes them all.  The colors on OSX are the standard RGB color vector.

Thank you, Marcin, for the referral to the ideit feature.  I will certainly try that feature out in the next few days, but have been buried in life's daily activities and also in acquiring the necessary skills to implement the fake cursors feature.

It sure would be great if a real programmer (instead of just a hobbyist like myself) could take this feature to the next level.  If the Windows setup is anything similar to OSX, implementing colors should not be that difficult to achieve (at least I hope that is the case).

I would like this feature to be similar to the original cursor such that a variable like `cursor-in-non-selected-windows' can be used to make the fake cursors displayed in only the selected window or in all windows where those points are visible.  At the present time, I've set it up so that only the selected window receives the fake cursors (as that is my personal preference).

Thank you for taking an interest in this potential new feature,

Keith

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

At Sat, 05 Mar 2016 07:59:52 +0100,
Marcin Borkowski wrote:
> 
> * * *
> 
> Out of curiosity: did you try iedit?  How does it compare wrt speed in
> such extreme cases?  (If it's applicable at all, that is - it's way
> simpler than multiple-cursors, of course.)