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

From: Keith David Bershatsky <[email-masked]>
Date: Fri, 04 Mar 2016 15:16:56 -0800

I see this feature request as having two (2) distinct, yet related components.  The fake cursors being the first component that will operate similar to overlays, and are thus fairly innocuous as they won't have any real affect on where point is located after redisplay finishes.  The second component, however, is the functionality that can be found in Magnar Sveen's library and also is present in a popular commercial editor known as Sublime Text.

I enjoy using the multiple cursors library written by Magnar Sveen, but often find myself taking advantage of the wait times to pour myself a cup of coffee while making edits with a few hundred fake cursors in a large buffer.  E.g., I will type the word I want inserted or tap the arrow key a few times in a particular direction and then walk away from the computer or surf the web while Emacs does its thing.  I often have to use `M-x replace-string` when dealing with large numbers of edits instead of using my preferred choice of multiple cursors.  Admittedly, I am using a slightly older customized version of Mr. Sveen's library -- but I don't think the basic functionality has changed all that much since I first started using it.

I am not a programmer by trade, but I assume there could be some significant speed increases by having multiple cursor abilities baked into the C code base of the Emacs internals.

I don't think (based on my limited programming knowledge) that all of the cursor-types are presently available as overlays.  I need the left bar cursor so that I can draw my solid vertical line that tracks the cursor position, and so that is what motivated me to write a sample draft patch to the C internals.  My draft is progressing nicely, but it is slow to perfect because I am learning a few of the basics to the C language as I go.  I'll post to #22873 a revised draft of the first component (i.e., just fake cursors) in the next few days depending upon how many road blocks I encounter.  I've set up a simple cache of x/y/hpos/vpos so that recalculation is not necessary when the list of fake cursors doesn't change -- cursors are redrawn more than once per command loop depending upon what happens, e.g., with the mouse, etc.  And a user may not wish to change the positions of fake cursors every command loop, so the cache is helpful.

It may be a very long time, however, before I have enough basic skills to be able to implement some of the functionality of the second component.  I understand the implementation of feature 22873 is only a discussion at this point in time.  The beauty of Emacs, however, is that it's open source and I can make modifications to a custom build for my in-house use.  :)

Keith

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

At Thu, 03 Mar 2016 07:54:17 +0100,
Marcin Borkowski wrote:
> 
> 
> * * *
> 
> What would be the added value of having that built-in vs. having it on
> M?elpa?
> 
> Best,
> 
> -- 
> Marcin Borkowski