diff --git a/lisp/crosshairs.el b/lisp/crosshairs.el
new file mode 100755
index 0000000..732fbb0
--- /dev/null
+++ b/lisp/crosshairs.el
@@ -0,0 +1,1233 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; BEGIN modification of the Multiple Cursors library written by  Magnar Sveen.
+
+(defvar package-archives)
+
+(defvar mc--max-cursors-original)
+(defvar mc/max-cursors)
+(defvar mc--max-cursors-original)
+(defvar mc/max-cursors)
+(defvar mc/always-run-for-all)
+(defvar mc--this-command)
+(defvar mc/cmds-to-run-once)
+(defvar mc--default-cmds-to-run-for-all)
+(defvar mc/cmds-to-run-for-all)
+(defvar mc--default-cmds-to-run-once)
+(defvar mc--executing-command-for-fake-cursor)
+
+(declare-function mc/make-cursor-overlay-at-point "ext:multiple-cursors-core")
+(declare-function multiple-cursors-mode "ext:multiple-cursors-core")
+(declare-function mc/num-cursors "ext:multiple-cursors-core")
+(declare-function mc/remove-fake-cursors "ext:multiple-cursors-core")
+(declare-function mc/create-cursor-id "ext:multiple-cursors-core")
+(declare-function mc/store-current-state-in-overlay "ext:multiple-cursors-core")
+(declare-function mc/make-region-overlay-between-point-and-mark "ext:multiple-cursors-core")
+(declare-function mc/execute-command-for-all-fake-cursors "ext:multiple-cursors-core")
+(declare-function mc/prompt-for-inclusion-in-whitelist "ext:multiple-cursors-core")
+(declare-function mc/all-fake-cursors "ext:multiple-cursors-core")
+(declare-function mc/mark-next-like-this "ext:mc-mark-more")
+(declare-function mc/mark-previous-like-this  "ext:mc-mark-more")
+
+;;;###autoload
+(defun mc-install ()
+"To use multiple-cursors after restarting Emacs, make sure that the following line
+appears somewhere in the .emacs/init.el:  (package-initialize)"
+(interactive)
+  (require 'package)
+  (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)
+  (package-initialize)
+  (package-refresh-contents)
+  (unless (locate-library "multiple-cursors-core")
+    (package-install 'multiple-cursors)))
+
+(eval-after-load "multiple-cursors-core" '(progn
+
+  (define-key global-map [S-mouse-1] 'mc/add-cursor-on-click)
+  (define-key global-map [?\M-d] 'mc/mark-next-like-this-cycle-forward)
+  (define-key global-map [?\M-D] 'mc/mark-previous-like-this-cycle-forward)
+  (define-key global-map [?\s-d] 'mc/mark-next-like-this-cycle-forward)
+  (define-key global-map [?\s-D] 'mc/mark-previous-like-this-cycle-forward)
+  (define-key global-map (kbd "<C-s-268632071>") 'mc/mark-all-like-this)
+  (define-key global-map (kbd "C-s-g") 'mc/mark-all-like-this)
+  (define-key global-map (kbd "S-s-d") 'mc/mark-previous-like-this-cycle-forward)
+  (define-key global-map (kbd "C-l") 'mc/edit-ends-of-lines)
+  (define-key global-map (kbd "C-S-l") 'mc/edit-beginnings-of-lines)
+
+  (add-hook 'multiple-cursors-mode-disabled-hook
+            (lambda () (kill-local-variable 'multiple-cursors-conf)))
+
+  (defvar mc/use-built-in-cursors t
+  "Whether to use the built-in fake cursors.")
+
+  (defun mc/create-fake-cursor-at-point (&optional id)
+    "Add a fake cursor and possibly a fake active region overlay based on point and mark.
+  Saves the current state in the overlay to be restored later."
+    (unless mc--max-cursors-original
+      (setq mc--max-cursors-original mc/max-cursors))
+    (when mc/max-cursors
+      (unless (< (mc/num-cursors) mc/max-cursors)
+        (if (yes-or-no-p (format "%d active cursors. Continue? " (mc/num-cursors)))
+            (setq mc/max-cursors (read-number "Enter a new, temporary maximum: "))
+          (mc/remove-fake-cursors)
+          (error "Aborted: too many cursors"))))
+    (let ((overlay
+            (if mc/use-built-in-cursors
+              (make-overlay (point) (point))
+              (mc/make-cursor-overlay-at-point))))
+      (overlay-put overlay 'mc-id (or id (mc/create-cursor-id)))
+      (overlay-put overlay 'type 'fake-cursor)
+      (overlay-put overlay 'priority 100)
+      (mc/store-current-state-in-overlay overlay)
+      (when (use-region-p)
+        (overlay-put overlay 'region-overlay
+                     (mc/make-region-overlay-between-point-and-mark)))
+      overlay))
+
+  (defun mc/execute-this-command-for-all-cursors-1 ()
+    "Used with post-command-hook to execute supported commands for all cursors.
+  -  It uses two lists of commands to know what to do: the run-once
+  list and the run-for-all list. If a command is in neither of these lists,
+  it will prompt for the proper action and then save that preference.
+  -  Some commands are so unsupported that they are even prevented for
+  the original cursor, to inform about the lack of support."
+    (unless mc--executing-command-for-fake-cursor
+      (if (eq 1 (mc/num-cursors)) ;; no fake cursors? disable mc-mode
+          (multiple-cursors-mode 0)
+        (when this-original-command
+          (let ((original-command (or mc--this-command
+                                      (command-remapping this-original-command)
+                                      this-original-command)))
+            ;; skip keyboard macros, since they will generate actual commands that are
+            ;; also run in the command loop - we'll handle those later instead.
+            (when (functionp original-command)
+              ;; if it's a lambda, we can't know if it's supported or not
+              ;; - so go ahead and assume it's ok, because we're just optimistic like that
+              (if (or (not (symbolp original-command))
+                      ;; lambda registered by smartrep
+                      (string-prefix-p "(" (symbol-name original-command)))
+                  (mc/execute-command-for-all-fake-cursors original-command)
+                ;; smartrep `intern's commands into own obarray to help
+                ;; `describe-bindings'.  So, let's re-`intern' here to
+                ;; make the command comparable by `eq'.
+                (setq original-command (intern (symbol-name original-command)))
+                ;; otherwise it's a symbol, and we can be more thorough
+                (if (get original-command 'mc--unsupported)
+                    (message "%S is not supported with multiple cursors%s"
+                             original-command
+                             (get original-command 'mc--unsupported))
+                  (when (and original-command
+                             (not (memq original-command mc--default-cmds-to-run-once))
+                             (not (memq original-command mc/cmds-to-run-once))
+                             (or mc/always-run-for-all
+                                 (memq original-command mc--default-cmds-to-run-for-all)
+                                 (memq original-command mc/cmds-to-run-for-all)
+                                 (mc/prompt-for-inclusion-in-whitelist original-command)))
+                    (mc/execute-command-for-all-fake-cursors original-command))))
+              (when mc/use-built-in-cursors
+                (setq multiple-cursors-conf
+                        (mapcar
+                          (lambda (x) (list (overlay-start x) "bar" nil))
+                          (mc/all-fake-cursors))))))))))
+
+  (defun mc/mark-next-like-this-cycle-forward ()
+  "Marks next occurence of word like this and advances cursor to this occurrence"
+  (interactive)
+    (mc/mark-next-like-this 1))
+
+  (defun mc/mark-previous-like-this-cycle-forward ()
+  "Marks next occurrence of word like this and advances cursor to this occurrence"
+  (interactive)
+    (mc/mark-previous-like-this 1))
+
+  (add-to-list 'mc--default-cmds-to-run-once 'mc/mark-next-like-this-cycle-forward)
+
+  (add-to-list 'mc--default-cmds-to-run-once 'mc/mark-previous-like-this-cycle-forward) ))
+
+;;; END modification of the Multiple Cursors library written by  Magnar Sveen.
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; BEGIN crosshairs.el
+
+;;; BUILT-IN VARIABLES:
+
+;;; The variables `crosshairs-horizontal-ruler' and `crosshairs-vertical-ruler'
+;;; may be used to suppress either or both of the rulers that create crosshairs.
+;;;
+;;; (setq crosshairs-horizontal-ruler nil)
+;;;
+;;; (setq crosshairs-vertical-ruler nil)
+
+;;; The variable `mc-real-fake-cursor' controls what type of cursor will
+;;; be drawn in lieu of the real cursor when crosshairs are active.  The string
+;;; "no" will cause the creation of a horizontal and vertical bar for a seamless
+;;; appearance.
+;;;
+;;; (setq mc-real-fake-cursor "no")
+
+;;; When `crosshairs-draw-forthwith' is non-nil, draw crosshairs whenever the
+;;; real cursor would ordinarily be drawn, which is sometimes more than once
+;;; every command loop.  When `crosshairs-draw-forthwith' is nil, crosshairs
+;;; will be placed on an idle-timer.  If this variable is reset while `+-mode'
+;;; is enabled, then it may be necessary to turn off/on `+-mode' to reset
+;;; functions attached to the `post-command-hook'.  The default is non-nil.
+;;;
+;;; (setq crosshairs-draw-forthwith nil)
+
+;;; The variables `multiple-cursors-inactive-windows' and `crosshairs-inactive-windows'
+;;; may be used to display multiple cursors and/or crosshairs in the inactive
+;;; windows.  The default is nil.  A non-nil value will turn on this feature.
+;;;
+;;; (setq multiple-cursors-inactive-windows t)
+;;;
+;;; (setq crosshairs-inactive-windows t)
+
+;;; When `multiple-cursors-draw-forthwith' is non-nil, draw crosshairs whenever the
+;;; real cursor would ordinarily be drawn, which is sometimes more than once
+;;; every command loop.  When `multiple-cursors-draw-forthwith' is nil, crosshairs
+;;; will be placed on an idle-timer.  If this variable is reset while `multiple-cursors-mode'
+;;; is enabled, then it may be necessary to turn off/on `multiple-cursors-mode' to reset
+;;; functions attached to the `post-command-hook'.  The default is non-nil.
+;;;
+;;; (setq multiple-cursors-draw-forthwith nil)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; FACES
+
+(defgroup +-mode nil
+  "Faces for the vertical ruler."
+  :group 'convenience)
+
+;;; Defined in `faces.el`; and, used in `xdisp.c`.
+;;;
+;;; (defface +-vertical-bar-face
+;;;   '((t (:foreground "magenta")))
+;;;   "Face for `+-vertical-bar-face'."
+;;;   :group '+-mode)
+
+;;; Defined in `faces.el`; and, used in `xdisp.c`.
+;;;
+;;; (defface +-even-numbered-column-face
+;;;   '((t (:foreground "yellow")))
+;;;   "Face for `+-even-numbered-column-face'."
+;;;   :group '+-mode)
+
+;;; Defined in `faces.el`; and, used in `xdisp.c`.
+;;;
+;;; (defface +-odd-numbered-column-face
+;;;   '((t (:foreground "red")))
+;;;   "Face for `+-odd-numbered-column-face'."
+;;;   :group '+-mode)
+
+;;; Defined in `faces.el`; and, used in `xdisp.c`.
+;;;
+;;; (defface +-beyond-fill-column-face
+;;;   '((t (:foreground "green")))
+;;;   "Face for `+-beyond-fill-column-face'."
+;;;   :group '+-mode)
+
+;;; Defined in `faces.el`; and, used in `xdisp.c`.
+;;;
+;;; (defface +-real-fake-cursor-face
+;;;   '((t (:foreground "cyan" :background "DarkBlue")))
+;;;   "Face for `+-real-fake-cursor-face'.  Used in `xdisp.c'.
+;;; As to a hollow style cursor, the :foreground parameter is used for the border and
+;;; the :background parameter is used for the inner filled shading.  The character
+;;; retains its own foreground color and is unaffected by this particular face."
+;;;   :group '+-mode)
+
+;;; Defined in `faces.el`; and, used in `xdisp.c`.
+;;;
+;;; (defface +-even-numbered-column-inactive-face
+;;;   '((t (:foreground "#eee8aa"))) ;;; PaleGoldenrod
+;;;   "Face for `+-even-numbered-column-inactive-face'.  Used in `xdisp.c'."
+;;;   :group '+-mode)
+
+;;; Defined in `faces.el`; and, used in `xdisp.c`.
+;;;
+;;; (defface +-odd-numbered-column-inactive-face
+;;;   '((t (:foreground "#ff6347"))) ;;; tomato
+;;;   "Face for `+-odd-numbered-column-inactive-face'.  Used in `xdisp.c'."
+;;;   :group '+-mode)
+
+;;; Defined in `faces.el`; and, used in `xdisp.c`.
+;;;
+;;; (defface +-beyond-fill-column-inactive-face
+;;;   '((t (:foreground "#2e8b57"))) ;;; SeaGreen
+;;;   "Face for `+-beyond-fill-column-inactive-face'.  Used in `xdisp.c'."
+;;;   :group '+-mode)
+
+;;; Defined in `faces.el`; and, used in `xdisp.c`.
+;;;
+;;; (defface +-real-fake-cursor-inactive-face
+;;;   '((t (:foreground "#ff00ff" :background "ForestGreen"))) ;;; magenta / ForestGreen
+;;;   "Face for `+-real-fake-cursor-inactive-face'.  Used in `xdisp.c'.
+;;; As to a hollow style cursor, the :foreground parameter is used for the border and
+;;; the :background parameter is used for the inner filled shading.  The character
+;;; retains its own foreground color and is unaffected by this particular face."
+;;;   :group '+-mode)
+
+;;; Defined in `faces.el`; and, used in `xdisp.c`.
+;;;
+;;; (defface +-overlay-arrow-face
+;;;   '((t (:foreground "red")))
+;;;   "Face for `+-overlay-arrow-face'."
+;;;   :group '+-mode)
+
+;;; Defined in `faces.el`; and, used in `xdisp.c`.
+;;;
+;;; (defface +-overlay-arrow-minimal-face
+;;;   '((t (:foreground "blue")))
+;;;   "Face for `+-overlay-arrow-minimal-face'."
+;;;   :group '+-mode)
+
+;;; Defined in `faces.el`; and, used in `xdisp.c`.
+;;;
+;;; (defface +-overlay-arrow-inactive-face
+;;;   '((t (:foreground "orange")))
+;;;   "Face for `+-overlay-arrow-inactive-face'."
+;;;   :group '+-mode)
+
+(defface +-form-feed-face
+  (cond
+    ((eq system-type 'darwin)
+      '((t (:foreground "magenta"))))
+    ((eq system-type 'windows-nt)
+      '((t (:foreground "magenta")))))
+  "Face for `+-form-feed-face'."
+  :group '+-mode)
+
+(defface +-newline-face
+  '((t (:foreground "#555555")))
+  "Face for `+-newline-face'."
+  :group '+-mode)
+
+(defface +-space-face
+  '((t (:foreground "DarkRed")))
+  "Face for `+-space-face'."
+  :group '+-mode)
+
+(defface +-tab-face
+  '((t (:foreground "cyan")))
+  "Face for `+-tab-face'."
+  :group '+-mode)
+
+(defface +-tab-spacer-face
+  '((t (:background "grey25")))
+  "Face for `+-tab-spacer-face'."
+  :group '+-mode)
+
+(defface +-left-fringe-current-line-face
+  '((t (:foreground "green")))
+  "Face for `+-left-fringe-current-line-face'."
+  :group '+-mode)
+
+(defface +-left-fringe-cursor-alt-one-face
+  '((t (:foreground "blue")))
+  "Face for `+-left-fringe-cursor-alt-one-face'."
+  :group '+-mode)
+
+(defface +-left-fringe-cursor-alt-two-face
+  '((t (:foreground "red")))
+  "Face for `+-left-fringe-cursor-alt-two-face'."
+  :group '+-mode)
+
+(defface +-hollow-rectangle-face
+  '((t (:foreground "chartreuse")))
+  "Face for `+-hollow-rectangle-face'."
+  :group '+-mode)
+
+(defface +-backslash-face
+  '((t (:foreground "grey25")))
+  "Face for `+-backslash-face'."
+  :group '+-mode)
+
+(defface +-fringe-question-mark-face
+  '((t (:foreground "green")))
+  "Face for `+-fringe-question-mark-face'."
+  :group '+-mode)
+
+(defface +-fringe-exclamation-mark-face
+  '((t (:foreground "cyan")))
+  "Face for `+-fringe-exclamation-mark-face'."
+  :group '+-mode)
+
+(defface +-fringe-left-arrow-face
+  '((t (:foreground "purple")))
+  "Face for `+-fringe-left-arrow-face'."
+  :group '+-mode)
+
+(defface +-fringe-right-arrow-face
+  '((t (:foreground "OrangeRed")))
+  "Face for `+-fringe-right-arrow-face'."
+  :group '+-mode)
+
+(defface +-fringe-up-arrow-face
+  '((t (:foreground "RoyalBlue")))
+  "Face for `+-fringe-up-arrow-face'."
+  :group '+-mode)
+
+(defface +-fringe-down-arrow-face
+  '((t (:foreground "cyan")))
+  "Face for `+-fringe-down-arrow-face'."
+  :group '+-mode)
+
+(defface +-fringe-left-curly-arrow-face
+  '((t (:foreground "grey25")))
+  "Face for `+-fringe-left-curly-arrow-face'."
+  :group '+-mode)
+
+(defface +-fringe-right-curly-arrow-face
+  '((t (:foreground "#3c3c3c")))
+  "Face for `+-fringe-right-curly-arrow-face'."
+  :group '+-mode)
+
+(defface +-fringe-left-triangle-face
+  '((t (:foreground "red")))
+  "Face for `+-fringe-left-triangle-face'."
+  :group '+-mode)
+
+(defface +-fringe-right-triangle-face
+  '((t (:foreground "yellow")))
+  "Face for `+-fringe-right-triangle-face'."
+  :group '+-mode)
+
+(defface +-fringe-top-left-angle-face
+  '((t (:foreground "magenta")))
+  "Face for `+-fringe-top-left-angle-face'."
+  :group '+-mode)
+
+(defface +-fringe-top-right-angle-face
+  '((t (:foreground "orange")))
+  "Face for `+-fringe-top-right-angle-face'."
+  :group '+-mode)
+
+(defface +-fringe-bottom-left-angle-face
+  '((t (:foreground "magenta")))
+  "Face for `+-fringe-bottom-left-angle-face'."
+  :group '+-mode)
+
+(defface +-fringe-bottom-right-angle-face
+  '((t (:foreground "magenta")))
+  "Face for `+-fringe-bottom-right-angle-face'."
+  :group '+-mode)
+
+(defface +-fringe-left-bracket-face
+  '((t (:foreground "yellow")))
+  "Face for `+-fringe-left-bracket-face'."
+  :group '+-mode)
+
+(defface +-fringe-right-bracket-face
+  '((t (:foreground "green")))
+  "Face for `+-fringe-right-bracket-face'."
+  :group '+-mode)
+
+(defface +-fringe-filled-rectangle-face
+  '((t (:foreground "chartreuse")))
+  "Face for `+-fringe-filled-rectangle-face'."
+  :group '+-mode)
+
+(defface +-fringe-hollow-square-face
+  '((t (:foreground "chartreuse")))
+  "Face for `+-fringe-hollow-square-face'."
+  :group '+-mode)
+
+(defface +-fringe-filled-square-face
+  '((t (:foreground "chartreuse")))
+  "Face for `+-fringe-filled-square-face'."
+  :group '+-mode)
+
+(defface +-fringe-horizontal-bar-face
+  '((t (:foreground "chartreuse")))
+  "Face for `+-fringe-horizontal-bar-face'."
+  :group '+-mode)
+
+(defface +-fringe-empty-line-face
+  '((t (:foreground "DarkGreen")))
+  "Face for `+-fringe-empty-line-face'."
+  :group '+-mode)
+
+(defface +-parens-one-face
+  '((t (:foreground "magenta")))
+  "Face for `+-parens-one-face'."
+  :group '+-mode)
+
+(defface +-parens-two-face
+  '((t (:foreground "red")))
+  "Face for `+-parens-two-face'."
+  :group '+-mode)
+
+(defface +-parens-three-face
+  '((t (:foreground "yellow")))
+  "Face for `+-parens-three-face'."
+  :group '+-mode)
+
+(defface +-parens-four-face
+  '((t (:foreground "green")))
+  "Face for `+-parens-four-face'."
+  :group '+-mode)
+
+(defface +-parens-five-face
+  '((t (:foreground "cyan")))
+  "Face for `+-parens-five-face'."
+  :group '+-mode)
+
+(defface +-parens-six-face
+  '((t (:foreground "orange")))
+  "Face for `+-parens-six-face'."
+  :group '+-mode)
+
+(defface +-parens-seven-face
+  '((t (:foreground "purple")))
+  "Face for `+-parens-seven-face'."
+  :group '+-mode)
+
+(defface +-parens-eight-face
+  '((t (:foreground "blue")))
+  "Face for `+-parens-eight-face'."
+  :group '+-mode)
+
+(defface +-parens-nine-face
+  '((t (:foreground "brown")))
+  "Face for `+-parens-nine-face'."
+  :group '+-mode)
+
+(defface +-parens-ten-face
+  '((t (:foreground "white")))
+  "Face for `+-parens-ten-face'."
+  :group '+-mode)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; VARIABLES
+
+(defvar +-mode)
+
+(defvar +-buffer-display-table
+  (let* ((ff-char ?\u0046)
+         (display-table (make-display-table))
+         (glyph-form-feed (make-glyph-code ff-char '+-form-feed-face))
+         (glyph-pilcrow (make-glyph-code ?\u00B6 '+-newline-face))
+         (glyph-space (make-glyph-code ?\u00B7 '+-space-face))
+         (glyph-tab (make-glyph-code ?\u00BB '+-tab-face))
+         (glyph-tab-spacer (make-glyph-code ?\t '+-tab-spacer-face)))
+    (aset display-table ?\n `[,glyph-pilcrow ?\n])
+    (aset display-table ?\f `[,glyph-form-feed ,glyph-form-feed])
+    ;;; minimum tab-width is `2`
+    ;; (aset display-table ?\t `[,glyph-tab ?\t])
+    (aset display-table ?\t `[,glyph-tab ,glyph-tab-spacer])
+    ;;; tab-width always equals `1`
+    ;; (aset display-table ?\t `[,glyph-tab])
+    (aset display-table ?\s `[,glyph-space])
+    display-table)
+  "The `buffer-display-table' that is used when `+-mode' is active.")
+
+(defvar +-timer-var nil
+"Timer used to highlight current column whenever Emacs is idle.")
+
+(defvar +-idle-timer-seconds 0.5
+  "The number of seconds to delay before drawing crosshairs when the variable
+`crosshairs-draw-forthwith' has a nil value.")
+
+(defvar +-truncate-lines-major-modes '()
+  "List of major modes were truncate lines shall be enabled.")
+
+(defvar +-truncate-lines-derived-modes '(prog-mode)
+  "List of derived modes were truncate lines shall be enabled.")
+
+(defvar +--saved-state nil
+  "Used to store/restore certain buffer-local variables when enabling/disabling)
+`+-mode'.")
+
+(defvar +-parens-inactive-windows t
+  "When non-nil, display matching parentheses in the inactive window.")
+(make-variable-buffer-local '+-parens-inactive-windows)
+
+(defvar +-parens-exclusions '(mwheel-scroll)
+  "List of functions that will prevent matching parentheses from updating.")
+
+(defvar +-parens-from-fn nil
+  "Custom function to determine how far back towards the beginning of the file
+should `+-parens-fn' search for matching parentheses -- the result thrown from
+this custom function must be a buffer point.  If no custom function is defined,
+then `+-parens-fn' will use `point-min'.")
+
+(defvar +-parens-overlays-exist-p nil
+"Simple test to see whether the parens overlays have been placed.
+This could be a different kind of test -- e.g., scanning for the
+presence of specific overlays, but perhaps that is overkill.")
+(make-variable-buffer-local '+-parens-overlays-exist-p)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; FUNCTIONS
+
+;;;###autoload
+(defun mc-test ()
+"Draw fake cursors at all POS defined in the `multiple-cursors-conf'.  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 multiple-cursors-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]))))
+    (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-activate-multiple-cursors (selected-window))))
+
+(defun +-timer-fn ()
+"Since this fires globally, we must control which buffers crosshairs appear in."
+  (when +-mode
+    (unless (memq last-command +-parens-exclusions)
+      (+-parens-fn))
+    (when +-timer-var
+      (setq timer-idle-list (delq +-timer-var timer-idle-list))
+      (setq +-timer-var nil))
+    (unless crosshairs-draw-forthwith
+      (mc-activate-crosshairs (selected-window)))))
+
+(defun +-draw-forthwith ()
+  "Force both rulers to be drawn/redrawn."
+  (+-draw-crosshairs 'force))
+
+(defun +-draw-crosshairs (&optional force)
+  (when +-mode
+    (when +-timer-var
+      (setq timer-idle-list (delq +-timer-var timer-idle-list))
+      (setq +-timer-var nil))
+    (unless (memq this-command +-parens-exclusions)
+      (+-delete-parens-overlays))
+    (if force
+      (progn
+        (+-parens-fn)
+        (unless crosshairs-draw-forthwith
+          (mc-activate-crosshairs (selected-window))))
+      (setq +-timer-var (run-with-idle-timer +-idle-timer-seconds nil #'+-timer-fn)))))
+
+;;;###autoload
+(define-minor-mode +-mode
+"Minor mode for displaying a horizontal ruler."
+  :init-value nil
+  :lighter " +"
+  :keymap nil
+  :global nil
+  :group '+-mode
+  (cond
+    (+-mode
+      (when (and global-eldoc-mode
+                 (called-interactively-p 'any)
+                 (equal current-prefix-arg '(4)))
+        (global-eldoc-mode -1))
+      (when (and jit-lock-context-timer
+                 (called-interactively-p 'any)
+                 (equal current-prefix-arg '(4)))
+        (when (timerp jit-lock-context-timer)
+          (cancel-timer jit-lock-context-timer))
+        ;; (setq jit-lock-context-timer (run-with-idle-timer 5.0 'repeat 'jit-lock-context-fontify))
+        (setq jit-lock-context-timer nil))
+      (when (and (called-interactively-p 'any)
+                 (equal current-prefix-arg '(4)))
+        (when (timerp undo-auto-current-boundary-timer)
+          (cancel-timer undo-auto-current-boundary-timer))
+        (fset 'undo-auto--undoable-change
+              (lambda () (add-to-list 'undo-auto--undoably-changed-buffers (current-buffer))))
+        (fset 'undo-auto-amalgamate 'ignore))
+      (when blink-cursor-mode
+        (blink-cursor-mode -1)
+        (when (memq 'blink-cursor-check post-command-hook)
+          (remove-hook 'post-command-hook 'blink-cursor-check)))
+      (when (and (called-interactively-p 'any)
+                 (equal current-prefix-arg '(4))
+                 (null crosshairs-draw-forthwith))
+        (setq crosshairs-draw-forthwith t))
+      (setq crosshairs t)
+      ;;; `auto-composition-mode' is needed for crosshairs to properly calculate
+      ;;; coordinates of composition characters.  Automatically becomes permanently
+      ;;; buffer-local when set.
+      (unless auto-composition-mode
+        (setq auto-composition-mode t))
+      ;;; @lawlist is focusing the initial development of feature requests #17684
+      ;;; and #22873 on L2R languages.  The feature test file used by @lawlist
+      ;;; bogs Emacs down unless `bidi-display-reordering' is set to a nil value.
+      ;;; However, most users will probably not want this particular setting.
+      (unless (null bidi-display-reordering)
+        (setq bidi-display-reordering nil))
+      (unless (and (called-interactively-p 'any)
+                   (equal current-prefix-arg '(4)))
+        (set (make-local-variable '+--saved-state) nil)
+        (dolist (var '(buffer-display-table
+                       fringe-indicator-alist
+                       tab-width
+                       line-move-visual
+                       truncate-lines
+                       truncate-partial-width-windows
+                       word-wrap))
+          (when (local-variable-p var)
+            (push (cons var (symbol-value var)) +--saved-state)))
+        (setq fill-column 80)
+        (setq display-line-numbers t)
+        (setq-local auto-hscroll-mode 'current-line)
+        (setq-local hscroll-step 5)
+        (setq buffer-display-table +-buffer-display-table)
+        (setq tab-width 4)
+        (set (make-local-variable 'line-move-visual) t)
+        (setq truncate-lines
+          (cond
+            ((let ((lst +-truncate-lines-derived-modes)
+                    mode)
+              (catch 'found
+                (while (setq mode (pop lst))
+                  (when (derived-mode-p mode)
+                    (throw 'found t))))))
+             ((memq major-mode +-truncate-lines-major-modes))
+             (t
+               nil)))
+        (set (make-local-variable 'truncate-partial-width-windows) nil)
+        (setq word-wrap t)
+        (setq indicate-empty-lines t)
+        (setq indicate-buffer-boundaries 'left)
+        (setq fringe-indicator-alist
+          '((hscl_temporary . +-fringe-left-arrow)
+            (truncation . (+-fringe-left-arrow +-fringe-right-arrow))
+            (continuation . (+-fringe-left-curly-arrow +-backslash))
+            (overlay-arrow . +-fringe-right-arrow)
+            (up . +-fringe-up-arrow)
+            (down . +-fringe-down-arrow)
+            (top . +-fringe-top-left-angle)
+            (bottom . +-fringe-bottom-right-angle)
+            (top-bottom . (+-fringe-left-bracket
+                           +-fringe-right-bracket
+                           +-fringe-top-right-angle
+                           +-fringe-top-left-angle))
+            (empty-line . +-fringe-empty-line)
+            (unknown . +-fringe-question-mark)))
+        (setq fringe-cursor-alist '((box . +-fringe-left-triangle)
+                                    (hollow . +-hollow-rectangle)
+                                    (bar . +-vertical-bar)
+                                    (hbar . +-fringe-horizontal-bar)
+                                    (hollow-small . +-fringe-hollow-square)))
+        (if crosshairs-draw-forthwith
+          (add-hook 'post-command-hook '+-draw-forthwith 'append 'local)
+          (add-hook 'post-command-hook '+-draw-crosshairs 'append 'local))
+        (when crosshairs-draw-forthwith
+          (add-hook 'window-configuration-change-hook '+-draw-forthwith nil 'local))
+        (add-hook 'change-major-mode-hook 'turn-off-+-mode nil 'local))
+      (when (called-interactively-p 'any)
+        (if (equal current-prefix-arg '(4))
+          (message "Turned ON `+-mode' -- debugging mode.")
+          (message "Turned ON `+-mode'."))))
+    (t
+      (kill-local-variable 'fill-column)
+      (kill-local-variable 'auto-hscroll-mode)
+      (kill-local-variable 'hscroll-step)
+      (kill-local-variable 'crosshairs)
+      (kill-local-variable 'display-line-numbers)
+      (kill-local-variable 'display-line-numbers-width)
+      (kill-local-variable 'multiple-cursors-conf)
+      (kill-local-variable 'buffer-display-table)
+      (kill-local-variable 'tab-width)
+      (kill-local-variable 'line-move-visual)
+      (kill-local-variable 'truncate-lines)
+      (kill-local-variable 'truncate-partial-width-windows)
+      (kill-local-variable 'word-wrap)
+      (kill-local-variable 'indicate-empty-lines)
+      (kill-local-variable 'indicate-buffer-boundaries)
+      (kill-local-variable 'fringe-indicator-alist)
+      (kill-local-variable 'fringe-cursor-alist)
+      (dolist (saved +--saved-state)
+        (set (make-local-variable (car saved)) (cdr saved)))
+      (kill-local-variable '+--saved-state)
+      (+-delete-parens-overlays)
+      (when (memq '+-draw-forthwith post-command-hook)
+        (remove-hook 'post-command-hook '+-draw-forthwith 'local))
+      (when (memq '+-draw-crosshairs post-command-hook)
+        (remove-hook 'post-command-hook '+-draw-crosshairs 'local))
+      (when (memq '+-draw-forthwith window-configuration-change-hook)
+        (remove-hook 'window-configuration-change-hook '+-draw-forthwith 'local))
+      (remove-hook 'change-major-mode-hook 'turn-off-+-mode 'local)
+      (when +-timer-var
+        (setq timer-idle-list (delq +-timer-var timer-idle-list))
+        (setq +-timer-var nil))
+      (when (called-interactively-p 'any)
+        (message "Turned OFF `+-mode'.")))))
+
+(defun turn-off-+-mode ()
+  (+-mode -1))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defun +-parens-fn ()
+  "Doc-string."
+  (let* ((opoint (point))
+         (from (if +-parens-from-fn
+                 (funcall +-parens-from-fn)
+                 (point-min)))
+         (win (selected-window))
+         (i 0)
+         (preceding-char (preceding-char))
+         (ochar (char-after opoint))
+         (pos1
+           (cond
+             ((and ochar
+                   (or ;;; (char-to-string 40) => opening parenthesis
+                       (= ochar 40)
+                       ;;; (char-to-string 91) => opening square bracket
+                       (= ochar 91)
+                       ;;; (char-to-string 123) => opening wavy bracket
+                       (= ochar 123)))
+                (min (1+ opoint) (point-max)))
+             ((or ;;; (char-to-string 41) => closing parenthesis
+                  (= preceding-char 41)
+                  ;;; (char-to-string 93) => closing square bracket
+                  (= preceding-char 93)
+                  ;;; (char-to-string 125) => closing wavy bracket
+                  (= preceding-char 125))
+                (max (point-min) (1- opoint)))
+             (t
+                opoint)))
+         pos2
+         selected-face)
+    (save-excursion
+      (condition-case nil
+        (while (setq pos1 (nth 1 (parse-partial-sexp from pos1)))
+          (setq pos2 (scan-sexps pos1 1))
+          (if (= i 10)
+            (setq i 1)
+            (setq i (1+ i)))
+          (setq selected-face (cond
+                                ((= i 1)
+                                  '+-parens-one-face)
+                                ((= i 2)
+                                  '+-parens-two-face)
+                                ((= i 3)
+                                  '+-parens-three-face)
+                                ((= i 4)
+                                  '+-parens-four-face)
+                                ((= i 5)
+                                  '+-parens-five-face)
+                                ((= i 6)
+                                  '+-parens-six-face)
+                                ((= i 7)
+                                  '+-parens-seven-face)
+                                ((= i 8)
+                                  '+-parens-eight-face)
+                                ((= i 9)
+                                  '+-parens-nine-face)
+                                ((= i 10)
+                                  '+-parens-ten-face)))
+          (let ((ov (make-overlay pos1 (1+ pos1))))
+            (unless +-parens-inactive-windows
+              (overlay-put ov 'window win))
+            (overlay-put ov 'face selected-face))
+          (when pos2
+            (let ((ov (make-overlay (1- pos2) pos2)))
+              (unless +-parens-inactive-windows
+                (overlay-put ov 'window win))
+              (overlay-put ov 'face selected-face))))
+        (error nil)))
+    (setq +-parens-overlays-exist-p t)))
+
+(defun +-remove-overlays (beg end name val)
+"Remove the overlays that are `equal-including-properties`.
+Includes a unique situation when an overlay with an `'after-string` property
+is at the very end of a narrowed-buffer."
+  (let* ((point-max (point-max))
+         (point-min (point-min))
+         (narrowed-p (buffer-narrowed-p))
+         (beg (if beg beg point-min))
+         (end
+           (cond
+             ((and
+                 (not narrowed-p)
+                 end)
+               end)
+             ((and
+                 (not narrowed-p)
+                 (null end))
+               point-max)
+             ((and
+                 narrowed-p
+                 end
+                 (< end point-max))
+               end)
+             ((and
+                 narrowed-p
+                 end
+                 (= end point-max))
+               (1+ end))
+             ((and
+                 narrowed-p
+                 (null end))
+               (1+ point-max)) ))
+         (overlays
+           (progn
+             (overlay-recenter end)
+             (overlays-in beg end))))
+    (when (and beg end name val)
+      (dolist (o overlays)
+        (cond
+          ((and (eq name 'face)
+                (eq (overlay-get o name) val))
+            ;; Either push this overlay outside beg...end
+            ;; or split it to exclude beg...end
+            ;; or delete it entirely (if it is contained in beg...end).
+            (if (< (overlay-start o) beg)
+                (if (> (overlay-end o) end)
+              (progn
+                (move-overlay (copy-overlay o)
+                  (overlay-start o) beg)
+                (move-overlay o end (overlay-end o)))
+                  (move-overlay o (overlay-start o) beg))
+              (if (> (overlay-end o) end)
+                  (move-overlay o end (overlay-end o))
+                (delete-overlay o))))
+          ((and (not (eq name 'face))
+                (equal-including-properties (overlay-get o name) val))
+            (delete-overlay o)))))))
+
+(defun +-delete-parens-overlays ()
+  (when +-parens-overlays-exist-p
+    (dolist (face '(+-parens-one-face
+                    +-parens-two-face
+                    +-parens-three-face
+                    +-parens-four-face
+                    +-parens-five-face
+                    +-parens-six-face
+                    +-parens-seven-face
+                    +-parens-eight-face
+                    +-parens-nine-face
+                    +-parens-ten-face))
+      (+-remove-overlays nil nil 'face face))
+    (setq +-parens-overlays-exist-p nil)))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;;; AUTHOR:  Nikolaj Schumacher -- https://github.com/nschum/fringe-helper.el
+(defun +-fringe-helper-decimal (&rest strings)
+"Convert STRINGS into a vector usable for `define-fringe-bitmap'.
+Each string in STRINGS represents a line of the fringe bitmap.
+Periods (.) are background-colored pixel; Xs are foreground-colored. The
+fringe bitmap always is aligned to the right. If the fringe has half
+width, only the left 4 pixels of an 8 pixel bitmap will be shown.
+For example, the following code defines a diagonal line.
+\(+-fringe-helper-decimal
+\"XX......\"
+\"..XX....\"
+\"....XX..\"
+\"......XX\"\)"
+  (unless (cdr strings)
+    (setq strings (split-string (car strings) "\n")))
+  (apply 'vector
+    (mapcar
+      (lambda (str)
+        (let ((num 0))
+          (dolist (c (string-to-list str))
+            (setq num (+ (* num 2) (if (eq c ?.) 0 1))))
+          num))
+      strings)))
+
+;;; Modification by @lawlist of `+-fringe-helper-decimal' written by
+;;; Nikolaj Schumacher -- https://github.com/nschum/fringe-helper.el
+(defun +-fringe-helper-hexadecimal (&rest strings)
+"Convert STRINGS into a vector usable for `define-fringe-bitmap'.
+Each string in STRINGS represents a line of the fringe bitmap.
+Periods (.) are background-colored pixel; Xs are foreground-colored. The
+fringe bitmap always is aligned to the right. If the fringe has half
+width, only the left 4 pixels of an 8 pixel bitmap will be shown.
+For example, the following code defines a diagonal line.
+\(+-fringe-helper-hexadecimal
+\"XX......\"
+\"..XX....\"
+\"....XX..\"
+\"......XX\"\)"
+  (unless (cdr strings)
+    (setq strings (split-string (car strings) "\n")))
+  (apply 'vector
+    (mapcar
+      (lambda (str)
+        (let ((num 0))
+          (dolist (c (string-to-list str))
+            (setq num (+ (* num 2) (if (eq c ?.) 0 1))))
+          (format "%#-x" num)))
+      strings)))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; FRINGE BITMAPS
+
+(define-fringe-bitmap '+-fringe-question-mark (+-fringe-helper-decimal
+"..xxxx.."
+".xxxxxx."
+"xx....xx"
+"xx....xx"
+"....xx.."
+"...xx..."
+"...xx..."
+"........"
+"...xx..."
+"...xx...") nil nil 'center)
+
+(define-fringe-bitmap '+-fringe-exclamation-mark (+-fringe-helper-decimal
+"...XX..."
+"...XX..."
+"...XX..."
+"...XX..."
+"...XX..."
+"...XX..."
+"...XX..."
+"........"
+"...XX..."
+"...XX...") nil nil 'center)
+
+(define-fringe-bitmap '+-fringe-left-arrow (+-fringe-helper-decimal
+"...xx..."
+"..xx...."
+".xx....."
+"xxxxxx.."
+"xxxxxx.."
+".xx....."
+"..xx...."
+"...xx...") nil nil 'center)
+
+(define-fringe-bitmap '+-fringe-right-arrow (+-fringe-helper-decimal
+"...xx..."
+"....xx.."
+".....xx."
+"..xxxxxx"
+"..xxxxxx"
+".....xx."
+"....xx.."
+"...xx...") nil nil 'center)
+
+(define-fringe-bitmap '+-fringe-up-arrow (+-fringe-helper-decimal
+"...xx..."
+"..xxxx.."
+".xxxxxx."
+"xxxxxxxx"
+"...xx..."
+"...xx..."
+"...xx..."
+"...xx...") nil nil 'top)
+
+(define-fringe-bitmap '+-fringe-down-arrow (+-fringe-helper-decimal
+"...xx..."
+"...xx..."
+"...xx..."
+"...xx..."
+"xxxxxxxx"
+".xxxxxx."
+"..xxxx.."
+"...xx...") nil nil 'bottom)
+
+(define-fringe-bitmap '+-fringe-left-curly-arrow (+-fringe-helper-decimal
+"...xxxx."
+"..xxxxx."
+".xx....."
+".xxx..x."
+".xxxxxx."
+"..xxxxx."
+"...xxxx."
+"..xxxxx.") nil nil 'center)
+
+(define-fringe-bitmap '+-fringe-right-curly-arrow (+-fringe-helper-decimal
+".xxxx..."
+".xxxxx.."
+".....xx."
+".x..xxx."
+".xxxxxx."
+".xxxxx.."
+".xxxx..."
+".xxxxx..") nil nil 'center)
+
+(define-fringe-bitmap '+-fringe-left-triangle (+-fringe-helper-decimal
+"......xx"
+"....xxxx"
+"...xxxxx"
+"..xxxxxx"
+"..xxxxxx"
+"...xxxxx"
+"....xxxx"
+"......xx") nil nil 'center)
+
+(define-fringe-bitmap '+-fringe-right-triangle (+-fringe-helper-decimal
+"xx......"
+"xxxx...."
+"xxxxx..."
+"xxxxxx.."
+"xxxxxx.."
+"xxxxx..."
+"xxxx...."
+"xx......") nil nil 'center)
+
+(define-fringe-bitmap '+-fringe-top-left-angle (+-fringe-helper-decimal
+"xxxxxx.."
+"xxxxxx.."
+"xx......"
+"xx......"
+"xx......"
+"xx......"
+"xx......"
+"........") nil nil 'top)
+
+(define-fringe-bitmap '+-fringe-top-right-angle (+-fringe-helper-decimal
+"..xxxxxx"
+"..xxxxxx"
+"......xx"
+"......xx"
+"......xx"
+"......xx"
+"......xx"
+"........") nil nil 'top)
+
+(define-fringe-bitmap '+-fringe-bottom-left-angle (+-fringe-helper-decimal
+"xx......"
+"xx......"
+"xx......"
+"xx......"
+"xx......"
+"xxxxxx.."
+"xxxxxx..") nil nil 'bottom)
+
+(define-fringe-bitmap '+-fringe-bottom-right-angle (+-fringe-helper-decimal
+"......xx"
+"......xx"
+"......xx"
+"......xx"
+"......xx"
+"..xxxxxx"
+"..xxxxxx") nil nil 'bottom)
+
+(define-fringe-bitmap '+-fringe-left-bracket (+-fringe-helper-decimal
+"xxxxxx.."
+"xxxxxx.."
+"xx......"
+"xx......"
+"xx......"
+"xx......"
+"xx......"
+"xx......"
+"xxxxxx.."
+"xxxxxx..") nil nil 'center)
+
+(define-fringe-bitmap '+-fringe-right-bracket (+-fringe-helper-decimal
+"..xxxxxx"
+"..xxxxxx"
+"......xx"
+"......xx"
+"......xx"
+"......xx"
+"......xx"
+"......xx"
+"..xxxxxx"
+"..xxxxxx") nil nil 'center)
+
+(define-fringe-bitmap '+-fringe-filled-rectangle (+-fringe-helper-decimal
+"xxxxxxx."
+"xxxxxxx."
+"xxxxxxx."
+"xxxxxxx."
+"xxxxxxx."
+"xxxxxxx."
+"xxxxxxx."
+"xxxxxxx."
+"xxxxxxx."
+"xxxxxxx."
+"xxxxxxx."
+"xxxxxxx."
+"xxxxxxx.") nil nil 'center)
+
+(define-fringe-bitmap '+-fringe-hollow-square (+-fringe-helper-decimal
+".xxxxxx."
+".x....x."
+".x....x."
+".x....x."
+".x....x."
+".xxxxxx.") nil nil 'center)
+
+(define-fringe-bitmap '+-fringe-filled-square (+-fringe-helper-decimal
+".xxxxxx."
+".xxxxxx."
+".xxxxxx."
+".xxxxxx."
+".xxxxxx."
+".xxxxxx.") nil nil 'center)
+
+(define-fringe-bitmap '+-fringe-horizontal-bar (+-fringe-helper-decimal
+"xxxxxxx."
+"xxxxxxx.") nil nil 'bottom)
+
+(define-fringe-bitmap '+-fringe-empty-line (+-fringe-helper-decimal
+"........"
+"..xxxx.."
+"........"
+"........"
+"..xxxx.."
+"........") nil nil '(top t))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; `set-fringe-bitmap-face'
+
+(set-fringe-bitmap-face '+-smiley-face '+-left-fringe-current-line-face)
+
+(set-fringe-bitmap-face '+-hollow-rectangle '+-hollow-rectangle-face)
+
+(set-fringe-bitmap-face '+-backslash '+-backslash-face)
+
+(set-fringe-bitmap-face '+-fringe-question-mark '+-fringe-question-mark-face)
+
+(set-fringe-bitmap-face '+-fringe-exclamation-mark '+-fringe-exclamation-mark-face)
+
+;; (set-fringe-bitmap-face '+-fringe-left-arrow '+-fringe-left-arrow-face)
+
+(set-fringe-bitmap-face '+-fringe-right-arrow '+-fringe-right-arrow-face)
+
+(set-fringe-bitmap-face '+-fringe-up-arrow '+-fringe-up-arrow-face)
+
+(set-fringe-bitmap-face '+-fringe-down-arrow '+-fringe-down-arrow-face)
+
+(set-fringe-bitmap-face '+-fringe-left-curly-arrow '+-fringe-left-curly-arrow-face)
+
+(set-fringe-bitmap-face '+-fringe-right-curly-arrow '+-fringe-right-curly-arrow-face)
+
+(set-fringe-bitmap-face '+-fringe-left-triangle '+-fringe-left-triangle-face)
+
+(set-fringe-bitmap-face '+-fringe-right-triangle '+-fringe-right-triangle-face)
+
+(set-fringe-bitmap-face '+-fringe-top-left-angle '+-fringe-top-left-angle-face)
+
+(set-fringe-bitmap-face '+-fringe-top-right-angle '+-fringe-top-right-angle-face)
+
+(set-fringe-bitmap-face '+-fringe-bottom-left-angle '+-fringe-bottom-left-angle-face)
+
+(set-fringe-bitmap-face '+-fringe-bottom-right-angle '+-fringe-bottom-right-angle-face)
+
+(set-fringe-bitmap-face '+-fringe-left-bracket '+-fringe-left-bracket-face)
+
+(set-fringe-bitmap-face '+-fringe-right-bracket '+-fringe-right-bracket-face)
+
+(set-fringe-bitmap-face '+-fringe-filled-rectangle '+-fringe-filled-rectangle-face)
+
+(set-fringe-bitmap-face '+-fringe-hollow-square '+-fringe-hollow-square-face)
+
+(set-fringe-bitmap-face '+-fringe-filled-square '+-fringe-filled-square-face)
+
+(set-fringe-bitmap-face '+-fringe-horizontal-bar '+-fringe-horizontal-bar-face)
+
+(set-fringe-bitmap-face '+-fringe-empty-line '+-fringe-empty-line-face)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(provide 'crosshairs)
\ No newline at end of file
diff --git a/lisp/faces.el b/lisp/faces.el
index 18b821a..37a7f75 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -2502,6 +2502,153 @@ unwanted effects."
   :group 'basic-faces
   :group 'display-line-numbers)
 
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; begin MULTIPLE CURSORS
+
+(defface +-vertical-bar-face
+  '((t (:foreground "magenta")))
+  "Face for `+-vertical-bar-face'.  Used in `xdisp.c'."
+  :group '+-mode)
+
+(defface +-even-numbered-column-face
+  '((t (:foreground "yellow")))
+  "Face for `+-even-numbered-column-face'.  Used in `xdisp.c'."
+  :group '+-mode)
+
+(defface +-odd-numbered-column-face
+  '((t (:foreground "red")))
+  "Face for `+-odd-numbered-column-face'.  Used in `xdisp.c'."
+  :group '+-mode)
+
+(defface +-beyond-fill-column-face
+  '((t (:foreground "green")))
+  "Face for `+-beyond-fill-column-face'.  Used in `xdisp.c'."
+  :group '+-mode)
+
+(defface +-even-numbered-column-inactive-face
+  '((t (:foreground "#eee8aa"))) ;;; PaleGoldenrod
+  "Face for `+-even-numbered-column-inactive-face'.  Used in `xdisp.c'."
+  :group '+-mode)
+
+(defface +-odd-numbered-column-inactive-face
+  '((t (:foreground "#ff6347"))) ;;; tomato
+  "Face for `+-odd-numbered-column-inactive-face'.  Used in `xdisp.c'."
+  :group '+-mode)
+
+(defface +-beyond-fill-column-inactive-face
+  '((t (:foreground "#2e8b57"))) ;;; SeaGreen
+  "Face for `+-beyond-fill-column-inactive-face'.  Used in `xdisp.c'."
+  :group '+-mode)
+
+(defface +-real-fake-cursor-face
+  '((((class color) (min-colors 88) (background dark))
+     :foreground "cyan" :background "DarkBlue")
+    (((class color) (min-colors 88) (background light) (type gtk))
+     :foreground "gtk_selection_fg_color" :background "gtk_selection_bg_color")
+    (((class color) (min-colors 88) (background light) (type ns))
+     :foreground "black" :background "LightSkyBlue")
+    (((class color) (min-colors 88) (background light))
+     :foreground "black" :background "LightSkyBlue")
+    (((class color) (min-colors 16) (background dark))
+     :foreground "yellow" :background "blue3")
+    (((class color) (min-colors 16) (background light))
+     :foreground "orange" :background "lightgoldenrod2")
+    (((class color) (min-colors 8))
+     :background "blue" :foreground "white")
+    (((type tty) (class mono))
+     :inverse-video t)
+    (t :foreground "pink" :background "gray"))
+  "Face for `+-real-fake-cursor-face'.  Used in `xdisp.c'.
+As to a hollow style cursor, the :foreground parameter is used for the border and
+the :background parameter is used for the inner filled shading.  The character
+retains its own foreground color and is unaffected by this particular face."
+  :group '+-mode)
+
+(defface +-real-fake-cursor-inactive-face
+  '((((class color) (min-colors 88) (background dark))
+     :foreground "#ff00ff" :background "ForestGreen")
+    (((class color) (min-colors 88) (background light) (type gtk))
+     :foreground "gtk_selection_fg_color" :background "gtk_selection_bg_color")
+    (((class color) (min-colors 88) (background light) (type ns))
+     :foreground "black" :background "grey70")
+    (((class color) (min-colors 88) (background light))
+     :foreground "black" :background "grey70")
+    (((class color) (min-colors 16) (background dark))
+     :foreground "yellow" :background "blue3")
+    (((class color) (min-colors 16) (background light))
+     :foreground "orange" :background "lightgoldenrod2")
+    (((class color) (min-colors 8))
+     :background "blue" :foreground "white")
+    (((type tty) (class mono))
+     :inverse-video t)
+    (t :foreground "pink" :background "gray"))
+  "Face for `+-real-fake-cursor-inactive-face'.  Used in `xdisp.c'.
+As to a hollow style cursor, the :foreground parameter is used for the border and
+the :background parameter is used for the inner filled shading.  The character
+retains its own foreground color and is unaffected by this particular face."
+  :group '+-mode)
+
+(defface +-real-fake-cursor-region-face
+  '((((class color) (min-colors 88) (background dark))
+     :foreground "grey15" :background "#8b795e")
+    (((class color) (min-colors 88) (background light) (type gtk))
+     :foreground "gtk_selection_fg_color" :background "gtk_selection_bg_color")
+    (((class color) (min-colors 88) (background light) (type ns))
+     :foreground "pink" :background "#8b795e")
+    (((class color) (min-colors 88) (background light))
+     :foreground "pink" :background "#8b795e")
+    (((class color) (min-colors 16) (background dark))
+     :foreground "yellow" :background "blue3")
+    (((class color) (min-colors 16) (background light))
+     :foreground "orange" :background "lightgoldenrod2")
+    (((class color) (min-colors 8))
+     :background "blue" :foreground "white")
+    (((type tty) (class mono))
+     :inverse-video t)
+    (t :foreground "pink" :background "gray"))
+  "Face for `+-real-fake-cursor-region-face'.  Used in `xdisp.c'.
+As to a hollow style cursor, the :foreground parameter is used for the inner
+filled shading when PT is _not_ within the active region; and, the :background
+parameter is used for the inner filled shading when PT _is_ within the active
+region.  The character retains its own foreground color and is unaffected by this
+particular face."
+  :group '+-mode)
+
+(defface +-overlay-arrow-face
+  '((t (:foreground "red")))
+  "Face for `+-overlay-arrow-face'."
+  :group '+-mode)
+
+(defface +-overlay-arrow-minimal-face
+  '((t (:foreground "blue")))
+  "Face for `+-overlay-arrow-minimal-face'."
+  :group '+-mode)
+
+(defface +-overlay-arrow-inactive-face
+  '((t (:foreground "orange")))
+  "Face for `+-overlay-arrow-inactive-face'."
+  :group '+-mode)
+
+(defface +-overlay-arrow-hscl-face
+  '((t (:foreground "chartreuse")))
+  "Face for `+-overlay-arrow-hscl-face'."
+  :group '+-mode)
+
+(defface +-overlay-arrow-hscl-minimal-face
+  '((t (:foreground "green")))
+  "Face for `+-overlay-arrow-hscl-minimal-face'."
+  :group '+-mode)
+
+(defface +-overlay-arrow-hscl-inactive-face
+  '((t (:foreground "yellow")))
+  "Face for `+-overlay-arrow-hscl-inactive-face'."
+  :group '+-mode)
+
+;;; end MULTIPLE CURSORS
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
 (defface escape-glyph
   '((((background dark)) :foreground "cyan")
     ;; See the comment in minibuffer-prompt for
diff --git a/src/buffer.c b/src/buffer.c
index 024e64f..4eeccd9 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -5077,6 +5077,25 @@ init_buffer_once (void)
   bset_last_selected_window (&buffer_local_flags, make_fixnum (0));
 
   idx = 1;
+
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+  XSETFASTINT (BVAR (&buffer_local_flags, mc_real_fake_cursor), idx); ++idx;
+  XSETFASTINT (BVAR (&buffer_local_flags, multiple_cursors_conf), idx); ++idx;
+  XSETFASTINT (BVAR (&buffer_local_flags, multiple_cursors_draw_forthwith), idx); ++idx;
+  XSETFASTINT (BVAR (&buffer_local_flags, multiple_cursors_inactive_windows), idx); ++idx;
+  XSETFASTINT (BVAR (&buffer_local_flags, crosshairs), idx); ++idx;
+  XSETFASTINT (BVAR (&buffer_local_flags, crosshairs_horizontal_ruler), idx); ++idx;
+  XSETFASTINT (BVAR (&buffer_local_flags, crosshairs_vertical_ruler), idx); ++idx;
+  XSETFASTINT (BVAR (&buffer_local_flags, crosshairs_draw_forthwith), idx); ++idx;
+  XSETFASTINT (BVAR (&buffer_local_flags, crosshairs_inactive_windows), idx); ++idx;
+  XSETFASTINT (BVAR (&buffer_local_flags, mc_stderr), idx); ++idx;
+
+/* *************************************************************************** */
+
+
   XSETFASTINT (BVAR (&buffer_local_flags, mode_line_format), idx); ++idx;
   XSETFASTINT (BVAR (&buffer_local_flags, abbrev_mode), idx); ++idx;
   XSETFASTINT (BVAR (&buffer_local_flags, overwrite_mode), idx); ++idx;
@@ -5158,6 +5177,25 @@ init_buffer_once (void)
   /* Must do these before making the first buffer! */
 
   /* real setup is done in bindings.el */
+
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+  bset_blv_mc_real_fake_cursor (&buffer_defaults, Qhollow);
+  bset_blv_multiple_cursors_conf (&buffer_defaults, Qnil);
+  bset_blv_multiple_cursors_draw_forthwith (&buffer_defaults, Qt);
+  bset_blv_multiple_cursors_inactive_windows (&buffer_defaults, Qt);
+  bset_blv_crosshairs (&buffer_defaults, Qnil);
+  bset_blv_crosshairs_horizontal_ruler (&buffer_defaults, Qt);
+  bset_blv_crosshairs_vertical_ruler (&buffer_defaults, Qt);
+  bset_blv_crosshairs_draw_forthwith (&buffer_defaults, Qt);
+  bset_blv_crosshairs_inactive_windows (&buffer_defaults, Qt);
+  bset_blv_mc_stderr (&buffer_defaults, Qnil);
+
+/* *************************************************************************** */
+
+
   bset_mode_line_format (&buffer_defaults, build_pure_c_string ("%-"));
   bset_header_line_format (&buffer_defaults, Qnil);
   bset_abbrev_mode (&buffer_defaults, Qnil);
@@ -5406,6 +5444,24 @@ syms_of_buffer (void)
   staticpro (&QSFundamental);
   staticpro (&Vbuffer_alist);
 
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+  DEFSYM (Qmc_real_fake_cursor, "mc-real-fake-cursor");
+  DEFSYM (Qmultiple_cursors_conf, "multiple-cursors-conf");
+  DEFSYM (Qmultiple_cursors_draw_forthwith, "multiple-cursors-draw-forthwith");
+  DEFSYM (Qmultiple_cursors_inactive_windows, "multiple-cursors-inactive-windows");
+  DEFSYM (Qcrosshairs, "crosshairs");
+  DEFSYM (Qcrosshairs_horizontal_ruler, "crosshairs-horizontal-ruler");
+  DEFSYM (Qcrosshairs_vertical_ruler, "crosshairs-vertical-ruler");
+  DEFSYM (Qcrosshairs_draw_forthwith, "crosshairs-draw-forthwith");
+  DEFSYM (Qcrosshairs_inactive_windows, "crosshairs-inactive-windows");
+  DEFSYM (Qmc_stderr, "mc-stderr");
+
+/* *************************************************************************** */
+
+
   DEFSYM (Qchoice, "choice");
   DEFSYM (Qleft, "left");
   DEFSYM (Qright, "right");
@@ -5443,6 +5499,52 @@ syms_of_buffer (void)
   Fput (Qprotected_field, Qerror_message,
 	build_pure_c_string ("Attempt to modify a protected field"));
 
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+  DEFVAR_PER_BUFFER ("mc-real-fake-cursor", &BVAR (current_buffer, mc_real_fake_cursor), Qnil,
+    doc: /* A bufer-local variable to set the cursor type of the real fake cursor. */);
+
+  DEFVAR_PER_BUFFER ("multiple-cursors-conf", &BVAR (current_buffer, multiple_cursors_conf), Qnil,
+    doc: /* A bufer-local variable to store the value of the multiple cursors to be displayed
+during the next redisplay. */);
+
+  DEFVAR_PER_BUFFER ("multiple-cursors-draw-forthwith", &BVAR (current_buffer, multiple_cursors_draw_forthwith), Qnil,
+    doc: /* When non-nil, draw multiple cursors whenever the real cursor would
+ordinarily be drawn, which is sometimes more than once every command loop.
+When nil, multiple-cursors will be placed on an idle-timer.  If this variable is
+reset while `multiple-cursors-mode' is enabled, then it may be necessary to turn off/on
+`multiple-cursors-mode' to reset functions attached to the `post-command-hook'. */);
+
+  DEFVAR_PER_BUFFER ("multiple-cursors-inactive-windows", &BVAR (current_buffer, multiple_cursors_inactive_windows), Qnil,
+    doc: /* When non-nil, draw multiple cursors in inactive windows. */);
+
+  DEFVAR_PER_BUFFER ("crosshairs", &BVAR (current_buffer, crosshairs), Qnil,
+    doc: /* A bufer-local variable to activate/deactivate crosshairs. */);
+
+  DEFVAR_PER_BUFFER ("crosshairs-horizontal-ruler", &BVAR (current_buffer, crosshairs_horizontal_ruler), Qnil,
+    doc: /* A bufer-local variable to activate/deactivate the crosshairs horizontal ruler. */);
+
+  DEFVAR_PER_BUFFER ("crosshairs-vertical-ruler", &BVAR (current_buffer, crosshairs_vertical_ruler), Qnil,
+    doc: /* A bufer-local variable to activate/deactivate the crosshairs vertical ruler. */);
+
+  DEFVAR_PER_BUFFER ("crosshairs-draw-forthwith", &BVAR (current_buffer, crosshairs_draw_forthwith), Qnil,
+    doc: /* When non-nil, draw crosshairs whenever the real cursor would
+ordinarily be drawn, which is sometimes more than once every command loop.
+When nil, crosshairs will be placed on an idle-timer.  If this variable is
+reset while `+-mode' is enabled, then it may be necessary to turn off/on
+`+-mode' to reset functions attached to the `post-command-hook'. */);
+
+  DEFVAR_PER_BUFFER ("crosshairs-inactive-windows", &BVAR (current_buffer, crosshairs_inactive_windows), Qnil,
+    doc: /* When non-nil, draw crosshairs in inactive windows. */);
+
+  DEFVAR_PER_BUFFER ("mc-stderr", &BVAR (current_buffer, mc_stderr), Qnil,
+    doc: /* A bufer-local variable to activate/deactivate debugging messages to stderr. */);
+
+/* *************************************************************************** */
+
+
   DEFVAR_PER_BUFFER ("header-line-format",
 		     &BVAR (current_buffer, header_line_format),
 		     Qnil,
diff --git a/src/buffer.h b/src/buffer.h
index 4ea7fa6..4a31996 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -636,6 +636,43 @@ struct buffer
      cache are enabled.  See search.c, indent.c and bidi.c for details.  */
   Lisp_Object cache_long_scans_;
 
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+  /* The cursor type of the real fake cursor. */
+  Lisp_Object mc_real_fake_cursor_;
+
+  /* The name of list used by multiple cursors for next redisplay. */
+  Lisp_Object multiple_cursors_conf_;
+
+  /* Whether to draw multiple cursors immediately, or on an idle-timer. */
+  Lisp_Object multiple_cursors_draw_forthwith_;
+
+  /* Whether to draw multiple cursors in inactive windows. */
+  Lisp_Object multiple_cursors_inactive_windows_;
+
+  /* The name of list. */
+  Lisp_Object crosshairs_;
+
+  /* The name of the crosshairs horizontal ruler. */
+  Lisp_Object crosshairs_horizontal_ruler_;
+
+  /* The name of the crosshairs vertical ruler. */
+  Lisp_Object crosshairs_vertical_ruler_;
+
+  /* Whether to draw crosshairs immediately, or on an idle-timer. */
+  Lisp_Object crosshairs_draw_forthwith_;
+
+  /* Whether to draw crosshairs in inactive windows. */
+  Lisp_Object crosshairs_inactive_windows_;
+
+  /* Used in conjunction with generating stderr debugging message. */
+  Lisp_Object mc_stderr_;
+
+/* *************************************************************************** */
+
+
   /* If the width run cache is enabled, this table contains the
      character widths width_run_cache (see above) assumes.  When we
      do a thorough redisplay, we compare this against the buffer's
@@ -792,9 +829,17 @@ struct buffer
      for a buffer-local variable is stored in that variable's slot
      in buffer_local_flags as a Lisp integer.  If the index is -1,
      this means the variable is always local in all buffers.  */
-#define MAX_PER_BUFFER_VARS 50
+
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+#define MAX_PER_BUFFER_VARS 60
   char local_flags[MAX_PER_BUFFER_VARS];
 
+/* *************************************************************************** */
+
+
   /* Set to the modtime of the visited file when read or written.
      modtime.tv_nsec == NONEXISTENT_MODTIME_NSECS means
      visited file was nonexistent.  modtime.tv_nsec ==
@@ -896,6 +941,74 @@ XBUFFER (Lisp_Object a)
 /* Most code should use these functions to set Lisp fields in struct
    buffer.  (Some setters that are private to a single .c file are
    defined as static in those files.)  */
+
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+INLINE void
+bset_blv_mc_real_fake_cursor (struct buffer *b, Lisp_Object val)
+{
+  b->mc_real_fake_cursor_ = val;
+}
+
+INLINE void
+bset_blv_multiple_cursors_conf (struct buffer *b, Lisp_Object val)
+{
+  b->multiple_cursors_conf_ = val;
+}
+
+INLINE void
+bset_blv_multiple_cursors_draw_forthwith (struct buffer *b, Lisp_Object val)
+{
+  b->multiple_cursors_draw_forthwith_ = val;
+}
+
+INLINE void
+bset_blv_multiple_cursors_inactive_windows (struct buffer *b, Lisp_Object val)
+{
+  b->multiple_cursors_inactive_windows_ = val;
+}
+
+INLINE void
+bset_blv_crosshairs (struct buffer *b, Lisp_Object val)
+{
+  b->crosshairs_ = val;
+}
+
+INLINE void
+bset_blv_crosshairs_horizontal_ruler (struct buffer *b, Lisp_Object val)
+{
+  b->crosshairs_horizontal_ruler_ = val;
+}
+
+INLINE void
+bset_blv_crosshairs_vertical_ruler (struct buffer *b, Lisp_Object val)
+{
+  b->crosshairs_vertical_ruler_ = val;
+}
+
+INLINE void
+bset_blv_crosshairs_draw_forthwith (struct buffer *b, Lisp_Object val)
+{
+  b->crosshairs_draw_forthwith_ = val;
+}
+
+INLINE void
+bset_blv_crosshairs_inactive_windows (struct buffer *b, Lisp_Object val)
+{
+  b->crosshairs_inactive_windows_ = val;
+}
+
+INLINE void
+bset_blv_mc_stderr (struct buffer *b, Lisp_Object val)
+{
+  b->mc_stderr_ = val;
+}
+
+/* *************************************************************************** */
+
+
 INLINE void
 bset_bidi_paragraph_direction (struct buffer *b, Lisp_Object val)
 {
diff --git a/src/dispextern.h b/src/dispextern.h
index 579665c..d15ff6e 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -3284,6 +3284,29 @@ extern void get_font_ascent_descent (struct font *, int *, int *);
 
 #ifdef HAVE_WINDOW_SYSTEM
 
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+enum mc_glyph_flavor
+{
+  NO_FLAVOR,
+  MC_GLYPH,
+  MC_GLYPHLESS,
+  MC_GLYPH_TAB,
+  MC_OVERLAY_ARROW_BITMAP,
+  MC_OVERLAY_ARROW_BITMAP_HSCL_TEMPORARY,
+  MC_PILCROW,
+  MC_HOLLOW_RECTANGLE_RIGHT_ANGLE,
+  MC_HOLLOW_RECTANGLE,
+  MC_VERTICAL_BAR_RIGHT_ANGLE,
+  MC_VERTICAL_BAR,
+  MC_VERTICAL_BAR_BACKSLASH
+};
+
+/* *************************************************************************** */
+
+
 #ifdef GLYPH_DEBUG
 extern void dump_glyph_string (struct glyph_string *) EXTERNALLY_VISIBLE;
 #endif
diff --git a/src/fringe.c b/src/fringe.c
index 6a44de1..7e7eadf 100644
--- a/src/fringe.c
+++ b/src/fringe.c
@@ -433,6 +433,231 @@ static unsigned short empty_line_bits[] = {
   0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00};
 
 
+/* *************************************************************************** */
+/* begin MULTIPLE CURSORS */
+
+/*  ;; AUTHOR:  Nikolaj Schumacher -- https://github.com/nschum/fringe-helper.el
+    (defun +-fringe-helper-hexadecimal (&rest strings)
+    "Convert STRINGS into a vector usable for `define-fringe-bitmap'.
+    Each string in STRINGS represents a line of the fringe bitmap.
+    Periods (.) are background-colored pixel; Xs are foreground-colored. The
+    fringe bitmap always is aligned to the right. If the fringe has half
+    width, only the left 4 pixels of an 8 pixel bitmap will be shown.
+    For example, the following code defines a diagonal line.
+    \(+-fringe-helper-hexadecimal
+    \"XX......\"
+    \"..XX....\"
+    \"....XX..\"
+    \"......XX\"\)"
+      (unless (cdr strings)
+        (setq strings (split-string (car strings) "\n")))
+      (apply 'vector
+        (mapcar
+          (lambda (str)
+            (let ((num 0))
+              (dolist (c (string-to-list str))
+                (setq num (+ (* num 2) (if (eq c ?.) 0 1))))
+              (format "%#-x" num)))
+          strings)))
+*/
+
+/* 24
+    (+-fringe-helper-hexadecimal
+      "x......."
+      "x......."
+      "x......."
+      "x..xx..."
+      "x...xx.."
+      "x....xx."
+      "x.xxxxxx"
+      "x.xxxxxx"
+      "x....xx."
+      "x...xx.."
+      "x..xx..."
+      "x......."
+      "x......."
+      "x.......")
+*/
+static unsigned short mc_vertical_bar_right_angle_bits[] ={
+  0x80, 0x80, 0x80, 0x98, 0x8c, 0x86, 0xbf,
+  0xbf, 0x86, 0x8c, 0x98, 0x80, 0x80, 0x80};
+
+/* 25
+    (+-fringe-helper-hexadecimal
+      "xxxxxxxx"
+      "x......x"
+      "x......x"
+      "x..xx..x"
+      "x...xx.x"
+      "x....xxx"
+      "x.xxxxxx"
+      "x.xxxxxx"
+      "x....xxx"
+      "x...xx.x"
+      "x..xx..x"
+      "x......x"
+      "x......x"
+      "xxxxxxxx")
+*/
+static unsigned short mc_hollow_rectangle_right_angle_bits[] ={
+  0xff, 0x81, 0x81, 0x99, 0x8d, 0x87, 0xbf,
+  0xbf, 0x87, 0x8d, 0x99, 0x81, 0x81, 0xff};
+
+/* 26
+    (+-fringe-helper-hexadecimal
+      "xxxxxxxx"
+      "x......x"
+      "x......x"
+      "x......x"
+      "x......x"
+      "x......x"
+      "x......x"
+      "x......x"
+      "x......x"
+      "x......x"
+      "x......x"
+      "x......x"
+      "x......x"
+      "xxxxxxxx")
+*/
+static unsigned short mc_hollow_rectangle_bits[] ={
+  0xff, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
+  0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xff};
+
+/* 27
+    (+-fringe-helper-hexadecimal
+      "x......."
+      "x......."
+      "x......."
+      "x......."
+      "x......."
+      "x......."
+      "x......."
+      "x......."
+      "x......."
+      "x......."
+      "x......."
+      "x......."
+      "x......."
+      "x.......")
+*/
+static unsigned short mc_vertical_bar_bits[] ={
+  0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
+  0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80};
+
+/* 28
+    (+-fringe-helper-hexadecimal
+      "xx......"
+      ".xx....."
+      "..xx...."
+      "...xx..."
+      "....xx.."
+      ".....xx."
+      "......xx"
+      ".....xx."
+      "....xx.."
+      "...xx..."
+      "..xx...."
+      ".xx....."
+      "xx......")
+*/
+static unsigned short mc_right_angle_bits[] ={
+  0xc0, 0x60, 0x30, 0x18, 0xc, 0x6, 0x3, 0x6, 0xc, 0x18, 0x30, 0x60, 0xc0};
+
+/* 29
+    (+-fringe-helper-hexadecimal
+      "xx......"
+      "xx......"
+      " xx....."
+      ".xx....."
+      "..xx...."
+      "..xx...."
+      "...xx..."
+      "...xx..."
+      "....xx.."
+      "....xx.."
+      ".....xx."
+      ".....xx."
+      "......xx"
+      "......xx")
+*/
+static unsigned short mc_backslash_bits[] ={
+  0xc0, 0xc0, 0xe0, 0x60, 0x30, 0x30, 0x18, 0x18, 0xc, 0xc, 0x6, 0x6, 0x3, 0x3};
+
+/* 30
+    (+-fringe-helper-hexadecimal
+      "xx......"
+      "xx......"
+      "xxx....."
+      "xxx....."
+      "x.xx...."
+      "x.xx...."
+      "x..xx..."
+      "x..xx..."
+      "x...xx.."
+      "x...xx.."
+      "x....xx."
+      "x....xx."
+      "x.....xx"
+      "x.....xx")
+*/
+static unsigned short mc_vertical_bar_backslash_bits[] ={
+  0xc0, 0xc0, 0xe0, 0xe0, 0xb0, 0xb0, 0x98,
+  0x98, 0x8c, 0x8c, 0x86, 0x86, 0x83, 0x83};
+
+/* 31
+    (+-fringe-helper-hexadecimal
+      ".xxxxxx."
+      "xxxx.x.."
+      "xxxx.x.."
+      "xxxx.x.."
+      ".xxx.x.."
+      "...x.x.."
+      "...x.x.."
+      "...x.x.."
+      "...x.x.."
+      "...x.x.."
+      "...x.x..")
+*/
+static unsigned short mc_pilcrow_bits[] ={
+  0x7e, 0xf4, 0xf4, 0xf4, 0x74, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14};
+
+/* 32
+    (+-fringe-helper-hexadecimal
+      "xx.xx..."
+      ".xx.xx.."
+      "..xx.xx."
+      "...xx.xx"
+      "..xx.xx."
+      ".xx.xx.."
+      "xx.xx...")
+*/
+static unsigned short mc_right_double_angle_bits[] ={
+  0xd8, 0x6c, 0x36, 0x1b, 0x36, 0x6c, 0xd8};
+
+/* 33
+    (+-fringe-helper-hexadecimal
+      "..xxxx.."
+      ".xxxxxx."
+      "x..xx..x"
+      "x..xx..x"
+      "xxxxxxxx"
+      "xx....xx"
+      "xxx..xxx"
+      ".xxxxxx."
+      "..xxxx..")
+*/
+static unsigned short mc_smiley_face_bits[] ={
+  0x3c, 0x7e, 0x99, 0x99, 0xff, 0xc3, 0xe7, 0x7e, 0x3c};
+
+/* Add the following bitmaps:
+  (define-fringe-bitmap 'breakpoint "\x3c\x7e\xff\xff\xff\xff\x7e\x3c")
+  (define-fringe-bitmap 'hollow-right-triangle "\xe0\x90\x88\x84\x84\x88\x90\xe0") */
+
+/* end MULTIPLE CURSORS */
+/* *************************************************************************** */
+
+
 #define BYTES_PER_BITMAP_ROW  (sizeof (unsigned short))
 #define STANDARD_BITMAP_HEIGHT(bits) (sizeof (bits)/BYTES_PER_BITMAP_ROW)
 #define FRBITS(bits)  bits, STANDARD_BITMAP_HEIGHT (bits)
@@ -466,6 +691,35 @@ static struct fringe_bitmap standard_bitmaps[] =
   { FRBITS (vertical_bar_bits),       8, 0, ALIGN_BITMAP_CENTER, 0 },
   { FRBITS (horizontal_bar_bits),     8, 0, ALIGN_BITMAP_BOTTOM, 0 },
   { FRBITS (empty_line_bits),         8, 3, ALIGN_BITMAP_TOP,    0 },
+
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+  /* 24 */
+  { FRBITS (mc_vertical_bar_right_angle_bits),     8, 0, ALIGN_BITMAP_CENTER, 0 },
+  /* 25 */
+  { FRBITS (mc_hollow_rectangle_right_angle_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
+  /* 26 */
+  { FRBITS (mc_hollow_rectangle_bits),             8, 0, ALIGN_BITMAP_CENTER, 0 },
+  /* 27 */
+  { FRBITS (mc_vertical_bar_bits),                 8, 0, ALIGN_BITMAP_CENTER, 0 },
+  /* 28 */
+  { FRBITS (mc_right_angle_bits),                  8, 0, ALIGN_BITMAP_CENTER, 0 },
+  /* 29 */
+  { FRBITS (mc_backslash_bits),                    8, 0, ALIGN_BITMAP_CENTER, 0 },
+  /* 30 */
+  { FRBITS (mc_vertical_bar_backslash_bits),       8, 0, ALIGN_BITMAP_CENTER, 0 },
+  /* 31 */
+  { FRBITS (mc_pilcrow_bits),                      8, 0, ALIGN_BITMAP_CENTER, 0 },
+  /* 32 */
+  { FRBITS (mc_right_double_angle_bits),           8, 0, ALIGN_BITMAP_CENTER, 0 },
+  /* 33 */
+  { FRBITS (mc_smiley_face_bits),                  8, 0, ALIGN_BITMAP_CENTER, 0 },
+
+/* *************************************************************************** */
+
+
 };
 
 #define NO_FRINGE_BITMAP 0
@@ -1715,6 +1969,77 @@ If nil, also continue lines which are exactly as wide as the window.  */);
   DEFVAR_LISP ("fringe-bitmaps", Vfringe_bitmaps,
     doc: /* List of fringe bitmap symbols.  */);
   Vfringe_bitmaps = Qnil;
+
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+  /* (get 'empty-line 'fringe) => 23 => the last standard-bitmap before this one.
+  See `fringe.el`. */
+
+  /* 24 */
+  DEFSYM (Qmc_vertical_bar_right_angle, "+-vertical-bar-right-angle");
+  Vfringe_bitmaps = Fcons (Qmc_vertical_bar_right_angle, Vfringe_bitmaps);
+  Fput (Qmc_vertical_bar_right_angle, Qfringe, make_fixnum (24));
+  /* (get '+-vertical-bar-right-angle 'fringe) => 24 */
+
+  /* 25 */
+  DEFSYM (Qmc_hollow_rectangle_right_angle, "+-hollow-rectangle-right-angle");
+  Vfringe_bitmaps = Fcons (Qmc_hollow_rectangle_right_angle, Vfringe_bitmaps);
+  Fput (Qmc_hollow_rectangle_right_angle, Qfringe, make_fixnum (25));
+  /* (get '+-hollow-rectangle-right-angle 'fringe) => 25 */
+
+  /* 26 */
+  DEFSYM (Qmc_hollow_rectangle, "+-hollow-rectangle");
+  Vfringe_bitmaps = Fcons (Qmc_hollow_rectangle, Vfringe_bitmaps);
+  Fput (Qmc_hollow_rectangle, Qfringe, make_fixnum (26));
+  /* (get '+-hollow-rectangle 'fringe) => 26 */
+
+  /* 27 */
+  DEFSYM (Qmc_vertical_bar, "+-vertical-bar");
+  Vfringe_bitmaps = Fcons (Qmc_vertical_bar, Vfringe_bitmaps);
+  Fput (Qmc_vertical_bar, Qfringe, make_fixnum (27));
+  /* (get '+-vertical-bar 'fringe) => 27 */
+
+  /* 28 */
+  DEFSYM (Qmc_right_angle, "+-right-angle");
+  Vfringe_bitmaps = Fcons (Qmc_right_angle, Vfringe_bitmaps);
+  Fput (Qmc_right_angle, Qfringe, make_fixnum (28));
+  /* (get '+-right-angle 'fringe) => 28 */
+
+  /* 29 */
+  DEFSYM (Qmc_backslash, "+-backslash");
+  Vfringe_bitmaps = Fcons (Qmc_backslash, Vfringe_bitmaps);
+  Fput (Qmc_backslash, Qfringe, make_fixnum (29));
+  /* (get '+-backslash 'fringe) => 29 */
+
+  /* 30 */
+  DEFSYM (Qmc_vertical_bar_backslash, "+-vertical-bar-backslash");
+  Vfringe_bitmaps = Fcons (Qmc_vertical_bar_backslash, Vfringe_bitmaps);
+  Fput (Qmc_vertical_bar_backslash, Qfringe, make_fixnum (30));
+  /* (get '+-vertical-bar-backslash 'fringe) => 30 */
+
+  /* 31 */
+  DEFSYM (Qmc_pilcrow, "+-pilcrow");
+  Vfringe_bitmaps = Fcons (Qmc_pilcrow, Vfringe_bitmaps);
+  Fput (Qmc_pilcrow, Qfringe, make_fixnum (31));
+  /* (get '+-pilcrow 'fringe) => 31 */
+
+  /* 32 */
+  DEFSYM (Qmc_right_double_angle, "+-right-double-angle");
+  Vfringe_bitmaps = Fcons (Qmc_right_double_angle, Vfringe_bitmaps);
+  Fput (Qmc_right_double_angle, Qfringe, make_fixnum (32));
+  /* (get '+-right-double-angle 'fringe) => 32 */
+
+  /* 33 */
+  DEFSYM (Qmc_smiley_face, "+-smiley-face");
+  Vfringe_bitmaps = Fcons (Qmc_smiley_face, Vfringe_bitmaps);
+  Fput (Qmc_smiley_face, Qfringe, make_fixnum (33));
+  /* (get '+-smiley-face 'fringe) => 33 */
+
+/* *************************************************************************** */
+
+
 }
 
 /* Garbage collection hook */
diff --git a/src/keyboard.c b/src/keyboard.c
index 8ea15d3..a89f322 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -1224,6 +1224,29 @@ static int read_key_sequence (Lisp_Object *, Lisp_Object,
                               bool, bool, bool, bool);
 static void adjust_point_for_property (ptrdiff_t, bool);
 
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+static void
+kbd_mc_activate_multiple_cursors (void)
+{
+  struct window *w = decode_live_window (selected_window);
+  w->mc.draw_multiple_cursors = true;
+  w->mc.erase_multiple_cursors = true;
+}
+
+static void
+kbd_mc_activate_crosshairs (void)
+{
+  struct window *w = decode_live_window (selected_window);
+  w->mc.draw_crosshairs = true;
+  w->mc.erase_crosshairs = true;
+}
+
+/* *************************************************************************** */
+
+
 Lisp_Object
 command_loop_1 (void)
 {
@@ -1419,6 +1442,15 @@ command_loop_1 (void)
       Vreal_this_command = cmd;
       safe_run_hooks (Qpre_command_hook);
 
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+      kbd_mc_activate_multiple_cursors ();
+
+/* *************************************************************************** */
+
+
       already_adjusted = 0;
 
       if (NILP (Vthis_command))
@@ -2448,7 +2480,7 @@ read_char (int commandflag, Lisp_Object map,
 	  if (help_echo_showing_p && !EQ (selected_window, minibuf_window))
 	    redisplay_preserve_echo_area (5);
 	  else
-	    redisplay ();
+	    redisplay (1);
 
 	  if (!input_pending)
 	    /* Normal case: no input arrived during redisplay.  */
@@ -2628,7 +2660,7 @@ read_char (int commandflag, Lisp_Object map,
     {
       Fdo_auto_save (auto_save_no_message ? Qt : Qnil, Qnil);
       /* Hooks can actually change some buffers in auto save.  */
-      redisplay ();
+      redisplay (2);
     }
 
   /* Try reading using an X menu.
@@ -2692,7 +2724,7 @@ read_char (int commandflag, Lisp_Object map,
 	      && ! CONSP (Vunread_command_events))
 	    {
 	      Fdo_auto_save (auto_save_no_message ? Qt : Qnil, Qnil);
-	      redisplay ();
+	      redisplay (3);
 	    }
 	}
 
@@ -2795,7 +2827,7 @@ read_char (int commandflag, Lisp_Object map,
     {
       if (commandflag >= 0
 	  && !input_pending && !detect_input_pending_run_timers (0))
-	redisplay ();
+	redisplay (4);
 
       goto wrong_kboard;
     }
@@ -3093,7 +3125,7 @@ read_char (int commandflag, Lisp_Object map,
       /* Remove the help from the frame.  */
       unbind_to (count, Qnil);
 
-      redisplay ();
+      redisplay (5);
       if (EQ (c, make_fixnum (040)))
 	{
 	  cancel_echoing ();
diff --git a/src/lisp.h b/src/lisp.h
index 5ecc48b..e3e2aee 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3577,7 +3577,7 @@ extern void message_with_string (const char *, Lisp_Object, bool);
 extern void message_log_maybe_newline (void);
 extern void update_echo_area (void);
 extern void truncate_echo_area (ptrdiff_t);
-extern void redisplay (void);
+extern void redisplay (int);
 
 void set_frame_cursor_types (struct frame *, Lisp_Object);
 extern void syms_of_xdisp (void);
diff --git a/src/nsterm.m b/src/nsterm.m
index 68ad646..d5952b8 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -1992,7 +1992,7 @@ so some key presses (TAB) are swallowed by the system.  */
           [[child parentWindow] removeChildWindow:child];
 #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
 #if MAC_OS_X_VERSION_MIN_REQUIRED < 101000
-          if ([child respondsToSelector:@selector(setAccessibilitySubrole:)]
+          if ([child respondsToSelector:@selector(setAccessibilitySubrole:)])
 #endif
               [child setAccessibilitySubrole:NSAccessibilityStandardWindowSubrole];
 #endif
@@ -2006,7 +2006,7 @@ so some key presses (TAB) are swallowed by the system.  */
                          ordered: NSWindowAbove];
 #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
 #if MAC_OS_X_VERSION_MIN_REQUIRED < 101000
-          if ([child respondsToSelector:@selector(setAccessibilitySubrole:)]
+          if ([child respondsToSelector:@selector(setAccessibilitySubrole:)])
 #endif
               [child setAccessibilitySubrole:NSAccessibilityFloatingWindowSubrole];
 #endif
@@ -3178,8 +3178,28 @@ Note that CURSOR_WIDTH is meaningful only for (h)bar cursors.
 
   if ((phys_cursor_glyph = get_phys_cursor_glyph (w)) == NULL)
     {
-      if (glyph_row->exact_window_width_line_p
-          && w->phys_cursor.hpos >= glyph_row->used[TEXT_AREA])
+
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+      /* This modification enables placement of the cursor-in-fringe bitmap when
+      the window-width is slightly less than `glyph_row->exact_window_width_line_p`.
+      This modification also prevents drawing the real cursor on the fringe (instead
+      of using the cursor-in-fringe bitmap) in the above-mentioned circumstance.
+      See the following related patches:
+      -  July 19, 2016:  bf5ddded70c11edaf3514b25da27fc71cfb8e965
+      -  May 21, 2016:  e5015c5d9632a0bf685c093249ae4a7d3e825b13
+      See the following bug reports:  #16856 and #29233. */
+      int frame_char_width = FRAME_COLUMN_WIDTH (f);
+      int text_area_width = window_box_width (w, TEXT_AREA);
+      bool cursor_in_fringe_p = w->phys_cursor.x + frame_char_width >= text_area_width;
+      if ((glyph_row->exact_window_width_line_p
+            && w->phys_cursor.hpos >= glyph_row->used[TEXT_AREA])
+          || cursor_in_fringe_p)
+
+/* *************************************************************************** */
+
         {
           glyph_row->cursor_in_fringe_p = 1;
           draw_fringe_bitmap (w, glyph_row, 0);
@@ -3215,23 +3235,107 @@ Note that CURSOR_WIDTH is meaningful only for (h)bar cursors.
       h = cursor_height;
     }
 
-  r.origin.x = fx, r.origin.y = fy;
-  r.size.height = h;
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+  r.origin.x = (w->mc.fx > 0)
+               ? w->mc.fx
+               : fx;
+  r.origin.y = (w->mc.fy > 0)
+               ? w->mc.fy
+               : fy;
+  r.size.height = (w->mc.h > 0)
+                  ? w->mc.h
+                  : h;
   r.size.width = w->phys_cursor_width;
 
+/* *************************************************************************** */
+
+
   /* Prevent the cursor from being drawn outside the text area.  */
   if (ns_clip_to_row (w, glyph_row, TEXT_AREA, NO))
     {
       face = FACE_FROM_ID_OR_NULL (f, phys_cursor_glyph->face_id);
-      if (face && NS_FACE_BACKGROUND (face)
-          == ns_index_color (FRAME_CURSOR_COLOR (f), f))
+
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+/* EXAMPLE OF HOW TO LOOK-UP A COLOR:
+  enum face_id face_id = lookup_named_face (w, f, intern ("+-vertical-bar-face"), true);
+  struct face *face = FACE_FROM_ID (f, face_id);
+  NSColor *color = ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), f);
+*/
+
+  if (w->mc.glyph_flavor == MC_GLYPH
+      || w->mc.glyph_flavor == MC_GLYPHLESS
+      || w->mc.glyph_flavor == MC_GLYPH_TAB)
+    {
+      [[NSColor colorWithCalibratedRed: w->mc.red green: w->mc.green blue: w->mc.blue alpha: 1.0] set];
+      Lisp_Object buf = w->contents;
+      CHECK_BUFFER (buf);
+      struct buffer *b = XBUFFER (buf);
+      bool region_active_p = (!NILP (Vtransient_mark_mode)
+                              && !NILP (BVAR (b, mark_active)));
+      ptrdiff_t region_beginning = (region_active_p) ? XFIXNUM (Fregion_beginning ()) : -1;
+      ptrdiff_t region_end = (region_active_p) ? XFIXNUM (Fregion_end ()) : -1;
+      bool region_in_bounds_p = (region_active_p
+                                 && w->mc.posint >= region_beginning
+                                 && w->mc.posint < region_end);
+      if (region_active_p
+          && region_in_bounds_p
+          && active_p)
         {
-          [ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), f) set];
-          hollow_color = FRAME_CURSOR_COLOR (f);
+          enum face_id hollow_active_region_face_id = lookup_named_face (w, f, intern ("+-real-fake-cursor-region-face"), true);
+          struct face *hollow_active_region_face = FACE_FROM_ID (f, hollow_active_region_face_id);
+          NSColor *hollow_active_region_color = ns_lookup_indexed_color (NS_FACE_BACKGROUND (hollow_active_region_face), f);
+          hollow_color = hollow_active_region_color;
         }
+        else if (region_active_p
+                 && !region_in_bounds_p
+                 && active_p)
+          {
+            enum face_id hollow_active_region_out_face_id = lookup_named_face (w, f, intern ("+-real-fake-cursor-region-face"), true);
+            struct face *hollow_active_region_out_face = FACE_FROM_ID (f, hollow_active_region_out_face_id);
+            NSColor *hollow_active_region_out_color = ns_lookup_indexed_color (NS_FACE_FOREGROUND (hollow_active_region_out_face), f);
+            hollow_color = hollow_active_region_out_color;
+          }
+          else if (!region_active_p && active_p)
+            {
+              enum face_id hollow_active_face_id = lookup_named_face (w, f, intern ("+-real-fake-cursor-face"), true);
+              struct face *hollow_active_face = FACE_FROM_ID (f, hollow_active_face_id);
+              NSColor *hollow_active_color = ns_lookup_indexed_color (NS_FACE_BACKGROUND (hollow_active_face), f);
+              hollow_color = hollow_active_color;
+            }
+            /* The region is _not_ visible in the inactive window because the overlay window property is used. */
+            else if (!active_p)
+              {
+                enum face_id hollow_inactive_face_id = lookup_named_face (w, f, intern ("+-real-fake-cursor-inactive-face"), true);
+                struct face *hollow_inactive_face = FACE_FROM_ID (f, hollow_inactive_face_id);
+                NSColor *hollow_inactive_color = ns_lookup_indexed_color (NS_FACE_BACKGROUND (hollow_inactive_face), f);
+                hollow_color = hollow_inactive_color;
+              }
+              else if (face && NS_FACE_BACKGROUND (face) == ns_index_color (FRAME_CURSOR_COLOR (f), f))
+                hollow_color = FRAME_CURSOR_COLOR (f);
+                else
+                  {
+                    struct face *default_bg_face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
+                    [ns_lookup_indexed_color (NS_FACE_BACKGROUND (default_bg_face), f) set];
+                    hollow_color = FRAME_CURSOR_COLOR (f);
+                  }
+    }
+    else if (face && NS_FACE_BACKGROUND (face) == ns_index_color (FRAME_CURSOR_COLOR (f), f))
+      {
+        [ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), f) set];
+        hollow_color = FRAME_CURSOR_COLOR (f);
+      }
       else
         [FRAME_CURSOR_COLOR (f) set];
 
+/* *************************************************************************** */
+
+
 #ifdef NS_IMPL_COCOA
       /* TODO: This makes drawing of cursor plus that of phys_cursor_glyph
          atomic.  Cleaner ways of doing this should be investigated.
@@ -3260,20 +3364,45 @@ Note that CURSOR_WIDTH is meaningful only for (h)bar cursors.
           break;
         case BAR_CURSOR:
           s = r;
-          /* If the character under cursor is R2L, draw the bar cursor
-             on the right of its glyph, rather than on the left.  */
-          cursor_glyph = get_phys_cursor_glyph (w);
-          if ((cursor_glyph->resolved_level & 1) != 0)
-            s.origin.x += cursor_glyph->pixel_width - s.size.width;
+
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+
+    /* @lawlist is focusing the initial development of feature requests #17684
+    and #22873 on L2R languages. */
+    if (w->mc.glyph_flavor != MC_GLYPH
+        && w->mc.glyph_flavor != MC_GLYPHLESS
+        && w->mc.glyph_flavor != MC_GLYPH_TAB)
+      {
+      /* If the character under cursor is R2L, draw the bar cursor
+         on the right of its glyph, rather than on the left.  */
+      cursor_glyph = get_phys_cursor_glyph (w);
+      if ((cursor_glyph->resolved_level & 1) != 0)
+        s.origin.x += cursor_glyph->pixel_width - s.size.width;
+      }
+
+/* *************************************************************************** */
+
 
           NSRectFill (s);
           break;
         }
       ns_reset_clipping (f);
 
-      /* draw the character under the cursor */
-      if (cursor_type != NO_CURSOR)
-        draw_phys_cursor_glyph (w, glyph_row, DRAW_CURSOR);
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+  /* draw the character under the cursor */
+  if (cursor_type != NO_CURSOR
+      && w->mc.glyph_flavor != MC_GLYPHLESS
+      && w->mc.glyph_flavor != MC_GLYPH_TAB)
+    draw_phys_cursor_glyph (w, glyph_row, DRAW_CURSOR);
+
+/* *************************************************************************** */
+
 
 #ifdef NS_IMPL_COCOA
       NSEnableScreenUpdates ();
diff --git a/src/w32term.c b/src/w32term.c
index 8d189ae..7dd7756 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -973,6 +973,20 @@ static void w32_draw_box_rect (struct glyph_string *, int, int, int, int,
 static void
 x_set_cursor_gc (struct glyph_string *s)
 {
+
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+  if (s->w->mc.cursor_gc_default)
+    {
+      s->gc = s->f->output_data.w32->cursor_gc;
+      return;
+    }
+
+/* *************************************************************************** */
+
+
   if (s->font == FRAME_FONT (s->f)
       && s->face->background == FRAME_BACKGROUND_PIXEL (s->f)
       && s->face->foreground == FRAME_FOREGROUND_PIXEL (s->f)
@@ -5690,6 +5704,26 @@ x_draw_hollow_cursor (struct window *w, struct glyph_row *row)
 
   /* Compute frame-relative coordinates for phys cursor.  */
   get_phys_cursor_geometry (w, row, cursor_glyph, &left, &top, &h);
+
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+/* LEGEND:
+
+-  top y == WINDOW_TO_FRAME_PIXEL_Y (w, row->y)
+
+-  bottom y == WINDOW_TO_FRAME_PIXEL_Y (w, row->y) - row->height
+
+-  h of HOLLOW_BOX_CURSOR == row->height
+   [This avoids a visible gap above/below.] */
+
+  if (w->mc.h > 0)
+    h = row->height;
+
+/* *************************************************************************** */
+
+
   rect.left = left;
   /* When on R2L character, show cursor at the right edge of the
      glyph, unless the cursor box is as wide as the glyph or wider
@@ -5753,7 +5787,17 @@ x_draw_bar_cursor (struct window *w, struct glyph_row *row,
 	 invisible.  Use the glyph's foreground color instead in this
 	 case, on the assumption that the glyph's colors are chosen so
 	 that the glyph is legible.  */
-      if (face->background == cursor_color)
+
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+      if (face->background == cursor_color
+          && !w->mc.cursor_gc_invisible_okay)
+
+/* *************************************************************************** */
+
+
 	cursor_color = face->foreground;
 
       x = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x);
@@ -5774,6 +5818,17 @@ x_draw_bar_cursor (struct window *w, struct glyph_row *row,
 	  if ((cursor_glyph->resolved_level & 1) != 0)
 	    x += cursor_glyph->pixel_width - width;
 
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+    /* Align all fake BAR_CURSOR of the VERTICAL_RULER with `opoint_x'. */
+    if (w->mc.fx > 0)
+      x = w->mc.fx;
+
+/* *************************************************************************** */
+
+
 	  w32_fill_area (f, hdc, cursor_color, x,
 			 WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y),
 			 width, row->height);
@@ -5895,31 +5950,159 @@ w32_draw_window_cursor (struct window *w, struct glyph_row *glyph_row,
 	  return;
 	}
 
-      switch (cursor_type)
-	{
-	case HOLLOW_BOX_CURSOR:
-	  x_draw_hollow_cursor (w, glyph_row);
-	  break;
 
-	case FILLED_BOX_CURSOR:
-	  draw_phys_cursor_glyph (w, glyph_row, DRAW_CURSOR);
-	  break;
+/* *************************************************************************** */
+/* begin MULTIPLE CURSORS */
 
-	case BAR_CURSOR:
-	  x_draw_bar_cursor (w, glyph_row, cursor_width, BAR_CURSOR);
-	  break;
+  struct frame *f = XFRAME (WINDOW_FRAME (w));
+  COLORREF original_cursor_pixel = f->output_data.w32->cursor_pixel;
+  /* xterm.c/xterm.h use GC; whereas, w32term.c/w32term.h use XGCValues * */
+  XGCValues *original_cursor_gc = f->output_data.w32->cursor_gc;
+  double base = 255.0;
+  double term_red = base * w->mc.red;
+  double term_green = base * w->mc.green;
+  double term_blue = base * w->mc.blue;
+  int int_red = XFIXNUM (Ftruncate (make_float (term_red), Qnil));
+  int int_green = XFIXNUM (Ftruncate (make_float (term_green), Qnil));;
+  int int_blue = XFIXNUM (Ftruncate (make_float (term_blue), Qnil));;
+  COLORREF color_pixel = PALETTERGB (int_red, int_green, int_blue);
+  switch (cursor_type)
+  {
+    case HOLLOW_BOX_CURSOR:
+    {
+      if (w->mc.red >= 0 && w->mc.blue >= 0 && w->mc.green >= 0)
+        {
+          XGCValues gc_values;
+          unsigned long mask = GCFont | GCForeground | GCBackground;
+          gc_values.font = FRAME_FONT (f);
+          struct face *default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
+          Lisp_Object buf = w->contents;
+          CHECK_BUFFER (buf);
+          struct buffer *b = XBUFFER (buf);
+          bool region_active_p = (!NILP (Vtransient_mark_mode)
+                                  && !NILP (BVAR (b, mark_active)));
+          ptrdiff_t region_beginning = (region_active_p) ? XFIXNUM (Fregion_beginning ()) : -1;
+          ptrdiff_t region_end = (region_active_p) ? XFIXNUM (Fregion_end ()) : -1;
+          bool region_in_bounds_p = (region_active_p
+                                     && w->mc.posint >= region_beginning
+                                     && w->mc.posint < region_end);
+          /* Temporarily hijack `f->output_data.w32->cursor_gc' by borrowing the
+          functionality of `x_make_gc' in w32fns.c.  */
+          if (region_active_p
+              && region_in_bounds_p
+              && active_p)
+            {
+              enum face_id hollow_active_region_face_id = lookup_named_face (w, f, intern ("+-real-fake-cursor-region-face"), true);
+              struct face *hollow_active_region_face = FACE_FROM_ID (f, hollow_active_region_face_id);
+              gc_values.foreground = default_face->foreground;
+              gc_values.background = hollow_active_region_face->background;
+            }
+            else if (region_active_p
+                     && !region_in_bounds_p
+                     && active_p)
+              {
+                enum face_id hollow_active_region_out_face_id = lookup_named_face (w, f, intern ("+-real-fake-cursor-region-face"), true);
+                struct face *hollow_active_region_out_face = FACE_FROM_ID (f, hollow_active_region_out_face_id);
+                gc_values.foreground = default_face->foreground;
+                gc_values.background = hollow_active_region_out_face->foreground;
+              }
+              else if (!region_active_p && active_p)
+                {
+                  enum face_id hollow_active_face_id = lookup_named_face (w, f, intern ("+-real-fake-cursor-face"), true);
+                  struct face *hollow_active_face = FACE_FROM_ID (f, hollow_active_face_id);
+                  gc_values.foreground = default_face->foreground;
+                  gc_values.background = hollow_active_face->background;
+                }
+                /* The region is _not_ visible in the inactive window because the overlay window property is used. */
+                else if (!active_p)
+                  {
+                    enum face_id hollow_inactive_face_id = lookup_named_face (w, f, intern ("+-real-fake-cursor-inactive-face"), true);
+                    struct face *hollow_inactive_face = FACE_FROM_ID (f, hollow_inactive_face_id);
+                    gc_values.foreground = default_face->foreground;
+                    gc_values.background = hollow_inactive_face->background;
+                  }
+          f->output_data.w32->cursor_gc = XCreateGC (NULL, FRAME_W32_WINDOW (f), mask, &gc_values);
+          block_input ();
+          /* Force `x_set_cursor_gc' to use `s->f->output_data.w32->cursor_gc'.  */
+          w->mc.cursor_gc_default = true;
+          draw_phys_cursor_glyph (w, glyph_row, DRAW_CURSOR);
+          w->mc.cursor_gc_default = false;
+          f->output_data.w32->cursor_gc = original_cursor_gc;
+          unblock_input ();
+          /* Temporarily hijack `f->output_data.w32->cursor_pixel'.  */
+          f->output_data.w32->cursor_pixel = color_pixel;
+          x_draw_hollow_cursor (w, glyph_row);
+          f->output_data.w32->cursor_pixel = original_cursor_pixel;
+        }
+        else
+          x_draw_hollow_cursor (w, glyph_row);
+      break;
+    }
+    case FILLED_BOX_CURSOR:
+    {
+      if (w->mc.red >= 0 && w->mc.blue >= 0 && w->mc.green >= 0)
+        {
+          /* Temporarily hijack `f->output_data.w32->cursor_gc' by borrowing the
+          functionality of `x_make_gc' in w32fns.c.  */
+          block_input ();
+          XGCValues gc_values;
+          unsigned long mask = GCFont | GCForeground | GCBackground;
+          gc_values.font = FRAME_FONT (f);
+          gc_values.foreground = FRAME_BACKGROUND_PIXEL (f);
+          gc_values.background = color_pixel;
+          f->output_data.w32->cursor_gc = XCreateGC (NULL, FRAME_W32_WINDOW (f), mask, &gc_values);
+          /* Force `x_set_cursor_gc' to use `s->f->output_data.w32->cursor_gc'.  */
+          w->mc.cursor_gc_default = true;
+          draw_phys_cursor_glyph (w, glyph_row, DRAW_CURSOR);
+          w->mc.cursor_gc_default = false;
+          f->output_data.w32->cursor_gc = original_cursor_gc;
+          unblock_input ();
+        }
+        else
+          draw_phys_cursor_glyph (w, glyph_row, DRAW_CURSOR);
+      break;
+    }
+    case BAR_CURSOR:
+    {
+      if (w->mc.red >= 0 && w->mc.blue >= 0 && w->mc.green >= 0)
+        {
+          /* Temporarily hijack `f->output_data.w32->cursor_pixel'.  */
+          f->output_data.w32->cursor_pixel = color_pixel;
+          w->mc.cursor_gc_invisible_okay = true;
+          x_draw_bar_cursor (w, glyph_row, cursor_width, BAR_CURSOR);
+          w->mc.cursor_gc_invisible_okay = false;
+          f->output_data.w32->cursor_pixel = original_cursor_pixel;
+        }
+        else
+          x_draw_bar_cursor (w, glyph_row, cursor_width, BAR_CURSOR);
+      break;
+    }
+    case HBAR_CURSOR:
+    {
+      if (w->mc.red >= 0 && w->mc.blue >= 0 && w->mc.green >= 0)
+        {
+          /* Temporarily hijack `f->output_data.w32->cursor_pixel'.  */
+          f->output_data.w32->cursor_pixel = color_pixel;
+          w->mc.cursor_gc_invisible_okay = true;
+          x_draw_bar_cursor (w, glyph_row, cursor_width, HBAR_CURSOR);
+          w->mc.cursor_gc_invisible_okay = false;
+          f->output_data.w32->cursor_pixel = original_cursor_pixel;
+        }
+        else
+          x_draw_bar_cursor (w, glyph_row, cursor_width, HBAR_CURSOR);
+      break;
+    }
+    case NO_CURSOR:
+      w->phys_cursor_width = 0;
+      break;
+    default:
+      emacs_abort ();
+  }
 
-	case HBAR_CURSOR:
-	  x_draw_bar_cursor (w, glyph_row, cursor_width, HBAR_CURSOR);
-	  break;
+/* end MULTIPLE CURSORS */
+/* *************************************************************************** */
 
-	case NO_CURSOR:
-	  w->phys_cursor_width = 0;
-	  break;
 
-	default:
-	  emacs_abort ();
-	}
     }
 }
 
diff --git a/src/window.c b/src/window.c
index 6cdc52f..045899c 100644
--- a/src/window.c
+++ b/src/window.c
@@ -6846,6 +6846,29 @@ get_phys_cursor_glyph (struct window *w)
   struct glyph *glyph;
   int hpos = w->phys_cursor.hpos;
 
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+/* This modification enables placement of the cursor-in-fringe bitmap when
+the window-width is slightly less than `glyph_row->exact_window_width_line_p`.
+This modification also prevents drawing the real cursor on the fringe (instead
+of using the cursor-in-fringe bitmap) in the above-mentioned circumstance.
+See the following related patches:
+-  July 19, 2016:  bf5ddded70c11edaf3514b25da27fc71cfb8e965
+-  May 21, 2016:  e5015c5d9632a0bf685c093249ae4a7d3e825b13
+See the following bug reports:  #16856 and #29233. */
+
+  struct frame *f = XFRAME (w->frame);
+  int frame_char_width = FRAME_COLUMN_WIDTH (f);
+  int text_area_width = window_box_width (w, TEXT_AREA);
+  bool cursor_in_fringe_p = w->phys_cursor.x + frame_char_width >= text_area_width;
+  if (cursor_in_fringe_p)
+    return NULL;
+
+/* *************************************************************************** */
+
+
   if (!(w->phys_cursor.vpos >= 0
 	&& w->phys_cursor.vpos < w->current_matrix->nrows))
     return NULL;
diff --git a/src/window.h b/src/window.h
index cc0b6b6..cabee27 100644
--- a/src/window.h
+++ b/src/window.h
@@ -76,6 +76,56 @@ one and the same, so its prev and next members are nil.
 
 A dead window has its contents field set to nil.  */
 
+
+/* *************************************************************************** */
+/* begin MULTIPLE CURSORS */
+
+/* Suffixes for the `mc` window pointer prefix. */
+struct multiple_cursors
+{
+  /* Values for previous and current `window-start' and `window-end'. */
+  EMACS_INT current_start, current_end, previous_start, previous_end, current_x, previous_x;
+
+  /* True means to force `x_set_cursor_gc' to use `s->f->output_data.w32->cursor_gc'
+  in w32term.c or `s->f->output_data.x->cursor_gc' in xterm.c. */
+  bool_bf cursor_gc_default : 1;
+
+  /* True means `x_set_cursor_gc' should permit the foreground and background
+  colors to be the same.  The default behavior disallows an invisible result. */
+  bool_bf cursor_gc_invisible_okay : 1;
+
+  /* True means `mc_draw_multiple_cursors' has not run yet drawn glyph fake cursors. */
+  bool_bf draw_multiple_cursors : 1;
+
+  /* True means `mc_erase_multiple_cursors' has not run yet erased glyph fake cursors. */
+  bool_bf erase_multiple_cursors : 1;
+
+  /* True means crosshairs have not yet been drawn. */
+  bool_bf draw_crosshairs : 1;
+
+  /* True means crosshairs have not yet been erased. */
+  bool_bf erase_crosshairs : 1;
+
+  /* The flavor of the glyph used by `draw_window_cursor'. */
+  int glyph_flavor;
+
+  /* L.S.L. colors. */
+  double red, green, blue;
+
+  /* The buffer position point of a fake cursor. */
+  int posint;
+
+  /* Pixel position (window relative) of horizontal/vertical rulers. */
+  int fx, fy, h;
+
+  /* Record FROM_WHERE when `redisplay_preserve_echo_area' is called. */
+  int redisplay_preserve_echo_area;
+};
+
+/* end MULTIPLE CURSORS */
+/* *************************************************************************** */
+
+
 struct cursor_pos
 {
   /* Pixel position.  These are always window relative.  */
@@ -181,6 +231,22 @@ struct window
     /* The help echo text for this window.  Qnil if there's none.  */
     Lisp_Object mode_line_help_echo;
 
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+    /* The cache for multiple glyph cursors.  For an example of the structure of
+    the list, see the comments at the beginning of `mc_calc' in xdisp.c.  */
+    Lisp_Object multiple_cursors_cache;
+
+    /* The cache for multiple glyph/glyphless cursors that form crosshairs.  For an
+    example of the structure of the list, see the comments at the beginning of
+    `mc_crosshairs' in xdisp.c.  */
+    Lisp_Object crosshairs_cache;
+
+/* *************************************************************************** */
+
+
     /* No Lisp data may follow below this point without changing
        mark_object in alloc.c.  The member current_matrix must be the
        first non-Lisp member.  */
@@ -283,6 +349,16 @@ struct window
 
 #ifdef HAVE_WINDOW_SYSTEM
 
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+    /* The prefix for window pointers relating to multiple cursors.  */
+    struct multiple_cursors mc;
+
+/* *************************************************************************** */
+
+
     /* Cursor type of last cursor drawn on the window.  */
     enum text_cursor_kinds phys_cursor_type;
 
@@ -421,6 +497,25 @@ XWINDOW (Lisp_Object a)
   return XUNTAG (a, Lisp_Vectorlike, struct window);
 }
 
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+INLINE void
+wset_multiple_cursors_cache (struct window *w, Lisp_Object val)
+{
+  w->multiple_cursors_cache = val;
+}
+
+INLINE void
+wset_crosshairs_cache (struct window *w, Lisp_Object val)
+{
+  w->crosshairs_cache = val;
+}
+
+/* *************************************************************************** */
+
+
 /* Most code should use these functions to set Lisp fields in struct
    window.  */
 INLINE void
diff --git a/src/xdisp.c b/src/xdisp.c
index d61d421..9df78b1 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -830,7 +830,7 @@ static intmax_t message_log_check_duplicate (ptrdiff_t, ptrdiff_t);
 static void push_it (struct it *, struct text_pos *);
 static void iterate_out_of_display_property (struct it *);
 static void pop_it (struct it *);
-static void redisplay_internal (void);
+static void redisplay_internal (int);
 static void echo_area_display (bool);
 static void block_buffer_flips (void);
 static void unblock_buffer_flips (void);
@@ -921,6 +921,4713 @@ static void show_mouse_face (Mouse_HLInfo *, enum draw_glyphs_face);
 static bool coords_in_mouse_face_p (struct window *, int, int);
 
 
+/* *************************************************************************** */
+/* begin MULTIPLE CURSORS */
+
+/* MULTIPLE CURSORS:  Emacs Bug #22873 (feature request)
+
+   CROSSHAIRS:  Emacs Bug #17684 (feature request)
+
+
+PATCH VERSION:  014.000 [08/28/2018]
+                014.001 [09/01/2018]
+                014.002 [09/02/2018]
+                014.003 [09/05/2018]
+/* *************************************************************************** */
+/* begin MULTIPLE CURSORS */
+
+/* MULTIPLE CURSORS:  Emacs Bug #22873 (feature request)
+
+   CROSSHAIRS:  Emacs Bug #17684 (feature request)
+
+
+PATCH VERSION:  014.000 [08/28/2018]
+                014.001 [09/01/2018]
+                014.002 [09/02/2018]
+                014.003 [09/05/2018]
+                014.004 [09/08/2018]
+                014.005 [09/09/2018]
+                014.006 [09/09/2018]
+                014.007 [09/10/2018]
+                014.008 [09/10/2018]
+                014.009 [09/11/2018]
+                014.010 [09/13/2018]
+                014.011 [09/14/2018]
+                014.012 [09/17/2018]
+                014.013 [09/18/2018]
+                014.014 [09/19/2018]
+                014.015 [09/23/2018]
+                014.016 [09/24/2018]
+                014.017 [09/25/2018]
+                014.018 [09/26/2018]
+                014.019 [10/01/2018]
+                014.020 [10/02/2018]
+                014.021 [10/09/2018]
+                014.022 [10/10/2018]
+                014.023 [10/10/2018]
+
+Apply patch to master branch:  Sat Jul 7 09:59:53 2018 -0700
+git reset --hard 98463bed07ecc9057094928ffdc2321eaaf3ab52
+
+Last Commit : Sat Jul 7 09:59:53 2018 -0700
+            : Glenn Morris <rgm@gnu.org>
+            : 98463bed07ecc9057094928ffdc2321eaaf3ab52
+            : * lisp/imenu.el: Require cl-lib, not internal components of same.
+
+
+SETUP:
+
+Step 1:  git clone -b master git://git.sv.gnu.org/emacs.git
+
+Step 2:  In the new emacs folder, go back to 07/07/2018:
+
+git reset --hard 98463bed07ecc9057094928ffdc2321eaaf3ab52
+
+[Going back in time to 07/07/2018 saves @lawlist a couple of hours by not having
+to deal with unrelated recent changes to the master branch by the Emacs team.]
+
+Step 3:  From within the new emacs folder created in Step 1, apply the patch:
+
+git apply /path/to/the/emacs/patch.diff
+
+[There should not be any error messages at this point; i.e, you should be returned to a new command prompt.]
+
+Step 4:  ./autogen.sh
+
+Step 5:  ./configure ... [your custom options]
+
+Step 6:  make
+
+Step 7:  make install
+
+-  To try out built-in fake cursors with Magnar Sveen's library (multiple-cursors), install that package first.
+
+  (progn
+    (require 'package)
+    (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)
+    (package-initialize)
+    (package-refresh-contents)
+    (package-install 'multiple-cursors))
+
+-  Load or evaluate the contents of crosshairs.el, which includes code modifying a couple of functions used by Magnar Sveen's library.
+
+-  To try out the crosshairs feature, open a simple buffer (nothing fancy, just code or text) and type:  M-x +-mode
+
+-  To see an example of crosshairs playing nicely with tab stretches, open up something like simple.el and type:  M-x +-mode.
+
+-  To see an example of a variety of built-in cursor styles and widths, type:  M-x mc-test
+
+
+EXAMPLE OF USING MULTIPLE FAKE CURSORS:
+
+  ;;; '(BUFFER-POSITION CURSOR-TYPE CURSOR-COLOR)
+  (setq multiple-cursors-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])))
+
+  ;;; TURN OFF.
+  (setq multiple-cursors-conf nil)
+
+
+TODO:
+
+-  Multiple Cursors:  If point is in the middle of a composite character, then
+   keep going until the next full character.
+
+-  Work on compatability with MacOS Mojave.  [Issue # 40.]
+
+-  Tab STRETCH -- not being drawn properly in all circumstances; including, but
+   limited to a situation when the user has not customized the tab slot of the
+   buffer `buffer-display-table'.  [Issue # 39.]
+
+-  When typing quickly, the floating horizontal ruler disappears temporarily.
+   This happened when draw crosshairs forthwith is non-nil.  [Issue # 38.]
+
+-  Suppress the drawing of crosshairs until the minor-mode has been fully loaded.
+   The X and/or HPOS are _sometimes_ (?) off while line numbers are being drawn
+   at the outset of initialization.  @lawlist is having trouble reproducing this.
+   [Issue # 36.]
+
+-  Horizontal Ruler:  Depending upon the font, certain letters that follow a tab
+   STRETCH cause the preceding horizontal hbar to be erased; e.g., "A".
+   [Issue # 30.]
+
+-  Fake cursors are being redrawn too often when non-selected visible windows
+   have an ongoing process that require frequent redisplay updates (e.g.,
+   an eshell buffer.  @lawlist may have already corrected the frequent redisplay
+   issue as to mouse-overs, but will need to check this once again to be sure.
+   [Issue # 16 and 24.]
+
+-  Implement a way to properly calculate X, Y, HPOS, VPOS when dealing with
+   overlays, text properties (invisible, etc.), and images.  [Issue # 17.]
+
+-  Implement functionality similar to the multiple cursors library by Magnar Sveen.
+   [Issue # 18.]
+
+-  Create a comprehensive list of features to always test, and setup a test file.
+   [Issue # 19.]
+
+-  Offer users the ability to create a second set of crosshairs similar to
+   https://gitlab.com/iankelling/visible-mark/blob/master/visible-mark.el
+   [Issue # 6.]
+
+-  Follow up with the Emacs team re bug#32177; i.e., (Current line number shifts
+   one column to the left.)  [Issue # 9.]
+
+-  Follow up with the Emacs team re bug#32060; i.e., (Horizontal Scrolling
+   (Current Line):  Wrong line gets h-scrolled.)  [Issue # 10.]
+
+-  Determine if bug #28936 needs to be fixed and help the Emacs team re same.
+   [Issue # 11.]
+
+
+TESTING:  Situations that always need to be tested when working on these features.
+
+-  Multiple Fake Cursors:  Line endings.
+
+-  Crosshairs:  Line endings.
+
+-  it->line_wrap == TRUNCATE
+
+-  it->line_wrap == WORD_WRAP
+
+-  it->line_wrap == WINDOW_WRAP
+
+-  Horizontal Scrolling -- Temporary:  (scroll-left 1)
+
+   (setq-local auto-hscroll-mode 'current-line)
+
+-  Horizontal Scrolling -- Permanent:  (scroll-left 1 t)
+
+   (setq-local auto-hscroll-mode 'current-line)
+
+-  (fundamental-mode)
+   (setq display-line-numbers t)
+   (setq buffer-display-table (make-display-table))
+   (aset buffer-display-table
+         ?\t
+         (vector (make-glyph-code ?\u00BB 'font-lock-warning-face)
+                 (make-glyph-code ?\t 'highlight)))
+   (aset buffer-display-table
+         ?\n
+         (vector (make-glyph-code ?\u00B6 'font-lock-comment-face)
+                 ?\n))
+   (setq tab-width 8)
+   (setq-local auto-hscroll-mode 'current-line)
+
+-  No Line Numbers
+
+
+CREATION OF REPOSITORY:
+
+  mkdir DIRECTORY
+
+  cd DIRECTORY
+
+  git init
+
+  git remote add origin https://github.com/lawlist/17684_22873.git
+
+  ### Have a look at the current configuration.
+  ###   origin https://github.com/lawlist/17684_22873.git (fetch)
+  ###   origin https://github.com/lawlist/17684_22873.git (push)
+  git remote -v
+
+  git remote add upstream https://git.savannah.gnu.org/git/emacs.git
+
+  ### Verify the new configuration.
+  ###   origin https://github.com/lawlist/17684_22873.git (fetch)
+  ###   origin https://github.com/lawlist/17684_22873.git (push)
+  ###   upstream https://git.savannah.gnu.org/git/emacs.git (fetch)
+  ###   upstream https://git.savannah.gnu.org/git/emacs.git (push)
+  git remote -v
+
+  git fetch upstream
+
+  ### Create a new branch `17684_22873` so you don't have to override the upstream `master`.
+  git checkout -b 17684_22873 98463bed07ecc9057094928ffdc2321eaaf3ab52
+
+  ### Create the online Github repository if not already in existence.
+  curl -u USERNAME:PASSWORD https://api.github.com/user/repos -d '{"name":"17684_22873.git"}'
+
+  git push -u origin 17684_22873
+
+  ### Apply the following patch:  014.000 [08/28/2018]
+  ### add/commit/push
+
+  ### Apply the following patch:  014.001 [09/01/2018]
+  ### add/commit/push
+
+  ### Apply the following patch:  014.002 [09/02/2018]
+  ### add/commit/push
+
+
+UPDATE THE REPOSITORY:
+
+  git apply /path/to/the/emacs/patch.diff
+  git add .
+  git commit -m "INSERT COMMIT MESSAGE."
+  git push -u origin 17684_22873
+
+CREATE PATCHES:  git format-patch -1 SHA
+                 git format-patch -1 -o /path/to/output/directory SHA
+
+LEGEND:
+
+#ifdef GLYPH_DEBUG
+  if (trace_redisplay_p
+      && (!NILP (BVAR (XBUFFER (w->contents), multiple_cursors_conf))
+          || !NILP (BVAR (XBUFFER (w->contents), crosshairs))))
+    {
+      Lisp_Object window;
+      XSETWINDOW (window, w);
+      Lisp_Object window_string = Fprin1_to_string (window, Qnil);
+      char *window_char = SSDATA (window_string);
+      fprintf (stderr, "\nwindow (%s)\n", window_char);
+    }
+#endif
+
+#ifdef GLYPH_DEBUG
+  struct frame *f = XFRAME (w->frame);
+  int temp_fx = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x);
+  int temp_fy = WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y);
+  enum window_part part = ON_NOTHING;
+  Lisp_Object window = window_from_coordinates (f, temp_fx, temp_fy, &part, false);
+  Lisp_Object window_string = Fprin1_to_string (window, Qnil);
+  debug_method_add (w, "window (%s)", SSDATA (window_string));
+#endif
+
+char *w_contents = (BUFFERP (w->contents) && STRINGP (BVAR (XBUFFER (w->contents), name)))
+                   ? SSDATA (BVAR (XBUFFER (w->contents), name))
+                   : "nil";
+fprintf (stderr, "\nBuffer (%s)\n", w_contents);
+
+struct face *face = mc_lookup_face (it);
+struct font *font = face->font;
+Lisp_Object foreground_face = face->lface[LFACE_FOREGROUND_INDEX];
+Lisp_Object background_face = face->lface[LFACE_BACKGROUND_INDEX];
+fprintf (stderr, "\nforeground/background (%s/%s)\n",
+          (!NILP (foreground_face) ? SSDATA (foreground_face) : "NILP foreground_face"),
+          (!NILP (background_face) ? SSDATA (background_face) : "NILP background_face"));
+
+fprintf (stderr, "My lisp object:  %s\n", SSDATA (Fchar_to_string (make_fixnum (101))));
+
+fprintf (stderr, "string: %s | int: %d\n", SSDATA (build_string ("foo")), 69);
+
+if (BUFFERP (w->contents) && STRINGP (BVAR (XBUFFER (w->contents), name)))
+  fprintf (stderr, "ns_update_window_end:  %s\n", SSDATA (BVAR (XBUFFER (w->contents), name)));
+
+AUTO_STRING (my_string_one, "This is the value of `my_object_one':  %s");
+Lisp_Object my_object_one = make_float (0.1);
+CALLN (Fmessage, my_string_one, my_object_one);
+
+AUTO_STRING (my_string_two, "This is the value of `my_object_two':  %s");
+Lisp_Object my_object_two = make_fixnum (777);
+CALLN (Fmessage, my_string_two, my_object_two);
+
+WINDOW:  w->contents
+
+BUFFER:  XBUFFER (w->contents)
+
+BUFFER LOCAL VARIABLE:  BVAR (XBUFFER (w->contents), variable_name)
+
+NO NARROWING:
+
+BEG == Beginning of Buffer (window displays current buffer)
+
+ZV == End of Buffer (window displays current buffer)
+
+BEG_BYTE == Beginning Byte of Buffer
+
+Z_BYTE == Ending Byte of Buffer
+
+NARROWED -- "V":
+
+BEGV == Beginning of NARROWED Buffer (window displays current buffer)
+
+ZV == End of NARROWED Buffer (window displays current buffer)
+
+BEGV_BYTE == Beginning Byte of NARROWED Buffer
+
+ZV_BYTE == Ending Byte of NARROWED buffer
+
+WINDOW DOES NOT NECESSARILY DISPLAY BUFFER:
+
+bob_disregard_narrow = BUF_BEG (buffer)
+eob_disregard_narrow = BUF_Z (buffer)
+
+bob_respect_narrow = BUF_BEGV (buffer)
+eob_respect_narrow = BUF_ZV (buffer)
+
+window_start = marker_position (w->start)
+window_end = eob_disregard_narrow - w->window_end_pos
+
+buffer_size = eob_disregard_narrow - bob_disregard_narrow
+
+buffer_narrowed_p = (eob_respect_narrow - bob_respect_narrow != buffer_size)
+
+window_contents_visible_p = (bob_respect_narrow == window_start
+                             && eob_respect_narrow == window_end)
+
+This is the C [ternary operator][1] (Objective-C is a superset of C):
+
+    label.frame = (inPseudoEditMode) ? kLabelIndentedRect : kLabelRect;
+
+is semantically equivalent to
+
+    if(inPseudoEditMode) {
+     label.frame = kLabelIndentedRect;
+    } else {
+     label.frame = kLabelRect;
+    }
+
+The ternary with no first element (e.g. `variable ?: anotherVariable`) means the same as `(valOrVar != 0) ? valOrVar : anotherValOrVar`
+
+EASSERT:
+
+  eassert (BUF_BEG (b) <= charpos && charpos <= BUF_Z (b));
+  bool barf_crash = (BUF_BEG (b) <= charpos && charpos <= BUF_Z (b)) ? false : true; */
+
+#include <time.h>
+#include <ftoastr.h>
+
+#define NO_FRINGE_BITMAP 0
+
+#define LEFT_FRINGE_BITMAP -3
+
+#define RIGHT_FRINGE_BITMAP -4
+
+/* Text cursor types.  */
+
+enum type_of_action
+{
+  MULTIPLE_CURSORS,
+  HORIZONTAL_RULER,
+  VERTICAL_RULER
+};
+
+/* Function prototypes.  */
+
+static void debug_method_add (struct window *, char const *, ...);
+
+static int window_hscroll_limited (struct window *w, struct frame *f);
+
+void dump_glyph_row (struct glyph_row *, int, int) EXTERNALLY_VISIBLE;
+
+/* Record FROM_WHERE when `redisplay_preserve_echo_area' is called. */
+static int mc_redisplay_preserve_echo_area;
+
+/* Record FROM_WHERE when `redisplay' is called. */
+static int mc_redisplay;
+
+/* Record FROM_WHERE when `redisplay_internal' is called. */
+static int mc_redisplay_internal;
+
+/* Set variables WIDTH and BYTES for a multibyte sequence starting at P.
+   DP is a display table or NULL. */
+
+#define MC_MULTIBYTE_BYTES_WIDTH(p, dp, bytes, width)			\
+  do {									\
+    int ch;								\
+										\
+    ch = STRING_CHAR_AND_LENGTH (p, bytes);				\
+    if (BYTES_BY_CHAR_HEAD (*p) != bytes)				\
+      width = bytes * 4;						\
+    else								\
+      {									\
+	if (dp != 0 && VECTORP (DISP_CHAR_VECTOR (dp, ch)))		\
+	  width = sanitize_char_width (ASIZE (DISP_CHAR_VECTOR (dp, ch))); \
+	else								\
+	  width = CHARACTER_WIDTH (ch);					\
+      }									\
+  } while (0)
+
+/* Check the presence of a display property and compute its width.
+   If a property was found and its width was found as well, return
+   its width (>= 0) and set the position of the end of the property
+   in ENDPOS.
+   Otherwise just return -1.  */
+static int
+mc_check_display_width (ptrdiff_t pos, ptrdiff_t col, ptrdiff_t *endpos)
+{
+  Lisp_Object val, overlay;
+  if (CONSP (val = get_char_property_and_overlay
+       (make_fixnum (pos), Qdisplay, Qnil, &overlay))
+      && EQ (Qspace, XCAR (val)))
+    { /* FIXME: Use calc_pixel_width_or_height.  */
+      Lisp_Object plist = XCDR (val), prop;
+      int width = -1;
+      EMACS_INT align_to_max =
+  (col < MOST_POSITIVE_FIXNUM - INT_MAX
+   ? (EMACS_INT) INT_MAX + col
+   : MOST_POSITIVE_FIXNUM);
+      if ((prop = Fplist_get (plist, QCwidth),
+     RANGED_FIXNUMP (0, prop, INT_MAX))
+    || (prop = Fplist_get (plist, QCrelative_width),
+        RANGED_FIXNUMP (0, prop, INT_MAX)))
+  width = XFIXNUM (prop);
+      else if (FLOATP (prop) && 0 <= XFLOAT_DATA (prop)
+         && XFLOAT_DATA (prop) <= INT_MAX)
+  width = (int)(XFLOAT_DATA (prop) + 0.5);
+      else if ((prop = Fplist_get (plist, QCalign_to),
+    RANGED_FIXNUMP (col, prop, align_to_max)))
+  width = XFIXNUM (prop) - col;
+      else if (FLOATP (prop) && col <= XFLOAT_DATA (prop)
+         && (XFLOAT_DATA (prop) <= align_to_max))
+  width = (int)(XFLOAT_DATA (prop) + 0.5) - col;
+      if (width >= 0)
+  {
+    ptrdiff_t start;
+    if (OVERLAYP (overlay))
+      *endpos = OVERLAY_POSITION (OVERLAY_END (overlay));
+    else
+      get_property_and_range (pos, Qdisplay, &val, &start, endpos, Qnil);
+    /* For :relative-width, we need to multiply by the column
+       width of the character at POS, if it is greater than 1.  */
+    if (!NILP (Fplist_get (plist, QCrelative_width))
+        && !NILP (BVAR (current_buffer, enable_multibyte_characters)))
+      {
+        int b, wd;
+        unsigned char *p = BYTE_POS_ADDR (CHAR_TO_BYTE (pos));
+        MC_MULTIBYTE_BYTES_WIDTH (p, buffer_display_table (), b, wd);
+        width *= wd;
+      }
+    return width;
+  }
+    }
+  return -1;
+}
+
+/* Scanning from the beginning of the current line, stop at the buffer
+   position ENDPOS or at the column GOALCOL or at the end of line, whichever
+   comes first.
+   Return the resulting buffer position and column in ENDPOS and GOALCOL.
+   PREVCOL gets set to the column of the previous position (it's always
+   strictly smaller than the goal column).  */
+void
+mc_scan_for_column (ptrdiff_t *endpos, EMACS_INT *goalcol, ptrdiff_t *prevcol, ptrdiff_t pt)
+{
+  EMACS_INT last_known_column_modified = 0;
+  ptrdiff_t last_known_column = 0;
+  int tab_width = SANE_TAB_WIDTH (current_buffer);
+  bool ctl_arrow = !NILP (BVAR (current_buffer, ctl_arrow));
+  struct Lisp_Char_Table *dp = buffer_display_table ();
+  bool multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters));
+  struct composition_it cmp_it;
+  Lisp_Object window;
+  struct window *w;
+  /* Start the scan at the beginning of this line with column number 0.  */
+  register ptrdiff_t col = 0, prev_col = 0;
+  EMACS_INT goal = goalcol ? *goalcol : MOST_POSITIVE_FIXNUM;
+  ptrdiff_t end = endpos ? *endpos : pt;
+  ptrdiff_t scan, scan_byte, next_boundary;
+  scan = find_newline (pt, CHAR_TO_BYTE (pt), BEGV, BEGV_BYTE, -1, NULL, &scan_byte, 1);
+  next_boundary = scan;
+  window = Fget_buffer_window (Fcurrent_buffer (), Qnil);
+  w = ! NILP (window) ? XWINDOW (window) : NULL;
+  memset (&cmp_it, 0, sizeof cmp_it);
+  cmp_it.id = -1;
+  composition_compute_stop_pos (&cmp_it, scan, scan_byte, end, Qnil);
+  /* Scan forward to the target position.  */
+  while (scan < end)
+    {
+      int c;
+      /* Occasionally we may need to skip invisible text.  */
+      while (scan == next_boundary)
+  {
+    ptrdiff_t old_scan = scan;
+    /* This updates NEXT_BOUNDARY to the next place
+       where we might need to skip more invisible text.  */
+    scan = skip_invisible (scan, &next_boundary, end, Qnil);
+    if (scan != old_scan)
+      scan_byte = CHAR_TO_BYTE (scan);
+    if (scan >= end)
+      goto endloop;
+  }
+      /* Test reaching the goal column.  We do this after skipping
+   invisible characters, so that we put point before the
+   character on which the cursor will appear.  */
+      if (col >= goal)
+  break;
+      prev_col = col;
+      { /* Check display property.  */
+  ptrdiff_t endp;
+  int width = mc_check_display_width (scan, col, &endp);
+  if (width >= 0)
+    {
+      col += width;
+      if (endp > scan) /* Avoid infinite loops with 0-width overlays.  */
+        {
+    scan = endp;
+    scan_byte = CHAR_TO_BYTE (scan);
+    continue;
+        }
+    }
+      }
+      /* Check composition sequence.  */
+      if (cmp_it.id >= 0
+    || (scan == cmp_it.stop_pos
+        && composition_reseat_it (&cmp_it, scan, scan_byte, end,
+          w, NULL, Qnil)))
+  composition_update_it (&cmp_it, scan, scan_byte, Qnil);
+      if (cmp_it.id >= 0)
+  {
+    scan += cmp_it.nchars;
+    scan_byte += cmp_it.nbytes;
+    if (scan <= end)
+      col += cmp_it.width;
+    if (cmp_it.to == cmp_it.nglyphs)
+      {
+        cmp_it.id = -1;
+        composition_compute_stop_pos (&cmp_it, scan, scan_byte, end,
+              Qnil);
+      }
+    else
+      cmp_it.from = cmp_it.to;
+    continue;
+  }
+      c = FETCH_BYTE (scan_byte);
+      /* See if there is a display table and it relates
+   to this character.  */
+      if (dp != 0
+    && ! (multibyte && LEADING_CODE_P (c))
+    && VECTORP (DISP_CHAR_VECTOR (dp, c)))
+  {
+    Lisp_Object charvec;
+    ptrdiff_t i, n;
+    /* This character is displayed using a vector of glyphs.
+       Update the column/position based on those glyphs.  */
+    charvec = DISP_CHAR_VECTOR (dp, c);
+    n = ASIZE (charvec);
+    for (i = 0; i < n; i++)
+      {
+        /* This should be handled the same as
+     next_element_from_display_vector does it.  */
+        Lisp_Object entry = AREF (charvec, i);
+        if (GLYPH_CODE_P (entry))
+    c = GLYPH_CODE_CHAR (entry);
+        else
+    c = ' ';
+        if (c == '\n')
+    goto endloop;
+        if (c == '\r' && EQ (BVAR (current_buffer, selective_display), Qt))
+    goto endloop;
+        if (c == '\t')
+    {
+      col += tab_width;
+      col = col / tab_width * tab_width;
+    }
+        else
+    ++col;
+      }
+  }
+      else
+  {
+    /* The display table doesn't affect this character;
+       it displays as itself.  */
+    if (c == '\n')
+      goto endloop;
+    if (c == '\r' && EQ (BVAR (current_buffer, selective_display), Qt))
+      goto endloop;
+    if (c == '\t')
+      {
+        col += tab_width;
+        col = col / tab_width * tab_width;
+      }
+    else if (multibyte && LEADING_CODE_P (c))
+      {
+        /* Start of multi-byte form.  */
+        unsigned char *ptr;
+        int bytes, width;
+        ptr = BYTE_POS_ADDR (scan_byte);
+        MC_MULTIBYTE_BYTES_WIDTH (ptr, dp, bytes, width);
+        /* Subtract one to compensate for the increment
+     that is going to happen below.  */
+        scan_byte += bytes - 1;
+        col += width;
+      }
+    else if (ctl_arrow && (c < 040 || c == 0177))
+      col += 2;
+    else if (c < 040 || c >= 0177)
+      col += 4;
+    else
+      col++;
+  }
+      scan++;
+      scan_byte++;
+    }
+ endloop:
+  last_known_column = col;
+  last_known_column_point = pt;
+  last_known_column_modified = MODIFF;
+  if (goalcol)
+    *goalcol = col;
+  if (endpos)
+    *endpos = scan;
+  if (prevcol)
+    *prevcol = prev_col;
+}
+
+ptrdiff_t
+mc_current_column (struct window *w, ptrdiff_t pt)
+{
+  /* `buf_charpos_to_bytepos':  eassert (BUF_BEG (b) <= charpos && charpos <= BUF_Z (b)); */
+  Lisp_Object buf = w->contents;
+  CHECK_BUFFER (buf);
+  struct buffer *b = XBUFFER (buf);
+  bool barf_crash = (BUF_BEG (b) <= pt && pt <= BUF_Z (b)) ? false : true;
+  if (barf_crash)
+    return 0;
+  EMACS_INT last_known_column_modified = 0;
+  ptrdiff_t last_known_column = 0;
+  ptrdiff_t col;
+  unsigned char *ptr, *stop;
+  bool tab_seen;
+  ptrdiff_t post_tab;
+  int c;
+  int tab_width = SANE_TAB_WIDTH (current_buffer);
+  bool ctl_arrow = !NILP (BVAR (current_buffer, ctl_arrow));
+  struct Lisp_Char_Table *dp = buffer_display_table ();
+  if (pt == last_known_column_point
+      && MODIFF == last_known_column_modified)
+    return last_known_column;
+  /* If the buffer has overlays, text properties,
+     or multibyte characters, use a more general algorithm.  */
+  if (buffer_intervals (current_buffer)
+      || buffer_has_overlays ()
+      || Z != Z_BYTE)
+    {
+      EMACS_INT col = MOST_POSITIVE_FIXNUM;
+      mc_scan_for_column (&pt, &col, NULL, pt);
+      return col;
+    }
+  /* Scan backwards from point to the previous newline,
+     counting width.  Tab characters are the only complicated case.  */
+  /* Make a pointer for decrementing through the chars before point.  */
+  ptr = BYTE_POS_ADDR (CHAR_TO_BYTE (pt) - 1) + 1;
+  /* Make a pointer to where consecutive chars leave off,
+     going backwards from point.  */
+  if (pt == BEGV)
+    stop = ptr;
+  else if (pt <= GPT || BEGV > GPT)
+    stop = BEGV_ADDR;
+  else
+    stop = GAP_END_ADDR;
+  col = 0, tab_seen = 0, post_tab = 0;
+  while (1)
+    {
+      ptrdiff_t i, n;
+      Lisp_Object charvec;
+      if (ptr == stop)
+  {
+    /* We stopped either for the beginning of the buffer
+       or for the gap.  */
+    if (ptr == BEGV_ADDR)
+      break;
+    /* It was the gap.  Jump back over it.  */
+    stop = BEGV_ADDR;
+    ptr = GPT_ADDR;
+    /* Check whether that brings us to beginning of buffer.  */
+    if (BEGV >= GPT)
+      break;
+  }
+      c = *--ptr;
+      if (dp && VECTORP (DISP_CHAR_VECTOR (dp, c)))
+  {
+    charvec = DISP_CHAR_VECTOR (dp, c);
+    n = ASIZE (charvec);
+  }
+      else
+  {
+    charvec = Qnil;
+    n = 1;
+  }
+      for (i = n - 1; i >= 0; --i)
+  {
+    if (VECTORP (charvec))
+      {
+        /* This should be handled the same as
+     next_element_from_display_vector does it.  */
+        Lisp_Object entry = AREF (charvec, i);
+        if (GLYPH_CODE_P (entry))
+    c = GLYPH_CODE_CHAR (entry);
+        else
+    c = ' ';
+      }
+    if (c >= 040 && c < 0177)
+      col++;
+    else if (c == '\n'
+       || (c == '\r'
+           && EQ (BVAR (current_buffer, selective_display), Qt)))
+      {
+        ptr++;
+        goto start_of_line_found;
+      }
+    else if (c == '\t')
+      {
+        if (tab_seen)
+    col = ((col + tab_width) / tab_width) * tab_width;
+        post_tab += col;
+        col = 0;
+        tab_seen = 1;
+      }
+    else if (VECTORP (charvec))
+      /* With a display table entry, C is displayed as is, and
+         not displayed as \NNN or as ^N.  If C is a single-byte
+         character, it takes one column.  If C is multi-byte in
+         a unibyte buffer, it's translated to unibyte, so it
+         also takes one column.  */
+      ++col;
+    else
+      col += (ctl_arrow && c < 0200) ? 2 : 4;
+  }
+    }
+ start_of_line_found:
+  if (tab_seen)
+    {
+      col = ((col + tab_width) / tab_width) * tab_width;
+      col += post_tab;
+    }
+  last_known_column = col;
+  last_known_column_point = pt;
+  last_known_column_modified = MODIFF;
+  return col;
+}
+
+static int
+mc_lisp_to_cursor_type (Lisp_Object arg)
+{
+  char *str;
+  if (XTYPE (arg) == Lisp_String)
+    str = SSDATA (arg);
+  else if (XTYPE (arg) == Lisp_Symbol)
+    str = SSDATA (SYMBOL_NAME (arg));
+  else return -1;
+  if (!strcmp (str, "box"))
+    return FILLED_BOX_CURSOR;
+  if (!strcmp (str, "hollow"))
+    return HOLLOW_BOX_CURSOR;
+  if (!strcmp (str, "hbar"))
+    return HBAR_CURSOR;
+  if (!strcmp (str, "bar"))
+    return BAR_CURSOR;
+  if (!strcmp (str, "left-fringe-bitmap"))
+    return LEFT_FRINGE_BITMAP;
+  if (!strcmp (str, "right-fringe-bitmap"))
+    return RIGHT_FRINGE_BITMAP;
+  if (!strcmp (str, "no"))
+    return NO_CURSOR;
+  return -1;
+}
+
+static Lisp_Object
+mc_cursor_type_to_lisp (int arg)
+{
+  switch (arg)
+    {
+    case FILLED_BOX_CURSOR: return Qbox;
+    case HOLLOW_BOX_CURSOR: return Qhollow;
+    case HBAR_CURSOR: return Qhbar;
+    case BAR_CURSOR: return Qbar;
+    case LEFT_FRINGE_BITMAP: return intern ("left-fringe-bitmap");
+    case RIGHT_FRINGE_BITMAP: return intern ("right-fringe-bitmap");
+    case NO_CURSOR:
+    default: return intern ("no");
+    }
+}
+
+static Lisp_Object
+mc_color_vector_calc (struct window *w, Lisp_Object color)
+{
+  CHECK_STRING (color);
+  Lisp_Object target_frame = w->frame;
+  Lisp_Object color_values;
+  double valmax = XFIXNUM (XCAR (Fxw_color_values (build_string ("#ffffff"), target_frame)));
+  Lisp_Object vlist;
+  ptrdiff_t x;
+  int i = 0;
+  Lisp_Object temp = Qnil;
+  Lisp_Object vector = (Fmake_vector (make_fixnum (3), Qnil));
+  if (!NILP (Fmemq ((Fframep (target_frame)), listn (CONSTYPE_HEAP, 3, intern ("x"), intern ("w32"), intern ("ns")))))
+    {
+      color_values = (Fxw_color_values (color, target_frame));
+      for (vlist = color_values;
+           CONSP (vlist);
+           vlist = XCDR (vlist))
+        {
+          x = XFIXNUM (XCAR (vlist));
+          temp = make_float (x / valmax);
+          ASET (vector, i, temp);
+          i = i + 1;
+        }
+    }
+  return vector;
+}
+
+static Lisp_Object
+mc_bg_lsl (struct window *w, enum face_id face_id)
+{
+  struct frame *f = XFRAME (w->frame);
+  struct face *face;
+  Lisp_Object color, color_vector;
+  if (!NILP (Vface_remapping_alist)
+      && (face_id == DEFAULT_FACE_ID /* Qdefault */
+          || face_id == MODE_LINE_FACE_ID /* Qmode_line */
+          || face_id == MODE_LINE_INACTIVE_FACE_ID /* Qmode_line_inactive */
+          || face_id == HEADER_LINE_FACE_ID /* Qheader_line */
+          || face_id == TOOL_BAR_FACE_ID /* Qtool_bar */
+          || face_id == FRINGE_FACE_ID /* Qfringe */
+          || face_id == SCROLL_BAR_FACE_ID /* Qscroll_bar */
+          || face_id == BORDER_FACE_ID /* Qborder */
+          || face_id == CURSOR_FACE_ID /* Qcursor */
+          || face_id == MOUSE_FACE_ID /* Qmouse */
+          || face_id == MENU_FACE_ID /* Qmenu */
+          || face_id == WINDOW_DIVIDER_FACE_ID /* Qwindow_divider */
+          || face_id == WINDOW_DIVIDER_FIRST_PIXEL_FACE_ID /* Qwindow_divider_first_pixel */
+          || face_id == WINDOW_DIVIDER_LAST_PIXEL_FACE_ID /* Qwindow_divider_last_pixel */
+          || face_id == VERTICAL_BORDER_FACE_ID /* Qvertical_border */
+          || face_id == INTERNAL_BORDER_FACE_ID)) /* Qinternal_border */
+    face = FACE_FROM_ID (f, lookup_basic_face (w, f, face_id));
+    else
+      face = FACE_FROM_ID (f, face_id);
+  color = face->lface[LFACE_BACKGROUND_INDEX];
+  CHECK_STRING (color);
+  color_vector = mc_color_vector_calc (w, color);
+  return color_vector;
+}
+
+static Lisp_Object
+mc_fg_lsl (struct window *w, enum face_id face_id)
+{
+  struct frame *f = XFRAME (w->frame);
+  struct face *face;
+  Lisp_Object color, color_vector;
+  if (!NILP (Vface_remapping_alist)
+      && (face_id == DEFAULT_FACE_ID /* Qdefault */
+          || face_id == MODE_LINE_FACE_ID /* Qmode_line */
+          || face_id == MODE_LINE_INACTIVE_FACE_ID /* Qmode_line_inactive */
+          || face_id == HEADER_LINE_FACE_ID /* Qheader_line */
+          || face_id == TOOL_BAR_FACE_ID /* Qtool_bar */
+          || face_id == FRINGE_FACE_ID /* Qfringe */
+          || face_id == SCROLL_BAR_FACE_ID /* Qscroll_bar */
+          || face_id == BORDER_FACE_ID /* Qborder */
+          || face_id == CURSOR_FACE_ID /* Qcursor */
+          || face_id == MOUSE_FACE_ID /* Qmouse */
+          || face_id == MENU_FACE_ID /* Qmenu */
+          || face_id == WINDOW_DIVIDER_FACE_ID /* Qwindow_divider */
+          || face_id == WINDOW_DIVIDER_FIRST_PIXEL_FACE_ID /* Qwindow_divider_first_pixel */
+          || face_id == WINDOW_DIVIDER_LAST_PIXEL_FACE_ID /* Qwindow_divider_last_pixel */
+          || face_id == VERTICAL_BORDER_FACE_ID /* Qvertical_border */
+          || face_id == INTERNAL_BORDER_FACE_ID)) /* Qinternal_border */
+    face = FACE_FROM_ID (f, lookup_basic_face (w, f, face_id));
+    else
+      face = FACE_FROM_ID (f, face_id);
+  color = face->lface[LFACE_FOREGROUND_INDEX];
+  CHECK_STRING (color);
+  color_vector = mc_color_vector_calc (w, color);
+  return color_vector;
+}
+
+static Lisp_Object
+mc_fg_face (struct window *w, enum face_id face_id)
+{
+  struct frame *f = XFRAME (w->frame);
+  struct face *face;
+  if (!NILP (Vface_remapping_alist)
+      && (face_id == DEFAULT_FACE_ID /* Qdefault */
+          || face_id == MODE_LINE_FACE_ID /* Qmode_line */
+          || face_id == MODE_LINE_INACTIVE_FACE_ID /* Qmode_line_inactive */
+          || face_id == HEADER_LINE_FACE_ID /* Qheader_line */
+          || face_id == TOOL_BAR_FACE_ID /* Qtool_bar */
+          || face_id == FRINGE_FACE_ID /* Qfringe */
+          || face_id == SCROLL_BAR_FACE_ID /* Qscroll_bar */
+          || face_id == BORDER_FACE_ID /* Qborder */
+          || face_id == CURSOR_FACE_ID /* Qcursor */
+          || face_id == MOUSE_FACE_ID /* Qmouse */
+          || face_id == MENU_FACE_ID /* Qmenu */
+          || face_id == WINDOW_DIVIDER_FACE_ID /* Qwindow_divider */
+          || face_id == WINDOW_DIVIDER_FIRST_PIXEL_FACE_ID /* Qwindow_divider_first_pixel */
+          || face_id == WINDOW_DIVIDER_LAST_PIXEL_FACE_ID /* Qwindow_divider_last_pixel */
+          || face_id == VERTICAL_BORDER_FACE_ID /* Qvertical_border */
+          || face_id == INTERNAL_BORDER_FACE_ID)) /* Qinternal_border */
+    face = FACE_FROM_ID (f, lookup_basic_face (w, f, face_id));
+    else
+      face = FACE_FROM_ID (f, face_id);
+  return face->lface[LFACE_FOREGROUND_INDEX];
+}
+
+static Lisp_Object
+mc_bg_face (struct window *w, enum face_id face_id)
+{
+  struct frame *f = XFRAME (w->frame);
+  struct face *face;
+  if (!NILP (Vface_remapping_alist)
+      && (face_id == DEFAULT_FACE_ID /* Qdefault */
+          || face_id == MODE_LINE_FACE_ID /* Qmode_line */
+          || face_id == MODE_LINE_INACTIVE_FACE_ID /* Qmode_line_inactive */
+          || face_id == HEADER_LINE_FACE_ID /* Qheader_line */
+          || face_id == TOOL_BAR_FACE_ID /* Qtool_bar */
+          || face_id == FRINGE_FACE_ID /* Qfringe */
+          || face_id == SCROLL_BAR_FACE_ID /* Qscroll_bar */
+          || face_id == BORDER_FACE_ID /* Qborder */
+          || face_id == CURSOR_FACE_ID /* Qcursor */
+          || face_id == MOUSE_FACE_ID /* Qmouse */
+          || face_id == MENU_FACE_ID /* Qmenu */
+          || face_id == WINDOW_DIVIDER_FACE_ID /* Qwindow_divider */
+          || face_id == WINDOW_DIVIDER_FIRST_PIXEL_FACE_ID /* Qwindow_divider_first_pixel */
+          || face_id == WINDOW_DIVIDER_LAST_PIXEL_FACE_ID /* Qwindow_divider_last_pixel */
+          || face_id == VERTICAL_BORDER_FACE_ID /* Qvertical_border */
+          || face_id == INTERNAL_BORDER_FACE_ID)) /* Qinternal_border */
+    face = FACE_FROM_ID (f, lookup_basic_face (w, f, face_id));
+    else
+      face = FACE_FROM_ID (f, face_id);
+  return face->lface[LFACE_BACKGROUND_INDEX];
+}
+
+struct face *
+mc_lookup_face (struct it *it)
+{
+  if (!NILP (Vface_remapping_alist)
+      && (it->face_id == DEFAULT_FACE_ID /* Qdefault */
+          || it->face_id == MODE_LINE_FACE_ID /* Qmode_line */
+          || it->face_id == MODE_LINE_INACTIVE_FACE_ID /* Qmode_line_inactive */
+          || it->face_id == HEADER_LINE_FACE_ID /* Qheader_line */
+          || it->face_id == TOOL_BAR_FACE_ID /* Qtool_bar */
+          || it->face_id == FRINGE_FACE_ID /* Qfringe */
+          || it->face_id == SCROLL_BAR_FACE_ID /* Qscroll_bar */
+          || it->face_id == BORDER_FACE_ID /* Qborder */
+          || it->face_id == CURSOR_FACE_ID /* Qcursor */
+          || it->face_id == MOUSE_FACE_ID /* Qmouse */
+          || it->face_id == MENU_FACE_ID /* Qmenu */
+          || it->face_id == WINDOW_DIVIDER_FACE_ID /* Qwindow_divider */
+          || it->face_id == WINDOW_DIVIDER_FIRST_PIXEL_FACE_ID /* Qwindow_divider_first_pixel */
+          || it->face_id == WINDOW_DIVIDER_LAST_PIXEL_FACE_ID /* Qwindow_divider_last_pixel */
+          || it->face_id == VERTICAL_BORDER_FACE_ID /* Qvertical_border */
+          || it->face_id == INTERNAL_BORDER_FACE_ID)) /* Qinternal_border */
+    return FACE_FROM_ID (it->f, lookup_basic_face (it->w, it->f, it->face_id));
+      else
+        return FACE_FROM_ID (it->f, it->face_id);
+}
+
+static int
+mc_get_logical_fringe_bitmap (struct window *w, Lisp_Object bitmap, int right_p, int partial_p)
+{
+  Lisp_Object cmap, bm1 = Qnil, bm2 = Qnil, bm;
+  EMACS_INT ln1 = 0, ln2 = 0;
+  int ix1 = right_p;
+  int ix2 = ix1 + (partial_p ? 2 : 0);
+  /* Lookup in buffer-local fringe-indicator-alist before global alist.
+     Elements are:
+  BITMAP    -- use for all
+  (L R)    -- use for left right (whether partial or not)
+  (L R PL PR)  -- use for left right partial-left partial-right
+  If any value in local binding is not present or t, use global value.
+     If partial, lookup partial bitmap in default value if not found here.
+     If not partial, or no partial spec is present, use non-partial bitmap.  */
+  if ((cmap = BVAR (XBUFFER (w->contents), fringe_indicator_alist)), !NILP (cmap))
+    {
+      bm1 = Fassq (bitmap, cmap);
+      if (CONSP (bm1))
+  {
+    if ((bm1 = XCDR (bm1)), NILP (bm1))
+      return NO_FRINGE_BITMAP;
+    if (CONSP (bm1))
+      {
+        ln1 = XFIXNUM (Flength (bm1));
+        if (partial_p)
+    {
+      if (ln1 > ix2)
+        {
+          bm = Fnth (make_fixnum (ix2), bm1);
+          if (!EQ (bm, Qt))
+      goto found;
+        }
+    }
+        else
+    {
+      if (ln1 > ix1)
+        {
+          bm = Fnth (make_fixnum (ix1), bm1);
+          if (!EQ (bm, Qt))
+      goto found;
+        }
+    }
+      }
+    else if ((bm = bm1, !EQ (bm, Qt)))
+      goto found;
+  }
+    }
+  if (!EQ (cmap, BVAR (&buffer_defaults, fringe_indicator_alist))
+      && !NILP (BVAR (&buffer_defaults, fringe_indicator_alist)))
+    {
+      bm2 = Fassq (bitmap, BVAR (&buffer_defaults, fringe_indicator_alist));
+      if (CONSP (bm2))
+  {
+    if ((bm2 = XCDR (bm2)), !NILP (bm2))
+      {
+        if (CONSP (bm2))
+    {
+      ln2 = XFIXNUM (Flength (bm2));
+      if (partial_p)
+        {
+          if (ln2 > ix2)
+      {
+        bm = Fnth (make_fixnum (ix2), bm2);
+        if (!EQ (bm, Qt))
+          goto found;
+      }
+        }
+    }
+      }
+  }
+    }
+  if (ln1 > ix1)
+    {
+      bm = Fnth (make_fixnum (ix1), bm1);
+      if (!EQ (bm, Qt))
+  goto found;
+    }
+  if (ln2 > ix1)
+    {
+      bm = Fnth (make_fixnum (ix1), bm2);
+      if (!EQ (bm, Qt))
+  goto found;
+      return NO_FRINGE_BITMAP;
+    }
+  else if ((bm = bm2, NILP (bm)))
+    return NO_FRINGE_BITMAP;
+ found:
+  return lookup_fringe_bitmap (bm);
+}
+
+/* This is meant to be used when target is visible and when code is sandwiched:
+     update_begin (f);
+     block_input ();
+     mc_erase_glyph_cursors (w, x, y, hpos, vpos, cursor_type, cursor_width);
+     unblock_input ();
+     update_end (f); */
+
+static void
+mc_erase_glyph_cursors (struct window *w, int x, int y, int hpos, int vpos,
+                        enum text_cursor_kinds cursor_type, int cursor_width)
+{
+  /* `matrix_row' in `dispnew.c` contains the following tests,
+  eassert (matrix && matrix->rows);
+  eassert (row >= 0 && row < matrix->nrows); */
+  bool barf_crash_one = (w->current_matrix && w->current_matrix->rows) ? false : true;
+  if (barf_crash_one)
+    return;
+  bool barf_crash_two = (vpos >= 0 && vpos < w->current_matrix->nrows) ? false : true;
+  if (barf_crash_two)
+    return;
+  if (x < 0
+      || y < 0
+      || hpos < 0
+      || vpos < 0)
+    return;
+  /* Record some of the current values for the cursor and glyph_row. */
+  bool phys_cursor_on_p = w->phys_cursor_on_p;
+  struct glyph_row *glyph_row = MATRIX_ROW (w->current_matrix, vpos);
+  bool cursor_in_fringe_p = glyph_row->cursor_in_fringe_p;
+  bool reversed_p = glyph_row->reversed_p;
+  ptrdiff_t phys_cursor_x = w->phys_cursor.x;
+  ptrdiff_t phys_cursor_y = w->phys_cursor.y;
+  ptrdiff_t phys_cursor_hpos = w->phys_cursor.hpos;
+  ptrdiff_t phys_cursor_vpos = w->phys_cursor.vpos;
+  ptrdiff_t phys_cursor_ascent = w->phys_cursor_ascent;
+  ptrdiff_t phys_cursor_height = w->phys_cursor_height;
+  ptrdiff_t phys_cursor_width = w->phys_cursor_width;
+  enum text_cursor_kinds phys_cursor_type = w->phys_cursor_type;
+  /* Hijack w->phys_cursor. */
+  w->phys_cursor.x = x;
+  w->phys_cursor.y = y;
+  w->phys_cursor.hpos = hpos;
+  w->phys_cursor.vpos = vpos;
+  w->phys_cursor_type = cursor_type;
+  w->phys_cursor_ascent = glyph_row->ascent;
+  w->phys_cursor_height = glyph_row->height;
+  w->phys_cursor_width = cursor_width;
+  erase_phys_cursor (w);
+  /* Restore the previous values for w->phys_cursor and glyph_row. */
+  w->phys_cursor_on_p = phys_cursor_on_p;
+  w->phys_cursor.x = phys_cursor_x;
+  w->phys_cursor.y = phys_cursor_y;
+  w->phys_cursor.hpos = phys_cursor_hpos;
+  w->phys_cursor.vpos = phys_cursor_vpos;
+  w->phys_cursor_type = phys_cursor_type;
+  glyph_row->cursor_in_fringe_p = cursor_in_fringe_p;
+  glyph_row->reversed_p = reversed_p;
+  w->phys_cursor_ascent = phys_cursor_ascent;
+  w->phys_cursor_height = phys_cursor_height;
+  w->phys_cursor_width = phys_cursor_width;
+}
+
+/* This is meant to be used when target is visible and when code is sandwiched:
+     update_begin (f);
+     block_input ();
+     mc_draw_erase_hybrid (...);
+     unblock_input ();
+     update_end (f);
+We call this a draw/erase hybrid because it does all of the following:
+-  Draw all glyph cursors, but erase with `mc_erase_glyph_cursors'.
+-  Draw/erase all fringe bitmaps relating to crosshairs.
+-  Draw/erase all glyphless cursors. */
+
+static void
+mc_draw_erase_hybrid (struct window *w, int x, int fx, int y, int fy, int hpos, int vpos,
+                      int h, enum text_cursor_kinds cursor_type, int cursor_width,
+                      Lisp_Object color_vector, bool active_cursor_p, int flavor, int posint)
+{
+  /* `matrix_row' in `dispnew.c` contains the following tests,
+  eassert (matrix && matrix->rows);
+  eassert (row >= 0 && row < matrix->nrows); */
+  bool barf_crash_one = (w->current_matrix && w->current_matrix->rows) ? false : true;
+  if (barf_crash_one)
+    return;
+  bool barf_crash_two = (vpos >= 0 && vpos < w->current_matrix->nrows) ? false : true;
+  if (barf_crash_two)
+    return;
+  if (x < 0
+      || y < 0
+      || hpos < 0
+      || vpos < 0)
+    return;
+  struct frame *f = XFRAME (w->frame);
+  /* Record some of the current values for the cursor and glyph_row. */
+  bool phys_cursor_on_p = w->phys_cursor_on_p;
+  struct glyph_row *glyph_row = MATRIX_ROW (w->current_matrix, vpos);
+  bool cursor_in_fringe_p = glyph_row->cursor_in_fringe_p;
+  bool reversed_p = glyph_row->reversed_p;
+  ptrdiff_t phys_cursor_x = w->phys_cursor.x;
+  ptrdiff_t phys_cursor_y = w->phys_cursor.y;
+  ptrdiff_t phys_cursor_hpos = w->phys_cursor.hpos;
+  ptrdiff_t phys_cursor_vpos = w->phys_cursor.vpos;
+  ptrdiff_t phys_cursor_ascent = w->phys_cursor_ascent;
+  ptrdiff_t phys_cursor_height = w->phys_cursor_height;
+  ptrdiff_t phys_cursor_width = w->phys_cursor_width;
+  enum text_cursor_kinds phys_cursor_type = w->phys_cursor_type;
+  /* Hijack w->phys_cursor. */
+  w->phys_cursor.x = x;
+  w->phys_cursor.y = glyph_row->y;
+  w->phys_cursor.hpos = hpos;
+  w->phys_cursor.vpos = vpos;
+  w->phys_cursor_type = cursor_type;
+  w->phys_cursor_ascent = glyph_row->ascent;
+  w->phys_cursor_height = glyph_row->height;
+  w->phys_cursor_width = cursor_width;
+  int fringe_bitmap = NO_FRINGE_BITMAP;
+  int face_id = DEFAULT_FACE_ID;
+  if (flavor == MC_OVERLAY_ARROW_BITMAP)
+    {
+      int mc_overlay_arrow_bitmap = XFIXNUM (AREF (color_vector, 0));
+      bool fringe_active_bitmap_p = XFIXNUM (AREF (color_vector, 1));
+      bool minimal_p = XFIXNUM (AREF (color_vector, 2));
+      enum face_id overlay_arrow_face_id =
+        (!fringe_active_bitmap_p
+         && !NILP (BVAR (XBUFFER (w->contents), crosshairs_inactive_windows)))
+        ? lookup_named_face (w, f, intern ("+-overlay-arrow-inactive-face"), true)
+        : (fringe_active_bitmap_p
+           && minimal_p)
+          ? lookup_named_face (w, f, intern ("+-overlay-arrow-minimal-face"), true)
+        : (fringe_active_bitmap_p
+           && !minimal_p)
+          ? lookup_named_face (w, f, intern ("+-overlay-arrow-face"), true)
+        : DEFAULT_FACE_ID;
+      face_id = (cursor_type == LEFT_FRINGE_BITMAP)
+                ? overlay_arrow_face_id
+                : DEFAULT_FACE_ID;
+      glyph_row->left_fringe_face_id = face_id;
+      fringe_bitmap = mc_get_logical_fringe_bitmap (w, Qoverlay_arrow, false, false);
+      /* As to `glyph_row->overlay_arrow_bitmap`, the face may be changed using
+      the `face-remapping-alist' so long as we have a Lisp setting of:
+        (set-fringe-bitmap-face '+-fringe-right-arrow '+-overlay-arrow-face)
+      If we use `glyph_row->left_fringe_bitmap`, then the face may be set using
+      BOTH the `face-remapping-alist' and `glyph_row->left_fringe_face_id`.  In
+      that situation, a Lisp setting of `set-fringe-bitmap-face' is not needed.
+      `draw_fringe_bitmap_1' is somewhat confusing and required stderr messages
+      to see that `glyph_row->overlay_arrow_bitmap` satisfies the first condition
+      of (which != NO_FRINGE_BITMAP).  At this time, @lawlist prefers not to
+      rely upon a Lisp setting using `set-fringe-bitmap-face'. */
+      glyph_row->left_fringe_bitmap = (cursor_type == LEFT_FRINGE_BITMAP)
+                                        ? fringe_bitmap
+                                        : NO_FRINGE_BITMAP;
+      glyph_row->left_fringe_offset = 0;
+      draw_fringe_bitmap (w, glyph_row, true);
+    }
+    else if (flavor == MC_OVERLAY_ARROW_BITMAP_HSCL_TEMPORARY)
+      {
+        int mc_overlay_arrow_bitmap = XFIXNUM (AREF (color_vector, 0));
+        bool fringe_active_bitmap_p = XFIXNUM (AREF (color_vector, 1));
+        bool minimal_p = XFIXNUM (AREF (color_vector, 2));
+        enum face_id overlay_arrow_face_id =
+          (!fringe_active_bitmap_p
+           && !NILP (BVAR (XBUFFER (w->contents), crosshairs_inactive_windows)))
+          ? lookup_named_face (w, f, intern ("+-overlay-arrow-hscl-inactive-face"), true)
+          : (fringe_active_bitmap_p
+             && minimal_p)
+            ? lookup_named_face (w, f, intern ("+-overlay-arrow-hscl-minimal-face"), true)
+          : (fringe_active_bitmap_p
+             && !minimal_p)
+            ? lookup_named_face (w, f, intern ("+-overlay-arrow-hscl-face"), true)
+          : DEFAULT_FACE_ID;
+        face_id = (cursor_type == LEFT_FRINGE_BITMAP)
+                  ? overlay_arrow_face_id
+                  : DEFAULT_FACE_ID;
+        glyph_row->left_fringe_face_id = face_id;
+        fringe_bitmap = mc_get_logical_fringe_bitmap (w, intern ("hscl_temporary"), false, false);
+        /* As to `glyph_row->overlay_arrow_bitmap`, the face may be changed using
+        the `face-remapping-alist' so long as we have a Lisp setting of:
+          (set-fringe-bitmap-face '+-fringe-right-arrow '+-overlay-arrow-face)
+        If we use `glyph_row->left_fringe_bitmap`, then the face may be set using
+        BOTH the `face-remapping-alist' and `glyph_row->left_fringe_face_id`.  In
+        that situation, a Lisp setting of `set-fringe-bitmap-face' is not needed.
+        `draw_fringe_bitmap_1' is somewhat confusing and required stderr messages
+        to see that `glyph_row->overlay_arrow_bitmap` satisfies the first condition
+        of (which != NO_FRINGE_BITMAP).  At this time, @lawlist prefers not to
+        rely upon a Lisp setting using `set-fringe-bitmap-face'. */
+        glyph_row->left_fringe_bitmap = (cursor_type == LEFT_FRINGE_BITMAP)
+                                          ? fringe_bitmap
+                                          : NO_FRINGE_BITMAP;
+        glyph_row->left_fringe_offset = 0;
+        draw_fringe_bitmap (w, glyph_row, true);
+      }
+      else if (flavor == MC_HOLLOW_RECTANGLE_RIGHT_ANGLE
+               || flavor == MC_HOLLOW_RECTANGLE
+               || flavor == MC_VERTICAL_BAR_RIGHT_ANGLE
+               || flavor == MC_VERTICAL_BAR
+               || flavor == MC_VERTICAL_BAR_BACKSLASH)
+        {
+          Lisp_Object bitmap_flavor = (flavor == MC_HOLLOW_RECTANGLE_RIGHT_ANGLE)
+                                      ? Qmc_hollow_rectangle_right_angle
+                                      : (flavor == MC_HOLLOW_RECTANGLE)
+                                        ? Qmc_hollow_rectangle
+                                      : (flavor == MC_VERTICAL_BAR_RIGHT_ANGLE)
+                                        ? Qmc_vertical_bar_right_angle
+                                      : (flavor == MC_VERTICAL_BAR)
+                                        ? Qmc_vertical_bar
+                                      : (flavor == MC_VERTICAL_BAR_BACKSLASH)
+                                        ? Qmc_vertical_bar_backslash
+                                      : Qnil;
+          fringe_bitmap = (cursor_type == RIGHT_FRINGE_BITMAP)
+                          ? lookup_fringe_bitmap (bitmap_flavor)
+                          : NO_FRINGE_BITMAP;
+          face_id = (cursor_type == RIGHT_FRINGE_BITMAP)
+                    ? lookup_named_face (w, f, intern ("+-vertical-bar-face"), true)
+                    : DEFAULT_FACE_ID;
+          glyph_row->cursor_in_fringe_p = false;
+          glyph_row->fringe_bitmap_periodic_p = 0;
+          glyph_row->right_fringe_bitmap = fringe_bitmap;
+          glyph_row->right_fringe_face_id = face_id;
+          glyph_row->right_fringe_offset = 0;
+          draw_fringe_bitmap (w, glyph_row, false);
+        }
+        else if (flavor == MC_GLYPH
+                 || flavor == MC_GLYPHLESS
+                 || flavor == MC_GLYPH_TAB)
+          {
+            w->mc.h = h;
+            w->mc.fx = fx;
+            w->mc.fy = fy;
+            w->mc.glyph_flavor = flavor;
+            w->mc.red = XFLOAT_DATA (AREF (color_vector, 0));
+            w->mc.green = XFLOAT_DATA (AREF (color_vector, 1));
+            w->mc.blue = XFLOAT_DATA (AREF (color_vector, 2));
+            w->mc.posint = posint;
+            /* Some of these values come through as 1.003906, which causes a breakage
+            of the colors in that multiplication by the base will exceed the base. */
+            if (w->mc.red > 1.0)
+              w->mc.red = 1.0;
+            if (w->mc.green > 1.0)
+              w->mc.green = 1.0;
+            if (w->mc.blue > 1.0)
+              w->mc.blue = 1.0;
+            FRAME_RIF (f)->draw_window_cursor (w, glyph_row, x, y, cursor_type,
+                                               cursor_width, true, active_cursor_p);
+          }
+  /* Restore the previous values for w->phys_cursor and glyph_row. */
+  w->phys_cursor_on_p = phys_cursor_on_p;
+  w->phys_cursor.x = phys_cursor_x;
+  w->phys_cursor.y = phys_cursor_y;
+  w->phys_cursor.hpos = phys_cursor_hpos;
+  w->phys_cursor.vpos = phys_cursor_vpos;
+  w->phys_cursor_type = phys_cursor_type;
+  glyph_row->cursor_in_fringe_p = cursor_in_fringe_p;
+  glyph_row->reversed_p = reversed_p;
+  w->phys_cursor_ascent = phys_cursor_ascent;
+  w->phys_cursor_height = phys_cursor_height;
+  w->phys_cursor_width = phys_cursor_width;
+}
+
+static void
+mc_stderr_1 (struct it *it, int count, int posint, int new_x,
+             int opoint_x, int opoint_y, int opoint_hpos, int opoint_vpos,
+             int ante_prior_previous_it_current_x, int prior_previous_it_current_x, int previous_it_current_x,
+             int ante_prior_previous_it_hpos, int prior_previous_it_hpos, int previous_it_hpos,
+             int ante_prior_previous_relative_x, int prior_previous_relative_x, int previous_relative_x, int relative_x,
+             int ante_prior_previous_fetch_byte, int prior_previous_fetch_byte, int previous_fetch_byte,
+             int ante_prior_previous_character, int prior_previous_character, int previous_character,
+             int ante_prior_previous_face_id, int prior_previous_face_id, int previous_face_id,
+             int ante_prior_previous_hpos, int prior_previous_hpos, int previous_hpos,
+             bool final_loop_p, bool issue_31716_p, bool lpw_reached_p, bool green_light_p,
+             bool real_fake_cursor_p, bool tab_invisible_p,
+             bool hscl_temporary_p, bool hscl_permanent_p, int rc, int action_type)
+{
+  int w_hscroll = it->w->hscroll;
+  int w_min_hscroll = it->w->min_hscroll;
+  int it_charpos = IT_CHARPOS (*it);
+  fprintf (stderr, "\n%d.  %s%s -- (%s)\n\
+    IT_CHARPOS (%d)\n\
+    posint (%d)\n\
+    it->c (%d)\n\
+    it->what (%s)\n\
+    it->cmp_it.nchars (%d)\n\
+    new_x (%d)\n\
+    opoint_x (%d)\n\
+    opoint_y (%d)\n\
+    opoint_hpos (%d)\n\
+    opoint_vpos (%d)\n\
+    it->current_y (%d)\n\
+    it->vpos (%d)\n\
+    ante_prior_previous_it_current_x (%d)\n\
+    prior_previous_it_current_x (%d)\n\
+    previous_it_current_x (%d)\n\
+    it->current_x (%d)\n\
+    ante_prior_previous_it_hpos (%d)\n\
+    prior_previous_it_hpos (%d)\n\
+    previous_it_hpos (%d)\n\
+    it->hpos (%d)\n\
+    ante_prior_previous_fetch_byte (%d)\n\
+    prior_previous_fetch_byte (%d)\n\
+    previous_fetch_byte (%d)\n\
+    fetch_byte (%d)\n\
+    ante_prior_previous_character (%s)\n\
+    prior_previous_character (%s)\n\
+    previous_character (%s)\n\
+    character (%s)\n\
+    ante_prior_previous_relative_x (%d)\n\
+    prior_previous_relative_x (%d)\n\
+    previous_relative_x (%d)\n\
+    relative_x (%d)\n\
+    ante_prior_previous_hpos (%d)\n\
+    prior_previous_hpos (%d)\n\
+    previous_hpos (%d)\n\
+    ante_prior_previous_face_id (%d) | fg (%s) | bg (%s)\n\
+    prior_previous_face_id (%d) | fg (%s) | bg (%s)\n\
+    previous_face_id (%d) | fg (%s) | bg (%s)\n\
+    it->face_id (%d) | fg (%s) | bg (%s)\n\
+    w->hscroll (%d)\n\
+    w->min_hscroll (%d)\n\
+    hscl_temporary_p (%s)\n\
+    hscl_permanent_p (%s)\n\
+    it->lnum_pixel_width (%d)\n\
+    it->lnum_width (%d)\n\
+    it->pixel_width (%d)\n\
+    it->first_visible_x (%d)\n\
+    it->last_visible_x (%d)\n\
+    final_loop_p (%s)\n\
+    issue_31716_p (%s)\n\
+    lpw_reached_p (%s)\n\
+    green_light_p (%s)\n\
+    real_fake_cursor_p (%s)\n\
+    tab_invisible_p (%s)\n\
+    rc (%s)\n",
+      count,
+      (it->c == 0
+        ? "NOTHING"
+        : it->c == 187
+          ? "TAB CHARACTER"
+        : it->c == '\t'
+          ? "TAB STRETCH"
+        : "TEXT"),
+      (relative_x == it->lnum_pixel_width
+        ? " -- THE FUN STARTS HERE"
+        : ""),
+      (action_type == MULTIPLE_CURSORS
+       ? "MULTIPLE_CURSORS"
+       : action_type == HORIZONTAL_RULER
+         ? "HORIZONTAL_RULER"
+       : action_type == VERTICAL_RULER
+         ? "VERTICAL_RULER"
+       : "OOPS"),
+      it_charpos,
+      posint,
+      it->c,
+      (it->what == 0
+       ? "IT_CHARACTER"
+       : it->what == 1
+         ? "IT_COMPOSITION"
+       : it->what == 2
+         ? "IT_IMAGE"
+       : it->what == 3
+         ? "IT_STRETCH"
+       : it->what == 4
+         ? "IT_EOB"
+       : it->what == 5
+         ? "IT_TRUNCATION"
+       : it->what == 6
+         ? "IT_CONTINUATION"
+       : "OOPS"),
+      (it->what == IT_COMPOSITION ? it->cmp_it.nchars : 1),
+      new_x,
+      opoint_x,
+      opoint_y,
+      opoint_hpos,
+      opoint_vpos,
+      it->current_y,
+      it->vpos,
+      ante_prior_previous_it_current_x,
+      prior_previous_it_current_x,
+      previous_it_current_x,
+      it->current_x,
+      ante_prior_previous_it_hpos,
+      prior_previous_it_hpos,
+      previous_it_hpos,
+      it->hpos,
+      ante_prior_previous_fetch_byte,
+      prior_previous_fetch_byte,
+      previous_fetch_byte,
+      FETCH_BYTE (IT_BYTEPOS (*it)),
+      (!NILP (Fchar_to_string (make_fixnum (ante_prior_previous_character)))
+        ? SSDATA (Fchar_to_string (make_fixnum (ante_prior_previous_character)))
+        : "NILP -- ante_prior_previous_character as a string"),
+      (!NILP (Fchar_to_string (make_fixnum (prior_previous_character)))
+        ? SSDATA (Fchar_to_string (make_fixnum (prior_previous_character)))
+        : "NILP -- prior_previous_character as a string"),
+      (!NILP (Fchar_to_string (make_fixnum (previous_character)))
+        ? SSDATA (Fchar_to_string (make_fixnum (previous_character)))
+        : "NILP -- previous_character as a string"),
+      (!NILP (Fchar_to_string (make_fixnum (it->c)))
+        ? SSDATA (Fchar_to_string (make_fixnum (it->c)))
+        : "NILP -- it->c as a string"),
+      ante_prior_previous_relative_x,
+      prior_previous_relative_x,
+      previous_relative_x,
+      relative_x,
+      ante_prior_previous_hpos,
+      prior_previous_hpos,
+      previous_hpos,
+      ante_prior_previous_face_id,
+        SSDATA (mc_fg_face (it->w, ante_prior_previous_face_id)),
+        SSDATA (mc_bg_face (it->w, ante_prior_previous_face_id)),
+      prior_previous_face_id,
+        SSDATA (mc_fg_face (it->w, prior_previous_face_id)),
+        SSDATA (mc_bg_face (it->w, prior_previous_face_id)),
+      previous_face_id,
+        SSDATA (mc_fg_face (it->w, previous_face_id)),
+        SSDATA (mc_bg_face (it->w, previous_face_id)),
+      it->face_id,
+        SSDATA (mc_fg_face (it->w, it->face_id)),
+        SSDATA (mc_bg_face (it->w, it->face_id)),
+      /* When `it->w->hscroll` is set to an `int`, gdb reports the value
+      as being:  <variable optimized away by compiler> */
+      w_hscroll,
+      w_min_hscroll,
+      (hscl_temporary_p ? "true" : "false"),
+      (hscl_permanent_p ? "true" : "false"),
+      it->lnum_pixel_width,
+      it->lnum_width,
+      it->pixel_width,
+      it->first_visible_x,
+      it->last_visible_x,
+      (final_loop_p ? "true" : "false"),
+      (issue_31716_p ? "true" : "false"),
+      (lpw_reached_p ? "true" : "false"),
+      (green_light_p ? "true" : "false"),
+      (real_fake_cursor_p ? "true" : "false"),
+      (tab_invisible_p ? "true" : "false"),
+      (rc == MOVE_UNDEFINED
+        ? "MOVE_UNDEFINED"
+        : rc == MOVE_POS_MATCH_OR_ZV
+          ? "MOVE_POS_MATCH_OR_ZV"
+        : rc == MOVE_X_REACHED
+          ? "MOVE_X_REACHED"
+        : rc == MOVE_LINE_CONTINUED
+          ? "MOVE_LINE_CONTINUED"
+        : rc == MOVE_LINE_TRUNCATED
+          ? "MOVE_LINE_TRUNCATED"
+        : rc == MOVE_NEWLINE_OR_CR
+          ? "MOVE_NEWLINE_OR_CR"
+        : "OOPS"));
+}
+
+static void
+mc_stderr_2 (struct it *it, int count, int action_type, int relative_x,
+             int temp_x, int temp_hpos, int temp_vpos, Lisp_Object foreground,
+             int temp_bg_face_id, int cursor_type, int flavor)
+{
+  struct face *face = mc_lookup_face (it);
+  struct font *font = face->font;
+  Lisp_Object foreground_face = face->lface[LFACE_FOREGROUND_INDEX];
+  Lisp_Object background_face = face->lface[LFACE_BACKGROUND_INDEX];
+  double red = XFLOAT_DATA (AREF (foreground, 0));
+  double green = XFLOAT_DATA (AREF (foreground, 1));
+  double blue = XFLOAT_DATA (AREF (foreground, 2));
+  /* Some of these values come through as 1.003906, which causes a breakage
+  of the colors in that multiplication by the base will exceed the base. */
+  if (red > 1.0)
+    red = 1.0;
+  if (green > 1.0)
+    green = 1.0;
+  if (blue > 1.0)
+    blue = 1.0;
+  fprintf (stderr, "\n%d.  %s%s -- (%s) SPECS\n\
+    temp_x (%d)\n\
+    y (%d)\n\
+    temp_hpos (%d)\n\
+    temp_vpos (%d)\n\
+    foreground:  R (%f) | G (%f) | B (%f)\n\
+    background (%s)\n\
+    cursor_type (%s)\n\
+    flavor (%s)\n",
+      count,
+      (it->c == 0
+        ? "NOTHING"
+        : it->c == 187
+          ? "TAB CHARACTER"
+        : it->c == '\t'
+          ? "TAB STRETCH"
+        : "TEXT"),
+      (relative_x == it->lnum_pixel_width
+        ? " -- THE FUN STARTS HERE"
+        : ""),
+      (action_type == MULTIPLE_CURSORS
+       ? "MULTIPLE_CURSORS"
+       : action_type == HORIZONTAL_RULER
+         ? "HORIZONTAL_RULER"
+       : action_type == VERTICAL_RULER
+         ? "VERTICAL_RULER"
+       : "OOPS"),
+    temp_x,
+    it->current_y,
+    temp_hpos,
+    temp_vpos,
+    red, green, blue,
+    SSDATA (mc_bg_face (it->w, temp_bg_face_id)),
+    SSDATA (Fprin1_to_string (mc_cursor_type_to_lisp (cursor_type), Qnil)),
+    (flavor == MC_GLYPH
+      ? "MC_GLYPH"
+      : flavor == MC_GLYPH_TAB
+        ? "MC_GLYPH_TAB"
+      : flavor == MC_GLYPHLESS
+        ? "MC_GLYPHLESS"
+      : flavor == MC_VERTICAL_BAR_RIGHT_ANGLE
+        ? "MC_VERTICAL_BAR_RIGHT_ANGLE"
+      : flavor == MC_VERTICAL_BAR_BACKSLASH
+        ? "MC_VERTICAL_BAR_BACKSLASH"
+      : flavor == MC_VERTICAL_BAR
+        ? "MC_VERTICAL_BAR"
+      : "OOPS"));
+}
+
+static void
+mc_helper (struct window *w, int x, int fx, int y, int fy, int hpos,
+           int vpos, int h, enum text_cursor_kinds cursor_type, int cursor_width,
+           Lisp_Object foreground, Lisp_Object background, bool active_cursor_p,
+           int flavor, ptrdiff_t posint, Lisp_Object *result)
+{
+  mc_draw_erase_hybrid (w, x, fx, y, fy, hpos, vpos, h, cursor_type,
+                        cursor_width, foreground, active_cursor_p, flavor, posint);
+  Lisp_Object fourteen_elements = listn (CONSTYPE_HEAP, 14,
+                                         make_fixnum (x),
+                                         make_fixnum (fx),
+                                         make_fixnum (y),
+                                         make_fixnum (fy),
+                                         make_fixnum (hpos),
+                                         make_fixnum (vpos),
+                                         make_fixnum (h),
+                                         mc_cursor_type_to_lisp (cursor_type),
+                                         make_fixnum (cursor_width),
+                                         foreground,
+                                         background,
+                                         make_fixnum (active_cursor_p),
+                                         make_fixnum (flavor),
+                                         make_fixnum (posint));
+  *result = Fcons (fourteen_elements, *result);
+}
+
+static void
+mc_get_phys_cursor_geometry (struct window *w, struct glyph_row *glyph_row,
+                             int x, int *fx, int y, int *fy, int hpos,
+                             int vpos, int *h, enum text_cursor_kinds cursor_type,
+                             int cursor_width)
+{
+  int cursor_height;
+  /* Record some of the current values for the cursor and glyph_row. */
+  bool phys_cursor_on_p = w->phys_cursor_on_p;
+  bool cursor_in_fringe_p = glyph_row->cursor_in_fringe_p;
+  bool reversed_p = glyph_row->reversed_p;
+  ptrdiff_t phys_cursor_x = w->phys_cursor.x;
+  ptrdiff_t phys_cursor_y = w->phys_cursor.y;
+  ptrdiff_t phys_cursor_hpos = w->phys_cursor.hpos;
+  ptrdiff_t phys_cursor_vpos = w->phys_cursor.vpos;
+  ptrdiff_t phys_cursor_ascent = w->phys_cursor_ascent;
+  ptrdiff_t phys_cursor_height = w->phys_cursor_height;
+  ptrdiff_t phys_cursor_width = w->phys_cursor_width;
+  enum text_cursor_kinds phys_cursor_type = w->phys_cursor_type;
+  /* Hijack w->phys_cursor. */
+  w->phys_cursor.x = x;
+  w->phys_cursor.y = y;
+  w->phys_cursor.hpos = hpos;
+  w->phys_cursor.vpos = vpos;
+  w->phys_cursor_type = cursor_type;
+  w->phys_cursor_ascent = glyph_row->ascent;
+  w->phys_cursor_height = glyph_row->height;
+  w->phys_cursor_width = cursor_width;
+  struct glyph *fake_phys_cursor_glyph = get_phys_cursor_glyph (w);
+  if (fake_phys_cursor_glyph != NULL)
+    {
+      get_phys_cursor_geometry (w, glyph_row, scratch_glyphs, fx, fy, h);
+      if (cursor_type == HBAR_CURSOR)
+        {
+          cursor_height = (cursor_width < 1) ? lrint (0.25 * *h) : cursor_width;
+          if (cursor_height > glyph_row->height)
+            cursor_height = glyph_row->height;
+          if (*h > cursor_height)
+            *fy += *h - cursor_height;
+          *h = cursor_height;
+        }
+    }
+  /* Restore the previous values for w->phys_cursor and glyph_row. */
+  w->phys_cursor_on_p = phys_cursor_on_p;
+  w->phys_cursor.x = phys_cursor_x;
+  w->phys_cursor.y = phys_cursor_y;
+  w->phys_cursor.hpos = phys_cursor_hpos;
+  w->phys_cursor.vpos = phys_cursor_vpos;
+  w->phys_cursor_type = phys_cursor_type;
+  glyph_row->cursor_in_fringe_p = cursor_in_fringe_p;
+  glyph_row->reversed_p = reversed_p;
+  w->phys_cursor_ascent = phys_cursor_ascent;
+  w->phys_cursor_height = phys_cursor_height;
+  w->phys_cursor_width = phys_cursor_width;
+}
+
+/* Return the start or end position of the region.
+   BEGINNINGP means return the start.
+   If there is no region active, signal an error.
+   EXAMPLE (region-beginning):  region_limit (1)
+   EXAMPLE (region-end):  region_limit (0) */
+
+static Lisp_Object
+mc_region_limit (bool beginningp)
+{
+  Lisp_Object m;
+  if (!NILP (Vtransient_mark_mode)
+      && NILP (Vmark_even_if_inactive)
+      && NILP (BVAR (current_buffer, mark_active)))
+    return Qnil;
+  m = Fmarker_position (BVAR (current_buffer, mark));
+  if (NILP (m))
+    return Qnil;
+  /* See `region-active-p' and `redisplay--update-region-highlight'. */
+  if (!NILP (Vtransient_mark_mode)
+      && !NILP (BVAR (current_buffer, mark_active))
+      && !NILP (m))
+    return make_fixnum ((PT < XFIXNAT (m)) == beginningp
+                        ? PT
+                        : clip_to_bounds (BEGV, XFIXNAT (m), ZV));
+      else
+        return Qnil;
+}
+
+static void
+mc_move_it (struct it *it, ptrdiff_t posint, enum text_cursor_kinds cursor_type,
+            int cursor_width, Lisp_Object foreground, bool active_cursor_p,
+            enum type_of_action action_type, Lisp_Object *result)
+{
+  int opoint_x = it->w->output_cursor.x;
+  int opoint_y = it->w->output_cursor.y;
+  int opoint_hpos = it->w->output_cursor.hpos;
+  int opoint_vpos = it->w->output_cursor.vpos;
+  enum move_it_result rc = MOVE_X_REACHED;
+  Lisp_Object buf = it->w->contents;
+  bool auto_hscroll_mode_p = EQ (Fbuffer_local_value (Qauto_hscroll_mode, buf), Qcurrent_line);
+  bool hscl_temporary_p = (!it->w->suspend_auto_hscroll
+                           && auto_hscroll_mode_p
+                           && it->w->hscroll > 0
+                           && it->w->min_hscroll == 0);
+  bool hscl_permanent_p = (!it->w->suspend_auto_hscroll
+                           && auto_hscroll_mode_p
+                           && it->w->hscroll > 0
+                           && it->w->min_hscroll > 0
+                           && it->w->min_hscroll != it->w->hscroll);
+  bool mc_stderr_p = NILP (BVAR (current_buffer, mc_stderr));
+  int frame_char_width = FRAME_COLUMN_WIDTH (it->f);
+  int text_area_width = window_box_width (it->w, TEXT_AREA);
+  bool cursor_in_fringe_p = opoint_x + frame_char_width >= text_area_width;
+  int hscl_first_hpos = window_hscroll_limited (it->w, it->f);
+  int header_line_height = WINDOW_HEADER_LINE_HEIGHT (it->w);
+  int count = 0;
+  int vpos = 0;
+  int new_x = 0;
+  /* current_x */
+  int ante_prior_previous_it_current_x = 0;
+  int prior_previous_it_current_x = 0;
+  int previous_it_current_x = 0;
+  /* hpos */
+  int ante_prior_previous_it_hpos = 0;
+  int prior_previous_it_hpos = 0;
+  int previous_it_hpos = 0;
+  /* relative_x */
+  int ante_prior_previous_relative_x = 0;
+  int prior_previous_relative_x = 0;
+  int previous_relative_x = 0;
+  int relative_x = 0;
+  /* fetch_byte */
+  int ante_prior_previous_fetch_byte = 0;
+  int prior_previous_fetch_byte = 0;
+  int previous_fetch_byte = 0;
+  /* character */
+  int ante_prior_previous_character = 0;
+  int prior_previous_character = 0;
+  int previous_character = 0;
+  /* face_id */
+  int ante_prior_previous_face_id = DEFAULT_FACE_ID;
+  int prior_previous_face_id = DEFAULT_FACE_ID;
+  int previous_face_id = DEFAULT_FACE_ID;
+  /* previous_hpos */
+  int ante_prior_previous_hpos = 0;
+  int prior_previous_hpos = 0;
+  int previous_hpos = 0;
+  /* region */
+  Lisp_Object region_limit_true = mc_region_limit (true);
+  ptrdiff_t region_beginning = (!NILP (region_limit_true))
+                               ? XFIXNUM (region_limit_true)
+                               : 0;
+  Lisp_Object region_limit_false = mc_region_limit (false);
+  ptrdiff_t region_end = (!NILP (region_limit_false))
+                         ? XFIXNUM (region_limit_false)
+                         : 0;
+  enum face_id region_face_id = lookup_named_face (it->w, it->f, intern ("region"), true);
+  struct glyph *real_phys_cursor_glyph = get_phys_cursor_glyph (it->w);
+  bool region_active_p = (region_beginning != region_end);
+  bool final_loop_p = false;
+  bool issue_31716_p = false;
+  int hscl_x = 0;
+  bool lpw_reached_p = false;
+  bool green_light_p = false;
+  bool tab_invisible_p = false;
+  bool real_fake_cursor_p = false;
+  while (!final_loop_p)
+    {
+      count += 1;
+      if (header_line_height > 0)
+        vpos = it->vpos + 1;
+        else
+          vpos = it->vpos;
+      /* Temporary horizontal scrolling of _only_ the current line.
+      This was difficult to get right, so be careful if ever changing it.
+      The reason it is difficult to get right is because in a vertical
+      ruler situation, we stop when `relative_x` equals `opoint_x` and the
+      latter is of course always correct, but the HPOS will sometimes be
+      wrong if `relative_x` and `opoint_x` are out of sync. */
+      if (new_x > 0
+          && hscl_permanent_p)
+        relative_x = new_x - (hscl_first_hpos * frame_char_width);
+        else if (new_x > 0
+                 && hscl_temporary_p
+                 && opoint_y == it->current_y
+                 && opoint_vpos == vpos)
+          relative_x = new_x - (hscl_first_hpos * frame_char_width);
+          else if (new_x > 0)
+            relative_x = new_x - it->first_visible_x;
+            else
+              relative_x = 0;
+      /* See the explanation by Eli Z. as to issue #31716.  Horizontal scrolling
+      (of all lines) is active.  The beginning of the TAB STRETCH lies before
+      it->first_visible_x + it->lnum_pixel_width; and, the next display element is
+      subsequent thereto.
+      -------------------------------
+      7.  TAB STRETCH
+          it->c (9)
+          char (	)
+          it->w->hscroll (4)
+          hscl_temporary_p (false)
+          it->hpos (0)
+          it->current_x (11)
+          new_x (77)
+          font_space_width (11)
+          it->lnum_pixel_width (44)
+          relative_x (33)
+          rc (MOVE_X_REACHED)
+      -------------------------------
+      8.  TEXT -- THE FUN STARTS HERE
+          it->c (72)
+          char (H)
+          it->w->hscroll (4)
+          hscl_temporary_p (false)
+          it->hpos (5)
+          it->current_x (132)
+          new_x (88)
+          font_space_width (11)
+          it->lnum_pixel_width (44)
+          relative_x (44)
+          rc (MOVE_X_REACHED)
+      ===============================
+      7.  TAB STRETCH
+          it->c (9)
+          char (	)
+          it->w->hscroll (2)
+          hscl_temporary_p (false)
+          it->hpos (0)
+          it->current_x (11)
+          new_x (77)
+          font_space_width (11)
+          it->lnum_pixel_width (44)
+          relative_x (55)
+          rc (MOVE_X_REACHED)
+      -------------------------------
+      8.  TEXT
+          it->c (72)
+          char (H)
+          it->w->hscroll (2)
+          hscl_temporary_p (false)
+          it->hpos (5)
+          it->current_x (132)
+          new_x (88)
+          font_space_width (11)
+          it->lnum_pixel_width (44)
+          relative_x (66)
+          rc (MOVE_X_REACHED) */
+      issue_31716_p = (!hscl_temporary_p
+                       && !hscl_permanent_p
+                       && it->w->hscroll > 0
+                       && prior_previous_hpos == 0
+                       && previous_character == '\t'
+                       && it->hpos > it->lnum_pixel_width / frame_char_width);
+      hscl_x = (hscl_temporary_p
+                || hscl_permanent_p)
+                ? it->current_x - (hscl_first_hpos * frame_char_width)
+                : it->current_x - it->first_visible_x;
+      final_loop_p = (IT_CHARPOS (*it) == ZV
+                      || (FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'
+                          && relative_x == it->current_x
+                          && it->c != 0)
+                      || rc == MOVE_LINE_CONTINUED
+                      || (rc == MOVE_LINE_TRUNCATED
+                          && relative_x > text_area_width))
+                       ? true
+                     /* IT may not stop at every CHARPOS if composite characters exist. */
+                     : (action_type == MULTIPLE_CURSORS
+                        && it->current_x > previous_it_current_x
+                        && (IT_CHARPOS (*it) > posint
+                            || (IT_CHARPOS (*it) == ZV
+                                && posint == ZV)
+                            || FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'
+                            || (rc == MOVE_LINE_CONTINUED
+                                && posint == IT_CHARPOS (*it))))
+                       ? true
+                     : (!hscl_temporary_p && !hscl_permanent_p
+                        && FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'
+                        && it->c != 0
+                        /* We keep going until `relative_x` catches up with
+                        `it->current_x` for a situation such as a line
+                        containing only a tab folled by a new line; e.g.,
+                        issue_31716_p followed by a Ghost of Christmas future.
+                        We use >= because there is no guarantee that all of
+                        characters will be exactly `font_char_width'. */
+                        && (relative_x >= it->current_x - it->first_visible_x
+                            /* Permanently h-scrolled and only a new line. */
+                            || it->current_x == 0))
+                       ? true
+                     : (!hscl_temporary_p && !hscl_permanent_p
+                        && hscl_x + frame_char_width >= text_area_width)
+                       ? true
+                     : (!hscl_temporary_p && !hscl_permanent_p
+                        && rc == MOVE_LINE_CONTINUED)
+                       ? true
+                     : ((hscl_temporary_p || hscl_permanent_p)
+                        && FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'
+                        && it->c != 0
+                        /* We keep going until `relative_x` catches up with
+                        `it->current_x` for a situation such as a line
+                        containing only a tab followed by a new line; e.g.,
+                        issue_31716_p followed by a Ghost of Christmas future.
+                        We use >= because there is no guarantee that all of
+                        characters will be exactly `font_char_width'. */
+                        && relative_x >= it->current_x - (hscl_first_hpos * frame_char_width))
+                       ? true
+                     : ((hscl_temporary_p || hscl_permanent_p)
+                        && (rc == MOVE_POS_MATCH_OR_ZV
+                            || rc == MOVE_LINE_CONTINUED
+                            || hscl_x + frame_char_width >= text_area_width))
+                       ? true
+                     : (IT_CHARPOS (*it) == ZV)
+                       ? true
+                     : false;
+      lpw_reached_p = (relative_x >= it->lnum_pixel_width
+                       || issue_31716_p);
+      green_light_p = (it->current_x > previous_it_current_x
+                       || (NILP (Vdisplay_line_numbers)
+                           && final_loop_p)) ? true : false;
+      real_fake_cursor_p = (issue_31716_p
+                            && FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'
+                            && previous_relative_x < it->lnum_pixel_width
+                            && previous_hpos == 0
+                            && opoint_x == it->lnum_pixel_width
+                            && opoint_hpos == it->lnum_pixel_width / frame_char_width
+                            && opoint_y == it->current_y
+                            && opoint_vpos == vpos)
+                              ? true
+                           : (action_type == VERTICAL_RULER
+                              && opoint_y == it->current_y
+                              && opoint_vpos == vpos)
+                              ? true
+                           : (opoint_x == previous_relative_x
+                              && opoint_hpos == previous_hpos
+                              && opoint_y == it->current_y
+                              && opoint_vpos == vpos)
+                             ? true
+                           /* E.g., PT is on a tab to the immediate right of line numbers */
+                           : (FETCH_BYTE (IT_BYTEPOS (*it)) != '\n'
+                              && previous_relative_x < it->lnum_pixel_width
+                              && relative_x > opoint_x
+                              && opoint_x == previous_it_current_x
+                              && opoint_hpos == it->lnum_pixel_width / frame_char_width
+                              && it->lnum_pixel_width > 0
+                              && opoint_y == it->current_y
+                              && opoint_vpos == vpos)
+                             ? true
+                           /* E.g., PT is on a tab to the immediate right of line numbers */
+                           : (FETCH_BYTE (IT_BYTEPOS (*it)) != '\n'
+                              && previous_relative_x < it->lnum_pixel_width
+                              && opoint_x == it->lnum_pixel_width
+                              && opoint_hpos == it->lnum_pixel_width / frame_char_width
+                              && previous_hpos == 0
+                              && it->lnum_pixel_width > 0
+                              && opoint_y == it->current_y
+                              && opoint_vpos == vpos)
+                             ? true
+                           /* The first loop is a final_loop_p situation.  This
+                           rare situation was observed when `truncate-lines' was
+                           non-nil.  However, this situation is somewhat rare. */
+                           : (FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'
+                              && it->c == 10
+                              && it->current_x == 0
+                              && it->hpos == 0
+                              && relative_x == 0
+                              && previous_relative_x == 0
+                              && new_x == 0
+                              && opoint_x == it->lnum_pixel_width
+                              && opoint_y == it->current_y
+                              && opoint_vpos == vpos)
+                             ? true
+                           /* New line is to the immediate right of the line numbers,
+                           but the while loop proceeded numerous times. */
+                           : (FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'
+                              && previous_relative_x < it->lnum_pixel_width
+                              && opoint_hpos == it->lnum_pixel_width / frame_char_width
+                              && opoint_x == it->lnum_pixel_width
+                              && opoint_x == previous_it_current_x
+                              && opoint_y == it->current_y
+                              && opoint_vpos == vpos)
+                             ? true
+                           : (opoint_x < it->lnum_pixel_width
+                              && relative_x <= it->lnum_pixel_width
+                              && previous_it_current_x < it->lnum_pixel_width
+                              && opoint_y == it->current_y
+                              && opoint_vpos == vpos)
+                             ? true
+                           : false;
+      tab_invisible_p = (action_type != VERTICAL_RULER
+                         && previous_character == '\t')
+                          ? true
+/* it->w->hscroll == 0 && hscl_temporary_p
+		¶ */
+                        : (action_type == VERTICAL_RULER
+                           && it->w->hscroll > 0
+                           && hscl_temporary_p
+                           && ante_prior_previous_character == '\t'
+                           && prior_previous_character != '\t'
+                           && previous_character != '\t'
+                           && FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'
+                           && opoint_x >= ante_prior_previous_it_current_x
+                           && opoint_x < prior_previous_it_current_x)
+                          ? true
+/* it->w->hscroll == 0 && hscl_temporary_p
+		¶ */
+                        : (action_type == VERTICAL_RULER
+                           && it->w->hscroll > 0
+                           && hscl_temporary_p
+                           && prior_previous_character != '\t' /* » */
+                           && previous_character == '\t'
+                           && FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'
+                           && opoint_x >= previous_relative_x
+                           && opoint_x < it->current_x)
+                          ? true
+/* it->w->hscroll > 0 && !hscl_temporary_p
+		¶ */
+                        : (action_type == VERTICAL_RULER
+                           && it->w->hscroll > 0
+                           && !hscl_temporary_p
+                           && ante_prior_previous_character != '\t' /* » */
+                           && prior_previous_character == '\t'
+                           && previous_fetch_byte == '\n'
+                           && FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'
+                           && opoint_x < previous_relative_x)
+                          ? true
+/* it->w->hscroll > 0 && !hscl_temporary_p
+		¶ */
+                        : (action_type == VERTICAL_RULER
+                           && it->w->hscroll > 0
+                           && !hscl_temporary_p
+                           && prior_previous_character != '\t' /* » */
+                           && previous_character == '\t'
+                           && FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'
+                           && previous_relative_x <= opoint_x)
+                          ? true
+/* it->w->hscroll > 0 && !hscl_temporary_p
+	¶ */
+                        : (action_type == VERTICAL_RULER
+                           && it->w->hscroll > 0
+                           && !hscl_temporary_p
+                           && prior_previous_character == '\t'
+                           && previous_fetch_byte == '\n'
+                           && FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'
+                           && opoint_x >= it->lnum_pixel_width
+                           && prior_previous_relative_x < it->lnum_pixel_width
+                           && previous_relative_x < it->lnum_pixel_width
+                           && opoint_x < relative_x)
+                          ? true
+/* it->w->hscroll > 0 && !hscl_temporary_p
+	¶ */
+                        : (action_type == VERTICAL_RULER
+                           && it->w->hscroll > 0
+                           && !hscl_temporary_p
+                           && prior_previous_character == '\t'
+                           && previous_character == '\t'
+                           && FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'
+                           && opoint_x >= it->lnum_pixel_width
+                           && prior_previous_relative_x < it->lnum_pixel_width
+                           && previous_relative_x < it->lnum_pixel_width
+                           && opoint_x < relative_x)
+                          ? true
+/* it->w->hscroll == 0
+	¶ */
+                        : (action_type == VERTICAL_RULER
+                           && it->w->hscroll == 0
+                           && prior_previous_character != '\t' /* » */
+                           && previous_character == '\t'
+                           && FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'
+                           && opoint_x >= previous_relative_x
+                           && opoint_x < relative_x)
+                          ? true
+/* it->w->hscroll > 0 && !hscl_temporary_p
+		Hello
+*/
+                        : (action_type == VERTICAL_RULER
+                           && it->w->hscroll > 0
+                           && !hscl_temporary_p
+                           && ante_prior_previous_character != '\t'
+                           && prior_previous_character == '\t'
+                           && previous_character != '\t'
+                           && FETCH_BYTE (IT_BYTEPOS (*it)) != '\n'
+                           && ante_prior_previous_hpos > it->lnum_pixel_width / frame_char_width
+                           && prior_previous_hpos > 0
+                           && previous_hpos > it->lnum_pixel_width / frame_char_width
+                           && ante_prior_previous_relative_x >= it->lnum_pixel_width
+                           && prior_previous_relative_x > it->lnum_pixel_width
+                           && previous_relative_x > it->lnum_pixel_width
+                           && opoint_x < previous_relative_x)
+                          ? true
+/* it->w->hscroll > 0 && !hscl_temporary_p
+		Hello
+*/
+                        : (action_type == VERTICAL_RULER
+                           && it->w->hscroll > 0
+                           && !hscl_temporary_p
+                           && ante_prior_previous_character != '\t'
+                           && prior_previous_character == '\t'
+                           && previous_character != '\t'
+                           && FETCH_BYTE (IT_BYTEPOS (*it)) != '\n'
+                           && ante_prior_previous_hpos == 0
+                           && prior_previous_hpos > it->lnum_pixel_width / frame_char_width
+                           && previous_hpos > it->lnum_pixel_width / frame_char_width
+                           && ante_prior_previous_relative_x < it->lnum_pixel_width
+                           && prior_previous_relative_x > it->lnum_pixel_width
+                           && previous_relative_x > it->lnum_pixel_width
+                           && opoint_x < previous_relative_x)
+                          ? true
+/* it->w->hscroll > 0 && !hscl_temporary_p
+	Hello
+*/
+                        : (action_type == VERTICAL_RULER
+                           && it->w->hscroll > 0
+                           && !hscl_temporary_p
+                           && ante_prior_previous_character == '\t'
+                           && prior_previous_character != '\t'
+                           && previous_character != '\t'
+                           && FETCH_BYTE (IT_BYTEPOS (*it)) != '\n'
+                           && ante_prior_previous_hpos == 0
+                           && prior_previous_hpos == 0
+                           && previous_hpos > it->lnum_pixel_width / frame_char_width
+                           && ante_prior_previous_relative_x < it->lnum_pixel_width
+                           && prior_previous_relative_x < it->lnum_pixel_width
+                           && previous_relative_x >= it->lnum_pixel_width
+                           && opoint_x < previous_relative_x)
+                          ? true
+/* it->w->hscroll > 0 && !hscl_temporary_p
+	Hello
+*/
+                        : (action_type == VERTICAL_RULER
+                           && it->w->hscroll > 0
+                           && !hscl_temporary_p
+                           && prior_previous_character == '\t'
+                           && previous_character != '\t'
+                           && FETCH_BYTE (IT_BYTEPOS (*it)) != '\n'
+                           && previous_hpos > it->lnum_pixel_width / frame_char_width
+                           && prior_previous_hpos == 0
+                           && prior_previous_relative_x < it->lnum_pixel_width
+                           && previous_relative_x >= it->lnum_pixel_width
+                           && opoint_x < previous_relative_x)
+                          ? true
+/* it->w->hscroll == 0
+	Hello
+*/
+                        : (action_type == VERTICAL_RULER
+                           && it->w->hscroll == 0
+                           && prior_previous_character == '\t'
+                           && previous_character != '\t'
+                           && FETCH_BYTE (IT_BYTEPOS (*it)) != '\n'
+                           && opoint_x < previous_relative_x)
+                          ? true
+/* it->w->hscroll == 0 && `buffer-display-table' is nil.
+			Hello
+*/
+                        : (action_type == VERTICAL_RULER
+                           && it->w->hscroll == 0
+                           && prior_previous_character == '\t'
+                           && previous_character == '\t'
+                           && FETCH_BYTE (IT_BYTEPOS (*it)) != '\n'
+                           && previous_relative_x >= it->lnum_pixel_width
+                           && opoint_x < previous_relative_x)
+                          ? true
+                        : false;
+      if (!mc_stderr_p)
+        mc_stderr_1 (it, count, posint, new_x,
+                     opoint_x, opoint_y, opoint_hpos, opoint_vpos,
+                     ante_prior_previous_it_current_x, prior_previous_it_current_x, previous_it_current_x,
+                     ante_prior_previous_it_hpos, prior_previous_it_hpos, previous_it_hpos,
+                     ante_prior_previous_relative_x, prior_previous_relative_x, previous_relative_x, relative_x,
+                     ante_prior_previous_fetch_byte, prior_previous_fetch_byte, previous_fetch_byte,
+                     ante_prior_previous_character, prior_previous_character, previous_character,
+                     ante_prior_previous_face_id, prior_previous_face_id, previous_face_id,
+                     ante_prior_previous_hpos, prior_previous_hpos, previous_hpos,
+                     final_loop_p, issue_31716_p, lpw_reached_p, green_light_p,
+                     real_fake_cursor_p, tab_invisible_p,
+                     hscl_temporary_p, hscl_permanent_p, rc, action_type);
+  switch (action_type)
+  {
+/* --------------------------------------------------------------------------- */
+/*                                Multiple Cursors                             */
+/* --------------------------------------------------------------------------- */
+    case MULTIPLE_CURSORS:
+    {
+      if (final_loop_p)
+        {
+          int flavor = MC_GLYPH;
+          bool anomaly_p = (rc == MOVE_LINE_CONTINUED
+                            && posint == IT_CHARPOS (*it)
+                            && previous_relative_x + it->pixel_width > text_area_width
+                            && previous_relative_x + frame_char_width > text_area_width)
+                           ? true
+                           : false;
+          int temp_vpos = (anomaly_p)
+                          ? vpos + 1
+                          : vpos;
+          enum face_id temp_bg_face_id = (IT_CHARPOS (*it) == posint
+                                          && (ITERATOR_AT_END_OF_LINE_P (it)
+                                              || FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'))
+                                         ? it->face_id
+                                         : previous_face_id;
+          int temp_x = (anomaly_p)
+                       ? it->lnum_pixel_width
+                       /* Fake cursor is just to the right of the line numbers. */
+                       : (IT_CHARPOS (*it) - 1 == posint
+                          && relative_x > it->lnum_pixel_width
+                          && previous_relative_x < it->lnum_pixel_width
+                          && previous_hpos == 0
+                          && it->lnum_pixel_width > 0)
+                         ? previous_it_current_x
+                       : (IT_CHARPOS (*it) - 1 == posint
+                          || (rc == MOVE_LINE_CONTINUED
+                              && posint == IT_CHARPOS (*it)))
+                         ? previous_relative_x
+                       : (it->current_x == 0
+                          && it->lnum_pixel_width == 0)
+                         ? 0
+                       : relative_x;
+          int temp_hpos = (anomaly_p)
+                          ? it->lnum_pixel_width / frame_char_width
+                          : (it->current_x == 0
+                             && it->lnum_pixel_width == 0)
+                            ? 0
+                          /* Fake cursor is just to the right of the line numbers. */
+                          : (IT_CHARPOS (*it) - 1 == posint
+                             && relative_x > it->lnum_pixel_width
+                             && previous_relative_x < it->lnum_pixel_width
+                             && previous_hpos == 0
+                             && it->lnum_pixel_width > 0)
+                            ? it->lnum_pixel_width / frame_char_width
+                          /* EOL ¶ is exactly 2nd to the right of the line numbers. */
+                          : (IT_CHARPOS (*it) == posint
+                             && FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'
+                             && relative_x > it->lnum_pixel_width
+                             && previous_relative_x < it->lnum_pixel_width
+                             && previous_hpos == 0
+                             && it->lnum_pixel_width > 0)
+                            ? (it->lnum_pixel_width / frame_char_width) + 1
+                          : (IT_CHARPOS (*it) == posint
+                             && (posint == ZV
+                                 || ITERATOR_AT_END_OF_LINE_P (it)
+                                 || FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'))
+                            ? previous_hpos + 1
+                          : previous_hpos;
+          if (!mc_stderr_p)
+            mc_stderr_2 (it, count, action_type, relative_x, temp_x, temp_hpos,
+                         temp_vpos, foreground, temp_bg_face_id, cursor_type,
+                         flavor);
+          mc_helper (it->w, temp_x, -1, it->current_y, -1, temp_hpos, temp_vpos,
+                     -1, cursor_type, cursor_width, foreground,
+                     mc_bg_lsl (it->w, temp_bg_face_id), active_cursor_p, flavor,
+                     posint, result);
+          return;
+        }
+      break;
+    }
+/* --------------------------------------------------------------------------- */
+/*                             HORIZONTAL RULER                                */
+/* --------------------------------------------------------------------------- */
+    case HORIZONTAL_RULER:
+    {
+/* --------------------------------------------------------------------------- */
+/*                                   MC_GLYPH                                  */
+/* --------------------------------------------------------------------------- */
+      if ((green_light_p
+           /* Place an MC_GLYPH on the last space of a wrapped line. */
+           || rc == MOVE_LINE_CONTINUED)
+          && !real_fake_cursor_p
+          && lpw_reached_p
+          && !tab_invisible_p)
+        {
+          int flavor = MC_GLYPH;
+          enum face_id temp_bg_face_id = (rc == MOVE_LINE_CONTINUED)
+                                         ? it->face_id
+                                         : previous_face_id;
+          int temp_x = (previous_relative_x < it->lnum_pixel_width)
+                        ? it->lnum_pixel_width
+                        : previous_relative_x;
+          ptrdiff_t it_charpos = (rc == MOVE_LINE_CONTINUED)
+                                  ? IT_CHARPOS (*it)
+                                  : IT_CHARPOS (*it) - 1;
+          int temp_hpos = (it->lnum_pixel_width > 0
+                           && previous_hpos < it->lnum_pixel_width / frame_char_width)
+                          ? it->lnum_pixel_width / frame_char_width
+                          : previous_hpos;
+          int temp_vpos = vpos;
+          if (!mc_stderr_p)
+            mc_stderr_2 (it, count, action_type, relative_x, temp_x, temp_hpos,
+                         temp_vpos, foreground, temp_bg_face_id, cursor_type,
+                         flavor);
+          /* Record some of the current values for the cursor and glyph_row. */
+          struct glyph_row *glyph_row =  MATRIX_ROW (it->w->current_matrix, temp_vpos);
+          int fx, fy, h;
+          mc_get_phys_cursor_geometry (it->w, glyph_row, temp_x, &fx,
+                                       glyph_row->y, &fy, temp_hpos, temp_vpos,
+                                       &h, cursor_type, cursor_width);
+          mc_helper (it->w, temp_x, -1, it->current_y, fy, temp_hpos, temp_vpos,
+                     -1, cursor_type, cursor_width, foreground,
+                     mc_bg_lsl (it->w, temp_bg_face_id), active_cursor_p, flavor,
+                     it_charpos, result);
+        }
+/* --------------------------------------------------------------------------- */
+/*                                MC_GLYPH_TAB                                 */
+/* --------------------------------------------------------------------------- */
+      /* FIXME:  Drawing a MC_GLYPH HBAR_CURSOR on certain letters (A, m, M, w, W)
+      located to the immediate right of a tab spacer, cause the MC_GLYPHLESS
+      HBAR_CURSOR to the immediate left to be erased.  This is probably an
+      overhang situation.  An obvious workaround would be to record the
+      coordinates for the MC_GLYPHLESS cursors and then draw them all AFTER the
+      MC_GLYPH cursors have been laid.  How about pushing all the coordinates
+      to the cache, and then executing a variation of `mc_redraw_crosshairs'
+      [with said version being rewritten] to loop twice over the list, first
+      for MC_GLYPH, and then for MC_GLYPHLESS? */
+      if ((green_light_p
+           && lpw_reached_p
+           && tab_invisible_p)
+          /* A somewhat rare situation when there is a very long STRETCH that
+          spans all the way to the right window edge, where it word-wraps and
+          the next word-wrapped line contains a character that is not a space or
+          a hard return. */
+          || (final_loop_p
+              && it->c == '\t'
+               && rc == MOVE_LINE_CONTINUED))
+        {
+          int i;
+          int temp_x = (issue_31716_p
+                        && !real_fake_cursor_p
+                        && relative_x < it->lnum_pixel_width
+                        && previous_hpos == 0)
+                         ? it->lnum_pixel_width
+                       : (issue_31716_p
+                          && real_fake_cursor_p
+                          && relative_x < it->lnum_pixel_width
+                          && previous_hpos == 0)
+                         ? it->lnum_pixel_width + frame_char_width
+                       : (!real_fake_cursor_p
+                          && it->lnum_pixel_width == 0
+                          && it->c == '\t'
+                          && prior_previous_relative_x == 0
+                          && prior_previous_fetch_byte == 0
+                          && previous_character == '\t'
+                          && prior_previous_hpos == 0)
+                         ? 0
+                       : (!real_fake_cursor_p
+                          && previous_relative_x < it->lnum_pixel_width)
+                         ? it->lnum_pixel_width
+                       : (real_fake_cursor_p
+                          && previous_relative_x < it->lnum_pixel_width)
+                         ? it->lnum_pixel_width + frame_char_width
+                       : real_fake_cursor_p
+                         ? previous_relative_x + frame_char_width
+                       : previous_relative_x;
+          int temp_hpos = (issue_31716_p
+                           && !real_fake_cursor_p
+                           && relative_x < it->lnum_pixel_width
+                           && previous_hpos == 0)
+                            ? it->lnum_pixel_width / frame_char_width
+                          /* HPOS is the same as when !real_fake_cursor_p */
+                          : (issue_31716_p
+                             && real_fake_cursor_p
+                             && relative_x < it->lnum_pixel_width
+                             && previous_hpos == 0)
+                              ? it->lnum_pixel_width / frame_char_width
+                          : (it->lnum_pixel_width == 0
+                             && it->c == '\t'
+                             && prior_previous_relative_x == 0
+                             && prior_previous_fetch_byte == 0
+                             && previous_character == '\t'
+                             && prior_previous_hpos == 0)
+                            ? 0
+                          : previous_hpos;
+          int temp_vpos = vpos;
+          int temp_bg_face_id = previous_face_id;
+          int flavor = MC_GLYPH_TAB;
+          int count = (issue_31716_p
+                       && relative_x < it->lnum_pixel_width
+                       && previous_hpos == 0)
+                        ? ((it->current_x - it->first_visible_x) - temp_x) / frame_char_width
+                      : (final_loop_p
+                         && it->c == '\t'
+                         && rc == MOVE_LINE_CONTINUED)
+                        ? (text_area_width - temp_x) / frame_char_width
+                      : (relative_x - temp_x) / frame_char_width;
+          for (i = 0; i < count; i++)
+            {
+              if (!mc_stderr_p)
+                mc_stderr_2 (it, count, action_type, relative_x, temp_x, temp_hpos,
+                             temp_vpos, foreground, temp_bg_face_id, cursor_type,
+                             flavor);
+              mc_helper (it->w, temp_x, -1, it->current_y, -1, temp_hpos,
+                         temp_vpos, -1, cursor_type, cursor_width, foreground,
+                         mc_bg_lsl (it->w, temp_bg_face_id), active_cursor_p,
+                         flavor, IT_CHARPOS (*it) - 1, result);
+              temp_x += frame_char_width;
+            }
+        }
+/* --------------------------------------------------------------------------- */
+/*                          EOL + FLOATING HORIZONTAL RULER                    */
+/* --------------------------------------------------------------------------- */
+      if (final_loop_p
+          && ((FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'
+               || IT_CHARPOS (*it) == ZV)
+              || (FETCH_BYTE (IT_BYTEPOS (*it)) == ' '
+                  && rc == MOVE_LINE_CONTINUED)))
+        {
+          /* We want to start drawing the floating horizontal line from IT
+          (line feed; ZV; or space-word_wrap) until the right fringe.
+          If the line is empty or hidden by horizontal scrolling, then `it.current_x`
+          may be somewhere before `lnum_pixel_width`.  The real cursor will be to the
+          left of `lnum_pixel_width` if we are horizontal scrolling and point is
+          hidden somewhere to the left thereof. */
+          enum face_id temp_bg_face_id = (real_phys_cursor_glyph == NULL)
+                                           ? DEFAULT_FACE_ID
+                                         : (FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'
+                                            && region_end == IT_CHARPOS (*it)
+                                            && it->face_id == region_face_id)
+                                           ? DEFAULT_FACE_ID
+                                         : IT_CHARPOS (*it) == ZV
+                                           ? DEFAULT_FACE_ID
+                                         : (IT_CHARPOS (*it) >= region_end
+                                            || region_beginning == region_end)
+                                           ? it->face_id
+                                         : real_phys_cursor_glyph->face_id;
+          /* An empty new line -- loop in previous section broke immediately. */
+          int temp_hpos = (relative_x == it->lnum_pixel_width)
+                           ? it->lnum_pixel_width / frame_char_width
+                           /* No need to readjust because it was done above. */
+                           : (rc == MOVE_LINE_CONTINUED)
+                             ? previous_hpos
+                           : (rc == MOVE_NEWLINE_OR_CR
+                              && real_fake_cursor_p
+                              && NILP (Vdisplay_line_numbers)
+                              && previous_hpos == 0)
+                             ? previous_hpos
+                           : (relative_x < it->lnum_pixel_width
+                              && it->lnum_pixel_width > 0
+                              && previous_hpos < it->lnum_pixel_width / frame_char_width)
+                               ? it->lnum_pixel_width / frame_char_width
+                           /* EOL ¶ is exactly 2nd to the right of the line numbers. */
+                           : (FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'
+                              && relative_x > it->lnum_pixel_width
+                              && previous_relative_x < it->lnum_pixel_width
+                              && previous_hpos == 0
+                              && it->lnum_pixel_width > 0)
+                             ? (it->lnum_pixel_width / frame_char_width) + 1
+                           : (FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'
+                              && it->hpos == previous_hpos)
+                             ? previous_hpos
+                           : previous_hpos + 1;
+          int temp_x = (relative_x < it->lnum_pixel_width
+                        && it->lnum_pixel_width == opoint_x)
+                         ? it->lnum_pixel_width
+                       : (IT_CHARPOS (*it) == ZV
+                          && rc == MOVE_POS_MATCH_OR_ZV
+                          && hscl_temporary_p)
+                         ? previous_relative_x
+                       : (opoint_x < it->lnum_pixel_width
+                          && relative_x < it->lnum_pixel_width)
+                         ? it->lnum_pixel_width
+                       : relative_x;
+          int temp_vpos = vpos;
+          int flavor = MC_GLYPH;
+          /* Do not use `real_fake_cursor_p' here because that relates to the
+          `previous_relative_x'; whereas, EOL is `relative_x` in _most_ cases. */
+          if (opoint_x != temp_x
+              && opoint_hpos != temp_hpos
+              && rc != MOVE_LINE_CONTINUED
+              && FETCH_BYTE (IT_BYTEPOS (*it)) == '\n')
+            {
+              if (!mc_stderr_p)
+                fprintf (stderr, "\nEOL:\n");
+              if (!mc_stderr_p)
+                mc_stderr_2 (it, count, action_type, relative_x, temp_x, temp_hpos,
+                             temp_vpos, foreground, temp_bg_face_id, cursor_type,
+                             flavor);
+              /* Record some of the current values for the cursor and glyph_row. */
+              struct glyph_row *glyph_row =  MATRIX_ROW (it->w->current_matrix, temp_vpos);
+              int fx, fy, h;
+              mc_get_phys_cursor_geometry (it->w, glyph_row, temp_x, &fx,
+                                           glyph_row->y, &fy, temp_hpos, temp_vpos,
+                                           &h, cursor_type, cursor_width);
+              mc_helper (it->w, temp_x, -1, it->current_y, fy, temp_hpos, temp_vpos,
+                         -1, cursor_type, cursor_width, foreground,
+                         mc_bg_lsl (it->w, temp_bg_face_id), active_cursor_p,
+                         flavor, IT_CHARPOS (*it), result);
+            }
+          if (IT_CHARPOS (*it) == ZV
+              && opoint_x == relative_x)
+            temp_x += frame_char_width;
+            else if (IT_CHARPOS (*it) == ZV
+                     && opoint_x == it->lnum_pixel_width
+                     && it->current_x == 0)
+              temp_x += frame_char_width;
+              else if (rc != MOVE_LINE_CONTINUED
+                       && IT_CHARPOS(*it) != ZV)
+                temp_x += frame_char_width;
+          if (!mc_stderr_p
+              && temp_x + frame_char_width < text_area_width)
+            fprintf (stderr, "\nFLOATING HORIZONTAL RULER -- SPECS:  temp_x (%d) | temp_hpos (%d)\n",
+              temp_x, temp_hpos);
+          while (temp_x + frame_char_width < text_area_width)
+            {
+              mc_helper (it->w, temp_x, -1, it->current_y, -1, temp_hpos, temp_vpos,
+                         -1, cursor_type, cursor_width, foreground,
+                         mc_bg_lsl (it->w, temp_bg_face_id), active_cursor_p,
+                         MC_GLYPHLESS, IT_CHARPOS (*it), result);
+              temp_x += frame_char_width;
+            }
+          return;
+        }
+      break;
+    }
+/* --------------------------------------------------------------------------- */
+/*                              VERTICAL RULER                                 */
+/* --------------------------------------------------------------------------- */
+    case VERTICAL_RULER:
+    {
+      if ((!final_loop_p
+           && it->current_x > previous_it_current_x
+           /* When the current line contains special characters like Japanese,
+           then opoint_x and previous_relative_x may not necessarily be the same.
+           We want to stop on the character _containing_ `opoint_x`. */
+           && previous_relative_x >= opoint_x)
+          || final_loop_p)
+        {
+          /* Skip this line. */
+          if (real_fake_cursor_p)
+            return;
+          struct glyph_row *glyph_row =  MATRIX_ROW (it->w->current_matrix, vpos);
+          int flavor = NO_FLAVOR;
+          enum face_id temp_bg_face_id = previous_face_id;
+          if (it->w->hscroll > 0
+               && !hscl_temporary_p
+               && opoint_x < it->lnum_pixel_width)
+            {
+              flavor = MC_GLYPHLESS;
+              temp_bg_face_id = DEFAULT_FACE_ID;
+            }
+          else if (cursor_in_fringe_p
+                   && glyph_row->truncated_on_right_p)
+            flavor = MC_VERTICAL_BAR_RIGHT_ANGLE;
+          else if (cursor_in_fringe_p
+                   && glyph_row->continued_p)
+            flavor = MC_VERTICAL_BAR_BACKSLASH;
+          else if (cursor_in_fringe_p
+                   && !glyph_row->truncated_on_right_p
+                   && !glyph_row->continued_p)
+            flavor = MC_VERTICAL_BAR;
+          /* This situation _excludes_ EOL. */
+          else if (!tab_invisible_p
+                   && !ITERATOR_AT_END_OF_LINE_P (it)
+                   && FETCH_BYTE (IT_BYTEPOS (*it)) != '\n'
+                   && FETCH_BYTE (IT_BYTEPOS (*it)) != '\f'
+                   && rc != MOVE_POS_MATCH_OR_ZV
+                   && rc != MOVE_LINE_CONTINUED
+                   && opoint_x >= it->lnum_pixel_width)
+            flavor = MC_GLYPH;
+                      /* EOL */
+          else if (!tab_invisible_p
+                   && relative_x <= opoint_x
+                   && opoint_x < relative_x + frame_char_width
+                   && (FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'
+                       || FETCH_BYTE (IT_BYTEPOS (*it)) == '\f')
+                   && rc != MOVE_POS_MATCH_OR_ZV
+                   && rc != MOVE_LINE_CONTINUED
+                   && relative_x >= it->lnum_pixel_width
+                   && opoint_x > it->lnum_pixel_width)
+            flavor = MC_GLYPH;
+          /* It is okay to use MC_GLYPH for a word-wrapped line. */
+          else if (!tab_invisible_p
+                   && rc == MOVE_LINE_CONTINUED
+                   && FETCH_BYTE (IT_BYTEPOS (*it)) == ' '
+                   && previous_relative_x == opoint_x)
+            flavor = MC_GLYPH;
+/* it->w->hscroll == 0 && hscl_temporary_p
+		¶ */
+          else if (action_type == VERTICAL_RULER
+                   && it->w->hscroll > 0
+                   && hscl_temporary_p
+                   && prior_previous_character != '\t' /* » */
+                   && previous_character == '\t'
+                   && FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'
+                   && opoint_x >= previous_relative_x
+                   && opoint_x < it->current_x)
+            {
+              flavor = MC_GLYPH_TAB;
+              temp_bg_face_id = previous_face_id;
+            }
+/* it->w->hscroll > 0 && !hscl_temporary_p
+		¶ */
+          else if (action_type == VERTICAL_RULER
+                   && it->w->hscroll > 0
+                   && !hscl_temporary_p
+                   && ante_prior_previous_character != '\t' /* » */
+                   && prior_previous_character == '\t'
+                   && previous_fetch_byte == '\n'
+                   && FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'
+                   && opoint_x < previous_relative_x)
+            {
+              flavor = MC_GLYPH_TAB;
+              temp_bg_face_id = prior_previous_face_id;
+            }
+/* it->w->hscroll > 0 && !hscl_temporary_p
+		¶ */
+          else if (action_type == VERTICAL_RULER
+                   && it->w->hscroll > 0
+                   && !hscl_temporary_p
+                   && prior_previous_character != '\t' /* » */
+                   && previous_character == '\t'
+                   && FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'
+                   && previous_relative_x <= opoint_x)
+            {
+              flavor = MC_GLYPH_TAB;
+              temp_bg_face_id = prior_previous_face_id;
+            }
+/* it->w->hscroll > 0 && !hscl_temporary_p
+	¶ */
+          else if (tab_invisible_p
+                   && it->w->hscroll > 0
+                   && !hscl_temporary_p
+                   && prior_previous_character == '\t'
+                   && previous_fetch_byte == '\n'
+                   && FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'
+                   && opoint_x >= it->lnum_pixel_width
+                   && prior_previous_relative_x < it->lnum_pixel_width
+                   && previous_relative_x < it->lnum_pixel_width
+                   && opoint_x < relative_x)
+            {
+              flavor = MC_GLYPH_TAB;
+              temp_bg_face_id = prior_previous_face_id;
+            }
+/* it->w->hscroll > 0 && !hscl_temporary_p
+	¶ */
+          else if (tab_invisible_p
+                   && it->w->hscroll > 0
+                   && !hscl_temporary_p
+                   && prior_previous_character == '\t'
+                   && previous_character == '\t'
+                   && FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'
+                   && opoint_x >= it->lnum_pixel_width
+                   && prior_previous_relative_x < it->lnum_pixel_width
+                   && previous_relative_x < it->lnum_pixel_width
+                   && opoint_x < relative_x)
+            {
+              flavor = MC_GLYPH_TAB;
+              temp_bg_face_id = previous_face_id;
+            }
+/* it->w->hscroll == 0
+	¶ */
+          else if (tab_invisible_p
+                   && it->w->hscroll == 0
+                   && prior_previous_character != '\t' /* » */
+                   && previous_character == '\t'
+                   && FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'
+                   && opoint_x >= previous_relative_x
+                   && opoint_x < relative_x)
+            {
+              flavor = MC_GLYPH_TAB;
+              temp_bg_face_id = previous_face_id;
+            }
+/* it->w->hscroll > 0 && !hscl_temporary_p
+	Hello
+*/
+          else if (tab_invisible_p
+                   && it->w->hscroll > 0
+                   && !hscl_temporary_p
+                   && ante_prior_previous_character == '\t'
+                   && prior_previous_character != '\t'
+                   && previous_character != '\t'
+                   && FETCH_BYTE (IT_BYTEPOS (*it)) != '\n'
+                   && ante_prior_previous_hpos == 0
+                   && prior_previous_hpos == 0
+                   && previous_hpos > it->lnum_pixel_width / frame_char_width
+                   && ante_prior_previous_relative_x < it->lnum_pixel_width
+                   && prior_previous_relative_x < it->lnum_pixel_width
+                   && previous_relative_x >= it->lnum_pixel_width
+                   && opoint_x < previous_relative_x)
+            {
+              flavor = MC_GLYPH_TAB;
+              temp_bg_face_id = ante_prior_previous_face_id;
+            }
+/* it->w->hscroll > 0 && !hscl_temporary_p
+	Hello
+*/
+          else if (tab_invisible_p
+                   && it->w->hscroll > 0
+                   && !hscl_temporary_p
+                   && prior_previous_character == '\t'
+                   && previous_character != '\t'
+                   && FETCH_BYTE (IT_BYTEPOS (*it)) != '\n'
+                   && previous_hpos > it->lnum_pixel_width / frame_char_width
+                   && prior_previous_hpos == 0
+                   && prior_previous_relative_x < it->lnum_pixel_width
+                   && previous_relative_x >= it->lnum_pixel_width
+                   && opoint_x < previous_relative_x)
+            {
+              flavor = MC_GLYPH_TAB;
+              temp_bg_face_id = prior_previous_face_id;
+            }
+/* it->w->hscroll == 0
+	Hello
+*/
+          else if (tab_invisible_p
+                   && it->w->hscroll == 0
+                   && prior_previous_character == '\t'
+                   && previous_character != '\t'
+                   && FETCH_BYTE (IT_BYTEPOS (*it)) != '\n'
+                   && opoint_x < previous_relative_x)
+            {
+              flavor = MC_GLYPH_TAB;
+              temp_bg_face_id = prior_previous_face_id;
+            }
+          else if (final_loop_p
+                   && tab_invisible_p
+                   && rc == MOVE_LINE_CONTINUED
+                   && FETCH_BYTE (IT_BYTEPOS (*it)) == '\t')
+            {
+              flavor = MC_GLYPH_TAB;
+              temp_bg_face_id = prior_previous_face_id;
+            }
+          else if (final_loop_p
+                   && opoint_x > it->lnum_pixel_width
+                   && (previous_relative_x >= opoint_x
+                       || opoint_x < relative_x))
+            flavor = MC_GLYPH;
+          else if (opoint_x == it->lnum_pixel_width)
+            {
+              flavor = MC_GLYPH;
+              temp_bg_face_id = it->face_id;
+            }
+          else
+            {
+              flavor = MC_GLYPHLESS;
+              temp_bg_face_id = it->face_id;
+            }
+          /* CORNER CASES:
+          -  When the vertical line is to the left of the text and just to the
+             right of the line numbers, we want the default face.
+          -  When there is an imaginary empty line at the end of the buffer with
+             nothing other than ZV, we want to use the frame default face if ZV
+             is at the end of an active region. */
+          if (region_active_p
+              && flavor != MC_GLYPH_TAB)
+            {
+              /* Subsequent to `region_end` and at the end of a line. */
+              if (opoint_x >= it->lnum_pixel_width
+                  && IT_CHARPOS (*it) >= region_end
+                  && (ITERATOR_AT_END_OF_LINE_P (it)
+                      || FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'))
+                temp_bg_face_id = it->face_id;
+              /* Subsequent to `region_end` and at the end of a line. */
+              else if (opoint_x >= it->lnum_pixel_width
+                       && IT_CHARPOS (*it) == region_end
+                       && IT_CHARPOS (*it) == ZV)
+                temp_bg_face_id = DEFAULT_FACE_ID;
+              /* Prior to `region_beginning` and at the end of a line. */
+              else if (opoint_x >= it->lnum_pixel_width
+                       && IT_CHARPOS (*it) < region_beginning
+                       && (ITERATOR_AT_END_OF_LINE_P (it)
+                           || FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'))
+                temp_bg_face_id = it->face_id;
+              /* -  Within the region.
+                 -  `real_phys_cursor_glyph` is NULL. */
+              else if (IT_CHARPOS (*it) >= region_beginning
+                       && IT_CHARPOS (*it) < region_end
+                       && real_phys_cursor_glyph == NULL)
+                temp_bg_face_id = previous_face_id;
+              /* -  Within the region.
+                 -  `real_phys_cursor_glyph` is non-NULL.
+                 -  At the end of the line.
+                 -  PT is at `region_beginning`. */
+              else if (IT_CHARPOS (*it) >= region_beginning
+                       && IT_CHARPOS (*it) < region_end
+                          && (ITERATOR_AT_END_OF_LINE_P (it)
+                              || FETCH_BYTE (IT_BYTEPOS (*it)) == '\n')
+                          && real_phys_cursor_glyph != NULL
+                          && PT == region_beginning)
+                temp_bg_face_id = real_phys_cursor_glyph->face_id;
+              /* -  Within the region.
+                 -  `real_phys_cursor_glyph` is non-NULL.
+                 -  At the end of the line.
+                 -  PT is at `region_region_end`. */
+              else if (IT_CHARPOS (*it) >= region_beginning
+                       && IT_CHARPOS (*it) < region_end
+                       && (ITERATOR_AT_END_OF_LINE_P (it)
+                           || FETCH_BYTE (IT_BYTEPOS (*it)) == '\n')
+                       && real_phys_cursor_glyph != NULL
+                       && PT == region_end)
+                /* temp_bg_face_id = real_phys_cursor_glyph->face_id; */
+                /* temp_bg_face_id = lookup_named_face (it->w, it->f, intern ("region"), true); */
+                temp_bg_face_id = it->face_id;
+              /* -  Within the region.
+                 -  `real_phys_cursor_glyph` is non-NULL.
+                 -  Not at the end of the line. */
+              else if (IT_CHARPOS (*it) >= region_beginning
+                       && IT_CHARPOS (*it) < region_end
+                       && (!ITERATOR_AT_END_OF_LINE_P (it)
+                           || FETCH_BYTE (IT_BYTEPOS (*it)) != '\n')
+                       && real_phys_cursor_glyph != NULL)
+                temp_bg_face_id = previous_face_id;
+            }
+          int temp_hpos =
+            (opoint_x == it->lnum_pixel_width)
+              ? it->lnum_pixel_width / frame_char_width
+            : (it->w->hscroll > 0
+               && !hscl_temporary_p
+               && opoint_x < it->lnum_pixel_width)
+              /* If point is to the left of the line numbers when scrolling
+              horizontally, then we want the vertical line to align with right edge
+              of the line numbers. */
+              ? (it->lnum_pixel_width / frame_char_width) - 1
+            : (NILP (Vdisplay_line_numbers)
+               && !final_loop_p
+               && it->current_x == 0
+               && previous_hpos == 0)
+              ? 0
+            /* EOL ¶ is exactly 2nd to the right of the line numbers. */
+            : (!tab_invisible_p
+               && FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'
+               && relative_x > it->lnum_pixel_width
+               && previous_relative_x < it->lnum_pixel_width
+               && previous_hpos == 0
+               && it->lnum_pixel_width > 0)
+              ? (it->lnum_pixel_width / frame_char_width) + 1
+            /* EOL ¶*/
+            : (it->w->hscroll == 0
+               && relative_x <= opoint_x
+               && opoint_x < relative_x + frame_char_width
+               && (FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'
+                   || FETCH_BYTE (IT_BYTEPOS (*it)) == '\f')
+               && rc != MOVE_POS_MATCH_OR_ZV
+               && rc != MOVE_LINE_CONTINUED
+               && relative_x >= it->lnum_pixel_width
+               && opoint_x > it->lnum_pixel_width
+               && previous_hpos != 0)
+              ? previous_hpos + 1
+/* it->w->hscroll > 0 && !hscl_temporary_p
+		¶ */
+            : (action_type == VERTICAL_RULER
+                && it->w->hscroll > 0
+                && !hscl_temporary_p
+                && ante_prior_previous_character != '\t' /* » */
+                && prior_previous_character == '\t'
+                && previous_fetch_byte == '\n'
+                && FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'
+                && opoint_x == previous_relative_x
+                && opoint_x == relative_x
+                && opoint_hpos == previous_hpos
+                && opoint_hpos == it->hpos)
+              ? previous_hpos
+/* it->w->hscroll > 0 && !hscl_temporary_p
+	Hello
+*/
+            : (tab_invisible_p
+               && it->w->hscroll > 0
+               && !hscl_temporary_p
+               && ante_prior_previous_character == '\t'
+               && prior_previous_character != '\t'
+               && previous_character != '\t'
+               && FETCH_BYTE (IT_BYTEPOS (*it)) != '\n'
+               && ante_prior_previous_hpos == 0
+               && prior_previous_hpos == 0
+               && previous_hpos > it->lnum_pixel_width / frame_char_width
+               && ante_prior_previous_relative_x < it->lnum_pixel_width
+               && prior_previous_relative_x < it->lnum_pixel_width
+               && previous_relative_x >= it->lnum_pixel_width
+               && opoint_x < previous_relative_x)
+              ? it->lnum_pixel_width / frame_char_width
+/* it->w->hscroll > 0 && !hscl_temporary_p
+	Hello
+*/
+            : (tab_invisible_p
+               && it->w->hscroll > 0
+               && !hscl_temporary_p
+               && prior_previous_character == '\t'
+               && previous_character != '\t'
+               && FETCH_BYTE (IT_BYTEPOS (*it)) != '\n'
+               && previous_hpos > it->lnum_pixel_width / frame_char_width
+               && prior_previous_hpos == 0
+               && prior_previous_relative_x < it->lnum_pixel_width
+               && previous_relative_x >= it->lnum_pixel_width
+               && opoint_x < previous_relative_x)
+              ? it->lnum_pixel_width / frame_char_width
+/* it->w->hscroll > 0 && !hscl_temporary_p
+Hello
+*/
+            : (!tab_invisible_p
+               && it->w->hscroll > 0
+               && !hscl_temporary_p
+               && prior_previous_character != '\t'
+               && previous_character != '\t'
+               && FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'
+               && previous_hpos < it->hpos
+               && opoint_x >= relative_x)
+              ? previous_hpos + 1
+            /* This situation may exist when point is on a composite character
+            and opoint_x is to the immediate right of the line numbers or just
+            a tad beyond the immediate right of the line numbers. */
+            : (previous_hpos == 0
+               && relative_x == it->lnum_pixel_width)
+              ? it->lnum_pixel_width / frame_char_width
+            : (flavor == MC_GLYPH
+               && previous_relative_x > opoint_x
+               && opoint_x != it->lnum_pixel_width
+               && prior_previous_relative_x >= it->lnum_pixel_width
+               && prior_previous_hpos >= it->lnum_pixel_width / frame_char_width)
+              ? prior_previous_hpos
+            : (flavor == MC_GLYPH
+               && previous_relative_x > opoint_x
+               && opoint_x != it->lnum_pixel_width
+               && prior_previous_relative_x < it->lnum_pixel_width
+               && prior_previous_hpos < it->lnum_pixel_width / frame_char_width)
+              ? it->lnum_pixel_width / frame_char_width
+            : (!tab_invisible_p
+               && it->w->hscroll > 0
+               && hscl_temporary_p
+               && opoint_x < it->current_x
+               && opoint_x == relative_x)
+               ? previous_hpos + 1
+            : previous_hpos;
+          int temp_x = 0;
+          /* EOL ¶*/
+          if (flavor == MC_GLYPH
+              && relative_x <= opoint_x
+              && opoint_x < relative_x + frame_char_width
+              && (FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'
+                  || FETCH_BYTE (IT_BYTEPOS (*it)) == '\f')
+              && rc != MOVE_POS_MATCH_OR_ZV
+              && rc != MOVE_LINE_CONTINUED
+              && relative_x >= it->lnum_pixel_width
+              && opoint_x > it->lnum_pixel_width)
+            temp_x = relative_x;
+            else if (flavor == MC_GLYPH
+                     && previous_relative_x > opoint_x
+                     && opoint_x != it->lnum_pixel_width
+                     && prior_previous_relative_x >= it->lnum_pixel_width
+                     && prior_previous_hpos >= it->lnum_pixel_width / frame_char_width)
+              temp_x = prior_previous_relative_x;
+              else if (flavor == MC_GLYPH
+                       && previous_relative_x > opoint_x
+                       && opoint_x != it->lnum_pixel_width
+                       && prior_previous_relative_x < it->lnum_pixel_width
+                       && prior_previous_hpos < it->lnum_pixel_width / frame_char_width)
+                temp_x = it->lnum_pixel_width;
+                else if (flavor == MC_GLYPH
+                         && final_loop_p
+                         && rc != MOVE_LINE_CONTINUED
+                         && opoint_x < relative_x
+                         && opoint_x != it->lnum_pixel_width)
+                  temp_x = previous_relative_x;
+                  /* It is okay to use MC_GLYPH for a word-wrapped line. */
+                  else if (flavor == MC_GLYPH
+                           && rc == MOVE_LINE_CONTINUED
+                           && FETCH_BYTE (IT_BYTEPOS (*it)) == ' '
+                           && previous_relative_x < opoint_x)
+                    temp_x = previous_relative_x;
+                    else
+                      temp_x = opoint_x;
+          int temp_vpos = vpos;
+          if (!mc_stderr_p)
+            mc_stderr_2 (it, count, action_type, relative_x, temp_x, temp_hpos,
+                         temp_vpos, foreground, temp_bg_face_id, cursor_type,
+                         flavor);
+          /* Record some of the current values for the cursor and glyph_row. */
+          int fx, fy, h;
+          mc_get_phys_cursor_geometry (it->w, glyph_row, temp_x, &fx,
+                                       glyph_row->y, &fy, temp_hpos, temp_vpos,
+                                       &h, cursor_type, cursor_width);
+          fx = WINDOW_TEXT_TO_FRAME_PIXEL_X (it->w, opoint_x);
+          if (flavor == MC_VERTICAL_BAR_RIGHT_ANGLE
+              || flavor == MC_VERTICAL_BAR_BACKSLASH
+              || flavor == MC_VERTICAL_BAR)
+            cursor_type = RIGHT_FRINGE_BITMAP;
+          mc_helper (it->w, temp_x, fx, it->current_y, -1, temp_hpos, temp_vpos,
+                     h, cursor_type, cursor_width, foreground,
+                     mc_bg_lsl (it->w, temp_bg_face_id), active_cursor_p, flavor,
+                     IT_CHARPOS (*it) -1, result);
+          return;
+          /* Do NOT remove this `break` under any circumstances!!!  Without this
+          `break`, the loop continues until `final_loop_p` and places an
+          erroneous second fake cursor over the first one.  That error is visible
+          when dealing with `MC_GLYPH_TAB` because the wrong face_id is used.
+          The error is difficult to debug because `opoint_x` is correct. */
+        }
+      break;
+    }
+  }
+/* --------------------------------------------------------------------------- */
+/*                          Store Values for Next Loop                         */
+/* --------------------------------------------------------------------------- */
+      if (it->current_x > previous_it_current_x)
+        {
+          int diff_previous_v_current_x = it->current_x - previous_it_current_x;
+          int diff_previous_v_relative_x = relative_x - previous_relative_x;
+          /* fetch_byte */
+          ante_prior_previous_fetch_byte = prior_previous_fetch_byte;
+          prior_previous_fetch_byte = previous_fetch_byte;
+          previous_fetch_byte = (it->c > 0)
+                                 ? FETCH_BYTE (IT_BYTEPOS (*it))
+                                 : 0;
+          /* character */
+          ante_prior_previous_character = prior_previous_character;
+          prior_previous_character = previous_character;
+          previous_character = it->c;
+          /* face_id */
+          ante_prior_previous_face_id = prior_previous_face_id;
+          prior_previous_face_id = previous_face_id;
+          previous_face_id = it->face_id;
+          /* relative_x */
+          ante_prior_previous_relative_x = prior_previous_relative_x;
+          prior_previous_relative_x = previous_relative_x;
+          if (diff_previous_v_current_x != diff_previous_v_relative_x
+              && previous_relative_x >= it->lnum_pixel_width)
+            {
+              if (!mc_stderr_p)
+                fprintf (stderr, "\nDIFF (%d / %d):  Sound the alarm!\n",
+                         diff_previous_v_current_x, diff_previous_v_relative_x);
+              previous_relative_x += diff_previous_v_current_x;
+            }
+            else if (issue_31716_p
+                     && relative_x < it->lnum_pixel_width
+                     && previous_hpos == 0)
+              previous_relative_x = it->current_x - it->first_visible_x;
+              else
+                previous_relative_x = relative_x;
+          /* it->current_x */
+          ante_prior_previous_it_current_x = prior_previous_it_current_x;
+          prior_previous_it_current_x = previous_it_current_x;
+          previous_it_current_x = it->current_x;
+          /* it->hpos */
+          ante_prior_previous_it_hpos = prior_previous_it_hpos;
+          prior_previous_it_hpos = previous_it_hpos;
+          previous_it_hpos = it->hpos;
+          /* previous_hpos */
+          ante_prior_previous_hpos = prior_previous_hpos;
+          prior_previous_hpos = previous_hpos;
+          previous_hpos += (issue_31716_p
+                            && relative_x < it->lnum_pixel_width
+                            && previous_hpos == 0)
+                             ? (it->lnum_pixel_width / frame_char_width) + 1
+                           : (previous_hpos == 0
+                              && relative_x > it->lnum_pixel_width
+                              && !NILP (Vdisplay_line_numbers)
+                              && !EQ (Vdisplay_line_numbers, Qvisual))
+                             ? (it->lnum_pixel_width / frame_char_width) + 1
+                           : (previous_hpos == 0
+                              && relative_x > it->lnum_pixel_width
+                              && !NILP (Vdisplay_line_numbers)
+                              && EQ (Vdisplay_line_numbers, Qvisual))
+                             ? (it->lnum_pixel_width / frame_char_width) + 1
+                           : (previous_hpos == 0
+                              && NILP (Vdisplay_line_numbers)
+                              && final_loop_p
+                              && it->current_x == 0)
+                             ? 0
+                           : (relative_x > it->lnum_pixel_width)
+                             ? 1
+                           : 0;
+        }
+        else if (it->c == 0
+                 && count == 1)
+          previous_fetch_byte = 0;
+          else if (previous_fetch_byte == 0
+                   && count == 2)
+            {
+              previous_fetch_byte = FETCH_BYTE (IT_BYTEPOS (*it));
+              previous_character = it->c;
+              previous_face_id == it->face_id;
+            }
+/* --------------------------------------------------------------------------- */
+/*                                 Move to X                                   */
+/* --------------------------------------------------------------------------- */
+      if (!final_loop_p)
+        {
+          struct it saved_it;
+          void *saved_itdata = bidi_shelve_cache ();
+          SAVE_IT (saved_it, *it, saved_itdata);
+          new_x += 1;
+          rc = move_it_in_display_line_to (it, ZV, new_x, MOVE_TO_POS | MOVE_TO_X);
+          /* When word-wrap is on, TO_X may lie past the end of a wrapped line.
+          Then it->current is the character on the next line, so backtrack to the
+          space before the wrap point.  */
+          if (it->line_wrap == WORD_WRAP
+              && rc == MOVE_LINE_CONTINUED)
+            RESTORE_IT (it, &saved_it, saved_itdata);
+          /* Workaround for bug #28936 -- correct the erroneous MOVE_POS_MATCH_OR_ZV.
+          #28936:  `move_it_in_display_line_to' returns MOVE_POS_MATCH_OR_ZV
+          before reaching ZV when the latter is at the end of the line AND `word-wrap'
+          is non-nil:  abcdefg[ZV].  The workaround is to add an extra check using
+          IT_CHARPOS and comparing it to ZV. */
+          if (it->current_x == new_x
+              && rc == MOVE_POS_MATCH_OR_ZV
+              && IT_CHARPOS (*it) != ZV)
+            rc = MOVE_X_REACHED;
+          bidi_unshelve_cache (saved_itdata, true);
+        }
+    }
+}
+/* MULTIPLE_CURSORS_CACHE:
+-  The first element is compared to the `multiple-cursors-conf' to determine whether we need to
+   recalculate coordinates.  [We also check whether window-start/window-end changed.]
+-  The second element contains all previously calculated coordinates.
+-  The third element is the buffer where the `w->multiple_cursors_cache' was set.  Because the
+   `w->multiple_cursors_cache' is window-local, we need to check both the window and the buffer.
+     (((22 20 2 0 cursor_type cursor_width foreground background active_cursor_p flavor posint)
+       (33 20 3 0 cursor_type cursor_width foreground background active_cursor_p flavor posint)
+       (44 20 4 0 cursor_type cursor_width foreground background active_cursor_p flavor posint)
+       (55 20 5 0 cursor_type cursor_width foreground background active_cursor_p flavor posint)
+       (66 20 6 0 cursor_type cursor_width foreground background active_cursor_p flavor posint)
+       (77 20 7 0 cursor_type cursor_width foreground background active_cursor_p flavor posint))
+      (WINDOW where `w->multiple_cursors_cache' was set.)
+      (BUFFER where `w->multiple_cursors_cache' was set.)) */
+/* If REMOVE is 0, then draw fake cursors.  If REMOVE is 1, then erase fake cursors. */
+
+void
+mc_draw_multiple_cursors (struct window *w, bool active_cursor_p)
+{
+/*
+#ifdef GLYPH_DEBUG
+  clock_t start, end;
+  double cpu_time_used;
+  char buf_time[DBL_BUFSIZE_BOUND];
+  start = clock();
+#endif
+*/
+#ifdef GLYPH_DEBUG
+  if (trace_redisplay_p
+      && (!NILP (BVAR (XBUFFER (w->contents), multiple_cursors_conf))
+          || !NILP (BVAR (XBUFFER (w->contents), crosshairs))))
+    {
+      Lisp_Object window;
+      XSETWINDOW (window, w);
+      Lisp_Object window_string = Fprin1_to_string (window, Qnil);
+      char *window_char = SSDATA (window_string);
+      fprintf (stderr, "mc_draw_multiple_cursors (%s)\n", window_char);
+    }
+#endif
+  ptrdiff_t opoint_pt = PT;
+  int opoint_x = w->phys_cursor.x;
+  int opoint_y = w->phys_cursor.y;
+  int opoint_hpos = w->phys_cursor.hpos;
+  int opoint_vpos = w->phys_cursor.vpos;
+  struct frame *f = XFRAME (w->frame);
+  Lisp_Object buf = w->contents;
+  CHECK_BUFFER (buf);
+  struct buffer *b = XBUFFER (buf);
+  struct buffer *old_buffer = NULL;
+  Lisp_Object window;
+  XSETWINDOW (window, w);
+  /* When swiching to another buffer (e.g., a new buffer), `w->contents` may not
+  necessarily be the `current_buffer`.  In such a case, all calculations would
+  be wrong unless `w->contents` is set as the `current_buffer`.  This avoids
+  errors that are time consuming to debug:  break args_out_of_range */
+  if (b != current_buffer)
+    {
+      old_buffer = current_buffer;
+      set_buffer_internal (b);
+    }
+  /* `start_display' calls `init_iterator' which crashes Emacs if:
+  eassert (charpos < 0 || (charpos >= BUF_BEG (current_buffer) && charpos <= ZV))
+  eassert (charpos == BYTE_TO_CHAR (bytepos))
+  This happens when multiple cursors are active and the user types:  M-x .... */
+  ptrdiff_t charpos = marker_position (w->start);
+  struct text_pos start_text_position;
+  SET_TEXT_POS_FROM_MARKER (start_text_position, w->start);
+  ptrdiff_t bytepos = BYTEPOS (start_text_position);
+  bool barf_crash_one = (charpos < 0 || (charpos >= BUF_BEG (current_buffer) && charpos <= ZV)) ? false : true;
+  if (barf_crash_one)
+    {
+      if (old_buffer)
+        set_buffer_internal (old_buffer);
+      return;
+    }
+  bool barf_crash_two = (charpos == BYTE_TO_CHAR (bytepos)) ? false : true;
+  if (barf_crash_two)
+    {
+      if (old_buffer)
+        set_buffer_internal (old_buffer);
+      return;
+    }
+  /* `matrix_row' in `dispnew.c` contains the following tests,
+  eassert (matrix && matrix->rows);
+  eassert (row >= 0 && row < matrix->nrows); */
+  bool barf_crash_three = (w->current_matrix && w->current_matrix->rows) ? false : true;
+  if (barf_crash_three)
+    {
+      if (old_buffer)
+        set_buffer_internal (old_buffer);
+      return;
+    }
+  bool barf_crash_four = (opoint_vpos >= 0 && opoint_vpos < w->current_matrix->nrows) ? false : true;
+  if (barf_crash_four)
+    {
+      if (old_buffer)
+        set_buffer_internal (old_buffer);
+      return;
+    }
+  struct it it;
+  void *itdata = bidi_shelve_cache ();
+  struct it saved_it_for_window_start;
+  void *saved_itdata_for_window_start = NULL;
+  ptrdiff_t it_start, it_end;
+  int first_x, last_x;
+  int lnum_width = 0;
+  int lnum_pixel_width = 0;
+  int new_x = 0;
+  ptrdiff_t posint = -1;
+  int x, fx, y, fy, hpos, vpos, h;
+  enum text_cursor_kinds cursor_type;
+  int cursor_width = 1;
+  Lisp_Object specs, lisp_type, foreground, vlist, fourteen_elements;
+  int flavor;
+  Lisp_Object background = Qnil;
+  Lisp_Object temp = Qnil;
+  Lisp_Object result = Qnil;
+  start_display (&it, w, start_text_position);
+  first_x = it.first_visible_x;
+  last_x = it.last_visible_x;
+  it_start = IT_CHARPOS (it);
+  it_end = BUF_Z (XBUFFER (w->contents)) - w->window_end_pos;
+  SAVE_IT (saved_it_for_window_start, it, saved_itdata_for_window_start);
+  /* Finish priming the IT for potential line numbers. */
+  if (!NILP (Vdisplay_line_numbers)
+      && !EQ (Vdisplay_line_numbers, Qvisual))
+    {
+      it.first_visible_x = 0;
+      move_it_by_lines (&it, 1);
+      lnum_width = it.lnum_width;
+      lnum_pixel_width = it.lnum_pixel_width;
+      RESTORE_IT (&it, &saved_it_for_window_start, saved_itdata_for_window_start);
+      it.first_visible_x = first_x;
+      it.last_visible_x = last_x;
+      it.lnum_width = lnum_width;
+      it.lnum_pixel_width = lnum_pixel_width;
+      SAVE_IT (saved_it_for_window_start, it, saved_itdata_for_window_start);
+    }
+/* ******************************************************************************
+                           ERASE THE REAL _INACTIVE_ CURSOR
+****************************************************************************** */
+  /* `display_and_set_cursor' properly sets `w->phys_cursor.x/y/hpos/vpos` when
+  the cursor is ON. */
+/* `w->phys_cursor.x/y/hpos/vpos` are incorrect after evaluating (scroll-left 1)
+a couple of times.  Redisplay erases the real cursor almost immediately after
+`mc_draw_crosshairs' runs its course -- almost too quickly to see it happening.
+The character where Emacs thinks the real cursor is located gets redrawn, albiet
+without the real cursor.  Emacs thinks the real cursor is one character to the
+right of where it should be -- this is most likely due to an incorrect HPOS.
+This phenomena does not occur when (scroll-left 1) is called interactively; e.g.,
+horizontal scroll wheel.  Inasmuch as `erase_phys_cursor' updates more than
+merely the aforementioned coordinates, resetting those coordinates after the fact
+is insufficient to fix the problem.  We use `w->output_cursor.x/y/hpos/vpos`
+because those coordinates are correct.  We fix `w->phys_cursor.x/y/hpos/vpos`
+BEFORE calling `erase_phys_cursor' so that other goodies are updated. */
+  if (w->hscroll > 0)
+    {
+      w->phys_cursor.x = w->output_cursor.x;
+      w->phys_cursor.y = w->output_cursor.y;
+      w->phys_cursor.hpos = w->output_cursor.hpos;
+      w->phys_cursor.vpos = w->output_cursor.vpos;
+    }
+  erase_phys_cursor (w);
+/* ******************************************************************************
+                          REPLACE THE REAL CURSOR
+****************************************************************************** */
+  ptrdiff_t current_col;
+  bool fill_column_p = !NILP (BVAR (b, fill_column));
+  ptrdiff_t fill_col = XFIXNUM (BVAR (b, fill_column));
+  enum face_id even_face_id =
+    (!active_cursor_p
+     && !NILP (BVAR (XBUFFER (w->contents), crosshairs_inactive_windows)))
+    ? lookup_named_face (w, f, intern ("+-even-numbered-column-inactive-face"), true)
+    : lookup_named_face (w, f, intern ("+-even-numbered-column-face"), true);
+  struct face *even_face = FACE_FROM_ID (f, even_face_id);
+  Lisp_Object even_color = even_face->lface[LFACE_FOREGROUND_INDEX];
+  CHECK_STRING (even_color);
+  Lisp_Object even_color_vector = mc_color_vector_calc (w, even_color);
+  enum face_id odd_face_id =
+    (!active_cursor_p
+     && !NILP (BVAR (XBUFFER (w->contents), crosshairs_inactive_windows)))
+    ? lookup_named_face (w, f, intern ("+-odd-numbered-column-inactive-face"), true)
+    : lookup_named_face (w, f, intern ("+-odd-numbered-column-face"), true);
+  struct face *odd_face = FACE_FROM_ID (f, odd_face_id);
+  Lisp_Object odd_color = odd_face->lface[LFACE_FOREGROUND_INDEX];
+  CHECK_STRING (odd_color);
+  Lisp_Object odd_color_vector = mc_color_vector_calc (w, odd_color);
+  enum face_id fill_face_id =
+    (!active_cursor_p
+     && !NILP (BVAR (XBUFFER (w->contents), crosshairs_inactive_windows)))
+    ? lookup_named_face (w, f, intern ("+-beyond-fill-column-inactive-face"), true)
+    : lookup_named_face (w, f, intern ("+-beyond-fill-column-face"), true);
+  struct face *fill_face = FACE_FROM_ID (f, fill_face_id);
+  Lisp_Object fill_color = fill_face->lface[LFACE_FOREGROUND_INDEX];
+  CHECK_STRING (fill_color);
+  Lisp_Object fill_color_vector = mc_color_vector_calc (w, fill_color);
+  struct glyph_row *glyph_row = MATRIX_ROW (w->current_matrix, opoint_vpos);
+  struct glyph *phys_cursor_glyph;
+  int face_id = ((phys_cursor_glyph = get_phys_cursor_glyph (w)) == NULL)
+                 ? DEFAULT_FACE_ID
+                 : phys_cursor_glyph->face_id;
+  int opoint_fx = -1;
+  int opoint_fy = -1;
+  int opoint_h = -1;
+  /* FIXME:  Put in some code to default to HOLLOW_BOX_CURSOR if the user has
+  unwittingly come up with some unacceptable form of unrecognized cursor type. */
+  Lisp_Object cursor_lisp_type = BVAR (b, mc_real_fake_cursor);
+  enum text_cursor_kinds temp_cursor_type = (CONSP (cursor_lisp_type))
+                                             ? mc_lisp_to_cursor_type (XCAR (cursor_lisp_type))
+                                             : mc_lisp_to_cursor_type (cursor_lisp_type);
+  int temp_cursor_width = (CONSP (cursor_lisp_type))
+                           ? XFIXNUM (XCAR (XCDR (cursor_lisp_type)))
+                           : 1;
+  enum face_id cursor_face_id =
+    (!active_cursor_p
+     && !NILP (BVAR (XBUFFER (w->contents), crosshairs_inactive_windows)))
+    ? lookup_named_face (w, f, intern ("+-real-fake-cursor-inactive-face"), true)
+    : lookup_named_face (w, f, intern ("+-real-fake-cursor-face"), true);
+  struct face *cursor_face = FACE_FROM_ID (f, cursor_face_id);
+  Lisp_Object cursor_color = cursor_face->lface[LFACE_FOREGROUND_INDEX];
+  CHECK_STRING (cursor_color);
+  if (opoint_pt >= it_start
+      && opoint_pt <= it_end)
+    {
+      RESTORE_IT (&it, &saved_it_for_window_start, saved_itdata_for_window_start);
+      move_it_to (&it, opoint_pt, it.last_visible_x, it.last_visible_y - 1, -1,
+                  MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y);
+    }
+  if (IT_CHARPOS (it) == opoint_pt)
+    {
+      int voffset = it.vpos;
+      current_col = mc_current_column (w, opoint_pt);
+      /* red */
+      if (current_col % 2 != 0
+          && !fill_column_p)
+        foreground = odd_color_vector;
+      /* yellow */
+      if (current_col % 2 == 0
+          && !fill_column_p)
+        foreground = even_color_vector;
+      /* red */
+      if (current_col % 2 != 0
+          && fill_column_p
+          && current_col <= fill_col)
+        foreground = odd_color_vector;
+      /* yellow */
+      if (current_col % 2 == 0
+          && fill_column_p
+          && current_col <= fill_col)
+        foreground = even_color_vector;
+      /* green */
+      if (fill_column_p
+          && current_col > fill_col)
+        foreground = fill_color_vector;
+      Lisp_Object cursor_fg = (active_cursor_p)
+                              ? foreground
+                              : mc_color_vector_calc (w, cursor_color);
+      RESTORE_IT (&it, &saved_it_for_window_start, saved_itdata_for_window_start);
+      move_it_by_lines (&it, voffset);
+      mc_move_it (&it, opoint_pt, temp_cursor_type, temp_cursor_width, cursor_fg, active_cursor_p, MULTIPLE_CURSORS, &result);
+    }
+    else
+      {
+        x = -1;
+        fx = -1;
+        y = -1;
+        fy = -1;
+        hpos = -1;
+        vpos = -1;
+        h = -1;
+        foreground = mc_fg_lsl (it.w, DEFAULT_FACE_ID);
+        background = mc_bg_lsl (it.w, DEFAULT_FACE_ID);
+        flavor = MC_GLYPH;
+        fourteen_elements = listn (CONSTYPE_HEAP, 14,
+                                 make_fixnum (x),
+                                 make_fixnum (fx),
+                                 make_fixnum (y),
+                                 make_fixnum (fy),
+                                 make_fixnum (hpos),
+                                 make_fixnum (vpos),
+                                 make_fixnum (h),
+                                 mc_cursor_type_to_lisp (temp_cursor_type),
+                                 make_fixnum (cursor_width),
+                                 foreground,
+                                 background,
+                                 make_fixnum (active_cursor_p),
+                                 make_fixnum (flavor),
+                                 make_fixnum (opoint_pt));
+        specs = listn (CONSTYPE_HEAP, 3, make_fixnum (opoint_pt),
+                                         mc_cursor_type_to_lisp (temp_cursor_type),
+                                         foreground);
+        temp = Fcons (specs, Fcons (fourteen_elements, Qnil));
+        result = Fcons (temp, result);
+      }
+/* *************************************************************************** */
+  for (vlist = BVAR (b, multiple_cursors_conf);
+       CONSP (vlist);
+       vlist = XCDR (vlist))
+    {
+      specs = XCAR (vlist);
+      posint = XFIXNUM (Fnth (make_fixnum (0), specs));
+      lisp_type = Fnth (make_fixnum (1), specs);
+      if (CONSP (lisp_type))
+        cursor_type = mc_lisp_to_cursor_type (XCAR (lisp_type));
+        else
+          cursor_type = mc_lisp_to_cursor_type (lisp_type);
+      if (CONSP (lisp_type))
+        cursor_width = XFIXNUM (XCAR (XCDR (lisp_type)));
+        else
+          cursor_width = 1;
+      foreground = Fnth (make_fixnum (2), specs);
+      if (STRINGP (foreground))
+        foreground = mc_color_vector_calc (w, foreground);
+      if (posint >= it_start
+          && posint <= it_end)
+        {
+          RESTORE_IT (&it, &saved_it_for_window_start, saved_itdata_for_window_start);
+          move_it_to (&it, posint, it.last_visible_x, it.last_visible_y - 1, -1,
+                      MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y);
+        }
+      if (IT_CHARPOS (it) == posint)
+        {
+          int voffset = it.vpos;
+          current_col = mc_current_column (w, posint);
+          if (NILP (foreground))
+            {
+              /* red */
+              if (current_col % 2 != 0
+                  && !fill_column_p)
+                foreground = odd_color_vector;
+              /* yellow */
+              if (current_col % 2 == 0
+                  && !fill_column_p)
+                foreground = even_color_vector;
+              /* red */
+              if (current_col % 2 != 0
+                  && fill_column_p
+                  && current_col <= fill_col)
+                foreground = odd_color_vector;
+              /* yellow */
+              if (current_col % 2 == 0
+                  && fill_column_p
+                  && current_col <= fill_col)
+                foreground = even_color_vector;
+              /* green */
+              if (fill_column_p
+                  && current_col > fill_col)
+                foreground = fill_color_vector;
+            }
+          RESTORE_IT (&it, &saved_it_for_window_start, saved_itdata_for_window_start);
+          move_it_by_lines (&it, voffset);
+          mc_move_it (&it, posint, cursor_type, cursor_width, foreground, active_cursor_p, MULTIPLE_CURSORS, &result);
+        }
+        else
+          {
+            x = -1;
+            fx = -1;
+            y = -1;
+            fy = -1;
+            hpos = -1;
+            vpos = -1;
+            h = -1;
+            foreground = mc_fg_lsl (it.w, DEFAULT_FACE_ID);
+            background = mc_bg_lsl (it.w, DEFAULT_FACE_ID);
+            flavor = MC_GLYPH;
+            fourteen_elements = listn (CONSTYPE_HEAP, 14,
+                                     make_fixnum (x),
+                                     make_fixnum (fx),
+                                     make_fixnum (y),
+                                     make_fixnum (fy),
+                                     make_fixnum (hpos),
+                                     make_fixnum (vpos),
+                                     make_fixnum (h),
+                                     mc_cursor_type_to_lisp (cursor_type),
+                                     make_fixnum (cursor_width),
+                                     foreground,
+                                     background,
+                                     make_fixnum (active_cursor_p),
+                                     make_fixnum (flavor),
+                                     make_fixnum (posint));
+            result = Fcons (fourteen_elements, result);
+          }
+    }
+/* `w->multiple_cursors_cache' is set for the window, not buffer+window -- i.e., all buffers appearing
+in the same window via `switch-to-buffer' will have `w->multiple_cursors_cache'.  This behavior
+is consistent with functions such as `set-window-display-table'.  We deal with this in
+`nsterm.m' / `w32term.c' / `xterm.c' by comparing `w->contents' to the value of the `buf'
+stored in `w->multiple_cursors_cache'. */
+  if (!NILP (result))
+    wset_multiple_cursors_cache (w, listn (CONSTYPE_HEAP, 3,
+                                 Freverse (result),
+                                 Fcons (window, Qnil),
+                                 Fcons (w->contents, Qnil)));
+  w->mc.draw_multiple_cursors = false;
+  bidi_unshelve_cache (itdata, false);
+  if (old_buffer)
+    set_buffer_internal (old_buffer);
+/*
+#ifdef GLYPH_DEBUG
+  end = clock();
+  cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC;
+  dtoastr (buf_time, sizeof buf_time, 0, 0, cpu_time_used);
+  debug_method_add (w, "mc_draw_multiple_cursors:  TIME (%s)", buf_time);
+#endif
+*/
+}
+
+void
+mc_redraw_multiple_cursors (struct window *w)
+{
+/*
+#ifdef GLYPH_DEBUG
+  clock_t start, end;
+  double cpu_time_used;
+  char buf_time[DBL_BUFSIZE_BOUND];
+  start = clock();
+#endif
+*/
+#ifdef GLYPH_DEBUG
+  if (trace_redisplay_p
+      && (!NILP (BVAR (XBUFFER (w->contents), multiple_cursors_conf))
+          || !NILP (BVAR (XBUFFER (w->contents), crosshairs))))
+    {
+      Lisp_Object window;
+      XSETWINDOW (window, w);
+      Lisp_Object window_string = Fprin1_to_string (window, Qnil);
+      char *window_char = SSDATA (window_string);
+      fprintf (stderr, "mc_redraw_multiple_cursors (%s)\n", window_char);
+    }
+#endif
+  Lisp_Object vlist = Qnil;
+  Lisp_Object fourteen_elements = Qnil;
+  int x, fx, y, fy, hpos, vpos, h;
+  enum text_cursor_kinds cursor_type;
+  int cursor_width;
+  Lisp_Object foreground = Qnil;
+  Lisp_Object background = Qnil;
+  bool active_cursor_p = false;
+  int flavor;
+  ptrdiff_t posint;
+  for (vlist = XCAR (w->multiple_cursors_cache);
+       CONSP (vlist);
+       vlist = XCDR (vlist))
+    {
+      fourteen_elements = XCAR (vlist);
+      x = XFIXNUM (Fnth (make_fixnum (0), fourteen_elements));
+      fx = XFIXNUM (Fnth (make_fixnum (1), fourteen_elements));
+      y = XFIXNUM (Fnth (make_fixnum (2), fourteen_elements));
+      fy = XFIXNUM (Fnth (make_fixnum (3), fourteen_elements));
+      hpos = XFIXNUM (Fnth (make_fixnum (4), fourteen_elements));
+      vpos = XFIXNUM (Fnth (make_fixnum (5), fourteen_elements));
+      h = XFIXNUM (Fnth (make_fixnum (6), fourteen_elements));
+      cursor_type = mc_lisp_to_cursor_type (Fnth (make_fixnum (7), fourteen_elements));
+      cursor_width = XFIXNUM (Fnth (make_fixnum (8), fourteen_elements));
+      foreground = Fnth (make_fixnum (9), fourteen_elements);
+      background = Fnth (make_fixnum (10), fourteen_elements);
+      active_cursor_p = XFIXNUM (Fnth (make_fixnum (11), fourteen_elements));
+      flavor = XFIXNUM (Fnth (make_fixnum (12), fourteen_elements));
+      posint = XFIXNUM (Fnth (make_fixnum (13), fourteen_elements));
+      mc_draw_erase_hybrid (w, x, fx, y, fy, hpos, vpos, h, cursor_type,
+                            cursor_width, foreground, active_cursor_p, MC_GLYPH, posint);
+    }
+/*
+#ifdef GLYPH_DEBUG
+  end = clock();
+  cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC;
+  dtoastr (buf_time, sizeof buf_time, 0, 0, cpu_time_used);
+  debug_method_add (w, "mc_redraw_multiple_cursors:  TIME (%s)", buf_time);
+#endif
+*/
+}
+
+void
+mc_erase_multiple_cursors (struct window *w, bool delete_cache)
+{
+/*
+#ifdef GLYPH_DEBUG
+  clock_t start, end;
+  double cpu_time_used;
+  char buf_time[DBL_BUFSIZE_BOUND];
+  start = clock();
+#endif
+*/
+#ifdef GLYPH_DEBUG
+  if (trace_redisplay_p
+      && (!NILP (BVAR (XBUFFER (w->contents), multiple_cursors_conf))
+          || !NILP (BVAR (XBUFFER (w->contents), crosshairs))))
+    {
+      Lisp_Object window;
+      XSETWINDOW (window, w);
+      Lisp_Object window_string = Fprin1_to_string (window, Qnil);
+      char *window_char = SSDATA (window_string);
+      fprintf (stderr, "mc_erase_multiple_cursors (%s):  delete_cache (%d)\n", window_char, delete_cache);
+    }
+#endif
+  Lisp_Object vlist = Qnil;
+  Lisp_Object fourteen_elements = Qnil;
+  int x, fx, y, fy, hpos, vpos, h;
+  enum text_cursor_kinds cursor_type;
+  int cursor_width;
+  Lisp_Object foreground = Qnil;
+  Lisp_Object background = Qnil;
+  bool active_cursor_p = false;
+  int flavor;
+  ptrdiff_t posint;
+  mc_erase_glyph_cursors (w, w->phys_cursor.x, w->phys_cursor.y, w->phys_cursor.hpos,
+                          w->phys_cursor.vpos, w->phys_cursor_type, w->phys_cursor_width);
+  for (vlist = XCAR (w->multiple_cursors_cache);
+       CONSP (vlist);
+       vlist = XCDR (vlist))
+    {
+      fourteen_elements = XCAR (vlist);
+      x = XFIXNUM (Fnth (make_fixnum (0), fourteen_elements));
+      fx = XFIXNUM (Fnth (make_fixnum (1), fourteen_elements));
+      y = XFIXNUM (Fnth (make_fixnum (2), fourteen_elements));
+      fy = XFIXNUM (Fnth (make_fixnum (3), fourteen_elements));
+      hpos = XFIXNUM (Fnth (make_fixnum (4), fourteen_elements));
+      vpos = XFIXNUM (Fnth (make_fixnum (5), fourteen_elements));
+      h = XFIXNUM (Fnth (make_fixnum (6), fourteen_elements));
+      cursor_type = mc_lisp_to_cursor_type (Fnth (make_fixnum (7), fourteen_elements));
+      cursor_width = XFIXNUM (Fnth (make_fixnum (8), fourteen_elements));
+      foreground = Fnth (make_fixnum (9), fourteen_elements);
+      background = Fnth (make_fixnum (10), fourteen_elements);
+      active_cursor_p = XFIXNUM (Fnth (make_fixnum (11), fourteen_elements));
+      flavor = XFIXNUM (Fnth (make_fixnum (12), fourteen_elements));
+      posint = XFIXNUM (Fnth (make_fixnum (13), fourteen_elements));
+      if (flavor == MC_GLYPH)
+        mc_erase_glyph_cursors (w, x, y, hpos, vpos, cursor_type, cursor_width);
+        else
+          {
+            if (flavor == MC_OVERLAY_ARROW_BITMAP
+                || flavor == MC_OVERLAY_ARROW_BITMAP_HSCL_TEMPORARY
+                || flavor == MC_HOLLOW_RECTANGLE_RIGHT_ANGLE
+                || flavor == MC_HOLLOW_RECTANGLE
+                || flavor == MC_VERTICAL_BAR_RIGHT_ANGLE
+                || flavor == MC_VERTICAL_BAR
+                || flavor == MC_VERTICAL_BAR_BACKSLASH)
+              cursor_type = NO_FRINGE_BITMAP;
+            mc_draw_erase_hybrid (w, x, fx, y, fy, hpos, vpos, h, cursor_type,
+                                  cursor_width, background, active_cursor_p, flavor, posint);
+          }
+    }
+  if (delete_cache)
+    wset_multiple_cursors_cache (w, Qnil);
+  w->mc.erase_multiple_cursors = false;
+/*
+#ifdef GLYPH_DEBUG
+  end = clock();
+  cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC;
+  dtoastr (buf_time, sizeof buf_time, 0, 0, cpu_time_used);
+  debug_method_add (w, "mc_erase_multiple_cursors:  TIME (%s)", buf_time);
+#endif
+*/
+}
+
+void
+mc_draw_crosshairs (struct window *w, bool active_cursor_p, bool minimal_p)
+{
+/*
+#ifdef GLYPH_DEBUG
+  clock_t start, end;
+  double cpu_time_used;
+  char buf_time[DBL_BUFSIZE_BOUND];
+  start = clock();
+#endif
+*/
+#ifdef GLYPH_DEBUG
+  if (trace_redisplay_p
+      && (!NILP (BVAR (XBUFFER (w->contents), multiple_cursors_conf))
+          || !NILP (BVAR (XBUFFER (w->contents), crosshairs))))
+    {
+      Lisp_Object window;
+      XSETWINDOW (window, w);
+      Lisp_Object window_string = Fprin1_to_string (window, Qnil);
+      char *window_char = SSDATA (window_string);
+      fprintf (stderr, "mc_draw_crosshairs (%s):  active_cursor_p (%d) | minimal_p (%d)\n",
+                        window_char, active_cursor_p, minimal_p);
+    }
+#endif
+  ptrdiff_t opoint_pt = (w == XWINDOW (selected_window))
+                        ? PT
+                        : XFIXNUM (Fmarker_position (w->pointm));
+  int opoint_x = w->phys_cursor.x;
+  int opoint_y = w->phys_cursor.y;
+  int opoint_hpos = w->phys_cursor.hpos;
+  int opoint_vpos = w->phys_cursor.vpos;
+  struct frame *f = XFRAME (w->frame);
+  Lisp_Object buf = w->contents;
+  CHECK_BUFFER (buf);
+  struct buffer *b = XBUFFER (buf);
+  struct buffer *old_buffer = NULL;
+  Lisp_Object window;
+  XSETWINDOW (window, w);
+  /* When swiching to another buffer (e.g., a new buffer), `w->contents` may not
+  necessarily be the `current_buffer`.  In such a case, all calculations would
+  be wrong unless `w->contents` is set as the `current_buffer`.  This avoids
+  errors that are time consuming to debug:  break args_out_of_range */
+  if (b != current_buffer)
+    {
+      old_buffer = current_buffer;
+      set_buffer_internal (b);
+    }
+/* eassert (CHARPOS (pos) >= BEGV && CHARPOS (pos) <= ZV);
+   eassert (charpos == BYTE_TO_CHAR (bytepos));
+   eassert (BUF_BEG_BYTE (b) <= bytepos && bytepos <= BUF_Z_BYTE (b)); */
+  ptrdiff_t charpos = marker_position (w->start);
+  ptrdiff_t bytepos = marker_byte_position (w->start);
+  /* Eli Z.:  If window's start point is invalid, it means the window needs to be
+  redisplayed.  Again, I'm not sure I understand how do you get into this situation
+  in the middle of redisplay. */
+  bool barf_crash_one = (charpos >= BEGV && charpos <= ZV) ? false : true;
+  if (barf_crash_one)
+    {
+      if (old_buffer)
+        set_buffer_internal (old_buffer);
+      return;
+    }
+  /* Eli Z.:  Likewise.  Markers are updated when a buffer is modified, so this
+  should never happen. */
+  bool barf_crash_two = (charpos == BYTE_TO_CHAR (bytepos)) ? false : true;
+  if (barf_crash_two)
+    {
+      if (old_buffer)
+        set_buffer_internal (old_buffer);
+      return;
+    }
+  /* `matrix_row' in `dispnew.c` contains the following tests,
+  eassert (matrix && matrix->rows);
+  eassert (row >= 0 && row < matrix->nrows); */
+  bool barf_crash_three = (w->current_matrix && w->current_matrix->rows) ? false : true;
+  if (barf_crash_three)
+    {
+      if (old_buffer)
+        set_buffer_internal (old_buffer);
+      return;
+    }
+  bool barf_crash_four = (opoint_vpos >= 0 && opoint_vpos < w->current_matrix->nrows) ? false : true;
+  if (barf_crash_four)
+    {
+      if (old_buffer)
+        set_buffer_internal (old_buffer);
+      return;
+    }
+  if (!BUFFERP (buf))
+    {
+      if (old_buffer)
+        set_buffer_internal (old_buffer);
+      return;
+    }
+  if (NILP (BVAR (b, crosshairs)))
+    {
+      if (old_buffer)
+        set_buffer_internal (old_buffer);
+      return;
+    }
+  if (NILP (BVAR (b, crosshairs_horizontal_ruler))
+      && NILP (BVAR (b, crosshairs_vertical_ruler)))
+    {
+      if (old_buffer)
+        set_buffer_internal (old_buffer);
+      return;
+    }
+/* ******************************************************************************
+                              BEGIN JOURNEY ...
+****************************************************************************** */
+  struct it it;
+  void *itdata = bidi_shelve_cache ();
+  struct it saved_it_for_window_start;
+  void *saved_itdata_for_window_start = NULL;
+  struct it saved_it_for_horizontal_ruler;
+  void *saved_itdata_for_horizontal_ruler = NULL;
+  struct text_pos start_text_position;
+  ptrdiff_t it_start;
+  int first_x, last_x;
+  int lnum_width = 0;
+  int lnum_pixel_width = 0;
+  int frame_char_width = FRAME_COLUMN_WIDTH (f);
+  int text_area_width = window_box_width (w, TEXT_AREA);
+  bool cursor_in_fringe_p = w->output_cursor.x + frame_char_width >= text_area_width;
+  struct glyph_row *glyph_row;
+  int header_line_height = WINDOW_HEADER_LINE_HEIGHT (w);
+  int cursor_width = 1;
+  ptrdiff_t posint = -1;
+  bool auto_hscroll_mode_p = EQ (Fbuffer_local_value (Qauto_hscroll_mode, buf), Qcurrent_line);
+  bool hscl_temporary_p = (!w->suspend_auto_hscroll
+                           && auto_hscroll_mode_p
+                           && w->hscroll > 0
+                           && w->min_hscroll == 0);
+/* ******************************************************************************
+                      START DISPLAY AND PRIME IT
+****************************************************************************** */
+  /* Begin the journey at w->start. */
+  SET_TEXT_POS_FROM_MARKER (start_text_position, w->start);
+  start_display (&it, w, start_text_position);
+  first_x = it.first_visible_x;
+  last_x = it.last_visible_x;
+  it_start = IT_CHARPOS (it);
+  SAVE_IT (saved_it_for_window_start, it, saved_itdata_for_window_start);
+  if (it_start > opoint_pt)
+    {
+      bidi_unshelve_cache (itdata, false);
+      if (old_buffer)
+        set_buffer_internal (old_buffer);
+      return;
+    }
+  /* Finish priming the IT for potential line numbers. */
+  if (!NILP (Vdisplay_line_numbers)
+      && !EQ (Vdisplay_line_numbers, Qvisual))
+    {
+      it.first_visible_x = 0;
+      move_it_by_lines (&it, 1);
+      lnum_width = it.lnum_width;
+      lnum_pixel_width = it.lnum_pixel_width;
+      RESTORE_IT (&it, &saved_it_for_window_start, saved_itdata_for_window_start);
+      it.first_visible_x = first_x;
+      it.last_visible_x = last_x;
+      it.lnum_width = lnum_width;
+      it.lnum_pixel_width = lnum_pixel_width;
+      SAVE_IT (saved_it_for_window_start, it, saved_itdata_for_window_start);
+    }
+  ptrdiff_t current_col = mc_current_column (w, opoint_pt);
+  bool fill_column_p = !NILP (BVAR (b, fill_column));
+  ptrdiff_t fill_col = XFIXNUM (BVAR (b, fill_column));
+  Lisp_Object result = Qnil;
+  int flavor;
+  /* Values for the current column of the vertical line. */
+  Lisp_Object foreground = Fmake_vector (make_fixnum (3), Qnil);
+  enum face_id face_id;
+  struct glyph *phys_cursor_glyph;
+/* ******************************************************************************
+                             COLOR OF CROSSHAIRS
+****************************************************************************** */
+  enum face_id even_face_id =
+    (!active_cursor_p
+     && !NILP (BVAR (XBUFFER (w->contents), crosshairs_inactive_windows)))
+    ? lookup_named_face (w, f, intern ("+-even-numbered-column-inactive-face"), true)
+    : lookup_named_face (w, f, intern ("+-even-numbered-column-face"), true);
+  struct face *even_face = FACE_FROM_ID (f, even_face_id);
+  Lisp_Object even_color = even_face->lface[LFACE_FOREGROUND_INDEX];
+  CHECK_STRING (even_color);
+  Lisp_Object even_color_vector = mc_color_vector_calc (w, even_color);
+  enum face_id odd_face_id =
+    (!active_cursor_p
+     && !NILP (BVAR (XBUFFER (w->contents), crosshairs_inactive_windows)))
+    ? lookup_named_face (w, f, intern ("+-odd-numbered-column-inactive-face"), true)
+    : lookup_named_face (w, f, intern ("+-odd-numbered-column-face"), true);
+  struct face *odd_face = FACE_FROM_ID (f, odd_face_id);
+  Lisp_Object odd_color = odd_face->lface[LFACE_FOREGROUND_INDEX];
+  CHECK_STRING (odd_color);
+  Lisp_Object odd_color_vector = mc_color_vector_calc (w, odd_color);
+  enum face_id fill_face_id =
+    (!active_cursor_p
+     && !NILP (BVAR (XBUFFER (w->contents), crosshairs_inactive_windows)))
+    ? lookup_named_face (w, f, intern ("+-beyond-fill-column-inactive-face"), true)
+    : lookup_named_face (w, f, intern ("+-beyond-fill-column-face"), true);
+  struct face *fill_face = FACE_FROM_ID (f, fill_face_id);
+  Lisp_Object fill_color = fill_face->lface[LFACE_FOREGROUND_INDEX];
+  CHECK_STRING (fill_color);
+  Lisp_Object fill_color_vector = mc_color_vector_calc (w, fill_color);
+  /* red */
+  if (current_col % 2 != 0
+      && !fill_column_p)
+    foreground = odd_color_vector;
+  /* yellow */
+  if (current_col % 2 == 0
+      && !fill_column_p)
+    foreground = even_color_vector;
+  /* red */
+  if (current_col % 2 != 0
+      && fill_column_p
+      && current_col <= fill_col)
+    foreground = odd_color_vector;
+  /* yellow */
+  if (current_col % 2 == 0
+      && fill_column_p
+      && current_col <= fill_col)
+    foreground = even_color_vector;
+  /* green */
+  if (fill_column_p
+      && current_col > fill_col)
+    foreground = fill_color_vector;
+/* ******************************************************************************
+                           ERASE THE REAL CURSOR
+****************************************************************************** */
+/* `w->phys_cursor.x/y/hpos/vpos` are incorrect after evaluating (scroll-left 1)
+a couple of times.  Redisplay erases the real cursor almost immediately after
+`mc_draw_crosshairs' runs its course -- almost too quickly to see it happening.
+The character where Emacs thinks the real cursor is located gets redrawn, albiet
+without the real cursor.  Emacs thinks the real cursor is one character to the
+right of where it should be -- this is most likely due to an incorrect HPOS.
+This phenomena does not occur when (scroll-left 1) is called interactively; e.g.,
+horizontal scroll wheel.  Inasmuch as `erase_phys_cursor' updates more than
+merely the aforementioned coordinates, resetting those coordinates after the fact
+is insufficient to fix the problem.  We use `w->output_cursor.x/y/hpos/vpos`
+because those coordinates are correct.  We fix `w->phys_cursor.x/y/hpos/vpos`
+BEFORE calling `erase_phys_cursor' so that other goodies are updated. */
+  if (w->hscroll > 0)
+    {
+      w->phys_cursor.x = w->output_cursor.x;
+      w->phys_cursor.y = w->output_cursor.y;
+      w->phys_cursor.hpos = w->output_cursor.hpos;
+      w->phys_cursor.vpos = w->output_cursor.vpos;
+    }
+  if (!minimal_p)
+    erase_phys_cursor (w);
+/* ******************************************************************************
+                          REPLACE THE REAL CURSOR
+****************************************************************************** */
+  glyph_row = MATRIX_ROW (w->current_matrix, opoint_vpos);
+  if (!cursor_in_fringe_p)
+    flavor = MC_GLYPH;
+    /* This condition probably does not exist for the real fake cursor. */
+    else if (cursor_in_fringe_p
+             && glyph_row->continued_p)
+      flavor = MC_PILCROW;
+      else if (cursor_in_fringe_p
+               && glyph_row->truncated_on_right_p)
+        flavor = MC_HOLLOW_RECTANGLE_RIGHT_ANGLE;
+        else if (cursor_in_fringe_p
+                 && !glyph_row->continued_p
+                 && !glyph_row->truncated_on_right_p)
+          flavor = MC_HOLLOW_RECTANGLE;
+  face_id = ((phys_cursor_glyph = get_phys_cursor_glyph (w)) == NULL)
+              ? DEFAULT_FACE_ID
+              : phys_cursor_glyph->face_id;
+  int opoint_fx = -1;
+  int opoint_fy = -1;
+  int opoint_h = -1;
+  /* FIXME:  Put in some code to default to HOLLOW_BOX_CURSOR if the user has
+  unwittingly come up with some unacceptable form of unrecognized cursor type. */
+  Lisp_Object cursor_lisp_type = BVAR (b, mc_real_fake_cursor);
+  enum text_cursor_kinds temp_cursor_type = (CONSP (cursor_lisp_type))
+                                             ? mc_lisp_to_cursor_type (XCAR (cursor_lisp_type))
+                                             : mc_lisp_to_cursor_type (cursor_lisp_type);
+  if (flavor == MC_PILCROW
+      || flavor == MC_HOLLOW_RECTANGLE_RIGHT_ANGLE
+      || flavor == MC_HOLLOW_RECTANGLE)
+    temp_cursor_type = RIGHT_FRINGE_BITMAP;
+  int temp_cursor_width = (CONSP (cursor_lisp_type))
+                           ? XFIXNUM (XCAR (XCDR (cursor_lisp_type)))
+                           : 1;
+  enum face_id cursor_face_id =
+    (!active_cursor_p
+     && !NILP (BVAR (XBUFFER (w->contents), crosshairs_inactive_windows)))
+    ? lookup_named_face (w, f, intern ("+-real-fake-cursor-inactive-face"), true)
+    : lookup_named_face (w, f, intern ("+-real-fake-cursor-face"), true);
+  struct face *cursor_face = FACE_FROM_ID (f, cursor_face_id);
+  Lisp_Object cursor_color = cursor_face->lface[LFACE_FOREGROUND_INDEX];
+  CHECK_STRING (cursor_color);
+  Lisp_Object cursor_fg = (temp_cursor_type == NO_CURSOR)
+                          ? foreground
+                          : mc_color_vector_calc (w, cursor_color);
+  /* FIXME:  This creates two MC_GLYPH at the same location and needs to be
+  reduced to just one MC_GLYPH, one vertical bar, and one horizontal bar.  The
+  problem with this is that the letter at point gets written twice and will be
+  just a little thicker than as would normally be the case. */
+  if (temp_cursor_type == NO_CURSOR
+      && !minimal_p)
+    {
+      if (flavor == MC_GLYPH)
+        mc_get_phys_cursor_geometry (w, glyph_row, opoint_x, &opoint_fx,
+                                     opoint_y, &opoint_fy, opoint_hpos, opoint_vpos,
+                                     &opoint_h, HBAR_CURSOR, cursor_width);
+      mc_helper (w, opoint_x, opoint_fx, opoint_y, opoint_fy, opoint_hpos,
+                 opoint_vpos, opoint_h, HBAR_CURSOR, cursor_width, cursor_fg,
+                 mc_bg_lsl (w, face_id), active_cursor_p, flavor, opoint_pt,
+                 &result);
+      if (flavor == MC_GLYPH)
+        mc_get_phys_cursor_geometry (w, glyph_row, opoint_x, &opoint_fx,
+                                     opoint_y, &opoint_fy, opoint_hpos, opoint_vpos,
+                                     &opoint_h, BAR_CURSOR, cursor_width);
+      mc_helper (w, opoint_x, opoint_fx, opoint_y, opoint_fy, opoint_hpos,
+                 opoint_vpos, opoint_h, BAR_CURSOR, cursor_width, cursor_fg,
+                 mc_bg_lsl (w, face_id), active_cursor_p, flavor, opoint_pt,
+                 &result);
+    }
+    else if (!minimal_p)
+      {
+        if (flavor == MC_GLYPH)
+          mc_get_phys_cursor_geometry (w, glyph_row, opoint_x, &opoint_fx,
+                                       opoint_y, &opoint_fy, opoint_hpos, opoint_vpos,
+                                       &opoint_h, temp_cursor_type, temp_cursor_width);
+        mc_helper (w, opoint_x, opoint_fx, opoint_y, opoint_fy, opoint_hpos,
+                   opoint_vpos, opoint_h, temp_cursor_type, temp_cursor_width,
+                   cursor_fg, mc_bg_lsl (w, face_id), active_cursor_p, flavor,
+                   opoint_pt, &result);
+      }
+  /* fringe bitmaps use face_id to set the foreground color.  The overlay-arrow
+  is presently the only situation where the `active_cursor_p` and `minimal_p` are
+  used to determine the applicable face_id. */
+  int overlay_arrow_bitmap = (hscl_temporary_p)
+                             ? MC_OVERLAY_ARROW_BITMAP_HSCL_TEMPORARY
+                             : MC_OVERLAY_ARROW_BITMAP;
+  Lisp_Object overlay_arrow_fg = (Fmake_vector (make_fixnum (3), Qnil));
+  ASET (overlay_arrow_fg, 0, make_fixnum (overlay_arrow_bitmap));
+  ASET (overlay_arrow_fg, 1, make_fixnum (active_cursor_p));
+  ASET (overlay_arrow_fg, 2, make_fixnum (minimal_p));
+  mc_helper (w, opoint_x, opoint_fx, opoint_y, opoint_fy, opoint_hpos,
+             opoint_vpos, opoint_h, LEFT_FRINGE_BITMAP, temp_cursor_width,
+             overlay_arrow_fg, mc_bg_lsl (w, face_id), active_cursor_p,
+             overlay_arrow_bitmap, opoint_pt, &result);
+  if (minimal_p)
+    goto crosshairs_finish;
+  if (NILP (BVAR (b, crosshairs_horizontal_ruler)))
+    goto vertical_ruler;
+/* ******************************************************************************
+                HORIZONTAL RULER:  FIRST X => EOL
+                                and
+       HORIZONTAL RULER:  DRAW FLOATING GLYPHLESS LINE (EOL TO FRINGE)
+****************************************************************************** */
+  /* Place the IT on the current line containing PT. */
+  int voffset = (header_line_height > 0
+                 && opoint_vpos > 0)
+                  ? opoint_vpos - 1
+                  : opoint_vpos;
+  if (voffset > 0)
+    move_it_by_lines (&it, voffset);
+  mc_move_it (&it, posint, HBAR_CURSOR, cursor_width, foreground, active_cursor_p, HORIZONTAL_RULER, &result);
+/* ******************************************************************************
+           VERTICAL RULER:  COMBINATION OF GLYPH & GLYPHLESS CURSORS
+****************************************************************************** */
+  vertical_ruler:
+  if (NILP (BVAR (b, crosshairs_vertical_ruler)))
+    goto crosshairs_finish;
+  RESTORE_IT (&it, &saved_it_for_window_start, saved_itdata_for_window_start);
+  while (true)
+    {
+      mc_move_it (&it, posint, BAR_CURSOR, cursor_width, foreground, active_cursor_p, VERTICAL_RULER, &result);
+      /* This combination of a ZV check before `move_it_by_lines' followed by a
+      Y check subsequent thereto gives us the FEATURE of having a vertical line
+      following a line terminating with ZV.  Whereas `display-line-numbers-mode'
+      has a FEATURE of suppressing the line numbers in this situation, we draw
+      crosshairs in that situation.  `mc_move_it' has been
+      equipped with a condition to test for ZV at the outset and return if true,
+      which prevents Emacs from crashing. */
+      if (IT_CHARPOS (it) == ZV)
+        break;
+      move_it_by_lines (&it, 1);
+      /* If there is a hard return at ZV, we want a vertical ruler on the
+      imaginary new line.  [NOTE:  Eli Z. expressly designed line numbers _not_
+      to display a line number in this situation.]  When `truncate-lines' is non-
+      nil, and the last line is horizontally scrolled with no hard return at EOL,
+      `move_it_by_lines' will place IT on a Y axis beyond the last line with no
+      EOL. In such a case, `it.c` will have the value of the last character in
+      the buffer.  When the last line with an EOL is word-wrapped, `it.c` is 0.
+      When the last line with an EOL is truncated, `it.c` is 10. */
+      if (IT_CHARPOS (it) == ZV
+          && it.c != 10
+          && it.c != 0)
+        break;
+      if (it.current_y >= it.last_visible_y)
+        break;
+    }
+/* ******************************************************************************
+                                SET THE CACHE
+****************************************************************************** */
+  crosshairs_finish:
+  if (!NILP (result))
+    wset_crosshairs_cache (w, listn (CONSTYPE_HEAP, 3,
+                                     Freverse (result),
+                                     Fcons (window, Qnil),
+                                     Fcons (w->contents, Qnil)));
+  w->mc.draw_crosshairs = false;
+  bidi_unshelve_cache (itdata, false);
+  if (old_buffer)
+    set_buffer_internal (old_buffer);
+/*
+#ifdef GLYPH_DEBUG
+  end = clock();
+  cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC;
+  dtoastr (buf_time, sizeof buf_time, 0, 0, cpu_time_used);
+  debug_method_add (w, "mc_draw_crosshairs:  TIME (%s)", buf_time);
+#endif
+*/
+}
+
+void
+mc_redraw_crosshairs (struct window *w)
+{
+/*
+#ifdef GLYPH_DEBUG
+  clock_t start, end;
+  double cpu_time_used;
+  char buf_time[DBL_BUFSIZE_BOUND];
+  start = clock();
+#endif
+*/
+#ifdef GLYPH_DEBUG
+  if (trace_redisplay_p
+      && (!NILP (BVAR (XBUFFER (w->contents), multiple_cursors_conf))
+          || !NILP (BVAR (XBUFFER (w->contents), crosshairs))))
+    {
+      Lisp_Object window;
+      XSETWINDOW (window, w);
+      Lisp_Object window_string = Fprin1_to_string (window, Qnil);
+      char *window_char = SSDATA (window_string);
+      fprintf (stderr, "mc_redraw_crosshairs (%s)\n", window_char);
+    }
+#endif
+  Lisp_Object vlist = Qnil;
+  Lisp_Object fourteen_elements = Qnil;
+  int x, fx, y, fy, hpos, vpos, h;
+  enum text_cursor_kinds cursor_type;
+  int cursor_width;
+  Lisp_Object foreground = Qnil;
+  Lisp_Object background = Qnil;
+  bool active_cursor_p = false;
+  int flavor;
+  ptrdiff_t posint;
+  for (vlist = XCAR (w->crosshairs_cache);
+       CONSP (vlist);
+       vlist = XCDR (vlist))
+    {
+      fourteen_elements = XCAR (vlist);
+      x = XFIXNUM (Fnth (make_fixnum (0), fourteen_elements));
+      fx = XFIXNUM (Fnth (make_fixnum (1), fourteen_elements));
+      y = XFIXNUM (Fnth (make_fixnum (2), fourteen_elements));
+      fy = XFIXNUM (Fnth (make_fixnum (3), fourteen_elements));
+      hpos = XFIXNUM (Fnth (make_fixnum (4), fourteen_elements));
+      vpos = XFIXNUM (Fnth (make_fixnum (5), fourteen_elements));
+      h = XFIXNUM (Fnth (make_fixnum (6), fourteen_elements));
+      cursor_type = mc_lisp_to_cursor_type (Fnth (make_fixnum (7), fourteen_elements));
+      cursor_width = XFIXNUM (Fnth (make_fixnum (8), fourteen_elements));
+      foreground = Fnth (make_fixnum (9), fourteen_elements);
+      background = Fnth (make_fixnum (10), fourteen_elements);
+      active_cursor_p = XFIXNUM (Fnth (make_fixnum (11), fourteen_elements));
+      flavor = XFIXNUM (Fnth (make_fixnum (12), fourteen_elements));
+      posint = XFIXNUM (Fnth (make_fixnum (13), fourteen_elements));
+      mc_draw_erase_hybrid (w, x, fx, y, fy, hpos, vpos, h, cursor_type,
+                            cursor_width, foreground, active_cursor_p, flavor, posint);
+    }
+/*
+#ifdef GLYPH_DEBUG
+  end = clock();
+  cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC;
+  dtoastr (buf_time, sizeof buf_time, 0, 0, cpu_time_used);
+  debug_method_add (w, "mc_redraw_crosshairs:  TIME (%s)", buf_time);
+#endif
+*/
+}
+
+void
+mc_erase_crosshairs (struct window *w, bool delete_cache)
+{
+/*
+#ifdef GLYPH_DEBUG
+  clock_t start, end;
+  double cpu_time_used;
+  char buf_time[DBL_BUFSIZE_BOUND];
+  start = clock();
+#endif
+*/
+#ifdef GLYPH_DEBUG
+  if (trace_redisplay_p
+      && (!NILP (BVAR (XBUFFER (w->contents), multiple_cursors_conf))
+          || !NILP (BVAR (XBUFFER (w->contents), crosshairs))))
+    {
+      Lisp_Object window;
+      XSETWINDOW (window, w);
+      Lisp_Object window_string = Fprin1_to_string (window, Qnil);
+      char *window_char = SSDATA (window_string);
+      fprintf (stderr, "mc_erase_crosshairs (%s):  delete_cache (%d)\n",
+                       window_char, delete_cache);
+    }
+#endif
+  Lisp_Object vlist = Qnil;
+  Lisp_Object fourteen_elements = Qnil;
+  int x, fx, y, fy, hpos, vpos, h;
+  enum text_cursor_kinds cursor_type;
+  int cursor_width;
+  Lisp_Object foreground = Qnil;
+  Lisp_Object background = Qnil;
+  bool active_cursor_p = false;
+  int flavor;
+  ptrdiff_t posint;
+  mc_erase_glyph_cursors (w, w->phys_cursor.x, w->phys_cursor.y, w->phys_cursor.hpos,
+                          w->phys_cursor.vpos, w->phys_cursor_type, w->phys_cursor_width);
+  for (vlist = XCAR (w->crosshairs_cache);
+       CONSP (vlist);
+       vlist = XCDR (vlist))
+    {
+      fourteen_elements = XCAR (vlist);
+      x = XFIXNUM (Fnth (make_fixnum (0), fourteen_elements));
+      fx = XFIXNUM (Fnth (make_fixnum (1), fourteen_elements));
+      y = XFIXNUM (Fnth (make_fixnum (2), fourteen_elements));
+      fy = XFIXNUM (Fnth (make_fixnum (3), fourteen_elements));
+      hpos = XFIXNUM (Fnth (make_fixnum (4), fourteen_elements));
+      vpos = XFIXNUM (Fnth (make_fixnum (5), fourteen_elements));
+      h = XFIXNUM (Fnth (make_fixnum (6), fourteen_elements));
+      cursor_type = mc_lisp_to_cursor_type (Fnth (make_fixnum (7), fourteen_elements));
+      cursor_width = XFIXNUM (Fnth (make_fixnum (8), fourteen_elements));
+      foreground = Fnth (make_fixnum (9), fourteen_elements);
+      background = Fnth (make_fixnum (10), fourteen_elements);
+      active_cursor_p = XFIXNUM (Fnth (make_fixnum (11), fourteen_elements));
+      flavor = XFIXNUM (Fnth (make_fixnum (12), fourteen_elements));
+      posint = XFIXNUM (Fnth (make_fixnum (13), fourteen_elements));
+      if (flavor == MC_GLYPH)
+        mc_erase_glyph_cursors (w, x, y, hpos, vpos, cursor_type, cursor_width);
+        else
+          {
+            if (flavor == MC_OVERLAY_ARROW_BITMAP
+                || flavor == MC_OVERLAY_ARROW_BITMAP_HSCL_TEMPORARY
+                || flavor == MC_HOLLOW_RECTANGLE_RIGHT_ANGLE
+                || flavor == MC_HOLLOW_RECTANGLE
+                || flavor == MC_VERTICAL_BAR_RIGHT_ANGLE
+                || flavor == MC_VERTICAL_BAR
+                || flavor == MC_VERTICAL_BAR_BACKSLASH)
+              cursor_type = NO_FRINGE_BITMAP;
+            mc_draw_erase_hybrid (w, x, fx, y, fy, hpos, vpos, h, cursor_type,
+                                  cursor_width, background, active_cursor_p, flavor, posint);
+          }
+    }
+  if (delete_cache)
+    wset_crosshairs_cache (w, Qnil);
+  w->mc.erase_crosshairs = false;
+/*
+#ifdef GLYPH_DEBUG
+  end = clock();
+  cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC;
+  dtoastr (buf_time, sizeof buf_time, 0, 0, cpu_time_used);
+  debug_method_add (w, "mc_erase_crosshairs:  TIME (%s)", buf_time);
+#endif
+*/
+}
+
+void
+mc_remove_multiple_cursors (struct window *w)
+{
+  struct frame *f = XFRAME (w->frame);
+  bool delete_cache = (w->mc.redisplay_preserve_echo_area == 8
+                       || mc_redisplay == 3)
+                      ? false
+                      : true;
+#ifdef GLYPH_DEBUG
+  if (trace_redisplay_p
+      && (!NILP (BVAR (XBUFFER (w->contents), multiple_cursors_conf))
+          || !NILP (BVAR (XBUFFER (w->contents), crosshairs))))
+    {
+      Lisp_Object window;
+      XSETWINDOW (window, w);
+      Lisp_Object window_string = Fprin1_to_string (window, Qnil);
+      char *window_char = SSDATA (window_string);
+      fprintf (stderr, "mc_remove_multiple_cursors (%s):  delete_cache (%d)\n",
+                        window_char, delete_cache);
+    }
+#endif
+  /* Remove fake cursors.  If we rely upon `update_frame' to remove fake cursors,
+  then it would be too late to remove fake cursors from all areas of the visible
+  window when cutting/pasting text and perhaps a few other situations. */
+  if (!w->pseudo_window_p
+      && !MINI_WINDOW_P (w)
+      && !NILP (w->multiple_cursors_cache)
+      && WINDOWP (XCAR (Fnth (make_fixnum (1), w->multiple_cursors_cache)))
+      && w == XWINDOW (XCAR (Fnth (make_fixnum (1), w->multiple_cursors_cache)))
+      && EQ (w->contents, XCAR (Fnth (make_fixnum (2), w->multiple_cursors_cache))))
+    {
+      update_begin (f);
+      block_input ();
+      mc_erase_multiple_cursors (w, delete_cache);
+      unblock_input ();
+      update_end (f);
+    }
+}
+
+void
+mc_remove_crosshairs (struct window *w)
+{
+  struct frame *f = XFRAME (w->frame);
+  bool delete_cache = ((w->mc.redisplay_preserve_echo_area == 8
+                        || mc_redisplay == 3)
+                       && !w->mc.draw_crosshairs
+                       && !w->mc.erase_crosshairs)
+                      ? false
+                      : true;
+#ifdef GLYPH_DEBUG
+  if (trace_redisplay_p
+      && (!NILP (BVAR (XBUFFER (w->contents), multiple_cursors_conf))
+          || !NILP (BVAR (XBUFFER (w->contents), crosshairs))))
+    {
+      Lisp_Object window;
+      XSETWINDOW (window, w);
+      Lisp_Object window_string = Fprin1_to_string (window, Qnil);
+      char *window_char = SSDATA (window_string);
+      fprintf (stderr, "mc_remove_crosshairs (%s):  delete_cache (%d)\n",
+                        window_char, delete_cache);
+    }
+#endif
+  /* Remove fake cursors.  If we rely upon `update_frame' to remove fake cursors,
+  then it would be too late to remove fake cursors from all areas of the visible
+  window when cutting/pasting text and perhaps a few other situations. */
+  if (!w->pseudo_window_p
+      && !MINI_WINDOW_P (w)
+      && !NILP (w->crosshairs_cache)
+      && WINDOWP (XCAR (Fnth (make_fixnum (1), w->crosshairs_cache)))
+      && w == XWINDOW (XCAR (Fnth (make_fixnum (1), w->crosshairs_cache)))
+      && EQ (w->contents, XCAR (Fnth (make_fixnum (2), w->crosshairs_cache))))
+    {
+      update_begin (f);
+      block_input ();
+      mc_erase_crosshairs (w, delete_cache);
+      unblock_input ();
+      update_end (f);
+    }
+}
+
+void
+mc_multiple_cursors_portal (struct window *w, bool on, bool active_cursor_p)
+{
+#ifdef GLYPH_DEBUG
+  if (trace_redisplay_p
+      && (!NILP (BVAR (XBUFFER (w->contents), multiple_cursors_conf))
+          || !NILP (BVAR (XBUFFER (w->contents), crosshairs))))
+    {
+      Lisp_Object window;
+      XSETWINDOW (window, w);
+      Lisp_Object window_string = Fprin1_to_string (window, Qnil);
+      char *window_char = SSDATA (window_string);
+      fprintf (stderr, "mc_multiple_cursors_portal (%s):  on (%d) | active_cursor_p (%d)\n",
+                        window_char, on, active_cursor_p);
+    }
+#endif
+  if (w->mc.erase_multiple_cursors && w->mc.draw_multiple_cursors
+      && !MINI_WINDOW_P (w)
+      && !NILP (w->multiple_cursors_cache)
+      && WINDOWP (XCAR (Fnth (make_fixnum (1), w->multiple_cursors_cache)))
+      && w == XWINDOW (XCAR (Fnth (make_fixnum (1), w->multiple_cursors_cache)))
+      && EQ (w->contents, XCAR (Fnth (make_fixnum (2), w->multiple_cursors_cache))))
+    mc_erase_multiple_cursors (w, true);
+  /* `w->multiple_cursors_cache` belongs to the window, not the buffer.  Switching
+  buffers within the same window renders the cache useless. */
+  if (!MINI_WINDOW_P (w)
+      && !NILP (w->multiple_cursors_cache)
+      && WINDOWP (XCAR (Fnth (make_fixnum (1), w->multiple_cursors_cache)))
+      && w == XWINDOW (XCAR (Fnth (make_fixnum (1), w->multiple_cursors_cache)))
+      && !EQ (w->contents, XCAR (Fnth (make_fixnum (2), w->multiple_cursors_cache))))
+    {
+      wset_multiple_cursors_cache (w, Qnil);
+      w->mc.erase_multiple_cursors = false;
+    }
+  if (on
+      && !MINI_WINDOW_P (w)
+      && (w == XWINDOW (selected_window)
+          || !NILP (BVAR (XBUFFER (w->contents), multiple_cursors_inactive_windows)))
+      && NILP (w->multiple_cursors_cache)
+      && !NILP (BVAR (XBUFFER (w->contents), multiple_cursors_conf)))
+    mc_draw_multiple_cursors (w, active_cursor_p);
+    else if (on
+             && !MINI_WINDOW_P (w)
+             && !NILP (w->multiple_cursors_cache)
+             && !NILP (BVAR (XBUFFER (w->contents), multiple_cursors_conf))
+             && WINDOWP (XCAR (Fnth (make_fixnum (1), w->multiple_cursors_cache)))
+             && w == XWINDOW (XCAR (Fnth (make_fixnum (1), w->multiple_cursors_cache)))
+             && EQ (w->contents, XCAR (Fnth (make_fixnum (2), w->multiple_cursors_cache))))
+      {
+        mc_erase_multiple_cursors (w, false);
+        mc_redraw_multiple_cursors (w);
+      }
+}
+
+void
+mc_crosshairs_portal (struct window *w, bool on, bool active_cursor_p)
+{
+  /* Remove crosshairs and delete the cache, but ONLY if we plan on redrawing them.
+  In a timer situation, we want to erase and redraw -- we go from `checkpoint_2'
+  in `redisplay_internal' and force our way over to `update_frame' 2 of 3.
+  Emacs refreshes the selected window after about 1 to 2 minutes of no activity
+  even though there is nothing attached to the `time_list'/`idle_timer_list'.
+  In that refresh no-timer situation, we want to erase/draw using the cache. */
+#ifdef GLYPH_DEBUG
+  if (trace_redisplay_p
+      && (!NILP (BVAR (XBUFFER (w->contents), multiple_cursors_conf))
+          || !NILP (BVAR (XBUFFER (w->contents), crosshairs))))
+    {
+      Lisp_Object window;
+      XSETWINDOW (window, w);
+      Lisp_Object window_string = Fprin1_to_string (window, Qnil);
+      char *window_char = SSDATA (window_string);
+      fprintf (stderr, "mc_crosshairs_portal (%s):  on (%d) | active_cursor_p (%d)\n",
+                        window_char, on, active_cursor_p);
+    }
+#endif
+  bool minimal_p = (!w->mc.draw_crosshairs
+                    && mc_redisplay_preserve_echo_area != 8
+                    && mc_redisplay != 3
+                    && w == XWINDOW (selected_window)
+                    && NILP (BVAR (XBUFFER (w->contents), crosshairs_draw_forthwith)));
+  if (w->mc.erase_crosshairs && w->mc.draw_crosshairs
+      && !MINI_WINDOW_P (w)
+      && !NILP (w->crosshairs_cache)
+      && WINDOWP (XCAR (Fnth (make_fixnum (1), w->crosshairs_cache)))
+      && w == XWINDOW (XCAR (Fnth (make_fixnum (1), w->crosshairs_cache)))
+      && EQ (w->contents, XCAR (Fnth (make_fixnum (2), w->crosshairs_cache))))
+    mc_erase_crosshairs (w, true);
+  /* `w->crosshairs_cache` belongs to the window, not the buffer.  Switching
+  buffers within the same window renders the cache useless. */
+  if (!MINI_WINDOW_P (w)
+      && !NILP (w->crosshairs_cache)
+      && WINDOWP (XCAR (Fnth (make_fixnum (1), w->crosshairs_cache)))
+      && w == XWINDOW (XCAR (Fnth (make_fixnum (1), w->crosshairs_cache)))
+      && !EQ (w->contents, XCAR (Fnth (make_fixnum (2), w->crosshairs_cache))))
+    {
+      wset_crosshairs_cache (w, Qnil);
+      w->mc.erase_crosshairs = false;
+    }
+  if (on
+      && !MINI_WINDOW_P (w)
+      && (w == XWINDOW (selected_window)
+          || !NILP (BVAR (XBUFFER (w->contents), crosshairs_inactive_windows)))
+      && NILP (w->crosshairs_cache)
+      && (!NILP (BVAR (XBUFFER (w->contents), crosshairs))))
+    mc_draw_crosshairs (w, active_cursor_p, minimal_p);
+    else if (on
+             && !MINI_WINDOW_P (w)
+             && !NILP (w->crosshairs_cache)
+             && !NILP (BVAR (XBUFFER (w->contents), crosshairs))
+             && WINDOWP (XCAR (Fnth (make_fixnum (1), w->crosshairs_cache)))
+             && w == XWINDOW (XCAR (Fnth (make_fixnum (1), w->crosshairs_cache)))
+             && EQ (w->contents, XCAR (Fnth (make_fixnum (2), w->crosshairs_cache))))
+      {
+        mc_erase_crosshairs (w, false);
+        mc_redraw_crosshairs (w);
+      }
+}
+
+bool
+mc_multiple_cursors_p (struct window *w)
+{
+#ifdef GLYPH_DEBUG
+  if (trace_redisplay_p
+      && (!NILP (BVAR (XBUFFER (w->contents), multiple_cursors_conf))
+          || !NILP (BVAR (XBUFFER (w->contents), crosshairs))))
+    {
+      Lisp_Object window;
+      XSETWINDOW (window, w);
+      Lisp_Object window_string = Fprin1_to_string (window, Qnil);
+      char *window_char = SSDATA (window_string);
+      fprintf (stderr, "mc_multiple_cursors_p (%s)\n", window_char);
+    }
+#endif
+/* Moving the mouse triggers `update_window_cursor' which calls
+`display_and_set_cursor' that would otherwise remove a portion of the
+horizontal ruler from point at end of visual line to window edge.
+In addition, switching to/from another application (e.g., ⌘-TAB) calls
+`expose_frame', followed by `expose_window', and `update_window_cursor'. */
+  if (!MINI_WINDOW_P (w)
+      && !w->mc.draw_multiple_cursors
+      && !NILP (w->multiple_cursors_cache)
+      && !NILP (BVAR (XBUFFER (w->contents), multiple_cursors_conf))
+      && WINDOWP (XCAR (Fnth (make_fixnum (1), w->multiple_cursors_cache)))
+      && w == XWINDOW (XCAR (Fnth (make_fixnum (1), w->multiple_cursors_cache)))
+      && EQ (w->contents, XCAR (Fnth (make_fixnum (2), w->multiple_cursors_cache))))
+    return true;
+    else
+      return false;
+}
+
+bool
+mc_crosshairs_p (struct window *w)
+{
+#ifdef GLYPH_DEBUG
+  if (trace_redisplay_p
+      && (!NILP (BVAR (XBUFFER (w->contents), multiple_cursors_conf))
+          || !NILP (BVAR (XBUFFER (w->contents), crosshairs))))
+    {
+      Lisp_Object window;
+      XSETWINDOW (window, w);
+      Lisp_Object window_string = Fprin1_to_string (window, Qnil);
+      char *window_char = SSDATA (window_string);
+      fprintf (stderr, "mc_crosshairs_p (%s)\n", window_char);
+    }
+#endif
+/* Moving the mouse triggers `update_window_cursor' which calls
+`display_and_set_cursor' that would otherwise remove a portion of the
+horizontal ruler from point at end of visual line to window edge.
+In addition, switching to/from another application (e.g., ⌘-TAB) calls
+`expose_frame', followed by `expose_window', and `update_window_cursor'. */
+  if (!MINI_WINDOW_P (w)
+      && !w->mc.draw_crosshairs
+      && !NILP (w->crosshairs_cache)
+      && !NILP (BVAR (XBUFFER (w->contents), crosshairs))
+      && WINDOWP (XCAR (Fnth (make_fixnum (1), w->crosshairs_cache)))
+      && w == XWINDOW (XCAR (Fnth (make_fixnum (1), w->crosshairs_cache)))
+      && EQ (w->contents, XCAR (Fnth (make_fixnum (2), w->crosshairs_cache))))
+    return true;
+    /* This is a situation whereby `redisplay_internal' would normally go to
+    `end_of_redisplay` -- `display_and_set_cursor' would not be called in that
+    situation.  Therefore, we must force call `display_and_set_cursor'. */
+    else if (!MINI_WINDOW_P (w)
+             && w->mc.draw_crosshairs
+             && w->cursor_off_p == w->last_cursor_off_p
+             && !NILP (w->crosshairs_cache)
+             && !NILP (BVAR (XBUFFER (w->contents), crosshairs))
+             && WINDOWP (XCAR (Fnth (make_fixnum (1), w->crosshairs_cache)))
+             && w == XWINDOW (XCAR (Fnth (make_fixnum (1), w->crosshairs_cache)))
+             && EQ (w->contents, XCAR (Fnth (make_fixnum (2), w->crosshairs_cache))))
+      return true;
+      else
+        return false;
+}
+
+bool
+mc_without_update_frame (struct window *w)
+{
+#ifdef GLYPH_DEBUG
+  if (trace_redisplay_p
+      && (!NILP (BVAR (XBUFFER (w->contents), multiple_cursors_conf))
+          || !NILP (BVAR (XBUFFER (w->contents), crosshairs))))
+    {
+      Lisp_Object window;
+      XSETWINDOW (window, w);
+      Lisp_Object window_string = Fprin1_to_string (window, Qnil);
+      char *window_char = SSDATA (window_string);
+      fprintf (stderr, "mc_without_update_frame (%s)\n", window_char);
+    }
+#endif
+/* `timer-list' / `timer-idle-list':  The boolean switches are not automatically
+turned on when a function attached to a timer is called.  We have switches that are
+set in `keyboard.c` for multiple fake cursors (e.g., a keyboard press).  We set
+the switches manually for both multiple cursors and crosshairs in conjunction with
+timer functions.  `update_frame' may not be called if there are no changes to the
+window/buffer.  To test this theory, throw the switches for crosshairs from an idle
+timer without drawing/erasing any overlays in the buffer.  `kbd_mc_activate_multiple_cursors'
+sets the multiple cursors boolean switches to `true` whenever there is a keyboard
+triggered command.  However, that does not necessarily mean that we need to draw
+multiple cursors.  Inasmuch as the multiple cursors boolean switches might have
+been set through a timer function, it is better to check the buffer local variables
+and the window caches.  In the case of crosshairs, the corresponding boolean
+switches are only set when we really want to draw the crosshairs.
+-  We also use this function as part of `update_window_cursor' when mousing over
+something that would ordinarily cause the real cursor to be redrawn. */
+      if (mc_multiple_cursors_p (w)
+          || mc_crosshairs_p (w))
+        {
+          /* We are bypassing `update_frame'. */
+          struct frame *f = XFRAME (w->frame);
+          update_begin (f);
+          block_input ();
+          display_and_set_cursor (w, true, w->output_cursor.hpos,
+                                           w->output_cursor.vpos,
+                                           w->output_cursor.x,
+                                           w->output_cursor.y);
+          unblock_input ();
+          update_end (f);
+          return true;
+        }
+        else
+          return false;
+}
+
+DEFUN ("mc-activate-crosshairs", Fmc_activate_crosshairs, Smc_activate_crosshairs, 1, 1, 0,
+       doc: /* Doc-string. */)
+  (Lisp_Object window)
+{
+  struct window *w = decode_live_window (window);
+  w->mc.draw_crosshairs = true;
+  w->mc.erase_crosshairs = true;
+  return Qnil;
+}
+
+DEFUN ("mc-activate-multiple-cursors", Fmc_activate_multiple_cursors, Smc_activate_multiple_cursors, 1, 1, 0,
+       doc: /* When using a timer, `kbd_mc_activate_multiple_cursors' in `keyboard.c' is not called.
+There are also some other circumstances where `mc-activate-multiple-cursors' is helpful. */)
+  (Lisp_Object window)
+{
+  struct window *w = decode_live_window (window);
+  w->mc.draw_multiple_cursors = true;
+  w->mc.erase_multiple_cursors = true;
+  return Qnil;
+}
+
+DEFUN ("mc-stderr", Fmc_stderr, Smc_stderr, 0, 1, "P",
+       doc: /* Toggle tracing of multiple fake cursors.
+With ARG, turn tracing on if and only if ARG is positive. */)
+  (Lisp_Object arg)
+{
+  struct buffer *b = current_buffer;
+  bool mc_stderr_p = (!NILP (BVAR (current_buffer, mc_stderr)))
+                   ? true
+                   : false;
+  if (NILP (arg))
+    mc_stderr_p = !mc_stderr_p;
+  else
+    {
+      arg = Fprefix_numeric_value (arg);
+      mc_stderr_p = XFIXNUM (arg) > 0;
+    }
+  if (mc_stderr_p)
+    bset_blv_mc_stderr (b, Qt);
+    else
+      bset_blv_mc_stderr (b, Qnil);
+  return Qnil;
+}
+
+/*  (fundamental-mode)
+    (setq display-line-numbers t)
+    (setq buffer-display-table (make-display-table))
+    (aset buffer-display-table
+          ?\t
+          (vector (make-glyph-code ?\u00BB 'font-lock-warning-face)
+                  (make-glyph-code ?\t 'highlight)))
+    (aset buffer-display-table
+          ?\n
+          (vector (make-glyph-code ?\u00B6 'font-lock-comment-face)
+                  ?\n))
+    (setq tab-width 8)
+    (setq-local auto-hscroll-mode 'current-line) */
+
+DEFUN ("debugging", Fdebugging, Sdebugging, 0, 0, 0,
+       doc: /* This function used for debugging. */)
+  (void)
+{
+/* ******************************************************************************
+                      PRELIMINARY STUFF
+****************************************************************************** */
+  struct window *w = decode_live_window (selected_window);
+  struct frame *f = XFRAME (w->frame);
+  struct it it;
+  void *itdata = bidi_shelve_cache ();
+  enum move_it_result rc = MOVE_X_REACHED;
+  struct text_pos start_text_position;
+  int frame_char_width = FRAME_COLUMN_WIDTH (f);
+  int new_x = 0;
+  int relative_x = 0;
+  int previous_relative_x = 0;
+  int previous_it_current_x = 0;
+/* ******************************************************************************
+                      START DISPLAY -- w->start
+****************************************************************************** */
+  /* Begin the journey at w->start. */
+  SET_TEXT_POS_FROM_MARKER (start_text_position, w->start);
+  start_display (&it, w, start_text_position);
+/* ******************************************************************************
+                GO TO THE BEGINNING OF THE CURRENT LINE.
+****************************************************************************** */
+  /* Place the IT on the current line containing PT. */
+  int voffset = (WINDOW_HEADER_LINE_HEIGHT (w) > 0
+                 && w->output_cursor.vpos > 0)
+                  ? w->output_cursor.vpos - 1
+                  : w->output_cursor.vpos;
+  if (voffset > 0)
+    move_it_by_lines (&it, voffset);
+/* ******************************************************************************
+                       MOVE IT:  INCREMENT == 1 pixel
+****************************************************************************** */
+  while (true)
+    {
+      if (new_x > 0)
+        relative_x = new_x - it.first_visible_x;
+      if (it.current_x > previous_it_current_x)
+        {
+          fprintf (stderr, "\nit.current_x (%d) | it.vpos (%d)\n",
+                           it.current_x, it.vpos);
+          int diff_previous_v_current_x = it.current_x - previous_it_current_x;
+          int diff_previous_v_relative_x = relative_x - previous_relative_x;
+          if (diff_previous_v_current_x != diff_previous_v_relative_x
+              && previous_relative_x >= it.lnum_pixel_width)
+            {
+              fprintf (stderr, "\nDIFF (%d):  Sound the alarm!\n",
+                               diff_previous_v_current_x);
+              previous_relative_x += diff_previous_v_current_x;
+            }
+            else
+              previous_relative_x = relative_x;
+          previous_it_current_x = it.current_x;
+        }
+      new_x += 1;
+      rc = move_it_in_display_line_to (&it, ZV, new_x, MOVE_TO_POS | MOVE_TO_X);
+      if (rc == MOVE_LINE_CONTINUED)
+        break;
+      if (it.current_x - it.first_visible_x + frame_char_width >=
+          window_box_width (w, TEXT_AREA))
+        break;
+      if ((FETCH_BYTE (IT_BYTEPOS (it)) == '\n'
+           && it.c != 0)
+          /* || ITERATOR_AT_END_OF_LINE_P (&it) */
+          || rc == MOVE_POS_MATCH_OR_ZV)
+        break;
+    }
+/* ******************************************************************************
+                                 THE END
+****************************************************************************** */
+  bidi_unshelve_cache (itdata, false);
+  return Qnil;
+}
+
+/* end MULTIPLE CURSORS */
+/* *************************************************************************** */
+
+
 
 /***********************************************************************
 		      Window display dimensions
@@ -11208,7 +15915,9 @@ resize_echo_area_exactly (void)
 	{
 	  windows_or_buffers_changed = 42;
 	  update_mode_lines = 30;
-	  redisplay_internal ();
+      mc_redisplay_internal = 1;
+      redisplay_internal (1);
+      mc_redisplay_internal = 0;
 	}
     }
 }
@@ -11695,7 +16404,9 @@ echo_area_display (bool update_frame_p)
 	      ptrdiff_t count = SPECPDL_INDEX ();
 	      specbind (Qredisplay_dont_pause, Qt);
 	      fset_redisplay (f);
-	      redisplay_internal ();
+          mc_redisplay_internal = 2;
+          redisplay_internal (2);
+          mc_redisplay_internal = 0;
 	      unbind_to (count, Qnil);
 	    }
 	  else if (FRAME_WINDOW_P (f) && n == 0)
@@ -13374,6 +18085,19 @@ hscroll_window_tree (Lisp_Object window)
 	      else
 		pt = clip_to_bounds (BEGV, marker_position (w->pointm), ZV);
 
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+  struct display_pos *pos = &cursor_row->start;
+  ptrdiff_t charpos = CHARPOS (pos->pos);
+  bool barf_crash = (charpos < 0 || (charpos >= BUF_BEG (current_buffer) && charpos <= ZV)) ? false : true;
+  if (barf_crash)
+    return hscrolled_p;
+
+/* *************************************************************************** */
+
+
 	      /* Move iterator to pt starting at cursor_row->start in
 		 a line with infinite width.  */
 	      init_to_row_start (&it, w, cursor_row);
@@ -13615,9 +18339,17 @@ text_outside_line_unchanged_p (struct window *w,
    mini-buffer if that is in use.  */
 
 void
-redisplay (void)
+redisplay (int from_where)
 {
-  redisplay_internal ();
+#ifdef GLYPH_DEBUG
+  if (trace_redisplay_p)
+    fprintf (stderr, "\nredisplay (%d)\n", from_where);
+#endif
+  mc_redisplay = from_where;
+  mc_redisplay_internal = 3;
+  redisplay_internal (3);
+  mc_redisplay_internal = 0;
+  mc_redisplay = 0;
 }
 
 
@@ -13886,8 +18618,12 @@ do { if (polling_stopped_here) start_polling ();	\
    is not necessary; currently that causes some problems.  */
 
 static void
-redisplay_internal (void)
+redisplay_internal (int from_where)
 {
+#ifdef GLYPH_DEBUG
+  if (trace_redisplay_p)
+    fprintf (stderr, "\nredisplay_internal (%d)\n", from_where);
+#endif
   struct window *w = XWINDOW (selected_window);
   struct window *sw;
   struct frame *fr;
@@ -14289,6 +19025,22 @@ redisplay_internal (void)
 #ifdef HAVE_WINDOW_SYSTEM
 	      update_window_fringes (w, false);
 #endif
+
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+/* NOTE:  An idle-timer function may not necessarily trigger `redisplay_window'.
+`optimization 1` (which includes left/right cursor movement on the first screen
+line), and `optimization 3` (which includes left/right cursor movement on screen
+lines subsequent to the first screen line), bypass `redisplay_window'. */
+
+      mc_remove_multiple_cursors (w);
+      mc_remove_crosshairs (w);
+
+/* *************************************************************************** */
+
+
 	      goto update;
 	    }
 	  else
@@ -14311,6 +19063,20 @@ redisplay_internal (void)
 		  && (w = XWINDOW (selected_window)) != sw)
 		goto retry;
 
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+/* NOTE:  An idle-timer function may not necessarily trigger `redisplay_window'.
+`optimization 1` (which includes left/right cursor movement on the first screen
+line), and `optimization 3` (which includes left/right cursor movement on screen
+lines subsequent to the first screen line), bypass `redisplay_window'. */
+        if (mc_without_update_frame (w))
+          goto end_of_redisplay;
+
+/* *************************************************************************** */
+
+
 	      /* We used to always goto end_of_redisplay here, but this
 		 isn't enough if we have a blinking cursor.  */
 	      if (w->cursor_off_p == w->last_cursor_off_p)
@@ -14352,6 +19118,22 @@ redisplay_internal (void)
 		  *w->desired_matrix->method = 0;
 		  debug_method_add (w, "optimization 3");
 #endif
+
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+/* NOTE:  An idle-timer function may not necessarily trigger `redisplay_window'.
+`optimization 1` (which includes left/right cursor movement on the first screen
+line), and `optimization 3` (which includes left/right cursor movement on screen
+lines subsequent to the first screen line), bypass `redisplay_window'. */
+
+      mc_remove_multiple_cursors (w);
+      mc_remove_crosshairs (w);
+
+/* *************************************************************************** */
+
+
 		  goto update;
 		}
 	      else
@@ -14732,16 +19514,36 @@ redisplay_preserve_echo_area (int from_where)
   block_buffer_flips ();
   unblock_input ();
 
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+  struct window *w = decode_live_window (selected_window);
+  w->mc.redisplay_preserve_echo_area = from_where;
+  mc_redisplay_preserve_echo_area = from_where;
+
   if (!NILP (echo_area_buffer[1]))
     {
       /* We have a previously displayed message, but no current
 	 message.  Redisplay the previous message.  */
       display_last_displayed_message_p = true;
-      redisplay_internal ();
+      mc_redisplay_internal = 4;
+      redisplay_internal (4);
+      mc_redisplay_internal = 0;
       display_last_displayed_message_p = false;
     }
   else
-    redisplay_internal ();
+    {
+      mc_redisplay_internal = 5;
+      redisplay_internal (5);
+      mc_redisplay_internal = 0;
+    }
+
+  w->mc.redisplay_preserve_echo_area = 0;
+  mc_redisplay_preserve_echo_area = 0;
+
+/* *************************************************************************** */
+
 
   flush_frame (SELECTED_FRAME ());
   unbind_to (count, Qnil);
@@ -17296,6 +22098,16 @@ redisplay_window (Lisp_Object window, bool just_this_one_p)
   debug_method_add (w, "recenter");
 #endif
 
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+  mc_remove_multiple_cursors (w);
+  mc_remove_crosshairs (w);
+
+/* *************************************************************************** */
+
+
   /* Forget any previously recorded base line for line number display.  */
   if (!buffer_unchanged_p)
     w->base_line_number = 0;
@@ -17726,6 +22538,21 @@ redisplay_window (Lisp_Object window, bool just_this_one_p)
   else
     TEMP_SET_PT_BOTH (CHARPOS (opoint), BYTEPOS (opoint));
 
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+/* NOTE:  An idle-timer function may not necessarily trigger `redisplay_window'.
+`optimization 1` (which includes left/right cursor movement on the first screen
+line), and `optimization 3` (which includes left/right cursor movement on screen
+lines subsequent to the first screen line), bypass `redisplay_window'. */
+
+  mc_remove_multiple_cursors (w);
+  mc_remove_crosshairs (w);
+
+/* *************************************************************************** */
+
+
   set_buffer_internal_1 (old);
   /* Avoid an abort in TEMP_SET_PT_BOTH if the buffer has become
      shorter.  This can be caused by log truncation in *Messages*.  */
@@ -21079,6 +25906,21 @@ display_count_lines_visually (struct it *it)
 static void
 maybe_produce_line_number (struct it *it)
 {
+
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+  bool barf_crash = (it->glyph_row == NULL
+                     || it->glyph_row->used[TEXT_AREA] == 0)
+                    ? false
+                    : true;
+  if (barf_crash)
+    return;
+
+/* *************************************************************************** */
+
+
   ptrdiff_t last_line = it->lnum;
   ptrdiff_t start_from, bytepos;
   ptrdiff_t this_line;
@@ -29759,9 +34601,32 @@ display_and_set_cursor (struct window *w, bool on,
       w->phys_cursor.vpos = vpos;
     }
 
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+  w->mc.h = -1;
+  w->mc.fx = -1;
+  w->mc.fy = -1;
+  w->mc.glyph_flavor = NO_FLAVOR;
+  w->mc.red = -1.0;
+  w->mc.green = -1.0;
+  w->mc.blue = -1.0;
+  w->mc.posint = -1;
+
   FRAME_RIF (f)->draw_window_cursor (w, glyph_row, x, y,
                                      new_cursor_type, new_cursor_width,
                                      on, active_cursor);
+
+  mc_multiple_cursors_portal (w, on, active_cursor);
+
+  /* The real cursor (drawn above) is gets removed by crosshairs.
+  `mc_draw_crosshairs' relies upon `w->phys_cursor.x/y/hpos/vpos' when ON. */
+  mc_crosshairs_portal (w, on, active_cursor);
+
+/* *************************************************************************** */
+
+
 }
 
 
@@ -29793,10 +34658,22 @@ update_window_cursor (struct window *w, bool on)
       if (row->reversed_p && hpos >= row->used[TEXT_AREA])
 	hpos = row->used[TEXT_AREA] - 1;
 
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+      if (!mc_crosshairs_p (w)
+          && !mc_multiple_cursors_p (w))
+        {
       block_input ();
       display_and_set_cursor (w, on, hpos, vpos,
 			      w->phys_cursor.x, w->phys_cursor.y);
       unblock_input ();
+        }
+
+/* *************************************************************************** */
+
+
     }
 }
 
@@ -32503,6 +37380,22 @@ x_intersect_rectangles (XRectangle *r1, XRectangle *r2, XRectangle *result)
 void
 syms_of_xdisp (void)
 {
+
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+  defsubr (&Smc_activate_multiple_cursors);
+
+  defsubr (&Smc_activate_crosshairs);
+
+  defsubr (&Smc_stderr);
+
+  defsubr (&Sdebugging);
+
+/* *************************************************************************** */
+
+
   Vwith_echo_area_save_vector = Qnil;
   staticpro (&Vwith_echo_area_save_vector);
 
@@ -33440,4 +38333,4 @@ cancel_hourglass (void)
     }
 }
 
-#endif /* HAVE_WINDOW_SYSTEM */
+#endif /* HAVE_WINDOW_SYSTEM */
\ No newline at end of file
diff --git a/src/xterm.c b/src/xterm.c
index f8ea787..71f184d 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -1530,6 +1530,20 @@ static void x_check_font (struct frame *, struct font *);
 static void
 x_set_cursor_gc (struct glyph_string *s)
 {
+
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+  if (s->w->mc.cursor_gc_default)
+    {
+      s->gc = s->f->output_data.x->cursor_gc;
+      return;
+    }
+
+/* *************************************************************************** */
+
+
   if (s->font == FRAME_FONT (s->f)
       && s->face->background == FRAME_BACKGROUND_PIXEL (s->f)
       && s->face->foreground == FRAME_FOREGROUND_PIXEL (s->f)
@@ -9252,6 +9266,26 @@ x_draw_hollow_cursor (struct window *w, struct glyph_row *row)
 
   /* Compute frame-relative coordinates for phys cursor.  */
   get_phys_cursor_geometry (w, row, cursor_glyph, &x, &y, &h);
+
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+/* LEGEND:
+
+-  top y == WINDOW_TO_FRAME_PIXEL_Y (w, row->y)
+
+-  bottom y == WINDOW_TO_FRAME_PIXEL_Y (w, row->y) - row->height
+
+-  h of HOLLOW_BOX_CURSOR == row->height
+   [This avoids a visible gap above/below.] */
+
+  if (w->mc.h > 0)
+    h = row->height;
+
+/* *************************************************************************** */
+
+
   wd = w->phys_cursor_width - 1;
 
   /* The foreground of cursor_gc is typically the same as the normal
@@ -9328,7 +9362,18 @@ x_draw_bar_cursor (struct window *w, struct glyph_row *row, int width, enum text
 	 invisible.  Use the glyph's foreground color instead in this
 	 case, on the assumption that the glyph's colors are chosen so
 	 that the glyph is legible.  */
-      if (face->background == f->output_data.x->cursor_pixel)
+
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+      if (face->background == f->output_data.x->cursor_pixel
+          && !w->mc.cursor_gc_invisible_okay)
+
+
+/* *************************************************************************** */
+
+
 	xgcv.background = xgcv.foreground = face->foreground;
       else
 	xgcv.background = xgcv.foreground = f->output_data.x->cursor_pixel;
@@ -9359,6 +9404,17 @@ x_draw_bar_cursor (struct window *w, struct glyph_row *row, int width, enum text
 	  if ((cursor_glyph->resolved_level & 1) != 0)
 	    x += cursor_glyph->pixel_width - width;
 
+
+/* *************************************************************************** */
+/* MULTIPLE CURSORS */
+
+    /* Align all fake BAR_CURSOR of the VERTICAL_RULER with `opoint_x'. */
+    if (w->mc.fx > 0)
+      x = w->mc.fx;
+
+/* *************************************************************************** */
+
+
 	  x_fill_rectangle (f, gc, x,
 			  WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y),
 			  width, row->height);
@@ -9435,31 +9491,163 @@ x_draw_window_cursor (struct window *w, struct glyph_row *glyph_row, int x,
 	}
       else
 	{
-	  switch (cursor_type)
-	    {
-	    case HOLLOW_BOX_CURSOR:
-	      x_draw_hollow_cursor (w, glyph_row);
-	      break;
 
-	    case FILLED_BOX_CURSOR:
-	      draw_phys_cursor_glyph (w, glyph_row, DRAW_CURSOR);
-	      break;
 
-	    case BAR_CURSOR:
-	      x_draw_bar_cursor (w, glyph_row, cursor_width, BAR_CURSOR);
-	      break;
+/* *************************************************************************** */
+/* begin MULTIPLE CURSORS */
 
-	    case HBAR_CURSOR:
-	      x_draw_bar_cursor (w, glyph_row, cursor_width, HBAR_CURSOR);
-	      break;
+  struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
+  Colormap cmap = FRAME_X_COLORMAP (f);
+  unsigned long original_cursor_pixel = f->output_data.x->cursor_pixel;
+  /* xterm.c/xterm.h use GC; whereas, w32term.c/w32term.h use XGCValues * */
+  GC original_cursor_gc = f->output_data.x->cursor_gc;
+  double base = 65535.0;
+  double term_red = base * w->mc.red;
+  double term_green = base * w->mc.green;
+  double term_blue = base * w->mc.blue;
+  int int_red = XFIXNUM (Ftruncate (make_float (term_red), Qnil));
+  int int_green = XFIXNUM (Ftruncate (make_float (term_green), Qnil));;
+  int int_blue = XFIXNUM (Ftruncate (make_float (term_blue), Qnil));;
+  XColor color;
+  color.red = int_red;
+  color.green = int_green;
+  color.blue = int_blue;
+  /* `x_alloc_nearest_color' sets the `color.pixel`. */
+  x_alloc_nearest_color (f, cmap, &color);
+  switch (cursor_type)
+  {
+    case HOLLOW_BOX_CURSOR:
+    {
+      if (w->mc.red >= 0 && w->mc.blue >= 0 && w->mc.green >= 0)
+        {
+          struct face *default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
+          Lisp_Object buf = w->contents;
+          CHECK_BUFFER (buf);
+          struct buffer *b = XBUFFER (buf);
+          bool region_active_p = (!NILP (Vtransient_mark_mode)
+                                  && !NILP (BVAR (b, mark_active)));
+          ptrdiff_t region_beginning = (region_active_p) ? XFIXNUM (Fregion_beginning ()) : -1;
+          ptrdiff_t region_end = (region_active_p) ? XFIXNUM (Fregion_end ()) : -1;
+          bool region_in_bounds_p = (region_active_p
+                                     && w->mc.posint >= region_beginning
+                                     && w->mc.posint < region_end);
+          /* Temporarily hijack `f->output_data.x->cursor_gc' by borrowing the
+          functionality of `x_make_gc' in xfns.c.  */
+          if (region_active_p
+              && region_in_bounds_p
+              && active_p)
+            {
+              enum face_id hollow_active_region_face_id = lookup_named_face (w, f, intern ("+-real-fake-cursor-region-face"), true);
+              struct face *hollow_active_region_face = FACE_FROM_ID (f, hollow_active_region_face_id);
+              XSetForeground (FRAME_X_DISPLAY (f), f->output_data.x->cursor_gc, default_face->foreground);
+              XSetBackground (FRAME_X_DISPLAY (f), f->output_data.x->cursor_gc, hollow_active_region_face->background);
+            }
+            else if (region_active_p
+                     && !region_in_bounds_p
+                     && active_p)
+              {
+                enum face_id hollow_active_region_out_face_id = lookup_named_face (w, f, intern ("+-real-fake-cursor-region-face"), true);
+                struct face *hollow_active_region_out_face = FACE_FROM_ID (f, hollow_active_region_out_face_id);
+                XSetForeground (FRAME_X_DISPLAY (f), f->output_data.x->cursor_gc, default_face->foreground);
+                XSetBackground (FRAME_X_DISPLAY (f), f->output_data.x->cursor_gc, hollow_active_region_out_face->foreground);
+              }
+              else if (!region_active_p && active_p)
+                {
+                  enum face_id hollow_active_face_id = lookup_named_face (w, f, intern ("+-real-fake-cursor-face"), true);
+                  struct face *hollow_active_face = FACE_FROM_ID (f, hollow_active_face_id);
+                  XSetForeground (FRAME_X_DISPLAY (f), f->output_data.x->cursor_gc, default_face->foreground);
+                  XSetBackground (FRAME_X_DISPLAY (f), f->output_data.x->cursor_gc, hollow_active_face->background);
+                }
+                /* The region is _not_ visible in the inactive window because the overlay window property is used. */
+                else if (!active_p)
+                  {
+                    enum face_id hollow_inactive_face_id = lookup_named_face (w, f, intern ("+-real-fake-cursor-inactive-face"), true);
+                    struct face *hollow_inactive_face = FACE_FROM_ID (f, hollow_inactive_face_id);
+                    XSetForeground (FRAME_X_DISPLAY (f), f->output_data.x->cursor_gc, default_face->foreground);
+                    XSetBackground (FRAME_X_DISPLAY (f), f->output_data.x->cursor_gc, hollow_inactive_face->background);
+                  }
+          block_input ();
+          /* Force `x_set_cursor_gc' to use `s->f->output_data.x->cursor_gc'.  */
+          w->mc.cursor_gc_default = true;
+          draw_phys_cursor_glyph (w, glyph_row, DRAW_CURSOR);
+          w->mc.cursor_gc_default = false;
+          f->output_data.x->cursor_gc = original_cursor_gc;
+          unblock_input ();
+          /* Temporarily hijack `f->output_data.x->cursor_pixel'.  */
+          f->output_data.x->cursor_pixel = color.pixel;
+          x_draw_hollow_cursor (w, glyph_row);
+          f->output_data.x->cursor_pixel = original_cursor_pixel;
+        }
+        else
+          x_draw_hollow_cursor (w, glyph_row);
+      break;
+    }
+    case FILLED_BOX_CURSOR:
+    {
+      if (w->mc.red >= 0 && w->mc.blue >= 0 && w->mc.green >= 0)
+        /* Temporarily hijack `f->output_data.x->cursor_gc' by borrowing the
+        functionality of `x_make_gc' in xfns.c.  */
+        {
+          block_input ();
+          XGCValues gc_values;
+          unsigned long mask = GCForeground | GCBackground | GCFillStyle | GCLineWidth;
+          gc_values.line_width = 0;  /* Means 1 using fast algorithm.  */
+          gc_values.foreground = FRAME_BACKGROUND_PIXEL (f);
+          gc_values.background = x_make_truecolor_pixel (dpyinfo, int_red, int_green, int_blue);
+          gc_values.fill_style = FillOpaqueStippled;
+          f->output_data.x->cursor_gc = XCreateGC (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), mask, &gc_values);
+          /* Force `x_set_cursor_gc' to use `s->f->output_data.x->cursor_gc'.  */
+          w->mc.cursor_gc_default = true;
+          draw_phys_cursor_glyph (w, glyph_row, DRAW_CURSOR);
+          w->mc.cursor_gc_default = false;
+          f->output_data.x->cursor_gc = original_cursor_gc;
+          unblock_input ();
+        }
+        else
+          draw_phys_cursor_glyph (w, glyph_row, DRAW_CURSOR);
+      break;
+    }
+    case BAR_CURSOR:
+    {
+      if (w->mc.red >= 0 && w->mc.blue >= 0 && w->mc.green >= 0)
+        {
+          /* Temporarily hijack `f->output_data.x->cursor_pixel'.  */
+          f->output_data.x->cursor_pixel = color.pixel;
+          w->mc.cursor_gc_invisible_okay = true;
+          x_draw_bar_cursor (w, glyph_row, cursor_width, BAR_CURSOR);
+          w->mc.cursor_gc_invisible_okay = false;
+          f->output_data.x->cursor_pixel = original_cursor_pixel;
+        }
+        else
+          x_draw_bar_cursor (w, glyph_row, cursor_width, BAR_CURSOR);
+      break;
+    }
+    case HBAR_CURSOR:
+    {
+      if (w->mc.red >= 0 && w->mc.blue >= 0 && w->mc.green >= 0)
+        {
+          /* Temporarily hijack `f->output_data.x->cursor_pixel'.  */
+          f->output_data.x->cursor_pixel = color.pixel;
+          w->mc.cursor_gc_invisible_okay = true;
+          x_draw_bar_cursor (w, glyph_row, cursor_width, HBAR_CURSOR);
+          w->mc.cursor_gc_invisible_okay = false;
+          f->output_data.x->cursor_pixel = original_cursor_pixel;
+        }
+        else
+          x_draw_bar_cursor (w, glyph_row, cursor_width, HBAR_CURSOR);
+      break;
+    }
+    case NO_CURSOR:
+      w->phys_cursor_width = 0;
+      break;
+    default:
+      emacs_abort ();
+  }
+
+/* end MULTIPLE CURSORS */
+/* *************************************************************************** */
 
-	    case NO_CURSOR:
-	      w->phys_cursor_width = 0;
-	      break;
 
-	    default:
-	      emacs_abort ();
-	    }
 	}
 
 #ifdef HAVE_X_I18N
