Subject: bug#22873: #22873 (multiple fake cursors); and, #17684 (crosshairs).

From: Keith David Bershatsky <[email-masked]>
Date: Sun, 28 Apr 2019 18:21:05 -0700

VERSION: 019.001 [04/28/2019]

CHANGELOG:

- With the gracious assistance of Paul Eggert on the Emacs Devel mailing list,
  the caches of fake cursors are now properly being reset.  [The error was due
  to a failure to assign the returned value of xnrealloc back to the cache.]

- Bug fix relating to floating fake cursors that were not being erased.  [This
  was caused because the glyph_flavor had erroneously been set by `mc_engine' as
  MC_GLYPH instead of MC_GLYPHLESS, and `mc_erase_cursor' was called instead of
  `mc_draw_erase_hybrid' (which handles MC_GLYPHLESS, among other things).

- Restored the triggering of update_begin/end when fake cursors are being erased.
  `mc_erase_pre_scroll_display' handles erasing and resetting of the caches.

- Added a mechanism to track the matrix containing the row with the real cursor.
  update_window now updates that row before other rows within the desired_matrix
  so that data relating to that row is available when processing all other rows.
  This is useful when determining which right fringe bitmaps to use when the
  crosshairs feature is active; e.g., cursor is either at or beyond the fringe.

- Added new fringe bitmaps and corresponding face that are used when cursor is
  beyond the fringe; e.g., when horizontal scrolling to the right.  One set of
  bitmaps are used when cursor is exactly at the fringe (a rare, but reproducible
  occurrence); and, another set when cursor is beyond the fringe.  Tests for
  each occurrence have been improved.  The new tests permit Emacs to also handle
  a situation where the fake cursors are partially visible when not quite at the
  fringe, which is noticeable when the real fake cursor is greater than 1 pixel
  wide; e.g., a hollow box cursor.

- Fixed a crash when debugging ns_judges_scroll_bars and wrapped the debugging
  code in a condition to limit its usage.

- All remaining function parameters dealing with RGB have been consolidated into
  struct mc_RGB instead of individual parameters for each color.

- Color determination for all three platforms is now streamlined a bit more with
  `mc_xw_color_values'.

  . NS platform needs no conversion after obtaining RGBA values from
  colorUsingDefaultColorSpace, which are stored in a mc_RGB sttruct until needed.

  . W32 platform:  RGB values are obtained from `w32_defined_color' and divided
  by 65535, which are then stored in a mc_RGB struct until needed.  When needed,
  those values are multiplied by 255 (result not to exceed 255).

  . X11 platform:  RGB values are obtained from `x_defined_color' and divided by
  65535, which are then stored in a mc_RGB struct until needed.  When needed,
  those values are multiplied by 65535 (result not to exceed 65535).

- Verified that garbage collection is under control.

- Fixed a bug that prevented the vertical ruler of crosshairs from drawing when
  the fill column was at the fringe (exactly).

- Fixed a bug affecting the drawing of a hollow cursor around images, which was
  due to the wrong cursor type being set before calling `mc_get_cursor_geometry'.

- Fixed a bug that prevented the real cursor from sometimes being erased.

SETUP:

Step 1:  git clone -b master git://git.sv.gnu.org/emacs.git

Step 2:  In the new emacs folder, go back to an Emacs version from 04/08/2019:

git reset --hard a038df77de7b1aa2d73a6478493b8838b59e4982

Step 3:  From within the new emacs folder created in Step 1, apply the patch:

git apply /path/to/the/patch.diff

Step 4:  ./autogen.sh

Step 5:  ./configure ... [your custom options]

Step 6:  make

Step 7:  make install

USAGE:

- For a minimal working example of built-in fake cursors, type:  M-x mc-test

  ;;; TURN ON FAKE CURSORS (buffer position, cursor-type, cursor color):

  (setq mc-conf '((1 "hbar" "magenta")
                  (2 "bar" "purple")
                  (3 "box" "#00FF00")
                  (4 "hollow" "#0000FF")
                  (5 ("hbar" 3) [1.0 0.0 1.0])
                  (6 ("bar" 3) [0.0 1.0 1.0])
                  (7 "framed" "OrangeRed"))))

  ;;; TURN OFF FAKE CURSORS:

  (setq mc-conf nil)

- To try out the crosshairs feature, type:  M-x +-mode

- To try out built-in fake cursors with Magnar Sveen's multiple-cursors package,
  install that package first.  [If the multiple-cursors package is installed, an
  eval-after-load "multiple-cursors-core" statement within `crosshairs.el` will
  redefine a couple of functions and set up a few keyboard shortcuts.]  If the
  multiple-cursors package by Magnar Sveen is not already installed, then here
  are two easy ways to install that package:

  Type:  M-x mc-install

  OR, evaluate the following snippet:

  (progn
    (require 'package)
    (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)
    (package-initialize)
    (package-refresh-contents)
    (package-install 'multiple-cursors))

TODO:

- When using the multiple fake cursors feature, a fake cursor does not show up at
  zv_p.

- Deal with left/right overwritten glyphs in the w32 and X ports of Emacs.

- Reduce the removal of fake cursors to the bare minimum when scrolling the text
  on the glass directly, and whenever `update_window' is called.

- When an idle-timer fires and point is at the end of a horizontally scrolled
  line in a narrow window, the temporary horizontal scroll is canceled.  Create
  an minimal working example and file a bug report.

- There is a bug affecting the recorded `w->mc.lnum_pixel_width` that is
  observable when not running under gdb, but disappears when running under gdb.
  While viewing a folded org-mode buffer, the non-gdb instance had a visible
  line number pixel-width of 44, but Emacs treated it as fluctuating between
  44 and 55 as the cursor was moved to the end of line.  In the gdb instance,
  the visible line number pixel width was 55 with no fluctuation under the same
  conditions as the non-gdb instance.  This appears to be a different bug than
  bug#32177 (current line number shifts one column to the left) because the line
  number of the current line does not shift left, and changing the bidi settings
  did not correct the issue.

- The current test for `auto_hscroll_mode_p' only looks for `current_line` and
  all five related tests are based upon that assumption, which may not be true.

- Multiple Cursors:  If point is in the middle of a composite character, then
  select a fully composed character so that the fake cursor is visible.

- Implement functionality similar to the Lisp multiple-cursors by Magnar Sveen.

- Follow up with the Emacs team re bug#32177; i.e., (Current line number shifts
  one column to the left.)

- Follow up with the Emacs team re bug#32060; i.e., Horizontal Scrolling
  (Current Line):  Wrong line gets h-scrolled.

- Determine if bug #28936 needs to be fixed and help the Emacs team re same.