GNU bug report logs - #22873
25.1.50; Feature Request -- Multiple Cursors (built-in support)

Previous Next

Package: emacs;

Reported by: Keith David Bershatsky <esq <at> lawlist.com>

Date: Tue, 1 Mar 2016 18:46:01 UTC

Severity: wishlist

Found in version 25.1.50

Full log


Message #71 received at 22873 <at> debbugs.gnu.org (full text, mbox):

From: Keith David Bershatsky <esq <at> lawlist.com>
To: 22873 <at> debbugs.gnu.org
Cc: John Wiegley <jwiegley <at> gmail.com>, Eli Zaretskii <eliz <at> gnu.org>,
 Marcin Borkowski <mbork <at> mbork.pl>, Richard Stallman <rms <at> gnu.org>
Subject: bug#22873:  Can we support multiple Cursors?
Date: Sun, 30 Jul 2017 10:39:45 -0700
[Message part 1 (text/plain, inline)]
VERSION:  009

-  The patch applies to commit a30e7e12ed8465e2565dd318d921bc87f52ce18e from 03/28/2016.  [@lawlist is unable to use the current master branch for daily workflow due to certain unrelated bugs.  Until those unrelated bugs are resolved, @lawlist will continue using earlier versions of the master branch.  @lawlist is tentatively thinking of moving forwards in time to October 1, 2016 bearing commit bb2ef5c6f7058b149adc9230a3db7d1fbd423c51, but testing will be needed prior thereto.]


WHAT'S NEW:

-  `mc_store_previous_values':  Recording values of the current command loop (to be compared against the previous command loop) has been consolidated into one function, which makes the modification to `xdisp.c` cleaner.

-  Bug Fixes:  Enabling error checking when configuring the build revealed a few errors in the code that have now been corrected.  It turned out that `update_window_end` is called in about 99% of the locations where multiple cursors need to be removed.  A previous attempted optimization of `mc_calc` prevented cursor removal, and that bug has now been fixed.  Fixed two crashes; one was caused by an improper usage of `intern_c_string`, and another was caused by attempting to remove cursors directly from `xdisp.c` instead of letting `update_window_end` do its job.


TODO:

-  Track down the cause for the 1% of the time when multiple fake cursors are not being removed.  [It may have something to do with redisplay being interrupted due to keyboard activity, or perhaps when windows/frames are changing size?]

-  Optimize drawing and removal of multiple fake cursors.

-  Implement a way to properly calculate x, y, hpos, vpos when overlays are present.  The overlay after-string property wreaks havoc on the current method of calculating coordinates.

-  Try and motivate one or more real programmers to take over from here.


ROAD MAP:

-  The first stage is the creation/removal of fake cursors.

-  The second stage will be built-in functionality similar to the multiple cursors library by Magnar Sveen.


INSTALLATION:

-  STEP #1 (clone master branch):  git clone -b master git://git.sv.gnu.org/emacs.git

-  STEP #2:  cd over to the root of the `emacs` source directory cloned in the first step above.

-  STEP #3 (hard reset):  git reset --hard a30e7e12ed8465e2565dd318d921bc87f52ce18e

The following message is displayed in the terminal:  "HEAD is now at a30e7e1 Mention the `M-q' changes"

-  STEP #4 (put the patch in place):  Copy the latest patch (multiple_cursors_008.diff) to the root of the emacs source directory cloned in the first step above.

-  STEP #5 (apply the patch):  git apply multiple_cursors_009.diff

-  STEP #6:  ./autogen.sh

-  STEP #7:  Configure the build for X, MS Windows, or OSX; e.g.,:  ./configure --with-ns

-  STEP #8:  make

-  STEP #9:  make install

-  STEP #10:  Launch the newly built Emacs, and copy the following function to the `*scratch*` buffer, and type `M-x mc-test`.

(defun mc-test ()
"Draw fake cursors at all POS defined in the `mc-list'.  Multiple fake cursors
are supported by GUI versions of Emacs built for X, Windows and OSX.
Popular forms of specifying colors such as \"red\" and \"#FF0000\" are now
supported, as well as LSL color vectors such as [1.0 0.0 0.0].  For those users
who choose the former familiar methods of specifying colors with strings,
`mc_color_vector_calculate' will convert those strings to LSL color vectors.
The color vectors are commonly referred to as LSL (The Linden Scripting Language).
`nsterm.m' uses `NSColor', which works well with LSL.  `w32term.c' uses
`PALETTERGB' or `RGB', and the conversion from LSL is done internally by
multiplying each element of the LSL color vector by 255.  `xterm.c' uses
`x_make_truecolor_pixel', which uses 16-bit RGB -- the conversion from LSL
happens internally by multiplying each element of the LSL color vector by 65535."
(interactive)
  (let ((buffer (get-buffer-create "*MC-TEST*")))
    (with-current-buffer buffer
      (erase-buffer)
      (insert "This is a test!")
      (setq mc-list '((1 "hbar" "red")
                      (2 "bar" "yellow")
                      (3 "box" "#00FF00")
                      (4 "hollow" "#0000FF")
                      (5 ("hbar" 3) [1.0 0.0 1.0])
                      (6 ("bar" 3) [0.0 1.0 1.0]))))
    (select-window (display-buffer buffer))
    ;;; The trigger in `keyboard.c` is not activated in this example, so we
    ;;; Force the multiple cursors to be drawn.
    (mc-draw-erase (selected-window))))

[multiple_cursors_009.diff (application/diff, attachment)]

This bug report was last modified 4 years and 354 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.