all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#17684: 24.4.50; Feature Request -- Vertical Lines to the Left of and Through Characters
@ 2014-06-03 20:36 Keith David Bershatsky
  2018-07-09  5:28 ` bug#17684: #22873 (multiple fake cursors); and, #17684 (crosshairs) Keith David Bershatsky
                   ` (16 more replies)
  0 siblings, 17 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2014-06-03 20:36 UTC (permalink / raw)
  To: 17684

As a feature request, please consider adding the ability to include vertical lines to the left of and also through characters.

CAVEAT:  The vertical line plus the character should be equal to only (1) `point` -- like a vertical cursor bar and a character to the right.

This new feature has many applications, including, but not limited to:

*  A thin fill column indicator line that can span the vertical length of the window / buffer.

*  Thin tab setting indicators in the form of vertical lines for each tab set.  (This is built-in to Sublime Text.)

*  A visual vertical division between different parts of the same buffer.

*  A thin vertical line (from top to bottom of the window) that tracks the cursor position.

See the following stackoverflow thread for a screenshot of how this looks, including the workaround / answer to the question:

http://stackoverflow.com/questions/23744237/emacs-how-to-create-a-vertical-strike-through-effect

My workaround shrinks the character to the right so that the visual sentence length is not altered.  The vertical bar cursor that is built-in to Emacs can sit next to a character without shrinking said character -- so implementation of a vertical line to the left of the character would be similar to how the cursor presently works.

BONUS:  As a related feature request, please consider adding the ability to draw these vertical lines (from top to bottom of the window) virtually instantaneously.  Creating these vertical lines in `elisp` when `visual-line-mode` is active is extremely time consuming to perform all the calculations (up to 0.25 seconds from start to finish) and needs to be done with an `idle-timer` so as not to slow down the normal movement of the cursor or typing text quickly.  The calculation and placement of overlays can be sped up significantly by *not* calculating for `visual-line-mode`, but I am *very* fond of that mode.

Thanks,

Keith

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

In GNU Emacs 24.4.50.1 (x86_64-apple-darwin10.8.0, NS appkit-1038.36 Version 10.6.8 (Build 10K549))
 of 2014-06-01 on MP.local
Repository revision: 117215 lekktu@gmail.com-20140601162519-4dacx2w0ak528z2r
Windowing system distributor `Apple', version 10.3.1038
Configured using:
 `configure --with-ns'

Configured features:
ACL LIBXML2 ZLIB

Important settings:
  locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
  lawlist-scroll-bar-mode: t
  lawlist-delete-selection-mode: t
  lawlist-linum-mode: t
  lawlist-visual-line-mode: t
  vr-mode: t
  hr-mode: t
  flyspell-mode: t
  desktop-save-mode: t
  tabbar-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  transient-mark-mode: t

Recent input:
<escape> x h r <return> <escape> x v r <return> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <s-right> 
<left> <left> <left> <left> <left> <left> <left> <left> 
<left> <s-left> <M-right> <M-right> <M-right> <M-right> 
<M-right> <M-right> <M-right> <M-right> <M-right> <M-right> 
<M-right> <M-right> <M-right> <M-right> <M-right> <M-right> 
<s-down> <up> <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <up> <s-right> <left> <left> <left> <left> <left> 
<left> <left> <left> <left> <left> <left> <left> <M-left> 
<M-left> <M-left> <M-left> s-N r e p o r t s-z s-w 
k <escape> x r e p o r t - e m a <tab> <tab> b u g 
<return>

Recent messages:
Loading mail-mime-setup...done
Updating addresses...done
Type C-c C-x C-z to exit MIME mode, and type C-c C-x ? to get help.
Saving...done
Mark set
Undo...
Undo!
[k]ill or [s]ave draft?
Loading msgdb for +/Users/HOME/.0.data/.0.emacs/.0.mail/msgdb/imap/mail.lawlist.com/lawlist/INBOX.Drafts/spool...done
Making completion list...

Load-path shadows:
/Users/HOME/.0.data/.0.emacs/.0.flim/md4 hides /Users/HOME/.0.data/.0.emacs/Emacs_06_01_2014.app/Contents/Resources/lisp/md4
/Users/HOME/.0.data/.0.emacs/.0.flim/hex-util hides /Users/HOME/.0.data/.0.emacs/Emacs_06_01_2014.app/Contents/Resources/lisp/hex-util
/Users/HOME/.0.data/.0.emacs/.0.flim/sasl hides /Users/HOME/.0.data/.0.emacs/Emacs_06_01_2014.app/Contents/Resources/lisp/net/sasl
/Users/HOME/.0.data/.0.emacs/.0.flim/sasl-ntlm hides /Users/HOME/.0.data/.0.emacs/Emacs_06_01_2014.app/Contents/Resources/lisp/net/sasl-ntlm
/Users/HOME/.0.data/.0.emacs/.0.flim/sasl-digest hides /Users/HOME/.0.data/.0.emacs/Emacs_06_01_2014.app/Contents/Resources/lisp/net/sasl-digest
/Users/HOME/.0.data/.0.emacs/.0.flim/sasl-cram hides /Users/HOME/.0.data/.0.emacs/Emacs_06_01_2014.app/Contents/Resources/lisp/net/sasl-cram
/Users/HOME/.0.data/.0.emacs/.0.flim/ntlm hides /Users/HOME/.0.data/.0.emacs/Emacs_06_01_2014.app/Contents/Resources/lisp/net/ntlm
/Users/HOME/.0.data/.0.emacs/.0.flim/hmac-md5 hides /Users/HOME/.0.data/.0.emacs/Emacs_06_01_2014.app/Contents/Resources/lisp/net/hmac-md5
/Users/HOME/.0.data/.0.emacs/.0.flim/hmac-def hides /Users/HOME/.0.data/.0.emacs/Emacs_06_01_2014.app/Contents/Resources/lisp/net/hmac-def
/Users/HOME/.0.data/.0.emacs/.0.wl/rfc2368 hides /Users/HOME/.0.data/.0.emacs/Emacs_06_01_2014.app/Contents/Resources/lisp/mail/rfc2368
/Users/HOME/.0.data/.0.emacs/.0.wl/utf7 hides /Users/HOME/.0.data/.0.emacs/Emacs_06_01_2014.app/Contents/Resources/lisp/gnus/utf7
/Users/HOME/.0.data/.0.emacs/.0.simi/smime hides /Users/HOME/.0.data/.0.emacs/Emacs_06_01_2014.app/Contents/Resources/lisp/gnus/smime
/Users/HOME/.emacs.d/elpa/tabulated-list-20120406.1351/tabulated-list hides /Users/HOME/.0.data/.0.emacs/Emacs_06_01_2014.app/Contents/Resources/lisp/emacs-lisp/tabulated-list
/Users/HOME/.0.data/.0.emacs/.0.simi/pgg hides /Users/HOME/.0.data/.0.emacs/Emacs_06_01_2014.app/Contents/Resources/lisp/obsolete/pgg
/Users/HOME/.0.data/.0.emacs/.0.simi/pgg-pgp5 hides /Users/HOME/.0.data/.0.emacs/Emacs_06_01_2014.app/Contents/Resources/lisp/obsolete/pgg-pgp5
/Users/HOME/.0.data/.0.emacs/.0.simi/pgg-pgp hides /Users/HOME/.0.data/.0.emacs/Emacs_06_01_2014.app/Contents/Resources/lisp/obsolete/pgg-pgp
/Users/HOME/.0.data/.0.emacs/.0.simi/pgg-parse hides /Users/HOME/.0.data/.0.emacs/Emacs_06_01_2014.app/Contents/Resources/lisp/obsolete/pgg-parse
/Users/HOME/.0.data/.0.emacs/.0.simi/pgg-gpg hides /Users/HOME/.0.data/.0.emacs/Emacs_06_01_2014.app/Contents/Resources/lisp/obsolete/pgg-gpg
/Users/HOME/.0.data/.0.emacs/.0.simi/pgg-def hides /Users/HOME/.0.data/.0.emacs/Emacs_06_01_2014.app/Contents/Resources/lisp/obsolete/pgg-def

Features:
(shadow emacsbug modb-legacy wl-mime mime-edit pgg-parse pccl pccl-20
signature mime-setup mail-mime-setup semi-setup mime-pgp pgg-def
mime-play filename mime-image modb-standard elmo-imap4 disp-table
bbdb-autoloads lawlist-wl wl-demo wl-draft eword-encode wl-template
sendmail elmo-net elmo-cache elmo-map elmo-dop wl-news wl-address
wl-thread wl-folder wl wl-e21 wl-spam wl-action wl-summary wl-refile
wl-util pp elmo-flag elmo-localdir wl-message elmo-mime mmelmo-buffer
mmelmo-imap mime-view mime-conf calist semi-def mmimap mime-parse
mmbuffer mmgeneric elmo-multi elmo-spam elsp-header elsp-generic elmo
elmo-signal wl-highlight wl-vars wl-version elmo-msgdb modb
modb-generic modb-entity luna mime elmo-util emu invisible inv-23 poem
poem-e20 poem-e20_3 eword-decode std11 elmo-date elmo-vars
elmo-version w3m-load mime-w3m w3m browse-url doc-view jka-compr
image-mode w3m-hist w3m-fb bookmark-w3m w3m-ems w3m-ccl ccl
w3m-favicon w3m-image w3m-proc w3m-util smiley gnus-art mm-uu mml2015
mm-view mml-smime smime savehist lawlist-vr-hr lawlist-whitespace
lawlist-github conf-mode log-edit add-log find-lisp package esh-var
esh-io esh-cmd esh-opt esh-ext esh-proc esh-arg eldoc esh-groups
eshell esh-module esh-mode esh-util dired-x view tramp tramp-compat
tramp-loaddefs trampver server grep epa epg epg-config diff-mode
autorevert filenotify log-view pcvs-util ido time-stamp vc-git vc
vc-dispatcher ediff-merg ediff-wind ediff-diff ediff-mult ediff-help
ediff-init ediff-util ediff rx ert ewoc debug eieio-base
lawlist-calculator ps-print ps-def lpr flyspell ispell bbdb timezone
find-func dired-aux lawlist-yasnippet help-mode multiple-cursors
mc-separate-operations rectangular-region-mode mc-mark-more thingatpt
mc-cycle-cursors mc-edit-lines multiple-cursors-core rect saveplace
lawlist-tex-mode pcase compile shell pcomplete comint ansi-color ring
skeleton compare-w desktop frameset lawlist-tabbar lawlist-org
lawlist-calendar edmacro kmacro derived lawlist-toodledo advice
url-http url-auth url-gw url url-proxy url-privacy url-expand
url-methods url-history url-cookie url-domsuf url-util url-parse
auth-source eieio byte-opt bytecomp byte-compile cconv eieio-core
password-cache url-vars mailcap json xml noutline outline easy-mmode
gnus-sum gnus-group gnus-undo gnus-start gnus-cloud nnimap nnmail
mail-source tls utf7 mel path-util mime-def alist mcharset mcs-20
mcs-e20 pcustom pces pces-e20 pces-20 broken poe pym static apel-ver
product netrc nnoo parse-time gnus-spec gnus-int gnus-range message
cl-macs dired format-spec rfc822 mml easymenu mml-sec mm-decode
mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums
mailabbrev gmm-utils mailheader gnus-win gnus gnus-ems nnheader
gnus-util mail-utils mm-util help-fns mail-prsvr wid-edit cl gv
cl-loaddefs cl-lib time-date tooltip electric uniquify ediff-hook
vc-hooks lisp-float-type mwheel ns-win tool-bar dnd fontset image
regexp-opt fringe tabulated-list newcomment lisp-mode prog-mode
register page menu-bar rfn-eshadow timer select scroll-bar mouse
jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
minibuffer nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
cocoa ns multi-tty emacs)

Memory information:
((conses 16 735058 70571)
 (symbols 48 55594 0)
 (miscs 40 466 1504)
 (strings 32 116283 16738)
 (string-bytes 1 3865036)
 (vectors 16 42190)
 (vector-slots 8 741311 45040)
 (floats 8 1012 256)
 (intervals 56 691 89)
 (buffers 960 14))


Sincerely,

Keith David Bershatsky, Esq.
Law Office of Keith David Bershatsky
1725 Echo Park Avenue
Los Angeles, CA  90026

Tel. / Fax.:  (213) 975-9447
esq@lawlist.com





^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support)
@ 2016-03-01 18:44 Keith David Bershatsky
  2016-03-03  6:30 ` bug#22873: Can we support multiple Cursors? John Wiegley
                   ` (31 more replies)
  0 siblings, 32 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2016-03-01 18:44 UTC (permalink / raw)
  To: 22873

[-- Attachment #1: Type: text/plain, Size: 3327 bytes --]

As a feature request, it would be appreciated if the Emacs development team could please consider adding built-in support for multiple cursors similar to the Lisp library that Magnar Sveen has written:  https://github.com/magnars

[Out of the box, Emacs does not presently support a left vertical bar fake cursor overlay.]

The multiple cursors API should please be made available to the user so that fake cursors of any style can be drawn anywhere on the visible window.  [Available styles include those defined in the variable `cursor-type'.]

The API available to the user should support standard points for positions, instead of x/y/vpos/hpos.  In other words, the API should make it easy for the user to specifying a list of points -- e.g., '(5 6 7 8 9 10).  In that scenario, fake cursors would be drawn at positions 5, 6, 7, 8, 9 and 10.  Perhaps a cons cell with the `cursor-type' for each specified point would be appropriate -- that way a user would not be limited to the buffer-local or default cursor style for all fake cursors.

This feature request has the added benefit that the user can create a vertical line the entire length of the screen by using multiple fake bar cursors in addition to a stretch space glyph and an XPM image that is thin (e.g., one pixel wide) with a pixel height equal to the line height at any location where no character exists -- e.g., overlays using the 'after-string property.  An example would be the fill-column-indicator library written by Alp Aker:  https://github.com/alpaker/Fill-Column-Indicator  In the context of the fill-column-indicator example, a user can draw a vertical line that extends through the left side of each character to form a solid line the entire length of the window from top to bottom.

In my own personal setup, I would be drawing a solid vertical line that tracks the cursor position -- the line would run through the left side of any character along that resides on vertical column.

The following draft proof concept patch contains a variety of things including a sample of this particular feature request for multiple cursors.  The example has been tested on Emacs master branch for OSX and Windows operating systems.  On OSX the fake cursors draw immediately, but on Windows it is necessary to press any key after calling `multiple-cursors-test' for the fake cursors to appear.  The fake cursors are designed to disappear during the next command loop.  The internal function `move_it_to' provides for a conveniently quick method to convert PT to the necessary x/y/vpos/hpos.

NOTE:  `posn-at-point` is painfully slow to obtain x/y/vpos/hpos -- so we certainly want to avoid using that function when converting the list of PT for fake cursors each command loop.

The following test function called `multiple-cursors-test` works with the proof concept draft patch attached below, which admittedly needs a lot more work.  I tested using the bar `cursor-type'.

(defun multiple-cursors-test (&optional list)
"Draw fake cursors at all POS defined in the `multiple-cursor-list'.
The list contains integers representing the various positions.
The default list is for positions 5, 6, 7, 8, 9 and 10."
(interactive)
  (setq cursor-type 'bar)
  (setq multiple-cursors-list (if list list (list 5 6 7 8 9 10))))

(global-set-key [f1] 'multiple-cursors-test)


[-- Attachment #2: multiple_cursors.diff --]
[-- Type: application/diff, Size: 42323 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: Can we support multiple Cursors?
  2016-03-01 18:44 bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support) Keith David Bershatsky
@ 2016-03-03  6:30 ` John Wiegley
  2016-03-03  6:30 ` John Wiegley
                   ` (30 subsequent siblings)
  31 siblings, 0 replies; 83+ messages in thread
From: John Wiegley @ 2016-03-03  6:30 UTC (permalink / raw)
  To: Keith David Bershatsky; +Cc: 22873, emacs-devel

>>>>> Keith David Bershatsky <esq@lawlist.com> writes:

> As a feature request, it would be appreciated if the Emacs development team
> could please consider adding built-in support for multiple cursors similar
> to the Lisp library that Magnar Sveen has written:
> https://github.com/magnars

I like this request, but my spidey sense tells me that implementing this at
the C level will introduce a huge number of ramifications that may not be
immediately apparent. For example, (point) conceptually goes from being one
position, to many. The implications of that are huge, which will mean
introducing special cases to avoid them, which then has its own implications,
etc.

I'd like to see discussion on this idea in emacs-devel, so I'm copying there.
This is something that deserves a larger audience than just those following
bug #22873. Is multiple-cursor editing a realistic possibility? And is it
worth the complexity?

-- 
John Wiegley                  GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com                          60E1 46C4 BD1A 7AC1 4BA2





^ permalink raw reply	[flat|nested] 83+ messages in thread

* Can we support multiple Cursors?
  2016-03-01 18:44 bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support) Keith David Bershatsky
  2016-03-03  6:30 ` bug#22873: Can we support multiple Cursors? John Wiegley
@ 2016-03-03  6:30 ` John Wiegley
  2016-03-03  6:54   ` bug#22873: " Marcin Borkowski
  2016-03-03  6:54   ` Marcin Borkowski
  2016-03-04 23:16 ` Keith David Bershatsky
                   ` (29 subsequent siblings)
  31 siblings, 2 replies; 83+ messages in thread
From: John Wiegley @ 2016-03-03  6:30 UTC (permalink / raw)
  To: Keith David Bershatsky; +Cc: 22873, emacs-devel

>>>>> Keith David Bershatsky <esq@lawlist.com> writes:

> As a feature request, it would be appreciated if the Emacs development team
> could please consider adding built-in support for multiple cursors similar
> to the Lisp library that Magnar Sveen has written:
> https://github.com/magnars

I like this request, but my spidey sense tells me that implementing this at
the C level will introduce a huge number of ramifications that may not be
immediately apparent. For example, (point) conceptually goes from being one
position, to many. The implications of that are huge, which will mean
introducing special cases to avoid them, which then has its own implications,
etc.

I'd like to see discussion on this idea in emacs-devel, so I'm copying there.
This is something that deserves a larger audience than just those following
bug #22873. Is multiple-cursor editing a realistic possibility? And is it
worth the complexity?

-- 
John Wiegley                  GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com                          60E1 46C4 BD1A 7AC1 4BA2



^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: Can we support multiple Cursors?
  2016-03-03  6:30 ` John Wiegley
@ 2016-03-03  6:54   ` Marcin Borkowski
  2016-03-03  6:54   ` Marcin Borkowski
  1 sibling, 0 replies; 83+ messages in thread
From: Marcin Borkowski @ 2016-03-03  6:54 UTC (permalink / raw)
  To: John Wiegley; +Cc: Keith David Bershatsky, 22873, emacs-devel


On 2016-03-03, at 07:30, John Wiegley <jwiegley@gmail.com> wrote:

>>>>>> Keith David Bershatsky <esq@lawlist.com> writes:
>
>> As a feature request, it would be appreciated if the Emacs development team
>> could please consider adding built-in support for multiple cursors similar
>> to the Lisp library that Magnar Sveen has written:
>> https://github.com/magnars
>
> I like this request, but my spidey sense tells me that implementing this at
> the C level will introduce a huge number of ramifications that may not be
> immediately apparent. For example, (point) conceptually goes from being one
> position, to many. The implications of that are huge, which will mean
> introducing special cases to avoid them, which then has its own implications,
> etc.
>
> I'd like to see discussion on this idea in emacs-devel, so I'm copying there.
> This is something that deserves a larger audience than just those following
> bug #22873. Is multiple-cursor editing a realistic possibility? And is it
> worth the complexity?

What would be the added value of having that built-in vs. having it on
M?elpa?

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University





^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: Can we support multiple Cursors?
  2016-03-03  6:30 ` John Wiegley
  2016-03-03  6:54   ` bug#22873: " Marcin Borkowski
@ 2016-03-03  6:54   ` Marcin Borkowski
  2016-03-03 11:20     ` bug#22873: " Richard Stallman
  2016-03-03 11:20     ` Richard Stallman
  1 sibling, 2 replies; 83+ messages in thread
From: Marcin Borkowski @ 2016-03-03  6:54 UTC (permalink / raw)
  To: John Wiegley; +Cc: Keith David Bershatsky, 22873, emacs-devel


On 2016-03-03, at 07:30, John Wiegley <jwiegley@gmail.com> wrote:

>>>>>> Keith David Bershatsky <esq@lawlist.com> writes:
>
>> As a feature request, it would be appreciated if the Emacs development team
>> could please consider adding built-in support for multiple cursors similar
>> to the Lisp library that Magnar Sveen has written:
>> https://github.com/magnars
>
> I like this request, but my spidey sense tells me that implementing this at
> the C level will introduce a huge number of ramifications that may not be
> immediately apparent. For example, (point) conceptually goes from being one
> position, to many. The implications of that are huge, which will mean
> introducing special cases to avoid them, which then has its own implications,
> etc.
>
> I'd like to see discussion on this idea in emacs-devel, so I'm copying there.
> This is something that deserves a larger audience than just those following
> bug #22873. Is multiple-cursor editing a realistic possibility? And is it
> worth the complexity?

What would be the added value of having that built-in vs. having it on
M?elpa?

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: Can we support multiple Cursors?
  2016-03-03  6:54   ` Marcin Borkowski
  2016-03-03 11:20     ` bug#22873: " Richard Stallman
@ 2016-03-03 11:20     ` Richard Stallman
  1 sibling, 0 replies; 83+ messages in thread
From: Richard Stallman @ 2016-03-03 11:20 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: esq, 22873, johnw, emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > What would be the added value of having that built-in vs. having it on
  > M?elpa?

Melpa and ELPA are totally different.

ELPA is effectively an extension of Emacs, and we refer users there.

Melpa is someone else's repository, which we cannot treat as part of
Emacs.  We do not steer users there.

-- 
Dr Richard Stallman
President, Free Software Foundation (gnu.org, fsf.org)
Internet Hall-of-Famer (internethalloffame.org)
Skype: No way! See stallman.org/skype.html.






^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: bug#22873: Can we support multiple Cursors?
  2016-03-03  6:54   ` Marcin Borkowski
@ 2016-03-03 11:20     ` Richard Stallman
  2016-03-03 15:05       ` Marcin Borkowski
  2016-03-03 15:05       ` Marcin Borkowski
  2016-03-03 11:20     ` Richard Stallman
  1 sibling, 2 replies; 83+ messages in thread
From: Richard Stallman @ 2016-03-03 11:20 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: esq, johnw, 22873, emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > What would be the added value of having that built-in vs. having it on
  > M?elpa?

Melpa and ELPA are totally different.

ELPA is effectively an extension of Emacs, and we refer users there.

Melpa is someone else's repository, which we cannot treat as part of
Emacs.  We do not steer users there.

-- 
Dr Richard Stallman
President, Free Software Foundation (gnu.org, fsf.org)
Internet Hall-of-Famer (internethalloffame.org)
Skype: No way! See stallman.org/skype.html.




^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: Can we support multiple Cursors?
  2016-03-03 11:20     ` bug#22873: " Richard Stallman
  2016-03-03 15:05       ` Marcin Borkowski
@ 2016-03-03 15:05       ` Marcin Borkowski
  1 sibling, 0 replies; 83+ messages in thread
From: Marcin Borkowski @ 2016-03-03 15:05 UTC (permalink / raw)
  To: rms; +Cc: esq, 22873, johnw, emacs-devel


On 2016-03-03, at 12:20, Richard Stallman <rms@gnu.org> wrote:

> [[[ To any NSA and FBI agents reading my email: please consider    ]]]
> [[[ whether defending the US Constitution against all enemies,     ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
>
>   > What would be the added value of having that built-in vs. having it on
>   > M?elpa?
>
> Melpa and ELPA are totally different.
>
> ELPA is effectively an extension of Emacs, and we refer users there.
>
> Melpa is someone else's repository, which we cannot treat as part of
> Emacs.  We do not steer users there.

I understand all this.  (In fact, I wanted to write Elpa, only to
discover - to my surprise - that Magnar's multiple-cursors package is
actually on Melpa.  It is GPL'd, however.)

Still, I think that trying to implement that in core would be duplicated
effort, and the feature does not seem essential (it is roughly
equivalent to keyboard macros, though admittedly way cooler).  If
anything, I'd check whether it can be put on Elpa.

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University





^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: bug#22873: Can we support multiple Cursors?
  2016-03-03 11:20     ` bug#22873: " Richard Stallman
@ 2016-03-03 15:05       ` Marcin Borkowski
  2016-03-04  9:19         ` Richard Stallman
  2016-03-04  9:19         ` Richard Stallman
  2016-03-03 15:05       ` Marcin Borkowski
  1 sibling, 2 replies; 83+ messages in thread
From: Marcin Borkowski @ 2016-03-03 15:05 UTC (permalink / raw)
  To: rms; +Cc: esq, johnw, 22873, emacs-devel


On 2016-03-03, at 12:20, Richard Stallman <rms@gnu.org> wrote:

> [[[ To any NSA and FBI agents reading my email: please consider    ]]]
> [[[ whether defending the US Constitution against all enemies,     ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
>
>   > What would be the added value of having that built-in vs. having it on
>   > M?elpa?
>
> Melpa and ELPA are totally different.
>
> ELPA is effectively an extension of Emacs, and we refer users there.
>
> Melpa is someone else's repository, which we cannot treat as part of
> Emacs.  We do not steer users there.

I understand all this.  (In fact, I wanted to write Elpa, only to
discover - to my surprise - that Magnar's multiple-cursors package is
actually on Melpa.  It is GPL'd, however.)

Still, I think that trying to implement that in core would be duplicated
effort, and the feature does not seem essential (it is roughly
equivalent to keyboard macros, though admittedly way cooler).  If
anything, I'd check whether it can be put on Elpa.

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: Can we support multiple Cursors?
  2016-03-03 15:05       ` Marcin Borkowski
@ 2016-03-04  9:19         ` Richard Stallman
  2016-03-04  9:19         ` Richard Stallman
  1 sibling, 0 replies; 83+ messages in thread
From: Richard Stallman @ 2016-03-04  9:19 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: esq, 22873, johnw, emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > I understand all this.  (In fact, I wanted to write Elpa, only to
  > discover - to my surprise - that Magnar's multiple-cursors package is
  > actually on Melpa.  It is GPL'd, however.)

Would he / can he contribute it so we can put it in ELPA?

-- 
Dr Richard Stallman
President, Free Software Foundation (gnu.org, fsf.org)
Internet Hall-of-Famer (internethalloffame.org)
Skype: No way! See stallman.org/skype.html.






^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: bug#22873: Can we support multiple Cursors?
  2016-03-03 15:05       ` Marcin Borkowski
  2016-03-04  9:19         ` Richard Stallman
@ 2016-03-04  9:19         ` Richard Stallman
  2016-03-04 14:59           ` Stefan Monnier
  1 sibling, 1 reply; 83+ messages in thread
From: Richard Stallman @ 2016-03-04  9:19 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: esq, johnw, 22873, emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > I understand all this.  (In fact, I wanted to write Elpa, only to
  > discover - to my surprise - that Magnar's multiple-cursors package is
  > actually on Melpa.  It is GPL'd, however.)

Would he / can he contribute it so we can put it in ELPA?

-- 
Dr Richard Stallman
President, Free Software Foundation (gnu.org, fsf.org)
Internet Hall-of-Famer (internethalloffame.org)
Skype: No way! See stallman.org/skype.html.




^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: bug#22873: Can we support multiple Cursors?
  2016-03-04  9:19         ` Richard Stallman
@ 2016-03-04 14:59           ` Stefan Monnier
  2016-03-04 22:18             ` Magnar Sveen
  2016-03-05 12:58             ` Richard Stallman
  0 siblings, 2 replies; 83+ messages in thread
From: Stefan Monnier @ 2016-03-04 14:59 UTC (permalink / raw)
  To: emacs-devel

>> I understand all this.  (In fact, I wanted to write Elpa, only to
>> discover - to my surprise - that Magnar's multiple-cursors package is
>> actually on Melpa.  It is GPL'd, however.)

> Would he / can he contribute it so we can put it in ELPA?

He already signed all the needed paperwork.  But there are probably
other contributors who haven't.


        Stefan




^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: bug#22873: Can we support multiple Cursors?
  2016-03-04 14:59           ` Stefan Monnier
@ 2016-03-04 22:18             ` Magnar Sveen
  2016-03-05  2:16               ` Stefan Monnier
  2016-03-06 20:33               ` Clément Pit--Claudel
  2016-03-05 12:58             ` Richard Stallman
  1 sibling, 2 replies; 83+ messages in thread
From: Magnar Sveen @ 2016-03-04 22:18 UTC (permalink / raw)
  To: Stefan Monnier, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1755 bytes --]

I'm pretty sure you don't want my multiple-cursors.el as an official
package. It's a major hack, basically trying to emulate the emacs command
loop in a post-command hook. After quite a lot of work, it now functions
properly for most commands - but it doesn't play so well in the presence of
other major hacks (like Evil).

I would say multiple cursors should be done properly if official.

Things that would help the multiple-cursors package, and also be a step
towards real support:

- allowing rendering of faux cursors. Right now I'm using inverted overlays
to create a block cursor (only).
- introduce the concept of cursor-local vars, much like buffer-local vars.
Right now I'm keeping track of a curated list of these in the package.
- document the inner workings of the command loop somewhere. This is what I
have right now:

(defun mc/execute-command (cmd)
  "Run command, simulating the parts of the command loop that makes sense
for fake cursors."
  (setq this-command cmd)
  (run-hooks 'pre-command-hook)
  (unless (eq this-command 'ignore)
    (call-interactively cmd))
  (run-hooks 'post-command-hook)
  (when deactivate-mark (deactivate-mark)))

I'm sure there's some nuance I'm missing, since there are still the odd
command that interacts oddly with it.

- Magnar


On Fri, Mar 4, 2016 at 3:59 PM Stefan Monnier <monnier@iro.umontreal.ca>
wrote:

> >> I understand all this.  (In fact, I wanted to write Elpa, only to
> >> discover - to my surprise - that Magnar's multiple-cursors package is
> >> actually on Melpa.  It is GPL'd, however.)
>
> > Would he / can he contribute it so we can put it in ELPA?
>
> He already signed all the needed paperwork.  But there are probably
> other contributors who haven't.
>
>
>         Stefan
>
>
>

[-- Attachment #2: Type: text/html, Size: 2411 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: Can we support multiple Cursors?
  2016-03-01 18:44 bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support) Keith David Bershatsky
  2016-03-03  6:30 ` bug#22873: Can we support multiple Cursors? John Wiegley
  2016-03-03  6:30 ` John Wiegley
@ 2016-03-04 23:16 ` Keith David Bershatsky
  2016-03-05  6:59   ` Marcin Borkowski
  2016-03-09  6:50   ` Keith David Bershatsky
  2016-03-09  6:27 ` Keith David Bershatsky
                   ` (28 subsequent siblings)
  31 siblings, 2 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2016-03-04 23:16 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: John Wiegley, 22873, Richard Stallman

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

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

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

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

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

Keith

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

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





^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: bug#22873: Can we support multiple Cursors?
  2016-03-04 22:18             ` Magnar Sveen
@ 2016-03-05  2:16               ` Stefan Monnier
  2016-03-05 13:00                 ` Richard Stallman
                                   ` (2 more replies)
  2016-03-06 20:33               ` Clément Pit--Claudel
  1 sibling, 3 replies; 83+ messages in thread
From: Stefan Monnier @ 2016-03-05  2:16 UTC (permalink / raw)
  To: Magnar Sveen; +Cc: emacs-devel

> I'm pretty sure you don't want my multiple-cursors.el as an official
> package.

Being in GNU ELPA doesn't mean it's "official".  It does grant some kind
of respectability, but the main things it does is:
- make sure the code has a reliable license (usually, not a bug deal
  for the end user).
- make sure it can be installed out of the box without any extra customization.
- gets to be seen (and can be fixed) by Emacs's maintainers, so tends to
  follow the conventions a bit better.
- gets to be seen by whoever watches elpa-diffs, so might be ever so
  slightly less at risk of malware.
- gets to be seen by Emacs's maintainers so they may become aware of
  some issues that might require changes to the core.
...

> - allowing rendering of faux cursors. Right now I'm using inverted overlays
> to create a block cursor (only).

Seems like a good solution.  If this bumps into problems, we should
probably try and improve overlay support rather than try to add
specific "multi-cursor" support in the redisplay engine.

> (defun mc/execute-command (cmd)
>   "Run command, simulating the parts of the command loop that makes sense
> for fake cursors."
>   (setq this-command cmd)
>   (run-hooks 'pre-command-hook)
>   (unless (eq this-command 'ignore)
>     (call-interactively cmd))
>   (run-hooks 'post-command-hook)
>   (when deactivate-mark (deactivate-mark)))

FWIW, we could/should work to move execute-command as well as the
read-eval loop from C to Elisp.

Note that the above is "wrong" also in the sense that execute-command does
not run pre/post command hooks (this is done by the read-eval loop
instead, around the call to command-execute).


        Stefan



^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: Can we support multiple Cursors?
  2016-03-04 23:16 ` Keith David Bershatsky
@ 2016-03-05  6:59   ` Marcin Borkowski
  2016-03-09  6:50   ` Keith David Bershatsky
  1 sibling, 0 replies; 83+ messages in thread
From: Marcin Borkowski @ 2016-03-05  6:59 UTC (permalink / raw)
  To: Keith David Bershatsky; +Cc: John Wiegley, 22873, Richard Stallman


On 2016-03-05, at 00:16, Keith David Bershatsky <esq@lawlist.com> wrote:

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

Out of curiosity: did you try iedit?  How does it compare wrt speed in
such extreme cases?  (If it's applicable at all, that is - it's way
simpler than multiple-cursors, of course.)

> Keith

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University





^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: bug#22873: Can we support multiple Cursors?
  2016-03-04 14:59           ` Stefan Monnier
  2016-03-04 22:18             ` Magnar Sveen
@ 2016-03-05 12:58             ` Richard Stallman
  1 sibling, 0 replies; 83+ messages in thread
From: Richard Stallman @ 2016-03-05 12:58 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > He already signed all the needed paperwork.  But there are probably
  > other contributors who haven't.

Could you talk with him about the situation?  Maybe we can
do without them.

-- 
Dr Richard Stallman
President, Free Software Foundation (gnu.org, fsf.org)
Internet Hall-of-Famer (internethalloffame.org)
Skype: No way! See stallman.org/skype.html.




^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: bug#22873: Can we support multiple Cursors?
  2016-03-05  2:16               ` Stefan Monnier
@ 2016-03-05 13:00                 ` Richard Stallman
  2016-03-06  4:47                 ` John Wiegley
  2016-03-06 20:30                 ` Clément Pit--Claudel
  2 siblings, 0 replies; 83+ messages in thread
From: Richard Stallman @ 2016-03-05 13:00 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel, magnar

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > Being in GNU ELPA doesn't mean it's "official".

It does, in some ways.  The packages in GNU ELPA are treated
mostly like part of Emacs, just distributed separately.

-- 
Dr Richard Stallman
President, Free Software Foundation (gnu.org, fsf.org)
Internet Hall-of-Famer (internethalloffame.org)
Skype: No way! See stallman.org/skype.html.




^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: bug#22873: Can we support multiple Cursors?
  2016-03-05  2:16               ` Stefan Monnier
  2016-03-05 13:00                 ` Richard Stallman
@ 2016-03-06  4:47                 ` John Wiegley
  2016-03-06 20:30                 ` Clément Pit--Claudel
  2 siblings, 0 replies; 83+ messages in thread
From: John Wiegley @ 2016-03-06  4:47 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel, Magnar Sveen

>>>>> Stefan Monnier <monnier@iro.umontreal.ca> writes:

> FWIW, we could/should work to move execute-command as well as the read-eval
> loop from C to Elisp.

I would like to see that happen too, if it makes sense.

-- 
John Wiegley                  GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com                          60E1 46C4 BD1A 7AC1 4BA2



^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: bug#22873: Can we support multiple Cursors?
  2016-03-05  2:16               ` Stefan Monnier
  2016-03-05 13:00                 ` Richard Stallman
  2016-03-06  4:47                 ` John Wiegley
@ 2016-03-06 20:30                 ` Clément Pit--Claudel
  2016-03-08  4:53                   ` Stefan Monnier
  2 siblings, 1 reply; 83+ messages in thread
From: Clément Pit--Claudel @ 2016-03-06 20:30 UTC (permalink / raw)
  To: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 596 bytes --]

On 03/04/2016 09:16 PM, Stefan Monnier wrote:
>> > - allowing rendering of faux cursors. Right now I'm using inverted overlays
>> > to create a block cursor (only).
>
> Seems like a good solution.  If this bumps into problems, we should
> probably try and improve overlay support rather than try to add
> specific "multi-cursor" support in the redisplay engine.

It already bumps into problems: when you set your cursor to a bar and use use multiple cursors, only the real one actually looks like a bar.
Maybe we could add an overlay property to display a cursor at the left edge?
 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: bug#22873: Can we support multiple Cursors?
  2016-03-04 22:18             ` Magnar Sveen
  2016-03-05  2:16               ` Stefan Monnier
@ 2016-03-06 20:33               ` Clément Pit--Claudel
  2016-03-08  4:55                 ` Stefan Monnier
  1 sibling, 1 reply; 83+ messages in thread
From: Clément Pit--Claudel @ 2016-03-06 20:33 UTC (permalink / raw)
  To: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 367 bytes --]

On 03/04/2016 05:18 PM, Magnar Sveen wrote:
> I'm sure there's some nuance I'm missing, since there are still the odd command that interacts oddly with it. 

Indeed: one such example is moving out of a composed region: secondary cursors (fake ones) move into prettified (composed) symbols, while the real cursor skips straight to the edges of composed regions.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: bug#22873: Can we support multiple Cursors?
  2016-03-06 20:30                 ` Clément Pit--Claudel
@ 2016-03-08  4:53                   ` Stefan Monnier
  0 siblings, 0 replies; 83+ messages in thread
From: Stefan Monnier @ 2016-03-08  4:53 UTC (permalink / raw)
  To: emacs-devel

>>> > - allowing rendering of faux cursors. Right now I'm using inverted
>>> > overlays to create a block cursor (only).
>> Seems like a good solution.  If this bumps into problems, we should
>> probably try and improve overlay support rather than try to add
>> specific "multi-cursor" support in the redisplay engine.
> It already bumps into problems: when you set your cursor to a bar and use
> use multiple cursors, only the real one actually looks like a bar.
> Maybe we could add an overlay property to display a cursor at the left edge?
 
Sounds like a fair solution.  Tho maybe it'd be even better to be able
to specify an overlay with a "bar cursor like thingy" regardless of what
kind of cursor is currently used.


        Stefan




^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: bug#22873: Can we support multiple Cursors?
  2016-03-06 20:33               ` Clément Pit--Claudel
@ 2016-03-08  4:55                 ` Stefan Monnier
  0 siblings, 0 replies; 83+ messages in thread
From: Stefan Monnier @ 2016-03-08  4:55 UTC (permalink / raw)
  To: emacs-devel

>> I'm sure there's some nuance I'm missing, since there are still the odd
>> command that interacts oddly with it. 

> Indeed: one such example is moving out of a composed region: secondary
> cursors (fake ones) move into prettified (composed) symbols, while the real
> cursor skips straight to the edges of composed regions.

Right: the adjust_point_for_property (in src/keyboard.c) functionality
should be exposed to Elisp.  It would be a part of a rewrite of the
read-eval loop.


        Stefan




^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: Can we support multiple Cursors?
  2016-03-01 18:44 bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support) Keith David Bershatsky
                   ` (2 preceding siblings ...)
  2016-03-04 23:16 ` Keith David Bershatsky
@ 2016-03-09  6:27 ` Keith David Bershatsky
  2016-03-09  6:45   ` Keith David Bershatsky
  2016-03-09 16:03   ` Eli Zaretskii
  2016-03-09 18:30 ` Keith David Bershatsky
                   ` (27 subsequent siblings)
  31 siblings, 2 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2016-03-09  6:27 UTC (permalink / raw)
  To: Marcin Borkowski, John Wiegley, Richard Stallman; +Cc: 22873

[-- Attachment #1: Type: text/plain, Size: 2687 bytes --]

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

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

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

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

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

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

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

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

Keith

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

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


[-- Attachment #2: multiple_cursors.diff --]
[-- Type: application/diff, Size: 58382 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: bug#22873: Can we support multiple Cursors?
  2016-03-09  6:27 ` Keith David Bershatsky
@ 2016-03-09  6:45   ` Keith David Bershatsky
  2016-03-09 16:03   ` Eli Zaretskii
  1 sibling, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2016-03-09  6:45 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 3414 bytes --]

Here is a duplicate copy of my recent e-mail and draft patch for the benefit of the emacs-devel@gnu.org

I will add emacs-devel@gnu.org to my list of automatic carbon-copy replies.

Thanks,

Keith

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

Begin forwarded message:

> From: Keith David Bershatsky <esq@lawlist.com>
> Date: March 8, 2016 10:27:02 PM PST
> To: Marcin Borkowski <mbork@mbork.pl>, John Wiegley <jwiegley@gmail.com>, Richard Stallman <rms@gnu.org>
> Cc: 22873@debbugs.gnu.org
> Subject: Re: bug#22873: Can we support multiple Cursors?
> 
> The second draft of the proposed feature for multiple fake cursors is attached.  For the record, I'm not a programmer -- just a hobbyist -- and the draft patch is not meant to be a proposed official patch -- it is just a working proof concept.  The patch contains a few extra things that I use for debugging and also for drawing my solid vertical line that tracks the cursor position.  It has been tested to some extent on Emacs built for OSX 10.6.8 and Windows XP (SP-3).  Different colors for each fake cursor have already been implemented on Emacs for OSX, but I haven't yet looked into how to accomplish that objective on Emacs for Windows.  The draft concept patch is for the master branch as of March 8, 2016 bearing commit "e0400b72a24d67b53f71c8b97915cae599e36c37".  After applying the patch, the new feature can be tested as follows:
> 
> (defun mc-test (&optional list)
> "Draw fake cursors at all POS defined in the `mc-list'."
> (interactive)
>  (setq mc-list '(
>    (3 "hbar" [1.0 0.0 0.0])
>    (4 "bar" [0.0 1.0 0.0])
>    (5 "box" [0.0 0.0 1.0])
>    (6 "hollow" [1.0 1.0 1.0])
>    (7 ("hbar" 3) [1.0 0.0 1.0])
>    (8 ("bar" 3) [0.0 1.0 1.0]))))
> 
> (global-set-key [f1] 'mc-test)
> 
> To remove the cursors or change the cursors, just modify the buffer-local variable `mc-list' -- e.g., `(setq mc-list nil)` removes them all.  The colors on OSX are the standard RGB color vector.
> 
> Thank you, Marcin, for the referral to the ideit feature.  I will certainly try that feature out in the next few days, but have been buried in life's daily activities and also in acquiring the necessary skills to implement the fake cursors feature.
> 
> It sure would be great if a real programmer (instead of just a hobbyist like myself) could take this feature to the next level.  If the Windows setup is anything similar to OSX, implementing colors should not be that difficult to achieve (at least I hope that is the case).
> 
> I would like this feature to be similar to the original cursor such that a variable like `cursor-in-non-selected-windows' can be used to make the fake cursors displayed in only the selected window or in all windows where those points are visible.  At the present time, I've set it up so that only the selected window receives the fake cursors (as that is my personal preference).
> 
> Thank you for taking an interest in this potential new feature,
> 
> Keith
> 
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> 
> At Sat, 05 Mar 2016 07:59:52 +0100,
> Marcin Borkowski wrote:
>> 
>> * * *
>> 
>> Out of curiosity: did you try iedit?  How does it compare wrt speed in
>> such extreme cases?  (If it's applicable at all, that is - it's way
>> simpler than multiple-cursors, of course.)
> 

[-- Attachment #2: multiple_cursors.diff --]
[-- Type: application/diff, Size: 58382 bytes --]

[-- Attachment #3: Type: text/plain, Size: 1 bytes --]



^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: bug#22873: Can we support multiple Cursors?
  2016-03-04 23:16 ` Keith David Bershatsky
  2016-03-05  6:59   ` Marcin Borkowski
@ 2016-03-09  6:50   ` Keith David Bershatsky
  1 sibling, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2016-03-09  6:50 UTC (permalink / raw)
  To: emacs-devel

Here is a copy of my e-mail from last Friday that I forgot to send to emacs-devel@gnu.org

Thanks,

Keith

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

Begin forwarded message:

> From: Keith David Bershatsky <esq@lawlist.com>
> Date: March 4, 2016 3:16:56 PM PST
> To: Marcin Borkowski <mbork@mbork.pl>
> Cc: 22873@debbugs.gnu.org, John Wiegley <jwiegley@gmail.com>, Richard Stallman <rms@gnu.org>
> Subject: Re: bug#22873: Can we support multiple Cursors?
> 
> I see this feature request as having two (2) distinct, yet related components.  The fake cursors being the first component that will operate similar to overlays, and are thus fairly innocuous as they won't have any real affect on where point is located after redisplay finishes.  The second component, however, is the functionality that can be found in Magnar Sveen's library and also is present in a popular commercial editor known as Sublime Text.
> 
> I enjoy using the multiple cursors library written by Magnar Sveen, but often find myself taking advantage of the wait times to pour myself a cup of coffee while making edits with a few hundred fake cursors in a large buffer.  E.g., I will type the word I want inserted or tap the arrow key a few times in a particular direction and then walk away from the computer or surf the web while Emacs does its thing.  I often have to use `M-x replace-string` when dealing with large numbers of edits instead of using my preferred choice of multiple cursors.  Admittedly, I am using a slightly older customized version of Mr. Sveen's library -- but I don't think the basic functionality has changed all that much since I first started using it.
> 
> I am not a programmer by trade, but I assume there could be some significant speed increases by having multiple cursor abilities baked into the C code base of the Emacs internals.
> 
> I don't think (based on my limited programming knowledge) that all of the cursor-types are presently available as overlays.  I need the left bar cursor so that I can draw my solid vertical line that tracks the cursor position, and so that is what motivated me to write a sample draft patch to the C internals.  My draft is progressing nicely, but it is slow to perfect because I am learning a few of the basics to the C language as I go.  I'll post to #22873 a revised draft of the first component (i.e., just fake cursors) in the next few days depending upon how many road blocks I encounter.  I've set up a simple cache of x/y/hpos/vpos so that recalculation is not necessary when the list of fake cursors doesn't change -- cursors are redrawn more than once per command loop depending upon what happens, e.g., with the mouse, etc.  And a user may not wish to change the positions of fake cursors every command loop, so the cache is helpful.
> 
> It may be a very long time, however, before I have enough basic skills to be able to implement some of the functionality of the second component.  I understand the implementation of feature 22873 is only a discussion at this point in time.  The beauty of Emacs, however, is that it's open source and I can make modifications to a custom build for my in-house use.  :)
> 
> Keith
> 
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> 
> At Thu, 03 Mar 2016 07:54:17 +0100,
> Marcin Borkowski wrote:
>> 
>> 
>> * * *
>> 
>> What would be the added value of having that built-in vs. having it on
>> M?elpa?
>> 
>> Best,
>> 
>> -- 
>> Marcin Borkowski




^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: Can we support multiple Cursors?
  2016-03-09  6:27 ` Keith David Bershatsky
  2016-03-09  6:45   ` Keith David Bershatsky
@ 2016-03-09 16:03   ` Eli Zaretskii
  1 sibling, 0 replies; 83+ messages in thread
From: Eli Zaretskii @ 2016-03-09 16:03 UTC (permalink / raw)
  To: Keith David Bershatsky; +Cc: jwiegley, mbork, rms, 22873

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

Looks like quite a few of the changes in the patch are not really
related to multiple cursors.  Did you produce diffs for all of your
other local changes?

> diff --git a/src/buffer.h b/src/buffer.h
> index 5783bfb..01c3755 100644
> --- a/src/buffer.h
> +++ b/src/buffer.h
> @@ -643,6 +643,15 @@ struct buffer
>       cache are enabled.  See search.c, indent.c and bidi.c for details.  */
>    Lisp_Object cache_long_scans_;
>  
> +  /* The name of the hook.  */
> +  Lisp_Object window_start_end_hook_;
> +
> +  /* The name of list.  */
> +  Lisp_Object posn_list_;
> +
> +  /* The name of list used by multiple cursors for next redisplay.  */
> +  Lisp_Object mc_list_;
> +
>    /* 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
> @@ -885,6 +894,21 @@ struct buffer
>     buffer.  (Some setters that are private to a single .c file are
>     defined as static in those files.)  */
>  INLINE void
> +bset_window_start_end_hook (struct buffer *b, Lisp_Object val)
> +{
> +  b->window_start_end_hook_ = val;
> +}

The above inline function and the corresponding member of struct
buffer seems unrelated.

> diff --git a/src/keyboard.c b/src/keyboard.c
> index 4e1ac15..329cba0 100644
> --- a/src/keyboard.c
> +++ b/src/keyboard.c
> @@ -1244,6 +1244,15 @@ static int read_key_sequence (Lisp_Object *, int, Lisp_Object,
>                                bool, bool, bool, bool);
>  static void adjust_point_for_property (ptrdiff_t, bool);
>  
> +static void
> +set_window_start_end_hook (void)
> +{
> +  Lisp_Object window = (selected_window);
> +  struct window *w = decode_live_window (window);
> +  w->window_start_end_hook_force = true;
> +  w->window_start_end_hook_pending = true;
> +}
> +
>  Lisp_Object
>  command_loop_1 (void)
>  {
> @@ -1269,6 +1278,8 @@ command_loop_1 (void)
>        if (!NILP (Vpost_command_hook) && !NILP (Vrun_hooks))
>  	safe_run_hooks (Qpost_command_hook);
>  
> +      set_window_start_end_hook ();
> +
>        /* If displaying a message, resize the echo area window to fit
>  	 that message's size exactly.  */
>        if (!NILP (echo_area_buffer[0]))
> @@ -1485,6 +1496,8 @@ command_loop_1 (void)
>  
>        safe_run_hooks (Qpost_command_hook);
>  
> +      set_window_start_end_hook ();
> +
>        /* If displaying a message, resize the echo area window to fit
>  	 that message's size exactly.  */
>        if (!NILP (echo_area_buffer[0]))

Likewise.

> diff --git a/src/xdisp.c b/src/xdisp.c
> index 5b96144..102ac23 100644
> --- a/src/xdisp.c
> +++ b/src/xdisp.c
> @@ -13414,6 +13414,93 @@ do { if (! polling_stopped_here) stop_polling ();	\
>  do { if (polling_stopped_here) start_polling ();	\
>         polling_stopped_here = false; } while (false)
>  
> +static void
> +run_window_start_end_hook (Lisp_Object window, struct text_pos startp, EMACS_INT posint, struct it it, char *string, bool force)
> +{

Likewise.

> +    case 'w':
> +      {
> +  ptrdiff_t window_start = marker_position (w->start);
> +  pint2str (decode_mode_spec_buf, width, window_start);
> +  return decode_mode_spec_buf;
> +      }
> +
> +    case 'W':
> +      {
> +  ptrdiff_t window_end = BUF_Z (b) - w->window_end_pos;
> +  pint2str (decode_mode_spec_buf, width, window_end);
> +  return decode_mode_spec_buf;
> +      }
> +

Likewise.

> +static const char *
> +internal_line_number_at_position (struct window *w, register int c, int field_width, Lisp_Object *string)
> +{

Likewise.

> +DEFUN ("line-number-at-position", Fline_number_at_position, Sline_number_at_position, 1, 2, 0,
> +       doc: /* Return line number at position.  */)
> +  (Lisp_Object window, Lisp_Object pos)
> +{

Likewise.

Thanks.





^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: Can we support multiple Cursors?
  2016-03-01 18:44 bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support) Keith David Bershatsky
                   ` (3 preceding siblings ...)
  2016-03-09  6:27 ` Keith David Bershatsky
@ 2016-03-09 18:30 ` Keith David Bershatsky
  2016-03-11  7:18 ` Keith David Bershatsky
                   ` (26 subsequent siblings)
  31 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2016-03-09 18:30 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: jwiegley, mbork, rms, 22873

Thank you, Eli, for taking a look at the second draft patch.  I agree that the unrelated features need to be removed so that we can focus specifically on feature 22873.

I would like some of my unrelated custom features to be available in-house while I am implementing fake cursors, but do not yet know how to easily separate them when creating a patch.  Absent that git knowledge, I will be manually cutting out those unrelated features in the various source code files and then creating a new diff that is 22873 specific.

The next phase will be for me to track down how to convert color vector RGB (three float numbers) to something that Emacs for Windows can recognize.  Different colors for each fake cursor is already working in Emacs for OSX 10.6.8.  When that next phase is implemented, I will ensure that the third draft patch is exclusively feature 22873 specific.

Keith

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

At Wed, 09 Mar 2016 18:03:25 +0200,
Eli Zaretskii wrote:
> 
> * * *
> 
> Looks like quite a few of the changes in the patch are not really
> related to multiple cursors.  Did you produce diffs for all of your
> other local changes?
> 
> * * *





^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: Can we support multiple Cursors?
  2016-03-01 18:44 bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support) Keith David Bershatsky
                   ` (4 preceding siblings ...)
  2016-03-09 18:30 ` Keith David Bershatsky
@ 2016-03-11  7:18 ` Keith David Bershatsky
  2016-03-14 18:35 ` Keith David Bershatsky
                   ` (25 subsequent siblings)
  31 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2016-03-11  7:18 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: jwiegley, mbork, rms, 22873

[-- Attachment #1: Type: text/plain, Size: 1612 bytes --]

Attached is the third draft, multiple_cursors_003.diff, which applies to the master branch as of commit "ea626c72e590aa7a45fd26df42240854e4225cef" on March 10, 2015.

Different colors for each fake cursor are now supported on Emacs for Windows (XP SP-3) and OSX (10.6.8).

The next phase will be to separate the custom feature called `window-start-end-hook` from this new fake cursor feature 22873.  Currently, I am using the existence of a definitive window-start and window-end derived from the `window-start-end-hook` as a guide and condition precedent to placing the fake cursors.  Given that fake cursors are placed late in the stage of the redisplay process, I suspect that I can rely on other methods to extract the correct window-start and window-end.

The other unrelated features that were present in my first couple of drafts have been removed from this third draft.  The fake cursors feature works as follows -- to erase everything or change anything, just modify the `mc-list':

(defun mc-test (&optional list)
"Draw fake cursors at all POS defined in the `mc-list'.
Color vector is LSL (The Linden Scripting Language), rather than standard RGB.
`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."
(interactive)
  (setq mc-list '(
    (3 "hbar" [1.0 0.0 0.0])
    (4 "bar" [0.0 1.0 0.0])
    (5 "box" [0.0 0.0 1.0])
    (6 "hollow" [0.8 0.4 0.2])
    (7 ("hbar" 3) [1.0 0.0 1.0])
    (8 ("bar" 3) [0.0 1.0 1.0]))))

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


[-- Attachment #2: multiple_cursors_003.diff --]
[-- Type: application/diff, Size: 47912 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: Can we support multiple Cursors?
  2016-03-01 18:44 bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support) Keith David Bershatsky
                   ` (5 preceding siblings ...)
  2016-03-11  7:18 ` Keith David Bershatsky
@ 2016-03-14 18:35 ` Keith David Bershatsky
  2016-03-14 18:49   ` Eli Zaretskii
  2016-03-14 22:38 ` Keith David Bershatsky
                   ` (24 subsequent siblings)
  31 siblings, 1 reply; 83+ messages in thread
From: Keith David Bershatsky @ 2016-03-14 18:35 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: John Wiegley, Marcin Borkowski, 22873, Richard Stallman

Help, please:  :)

I reached a roadblock on Emacs for Windows and I haven't the slightest idea why my cached list of multiple cursors is being converted into a value `<optimized out>` sporadically when holding down the arrow key and moving the active cursor repetitively through plain text in a fundamental-mode buffer.  Emacs crashes in that circumstance.  The cache is a Lisp_Object pointer defined in `window.h` named mc_cache (aka `w->mc_cache`).  The value of `w->mc_cache` is:

  '((
    (3 hbar [1.0 0.0 0.0])
    (4 bar [0.0 1.0 0.0])
    (5 box [0.0 0.0 1.0])
    (6 hollow [0.8 0.4 0.2])
    (7 (hbar 3) [1.0 0.0 1.0])
    (8 (bar 3) [0.0 1.0 1.0]))
   (
    ((3 hbar [1.0 0.0 0.0]) (22 20 2 0))
    ((4 bar [0.0 1.0 0.0]) (33 20 3 0))
    ((5 box [0.0 0.0 1.0]) (44 20 4 0))
    ((6 hollow [0.8 0.4 0.2]) (55 20 5 0))
    ((7 (hbar 3) [1.0 0.0 1.0]) (66 20 6 0))
    ((8 (bar 3) [0.0 1.0 1.0]) (77 20 7 0))
    ))

The "for" loop looks like this and Emacs crashes when reading the line containing "cursor_spec_list = XCAR (XCAR (vlist))".  `cursor_spec_list` and `vlist` are both Lisp_Object:

   for (vlist = XCAR (XCDR (w->mc_cache));
        CONSP (vlist);
        vlist = XCDR (vlist))
     {
       cursor_spec_list = XCAR (XCAR (vlist));
       ***

Here is the gdb backtrace:

Administrator@lawlistf0aa /c/docume~1/administrator/desktop/emacs
$ gdb /c/docume~1/administrator/desktop/trunk/bin/emacs.exe
GNU gdb (GDB) 7.6.1
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "mingw32".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from c:\docume~1\administrator\desktop\trunk\bin\emacs.exe...don
e.
(gdb) run
Starting program: c:/docume~1/administrator/desktop/trunk/bin/emacs.exe
[New Thread 1784.0x360]
[New Thread 1784.0x310]
[New Thread 1784.0x75c]
[New Thread 1784.0x1e8]
[New Thread 1784.0x3ec]

Program received signal SIGSEGV, Segmentation fault.
mc_calc (w=w@entry=0x55d24b8) at xdisp.c:29025
29025             cursor_spec_list = XCAR (XCAR (vlist));
(gdb) print vlist
$1 = -1006130013
(gdb) print cursor_spec_list
$2 = <optimized out>
(gdb) backtrace
#0  mc_calc (w=w@entry=0x55d24b8) at xdisp.c:29025
#1  0x010448db in display_and_set_cursor (w=w@entry=0x55d24b8,
    on=on@entry=true, hpos=57, vpos=17, x=627, y=345) at xdisp.c:29286
#2  0x011665e0 in x_update_window_end (w=0x55d24b8, cursor_on_p=true,
    mouse_face_overwritten_p=false) at w32term.c:686
#3  0x01005c13 in update_window (w=w@entry=0x55d24b8,
    force_p=<optimized out>, force_p@entry=true) at dispnew.c:3539
#4  0x01006e72 in update_window_tree (w=w@entry=0x55d24b8,
    force_p=force_p@entry=true) at dispnew.c:3217
#5  0x01009450 in update_frame (f=f@entry=0x55d2350, force_p=<optimized out>,
    force_p@entry=false, inhibit_hairy_id_p=inhibit_hairy_id_p@entry=false)
    at dispnew.c:3106
#6  0x0103ab20 in redisplay_internal () at xdisp.c:14142
#7  0x0103b9d8 in redisplay () at xdisp.c:13171
#8  0x010a3aed in read_char (commandflag=commandflag@entry=1,
    map=map@entry=136502483, prev_event=0,
    used_mouse_menu=used_mouse_menu@entry=0x82f8db,
    end_time=end_time@entry=0x0) at keyboard.c:2483
#9  0x010a6006 in read_key_sequence (keybuf=keybuf@entry=0x82f978,
    prompt=prompt@entry=0, dont_downcase_last=dont_downcase_last@entry=false,
    can_return_switch_frame=can_return_switch_frame@entry=true,
    fix_current_buffer=fix_current_buffer@entry=true,
    prevent_redisplay=prevent_redisplay@entry=false, bufsize=30)
    at keyboard.c:9066
#10 0x010a786f in command_loop_1 () at keyboard.c:1369
#11 0x010ff9e7 in internal_condition_case (
    bfun=bfun@entry=0x10a7697 <command_loop_1>,
    handlers=handlers@entry=12256, hfun=hfun@entry=0x109f644 <cmd_error>)
    at eval.c:1309
#12 0x0109b233 in command_loop_2 (ignore=0) at keyboard.c:1100
#13 0x010ff9ab in internal_catch (tag=tag@entry=32480,
    func=func@entry=0x109b214 <command_loop_2>, arg=arg@entry=0)
    at eval.c:1074
#14 0x0109b1f5 in command_loop () at keyboard.c:1079
#15 0x0109f2fc in recursive_edit_1 () at keyboard.c:685
#16 0x0109f58c in Frecursive_edit () at keyboard.c:756
#17 0x011b76fa in main (argc=<optimized out>, argv=0xa428b0) at emacs.c:1617
(gdb)

Thanks,

Keith





^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: Can we support multiple Cursors?
  2016-03-14 18:35 ` Keith David Bershatsky
@ 2016-03-14 18:49   ` Eli Zaretskii
  0 siblings, 0 replies; 83+ messages in thread
From: Eli Zaretskii @ 2016-03-14 18:49 UTC (permalink / raw)
  To: Keith David Bershatsky; +Cc: jwiegley, mbork, 22873, rms

> Date:  Mon, 14 Mar 2016 11:35:18 -0700
> From:  Keith David Bershatsky <esq@lawlist.com>
> Cc:  22873@debbugs.gnu.org,John Wiegley <jwiegley@gmail.com>,Marcin Borkowski <mbork@mbork.pl>,Richard Stallman <rms@gnu.org>
> 
> I reached a roadblock on Emacs for Windows and I haven't the slightest idea why my cached list of multiple cursors is being converted into a value `<optimized out>` sporadically when holding down the arrow key and moving the active cursor repetitively through plain text in a fundamental-mode buffer.  Emacs crashes in that circumstance.  The cache is a Lisp_Object pointer defined in `window.h` named mc_cache (aka `w->mc_cache`).  The value of `w->mc_cache` is:
> 
>   '((
>     (3 hbar [1.0 0.0 0.0])
>     (4 bar [0.0 1.0 0.0])
>     (5 box [0.0 0.0 1.0])
>     (6 hollow [0.8 0.4 0.2])
>     (7 (hbar 3) [1.0 0.0 1.0])
>     (8 (bar 3) [0.0 1.0 1.0]))
>    (
>     ((3 hbar [1.0 0.0 0.0]) (22 20 2 0))
>     ((4 bar [0.0 1.0 0.0]) (33 20 3 0))
>     ((5 box [0.0 0.0 1.0]) (44 20 4 0))
>     ((6 hollow [0.8 0.4 0.2]) (55 20 5 0))
>     ((7 (hbar 3) [1.0 0.0 1.0]) (66 20 6 0))
>     ((8 (bar 3) [0.0 1.0 1.0]) (77 20 7 0))
>     ))
> 
> The "for" loop looks like this and Emacs crashes when reading the line containing "cursor_spec_list = XCAR (XCAR (vlist))".  `cursor_spec_list` and `vlist` are both Lisp_Object:
> 
>    for (vlist = XCAR (XCDR (w->mc_cache));
>         CONSP (vlist);
>         vlist = XCDR (vlist))
>      {
>        cursor_spec_list = XCAR (XCAR (vlist));
>        ***

You maintain a Lisp object in a window object, but did you make sure
it's declared before the place in 'struct window' where we have this
comment:

    /* 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.  */

If mc_cache is beyond this point, chances are it's being GC'ed behind
your back.





^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: Can we support multiple Cursors?
  2016-03-01 18:44 bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support) Keith David Bershatsky
                   ` (6 preceding siblings ...)
  2016-03-14 18:35 ` Keith David Bershatsky
@ 2016-03-14 22:38 ` Keith David Bershatsky
  2016-03-16  8:00 ` Keith David Bershatsky
                   ` (23 subsequent siblings)
  31 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2016-03-14 22:38 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: John Wiegley, Marcin Borkowski, 22873, Richard Stallman

[-- Attachment #1: Type: text/plain, Size: 2383 bytes --]

Thank you, Eli, for resolving the issue with the `mc_cache` being GC'ed behind my back.  As per your suggestion, I moved the Lisp_Object definition of `mc_cache` in `window.h` to above the section beginning with the comment "No Lisp data may follow below this point . . . ."  I also moved the other mc-realted `int` and `bool_bf` definitions into the section beginning with "#ifdef HAVE_WINDOW_SYSTEM".

The enclosed `multiple_cursors_004.diff` applies to Emacs master branch from last night (March 13, 2016) bearing commit "181e92c4e060a7ce4740b561375f9ec9f473f144".

Multiple fake cursors now have preliminary support on all three (3) window systems -- i.e., X (--with-x --with-x-toolkit=no), Windows (XP SP-3) and OSX (10.6.8).

I will need to track down why (on Emacs for Windows) a fake cursor appearing as FILLED_BOX_CURSOR sometimes takes on the background color of the real active cursor.  This seems to depend upon whether I start with Emacs -Q versus a full configuration, so perhaps it won't be that difficult to track down.

I haven't done any calculations regarding the time needed to run `mc_x_y_hpos_vpos` on each position for fake cursors, so I don't really know how advantageous a cache is and whether more effort should be made to perfect a caching mechanism.

I'm assuming that just multiplying the LSL color vector elements by 255 for Windows and by 65535 for X is sufficient to obtain the exact color, but it certainly appears to look okay to my untrained eyes.

(defun mc-test (&optional list)
"Draw fake cursors at all POS defined in the `mc-list'.  Multiple fake cursors
are supported by GUI versions of Emacs built for X, Windows and OSX.
Color vector is LSL (The Linden Scripting Language), rather than standard RGB.
`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)
  (setq mc-list (if list list '(
    (3 "hbar" [1.0 0.0 0.0])
    (4 "bar" [0.0 1.0 0.0])
    (5 "box" [0.0 0.0 1.0])
    (6 "hollow" [0.8 0.4 0.2])
    (7 ("hbar" 3) [1.0 0.0 1.0])
    (8 ("bar" 3) [0.0 1.0 1.0])))))

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


[-- Attachment #2: multiple_cursors_004.diff --]
[-- Type: application/diff, Size: 35638 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: Can we support multiple Cursors?
  2016-03-01 18:44 bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support) Keith David Bershatsky
                   ` (7 preceding siblings ...)
  2016-03-14 22:38 ` Keith David Bershatsky
@ 2016-03-16  8:00 ` Keith David Bershatsky
  2016-03-18  4:00 ` Keith David Bershatsky
                   ` (22 subsequent siblings)
  31 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2016-03-16  8:00 UTC (permalink / raw)
  To: 22873; +Cc: John Wiegley, Marcin Borkowski, Richard Stallman

[-- Attachment #1: Type: text/plain, Size: 1510 bytes --]

This fifth draft patch `multiple_cursors_005.diff` fixes the problem mentioned in my last email with the FILLED_BOX_CURSOR (a fake cursor) sometimes taking on the background color of the primary active cursor.  I see that the fake cursors do not always appear immediately in Emacs for Windows after pressing the F1 key to trigger the Lisp function `mc-test` -- i.e., there is a delay before the screen updates, so that will be one of my next projects to debug.  I didn't update the master branch tonight, so the patch applies as of the March 13, 2016 commit bearing "181e92c4e060a7ce4740b561375f9ec9f473f144".

(defun mc-test (&optional list)
"Draw fake cursors at all POS defined in the `mc-list'.  Multiple fake cursors
are supported by GUI versions of Emacs built for X, Windows and OSX.
Color vector is LSL (The Linden Scripting Language), rather than standard RGB.
`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)
  (setq mc-list (if list list '(
    (3 "hbar" [1.0 0.0 0.0])
    (4 "bar" [0.0 1.0 0.0])
    (5 "box" [0.0 0.0 1.0])
    (6 "hollow" [0.8 0.4 0.2])
    (7 ("hbar" 3) [1.0 0.0 1.0])
    (8 ("bar" 3) [0.0 1.0 1.0])))))

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


[-- Attachment #2: multiple_cursors_005.diff --]
[-- Type: application/diff, Size: 38068 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: Can we support multiple Cursors?
  2016-03-01 18:44 bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support) Keith David Bershatsky
                   ` (8 preceding siblings ...)
  2016-03-16  8:00 ` Keith David Bershatsky
@ 2016-03-18  4:00 ` Keith David Bershatsky
  2016-03-26 23:58   ` John Wiegley
  2016-03-29  3:45 ` Keith David Bershatsky
                   ` (21 subsequent siblings)
  31 siblings, 1 reply; 83+ messages in thread
From: Keith David Bershatsky @ 2016-03-18  4:00 UTC (permalink / raw)
  To: 22873; +Cc: John Wiegley, Marcin Borkowski, Richard Stallman

[-- Attachment #1: Type: text/plain, Size: 2210 bytes --]

Attached is the next draft patch -- multiple_cursors_006.diff -- that applies to Emacs master branch as of March 17, 2016, bearing commit "2fbdb1bb4c878f8ae17bd69d1b4ff51c47497e41".

This patch resolves the issue relating to a delay of the fake cursors appearing in Emacs for Windows.  The bug was caused because I had erroneously thought that the tail end of `redisplay_window' would be a sufficient location to calculate window-start/end for all circumstances, but it turned out that initializing fake cursors by merely setting the `mc-list` variable does not necessarily trigger the tail end of the former internal function.  Thus, there is now a second location at the beginning of `mc_calc' to determine window-start/end if it has not already been determined.  Other changes include setting up a struct prefix of `mc` in window.h for the pointers, except for the Lisp_Object `mc_cache' which apparently requires special treatment not lending itself to using a prefix.

That was the last of the known problems with fake cursors, so the next phase will be for me to try it out with a custom minor mode over the next few weeks to see what else may be needed.  The current draft patch has been lightly tested on Emacs for all three (3) window systems -- X11 (no toolkit), Windows (XP SP-3), and OSX (10.6.8).

(defun mc-test (&optional list)
"Draw fake cursors at all POS defined in the `mc-list'.  Multiple fake cursors
are supported by GUI versions of Emacs built for X, Windows and OSX.
Color vector is LSL (The Linden Scripting Language), rather than standard RGB.
`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)
  (setq mc-list (if list list '(
    (3 "hbar" [1.0 0.0 0.0])
    (4 "bar" [0.0 1.0 0.0])
    (5 "box" [0.0 0.0 1.0])
    (6 "hollow" [0.8 0.4 0.2])
    (7 ("hbar" 3) [1.0 0.0 1.0])
    (8 ("bar" 3) [0.0 1.0 1.0])))))

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


[-- Attachment #2: multiple_cursors_006.diff --]
[-- Type: application/diff, Size: 39269 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: Can we support multiple Cursors?
  2016-03-18  4:00 ` Keith David Bershatsky
@ 2016-03-26 23:58   ` John Wiegley
  0 siblings, 0 replies; 83+ messages in thread
From: John Wiegley @ 2016-03-26 23:58 UTC (permalink / raw)
  To: Keith David Bershatsky; +Cc: Marcin Borkowski, 22873, Richard Stallman

>>>>> Keith David Bershatsky <esq@lawlist.com> writes:

> That was the last of the known problems with fake cursors, so the next phase
> will be for me to try it out with a custom minor mode over the next few
> weeks to see what else may be needed. The current draft patch has been
> lightly tested on Emacs for all three (3) window systems -- X11 (no
> toolkit), Windows (XP SP-3), and OSX (10.6.8).

Thanks for carrying forward with this research, Keith!

-- 
John Wiegley                  GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com                          60E1 46C4 BD1A 7AC1 4BA2





^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: Can we support multiple Cursors?
  2016-03-01 18:44 bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support) Keith David Bershatsky
                   ` (9 preceding siblings ...)
  2016-03-18  4:00 ` Keith David Bershatsky
@ 2016-03-29  3:45 ` Keith David Bershatsky
  2016-03-29 14:58   ` Eli Zaretskii
  2016-03-29 17:26 ` Keith David Bershatsky
                   ` (20 subsequent siblings)
  31 siblings, 1 reply; 83+ messages in thread
From: Keith David Bershatsky @ 2016-03-29  3:45 UTC (permalink / raw)
  To: 22873; +Cc: John Wiegley, Marcin Borkowski, Richard Stallman

[-- Attachment #1: Type: text/plain, Size: 4692 bytes --]

The attached multiple_cursors_007.diff applies to the master branch as of today, March 28, 2016, bearing commit a30e7e12ed8465e2565dd318d921bc87f52ce18e.

mc_calc now runs from the applicable nsterm.m/w32term.c/xterm.c, instead of xdisp.c.  mc-calc has been broken down into 3 distinct sections, rather than if / if else / if else.  A bool argument has been added to mc_calc -- true for remove/cleanup, false for draw fake cursors.  The real cursor is redrawn if mc-list is set to Qnil (just in case it got erased during cleanup).  I do not believe mc_calc needs to run inside xdisp.c where draw_window_cursor is called at either location.

I've lightly tested this patch on Windows (XP SP-3), X11 (on an OSX box), and OSX (10.6.8).  I've switched over my own in-house setup to use this latest patch and I will be making notes of any problems as they arise -- e.g., I see there are a few rare instances where some of the fake cursors are not getting erased on OSX, and I see that Windows is a little slow drawing fake cursors when dealing with about 50 on the screen [I'm testing in a virtual machine called Parallels).  My primary usage of fake cursors is a vertical line that tracks the cursor position (compatible with word-wrap), and my secondary usage is with Magnar's library.

The usage of this patch is as follows:

    (defun mc-test (&optional list)
    "Draw fake cursors at all POS defined in the `mc-list'.  Multiple fake cursors
    are supported by GUI versions of Emacs built for X, Windows and OSX.
    Color vector is LSL (The Linden Scripting Language), rather than standard RGB.
    `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)
      (setq mc-list (if list list '(
        (3 "hbar" [1.0 0.0 0.0])
        (4 "bar" [0.0 1.0 0.0])
        (5 "box" [0.0 0.0 1.0])
        (6 "hollow" [0.8 0.4 0.2])
        (7 ("hbar" 3) [1.0 0.0 1.0])
        (8 ("bar" 3) [0.0 1.0 1.0])))))

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


For anyone interested in trying out this latest patch with Magnar's library, the following are the only modifications that I am are of that would be needed (as of today, 03/28/2016) -- blue colored bar cursor for even numbered columns, red colored bar cursor for odd numbered columns.  One of the nifty things I see is that these fake cursors work well when placed at the very end of a line.

    (require 'multiple-cursors)

    (defun mc/clear-mc-list ()
      (setq mc-list nil))

    (add-hook 'multiple-cursors-mode-disabled-hook 'mc/clear-mc-list)

    (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 (make-overlay (point) (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)))
        (let* (
            (overlays (mc/all-fake-cursors))
            (lst
              (mapcar
                (lambda (x)
                  (save-excursion
                    (let* (
                        current-column
                        (pos (overlay-start x)))
                      (goto-char pos)
                      (setq current-column (current-column))
                      (cond
                        ((oddp current-column)
                          (list pos "bar" [1.0 0.0 0.0])) ;; red
                        ((evenp current-column)
                          (list pos "bar" [0.0 0.0 1.0])))))) ;; blue
                overlays)) )
          (setq mc-list lst))
        overlay))

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


[-- Attachment #2: multiple_cursors_007.diff --]
[-- Type: application/diff, Size: 43091 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: Can we support multiple Cursors?
  2016-03-29  3:45 ` Keith David Bershatsky
@ 2016-03-29 14:58   ` Eli Zaretskii
  0 siblings, 0 replies; 83+ messages in thread
From: Eli Zaretskii @ 2016-03-29 14:58 UTC (permalink / raw)
  To: Keith David Bershatsky; +Cc: jwiegley, mbork, 22873, rms

> Date:  Mon, 28 Mar 2016 20:45:07 -0700
> From:  Keith David Bershatsky <esq@lawlist.com>
> Cc:  John Wiegley <jwiegley@gmail.com>,Eli Zaretskii <eliz@gnu.org>,Marcin Borkowski <mbork@mbork.pl>,Richard Stallman <rms@gnu.org>
> 
> The attached multiple_cursors_007.diff applies to the master branch as of today, March 28, 2016, bearing commit a30e7e12ed8465e2565dd318d921bc87f52ce18e.
> 
> mc_calc now runs from the applicable nsterm.m/w32term.c/xterm.c, instead of xdisp.c.

Why is that a good idea?  You have 3 almost identical copies of the
same code, which goes against our long-time trend to have terminal
independent code only once, for easier maintenance.

>                         ((oddp current-column)
>                           (list pos "bar" [1.0 0.0 0.0])) ;; red
>                         ((evenp current-column)
>                           (list pos "bar" [0.0 0.0 1.0])))))) ;; blue

That's not how we specify colors in Emacs, not on the user level,
anyway.  I don't think I like this design.  Why not use the existing
mechanisms for specifying the cursor color?





^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: Can we support multiple Cursors?
  2016-03-01 18:44 bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support) Keith David Bershatsky
                   ` (10 preceding siblings ...)
  2016-03-29  3:45 ` Keith David Bershatsky
@ 2016-03-29 17:26 ` Keith David Bershatsky
  2017-06-25 22:09 ` Keith David Bershatsky
                   ` (19 subsequent siblings)
  31 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2016-03-29 17:26 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: John Wiegley, Marcin Borkowski, 22873, Richard Stallman

Thank you, Eli, for taking a look at the 7th working draft of mc.

Essentially, mc_calc is called at only one location depending on how Emacs was built:

* nsterm.m when built --with-ns.

* w32term.c when built for Windows.

* xterm.c when built --with-x.

All three of those files have similarities, and some of the functions in each file are either the same or similar.  I felt that tacking mc_calc onto the heels of a function from `xdisp.c` and putting in exceptions (to prevent it from always being called), is not as clean as putting it only where it was truly needed.  In a nutshell, I'm just following in the footsteps of my predecessors as to cursors for Emacs on Windows, OSX and X11.

I have made a note on my todo-list to add support for alternative methods for the end user to define colors:  [1.0 0.0 0.0]; "red"; "#FF0000"; (255, 0, 0); (65535, 0, 0) -- with some way to distinguish between the last two forms.  (1.0 is used by OSX; 255 is used by Windows; and 65535 is used by X11).

Keith

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

At Tue, 29 Mar 2016 17:58:21 +0300,
Eli Zaretskii wrote:
> 
> * * *
> > 
> > mc_calc now runs from the applicable nsterm.m/w32term.c/xterm.c, instead of xdisp.c.
> 
> Why is that a good idea?  You have 3 almost identical copies of the
> same code, which goes against our long-time trend to have terminal
> independent code only once, for easier maintenance.
> 
> >                         ((oddp current-column)
> >                           (list pos "bar" [1.0 0.0 0.0])) ;; red
> >                         ((evenp current-column)
> >                           (list pos "bar" [0.0 0.0 1.0])))))) ;; blue
> 
> That's not how we specify colors in Emacs, not on the user level,
> anyway.  I don't think I like this design.  Why not use the existing
> mechanisms for specifying the cursor color?





^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: Can we support multiple Cursors?
  2016-03-01 18:44 bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support) Keith David Bershatsky
                   ` (11 preceding siblings ...)
  2016-03-29 17:26 ` Keith David Bershatsky
@ 2017-06-25 22:09 ` Keith David Bershatsky
  2017-07-30 17:39 ` Keith David Bershatsky
                   ` (18 subsequent siblings)
  31 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2017-06-25 22:09 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: John Wiegley, Marcin Borkowski, 22873, Richard Stallman

[-- Attachment #1: Type: text/plain, Size: 5429 bytes --]

WHAT'S NEW:

-  Fake cursors now only appear in the selected-window if the `mc-list' is defined -- i.e., the fake cursors are removed when the window loses focus, and they are added again when the window acquires focus.

-  `mc_color_vector_calculate` will take the familiar Emacs way of specifying colors (e.g., "red" and "#FF0000") and convert them internally to the LSL color vector.  The conversion process is transparent to the user.

-  `mc_remove_when_scrolled` will remove multiple cursors when scrolling.  This is important because `update_window_end` will not remove the cursors when scrolling.  [There was an emacs-devel thread (about 1.5 years ago) where I had sought help tracking the multiple cursors when scrolling.  It turned out that the method of tracking cursors was not the problem (since they don't move) -- it was simply that `update_window_end` was not being called in that circumstance.]

-  `mc_x_y_hpos_vpos' contains some extra `stuff` that is irrelevant to the functionality of this patch -- the extra `stuff` is used by me as a workaround to deal with the overlay after-string property that gets in the way of properly calculating coordinates.  [See the TODO section below.]

-  The patch applies to commit a30e7e12ed8465e2565dd318d921bc87f52ce18e from 03/28/2016.  [See apology for the inconvenience further down below.]


TODO:

-  Optimize drawing and removal of multiple fake cursors.

-  Fix any bugs (there will surely be many).

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

-  Try and convince one or more real programmers to take over from here, since we now have a working proof concept.  [I am just a weekend hobbyist without any formal programming study.]


SUGGESTION:

I would respectfully suggest to the Emacs development team that multiple cursors be implemented in two stages:

-  The first stage would be the creation and removal of fake cursors to be used kind of like overlays.  I.e., specify the `point`, cursor-style, and color.  The suggestion by Eli Z. to support specifying colors with strings like "red" and "#FF0000" has now been implemented.

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


[In an earlier section of this thread, I mentioned a substantial slow-down that I experienced when using the library written by Mr. Sveen.  I have since discovered that it was due to `line-number-at-pos', and I have already reached out to the author with an alternative suggestion to use (format-mode-line "%l").]


INSTALLATION (for anyone a little less familiar):

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

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

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

You will see a message:  "HEAD is now at a30e7e1 Mention the `M-q' changes"

[We need to go back in time to 03/28/2016 as that is the master branch version that I am still using -- sorry for the inconvenience.  I will update to the latest version of Emacs at some point in the future as time permits.  Creating patches that apply to a "moving target" is challenging.]

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

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

STEP #6:  ./autogen.sh

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

STEP #8:  make

STEP #9:  make install

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

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



[-- Attachment #2: multiple_cursors_008.diff --]
[-- Type: application/diff, Size: 68462 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: Can we support multiple Cursors?
  2016-03-01 18:44 bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support) Keith David Bershatsky
                   ` (12 preceding siblings ...)
  2017-06-25 22:09 ` Keith David Bershatsky
@ 2017-07-30 17:39 ` Keith David Bershatsky
  2017-08-11  0:00 ` bug#22873: Can we support multiple cursors? Keith David Bershatsky
                   ` (17 subsequent siblings)
  31 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2017-07-30 17:39 UTC (permalink / raw)
  To: 22873; +Cc: John Wiegley, Marcin Borkowski, Richard Stallman

[-- Attachment #1: Type: text/plain, Size: 4522 bytes --]

VERSION:  009

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


WHAT'S NEW:

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

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


TODO:

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

-  Optimize drawing and removal of multiple fake cursors.

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

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


ROAD MAP:

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

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


INSTALLATION:

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

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

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

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

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

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

-  STEP #6:  ./autogen.sh

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

-  STEP #8:  make

-  STEP #9:  make install

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

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


[-- Attachment #2: multiple_cursors_009.diff --]
[-- Type: application/diff, Size: 67354 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: Can we support multiple cursors?
  2016-03-01 18:44 bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support) Keith David Bershatsky
                   ` (13 preceding siblings ...)
  2017-07-30 17:39 ` Keith David Bershatsky
@ 2017-08-11  0:00 ` Keith David Bershatsky
  2017-08-13 18:19 ` Keith David Bershatsky
                   ` (16 subsequent siblings)
  31 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2017-08-11  0:00 UTC (permalink / raw)
  To: 22873; +Cc: John Wiegley, Marcin Borkowski, Richard Stallman

[-- Attachment #1: Type: text/plain, Size: 5173 bytes --]

PATCH VERSION:  010

-  This patch applies to commit a30e7e12ed8465e2565dd318d921bc87f52ce18e from 03/28/2016.  [@lawlist is presently unable to use the current master branch for daily workflow due to certain unrelated bugs.]


WHAT'S NEW:

-  `update_frame` runs too late in the redisplay cycle to reliably remove all fake cursors when cutting/pasting text in conjunction with the current command loop.  If we erase the fake cursors at the outset of `redisplay_window`, removal occurs too early in the redisplay cycle and the user sees the cursors being removed before the current command finishes.  The very end of `redisplay_window` is a little closer to being the "sweet spot" for initial fake cursor removal, which is where it now occurs.  Fake cursors are presently only being drawn whenever `update_frame` is called.  Removal of fake cursors is faster on OSX, and slower on Windows and X11.

-  Recordation of prior values at the end of `redisplay_window` has been simplified to just four (4) values (current/previous window-start/window-end).

-  `mc_erase` has been simplified to use the existing function `erase_phys_cursor`.

-  Miscellaneous bug fixes, including, but not limited to checks to ensure that coordinates (X, Y, HPOS, VPOS) are within bounds.

-  Improved comments and doc-strings.


TODO:

-  Set up a user option similar to `cursor-in-non-selected-windows'.

-  Explore the idea of whether we need additional code to handle removing/redrawing
   fake cursors when windows change sizes / layouts.

-  `w->phys_cursor.vpos` of the real cursor is accurate as to VPOS irrespective of
   whether the `header-line-format' exists.  `mc_x_y_hpos_vpos' may need to adopt
   a similar approach as to VPOS instead of checking the `header-line-format'
   and potentially adding a value of 1 immediately before calling `mc_erase' / `mc_draw'.

-  Fake cursors are being redrawn too often when mousing over text (underneath the
   real cursor) with mouse-face properties, and also when non-selected windows/frames
   have an ongoing process that require frequent redisplay updates.

-  Optimize drawing/erasing fake cursors.

-  Implement a way to properly calculate X, Y, HPOS, VPOS when overlays are present.
   The overlay after-string wreaks havoc when calculating coordinates.

-  Fix any bugs (there will surely be many).

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


ROAD MAP:

-  The first stage of development is the creation and removal of fake cursors,
   which are specified with:  buffer point, cursor-style, and cursor color.

-  The second stage of development is the built-in C implementation of functionality
   similar to the multiple cursors library by Magnar Sveen.


INSTALLATION:

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

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

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

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

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

-  STEP #5 (apply the patch):  git apply [latest-patch.diff]

-  STEP #6:  ./autogen.sh

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

-  STEP #8:  make

-  STEP #9:  make install

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

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



[-- Attachment #2: multiple_cursors_010.diff --]
[-- Type: application/diff, Size: 63742 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: Can we support multiple cursors?
  2016-03-01 18:44 bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support) Keith David Bershatsky
                   ` (14 preceding siblings ...)
  2017-08-11  0:00 ` bug#22873: Can we support multiple cursors? Keith David Bershatsky
@ 2017-08-13 18:19 ` Keith David Bershatsky
  2017-08-13 18:36   ` Eli Zaretskii
  2017-08-14  3:20 ` Keith David Bershatsky
                   ` (15 subsequent siblings)
  31 siblings, 1 reply; 83+ messages in thread
From: Keith David Bershatsky @ 2017-08-13 18:19 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: John Wiegley, Marcin Borkowski, 22873, Richard Stallman

Dear Eli:

I could use some help/guidance, please.

I have encountered a situation where the Y and VPOS coordinates returned by `move_it_to` are sometimes out of bounds, and MATRIX_ROW crashes Emacs when drawing fake cursors that are out of bounds.  The solution appears to be a test for whether Y and VPOS are out of bounds.  I would like to use `window_box_height` to give me essentially the same value as `window-body-height` with a non-nil PIXELWISE argument.  In my case, I have 998 pixels for the window body height as depicted in the diagram of the Emacs manual:  https://www.gnu.org/software/emacs/manual/html_node/elisp/Window-Sizes.html  The last Y that I am interested in is at 1000 pixels because my `frame-char-height` -- aka `FRAME_LINE_HEIGHT (XFRAME (w->frame))` -- is 20.  Two pixels are hidden by the mode-line, so the line of text is
  partially visible.  `count-screen-lines` is not a viable option because using `vertical-motion` is too slow.  The last VPOS that I am interested in is 50 -- again, same thing, partially visible wit
 h two pixels hidden underneath the mode-line.

Testing and limiting the drawing of fake cursors with `y <= window_box_height (w)` gives me mixed results; i.e., sometimes fake cursors are drawn/erased only up to line 49, but sometimes it works up to line 50 (partially visible).  I think I want to test for whether Y is less than or equal to 1000 and if VPOS is less than or equal to 50 -- if the test is true, then go ahead and draw fake cursors up to and including that location.

However, I can foresee situations where there might be mixed line heights on the visible window, and relying upon the frame character height and window body height will not be reliable.  In a simple case, we can take 1000 divided by 20 and know that the VPOS is 50.

Is there a more reliable test for the last partially visible Y and VPOS within the window body height?  Should I be using pos_visible_p in some capacity here?

Thanks,

Keith





^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: Can we support multiple cursors?
  2017-08-13 18:19 ` Keith David Bershatsky
@ 2017-08-13 18:36   ` Eli Zaretskii
  0 siblings, 0 replies; 83+ messages in thread
From: Eli Zaretskii @ 2017-08-13 18:36 UTC (permalink / raw)
  To: Keith David Bershatsky; +Cc: jwiegley, mbork, 22873, rms

> Date:  Sun, 13 Aug 2017 11:19:30 -0700
> From:  Keith David Bershatsky <esq@lawlist.com>
> Cc:  22873@debbugs.gnu.org,John Wiegley <jwiegley@gmail.com>,Marcin Borkowski <mbork@mbork.pl>,Richard Stallman <rms@gnu.org>
> 
> I have encountered a situation where the Y and VPOS coordinates returned by `move_it_to` are sometimes out of bounds, and MATRIX_ROW crashes Emacs when drawing fake cursors that are out of bounds.  The solution appears to be a test for whether Y and VPOS are out of bounds.

Actually, the usual solution is to limit move_it_to to
last_visible_y.  Are you saying that you already do that, and the
values of Y and VPOS are still out of bounds?  That would be strange,
because the display engine does that in many places.

> I would like to use `window_box_height` to give me essentially the same value as `window-body-height` with a non-nil PIXELWISE argument.

And that's not what you get?  Can you show a simple example?

`count-screen-lines` is not a viable option because using `vertical-motion` is too slow.

It's strange that you say so because vertical-motion uses the same
move_it_to subroutines that you'd like to use directly.

> Testing and limiting the drawing of fake cursors with `y <= window_box_height (w)` gives me mixed results; i.e., sometimes fake cursors are drawn/erased only up to line 49, but sometimes it works up to line 50 (partially visible).  I think I want to test for whether Y is less than or equal to 1000 and if VPOS is less than or equal to 50 -- if the test is true, then go ahead and draw fake cursors up to and including that location.

Are you sure you account for the height of the cursor and the line on
which it is shown?  The Y coordinate is where the line begins; it ends
several pixels lower, i.e. at a greater value of Y.

> However, I can foresee situations where there might be mixed line heights on the visible window, and relying upon the frame character height and window body height will not be reliable.  In a simple case, we can take 1000 divided by 20 and know that the VPOS is 50.

For reliable calculations, you must do everything in pixels.

> Is there a more reliable test for the last partially visible Y and VPOS within the window body height?  Should I be using pos_visible_p in some capacity here?

You could use pos_visible_p, although it, again, uses move_it_to.  But
I don't think I have a clear understanding of your problem, so maybe
it's immaterial.





^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: Can we support multiple cursors?
  2016-03-01 18:44 bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support) Keith David Bershatsky
                   ` (15 preceding siblings ...)
  2017-08-13 18:19 ` Keith David Bershatsky
@ 2017-08-14  3:20 ` Keith David Bershatsky
  2017-08-14 15:01   ` Eli Zaretskii
  2017-08-14 20:35 ` Keith David Bershatsky
                   ` (14 subsequent siblings)
  31 siblings, 1 reply; 83+ messages in thread
From: Keith David Bershatsky @ 2017-08-14  3:20 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: John Wiegley, Marcin Borkowski, 22873, Richard Stallman

I read through the comments in xdisp.c that immediately precede move_it_to and I also looked at all of it uses within xdisp.c, but I am still unclear how to limit move_it_to the it.last_visible_y.  I got the impression that if I put it.last_visible_y as an argument of move_it_to, that `it` would move to that location instead of POS if POS cannot be found.  I'd like the function mc_x_y_hpos_vpos to return valid coordinates if POSINT is on the visible window, or -1 for all four coordinates if it is not visible.  I'm calling mc_x_y_hpos_vpos late in the redisplay cycle and the START/END arguments "should be" correct.  I am unclear as why the Y and VPOS were sometimes out of bounds in a few corner cases (e.g., when I compiled a tex document that had errors in the LaTeX code) -- my best guess i
 s that START/END may have been wrong because another window was opened displaying the tex compile messages.

I was pretty sure that I could substitute window_box_height for window-body-height (with a non-nil PIXELWISE argument), and that is why I phrased that previous comment with a degree of uncertainty.  Based on your comment, I now feel better about using window_box_height.  I was unaware that my usage of move_it_to may have been incorrect, so that is why I was trying to come up with new ways to workaround coordinates that were out of bounds.  If we can fix mc_x_y_hpos_vpos, then there would be no need to perform additional subsequent checks to see whether the values were correct.

Drawing and erasing fake cursors is done by temporarily hijacking w->phys_cursor and then calling either erase_phys_cursor or draw_window_cursor.

Today, I added "if (it.current_y >= it.last_visible_y) ... goto done"

Lisp_Object
mc_x_y_hpos_vpos (struct window *w, EMACS_INT posint, EMACS_INT start, EMACS_INT end)
{
  struct it it;
  void *itdata = bidi_shelve_cache ();
  struct text_pos pt;
  int x, y, hpos, vpos;
  if (posint >= start
      && posint <= end)
    {
      SET_TEXT_POS_FROM_MARKER (pt, w->start);
      start_display (&it, w, pt);
      move_it_to (&it, posint, -1, -1, -1, MOVE_TO_POS);
      if (it.current_y >= it.last_visible_y)
        {
          bidi_unshelve_cache (itdata, false);
          goto done;
        }
      x = it.current_x;
      y = it.current_y;
      hpos = it.hpos;
      vpos = it.vpos;
      bidi_unshelve_cache (itdata, false);
    }
    else
      {
        done:
        x = -1;
        y = -1;
        hpos = -1;
        vpos = -1;
      }
  return
    listn (CONSTYPE_HEAP, 4, make_number (x), make_number (y), make_number (hpos), make_number (vpos));
}





^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: Can we support multiple cursors?
  2017-08-14  3:20 ` Keith David Bershatsky
@ 2017-08-14 15:01   ` Eli Zaretskii
  0 siblings, 0 replies; 83+ messages in thread
From: Eli Zaretskii @ 2017-08-14 15:01 UTC (permalink / raw)
  To: Keith David Bershatsky; +Cc: jwiegley, mbork, 22873, rms

> Date:  Sun, 13 Aug 2017 20:20:10 -0700
> From:  Keith David Bershatsky <esq@lawlist.com>
> Cc:  22873@debbugs.gnu.org,John Wiegley <jwiegley@gmail.com>,Marcin Borkowski <mbork@mbork.pl>,Richard Stallman <rms@gnu.org>
> 
> I read through the comments in xdisp.c that immediately precede move_it_to and I also looked at all of it uses within xdisp.c, but I am still unclear how to limit move_it_to the it.last_visible_y.

Like this:

 move_it_to (&it, POS, -1, it.last_visible_y - 1, -1, MOVE_TO_POS | MOVE_TO_Y);

where POS is the buffer position.  You can find many examples of this
in xdisp.c.

> I got the impression that if I put it.last_visible_y as an argument of move_it_to, that `it` would move to that location instead of POS if POS cannot be found.

It stops when the first condition is satisfied.  If it reaches POS
before the window end, it stops there; otherwise it stops at the
window end.  It is then a simple matter of testing IT_CHARPOS(&it)
against POS to see which of these conditions caused it to stop.





^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: Can we support multiple cursors?
  2016-03-01 18:44 bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support) Keith David Bershatsky
                   ` (16 preceding siblings ...)
  2017-08-14  3:20 ` Keith David Bershatsky
@ 2017-08-14 20:35 ` Keith David Bershatsky
  2017-12-27 17:13 ` bug#22873: #22873 (multiple fake cursors); and, #17684 (crosshairs) Keith David Bershatsky
                   ` (13 subsequent siblings)
  31 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2017-08-14 20:35 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: John Wiegley, Marcin Borkowski, 22873, Richard Stallman

Thank you, Eli, for teaching me how to better use move_it_to.

In the tests that I ran today using:

move_it_to (&it, POS, -1, it.last_visible_y - 1, -1, MOVE_TO_POS | MOVE_TO_Y);

I observed that IT will stop at *the beginning of the last partially visible line* when POS is on the last partially visible line and POS's X coordinate is greater than 0.  IT does *not* stop at the window-end.

The following seems to work better when POS is on the last partially visible line and POS's x coordinate is greater than 0.

move_it_to (&it, POS, it.last_visible_x, it.last_visible_y - 1, -1, MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y);

I built a new working draft of Emacs based on the latter example and will be trying using it throughout the day.

Keith





^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: #22873 (multiple fake cursors); and, #17684 (crosshairs).
  2016-03-01 18:44 bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support) Keith David Bershatsky
                   ` (17 preceding siblings ...)
  2017-08-14 20:35 ` Keith David Bershatsky
@ 2017-12-27 17:13 ` Keith David Bershatsky
  2017-12-27 23:55   ` John Wiegley
  2017-12-28  1:20 ` bug#22873: #22873 (multiple fake cursors) Keith David Bershatsky
                   ` (12 subsequent siblings)
  31 siblings, 1 reply; 83+ messages in thread
From: Keith David Bershatsky @ 2017-12-27 17:13 UTC (permalink / raw)
  To: 22873, 17684; +Cc: John Wiegley, Marcin Borkowski, Richard Stallman

[-- Attachment #1: Type: text/plain, Size: 1215 bytes --]

The attached draft patch.diff applies to the Emacs 26 branch; bearing last commit da94ea92bc3ba6c236b394c00e6bbb725131a149; dated 12/26/2017.

Feature request #17684 (crosshairs) uses the same mechanism as #22873 (multiple fake cursors), and the former was actually what inspired me to work on the latter.  There is still no support to deal with placing fake cursors on text containing fancy overlays, text properties or combined characters.  At this time, multiple fake cursors that persist are redrawn each command loop -- which can someday be optimized.  Crosshairs are on an idle-timer.

In my own setup, I have incorporated #22873 to work with Magnar's multiple cursors library using just a slight modification to a couple of his functions, and can provide that if anyone is interested.  In a nutshell, Emacs can draw multiple fake cursors using #22873 instead of using the rectangle overlay chosen by Magnar.

+-mode is pretty straight forward.  Evaluate or load +-mode.el and type:  M-x +-mode

A simple interactive function demonstrating multiple fake cursors is named mc-test, which is within +-mode.el

I will continue to work on this project as time goes by -- it is still a work in progress ...

Keith


[-- Attachment #2: patch.diff --]
[-- Type: application/diff, Size: 121678 bytes --]

[-- Attachment #3: +-mode.el --]
[-- Type: application/el, Size: 29130 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: #22873 (multiple fake cursors); and, #17684 (crosshairs).
  2017-12-27 17:13 ` bug#22873: #22873 (multiple fake cursors); and, #17684 (crosshairs) Keith David Bershatsky
@ 2017-12-27 23:55   ` John Wiegley
  0 siblings, 0 replies; 83+ messages in thread
From: John Wiegley @ 2017-12-27 23:55 UTC (permalink / raw)
  To: Keith David Bershatsky; +Cc: 17684, Marcin Borkowski, 22873, Richard Stallman

>>>>> Keith David Bershatsky <esq@lawlist.com> writes:

> In my own setup, I have incorporated #22873 to work with Magnar's multiple
> cursors library using just a slight modification to a couple of his
> functions, and can provide that if anyone is interested. In a nutshell,
> Emacs can draw multiple fake cursors using #22873 instead of using the
> rectangle overlay chosen by Magnar.

I'm interested in that patch to multiple-cursors, Keith.

-- 
John Wiegley                  GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com                          60E1 46C4 BD1A 7AC1 4BA2





^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: #22873 (multiple fake cursors)
  2016-03-01 18:44 bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support) Keith David Bershatsky
                   ` (18 preceding siblings ...)
  2017-12-27 17:13 ` bug#22873: #22873 (multiple fake cursors); and, #17684 (crosshairs) Keith David Bershatsky
@ 2017-12-28  1:20 ` Keith David Bershatsky
  2017-12-28  1:26 ` Keith David Bershatsky
                   ` (11 subsequent siblings)
  31 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2017-12-28  1:20 UTC (permalink / raw)
  To: John Wiegley; +Cc: Marcin Borkowski, 22873, Richard Stallman

John:  Here is an example modification to the most recent version Magnar's multiple-cursors package to make use of #22873 with the patch.diff from earlier today for Emacs 26.  I like yellow for even numbered columns and red for odd numbered columns, and I like the vertical bar fake cursor, so that is what is used in this example.

(require 'multiple-cursors-core)
(require 'cl) ;; for oddp and evenp

(add-hook 'multiple-cursors-mode-disabled-hook
          (lambda () (kill-local-variable 'mc-glyph-list)))

(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
        (mc/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 (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
              (let* ((win (selected-window))
                     (window-start (window-start win))
                     (window-end (window-end win))
                     (overlays (mc/all-fake-cursors))
                     (lst
                       (mapcar
                         (lambda (x)
                           (let* ((pos (overlay-start x))
                                  (current-column
                                    (if (and (>= pos window-start)
                                             (<= pos window-end))
                                      (save-excursion
                                        (goto-char pos)
                                        (current-column))
                                      0)))
                             (cond
                               ((oddp current-column)
                                 (list pos "bar" "#FF0000")) ;; red or [1.0 0.0 0.0]
                               ((evenp current-column)
                                 (list pos "bar" "yellow"))))) ;; [1.0 1.0 0.0]
                         overlays)))
                (setq mc-glyph-list lst)))))))))


(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
              (let* ((win (selected-window))
                     (window-start (window-start win))
                     (window-end (window-end win))
                     (overlays (mc/all-fake-cursors))
                     (lst
                       (mapcar
                         (lambda (x)
                           (let* ((pos (overlay-start x))
                                  (current-column
                                    (if (and (>= pos window-start)
                                             (<= pos window-end))
                                      (save-excursion
                                        (goto-char pos)
                                        (current-column))
                                      0)))
                             (cond
                               ((oddp current-column)
                                 (list pos "bar" "#FF0000")) ;; red or [1.0 0.0 0.0]
                               ((evenp current-column)
                                 (list pos "bar" "yellow"))))) ;; [1.0 1.0 0.0]
                         overlays)))
                (setq mc-glyph-list lst))) ))))





^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: #22873 (multiple fake cursors)
  2016-03-01 18:44 bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support) Keith David Bershatsky
                   ` (19 preceding siblings ...)
  2017-12-28  1:20 ` bug#22873: #22873 (multiple fake cursors) Keith David Bershatsky
@ 2017-12-28  1:26 ` Keith David Bershatsky
  2018-07-17 19:09 ` bug#22873: #22873 (multiple fake cursors); and, #17684 (crosshairs) Keith David Bershatsky
                   ` (10 subsequent siblings)
  31 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2017-12-28  1:26 UTC (permalink / raw)
  To: John Wiegley; +Cc: Marcin Borkowski, 22873, Richard Stallman

John:  I had an extra function in the previous email, sorry.  Here is the shortened version:

(require 'multiple-cursors-core)
(require 'cl) ;; for oddp and evenp

(add-hook 'multiple-cursors-mode-disabled-hook
          (lambda () (kill-local-variable 'mc-glyph-list)))

(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
              (let* ((win (selected-window))
                     (window-start (window-start win))
                     (window-end (window-end win))
                     (overlays (mc/all-fake-cursors))
                     (lst
                       (mapcar
                         (lambda (x)
                           (let* ((pos (overlay-start x))
                                  (current-column
                                    (if (and (>= pos window-start)
                                             (<= pos window-end))
                                      (save-excursion
                                        (goto-char pos)
                                        (current-column))
                                      0)))
                             (cond
                               ((oddp current-column)
                                 (list pos "bar" "#FF0000")) ;; red or [1.0 0.0 0.0]
                               ((evenp current-column)
                                 (list pos "bar" "yellow"))))) ;; [1.0 1.0 0.0]
                         overlays)))
                (setq mc-glyph-list lst))) ))))





^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#17684: #22873 (multiple fake cursors); and, #17684 (crosshairs).
  2014-06-03 20:36 bug#17684: 24.4.50; Feature Request -- Vertical Lines to the Left of and Through Characters Keith David Bershatsky
@ 2018-07-09  5:28 ` Keith David Bershatsky
  2018-11-11  3:36 ` Keith David Bershatsky
                   ` (15 subsequent siblings)
  16 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2018-07-09  5:28 UTC (permalink / raw)
  To: 22873, 17684; +Cc: John Wiegley, Marcin Borkowski, Richard Stallman

[-- Attachment #1: Type: text/plain, Size: 1402 bytes --]

I am now at proof concept patch version 012.  The patch applies to the master branch as of yesterday (07/07/2018).  Multiple fake cursors and crosshairs now use the same function (mc_move_it) to obtain the relevant X/HPOS coordinates.  This version provides better compatibility with horizontal scrolling.  Crosshairs now works with X11 and Windows.

1.  Download a current version of Emacs master branch.

2.  Reset the repository to 07/07/2018:  git reset --hard 98463bed07ecc9057094928ffdc2321eaaf3ab52

3.  Apply the attached patch from the root repository directory.

4.  Build a GUI version of Emacs:  X11, NS, or Windows.

5.  To try out real fake cursors with Magnar Sveen's library (multiple-fake-cursors), install that package first.

6.  Open crosshairs.el (attached) and evaluate the buffer.

7.  To play with crosshairs, type:  M-x +-mode

8.  To see an example of crosshairs playing nicely with tab stretches, open up something like simple.el and enable +-mode.

9.  To see an example of a variety of cursor styles and widths, type:  M-x mc-test

X11 and NS are much quicker than Windows.  At some point in the future, I will work on more efficient means of calculating X and HPOS and other ways to speed this up.  Before moving on to more complicated aspects, I will continue working on compatibility with horizontal scrolling, tab stretches, and word-wrap/window-wrap/truncate.

Keith


[-- Attachment #2: crosshairs.el --]
[-- Type: application/el, Size: 37339 bytes --]

[-- Attachment #3: patch_012.diff --]
[-- Type: application/diff, Size: 159358 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: #22873 (multiple fake cursors); and, #17684 (crosshairs).
  2016-03-01 18:44 bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support) Keith David Bershatsky
                   ` (20 preceding siblings ...)
  2017-12-28  1:26 ` Keith David Bershatsky
@ 2018-07-17 19:09 ` Keith David Bershatsky
  2018-08-29  6:39 ` Keith David Bershatsky
                   ` (9 subsequent siblings)
  31 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2018-07-17 19:09 UTC (permalink / raw)
  To: Eli Zaretskii, Marcin Borkowski, Richard Stallman, John Wiegley
  Cc: 17684, 22873

[-- Attachment #1: Type: text/plain, Size: 1729 bytes --]

Proof concept patch version 013.  Changes include, but are not limited to:

-  The previous problem with the speed of drawing multiple fake cursors on Emacs for Windows (which occurred with patch version 012) was caused by a plethora of useful debugging messages being sent to STDERR, which caused a tremendous slow down even when launching runemacs.exe (i.e., not the terminal).  [Solution:  turn off STDERR debugging messages when not needed.]

-  Debugging messages to STDERR is now controlled by the variable mc-stderr (non-nil for ON, and nil for OFF).

-  Miscellaneous cleanup of unused variables in various functions.

-  Minor bug fixes.

-  Reorganized/grouped sections within mc_move_it [MULTIPLE_CURSORS, HORIZONTAL_RULER, VERTICAL_RULER] and added more debugging details to STDERR.

INSTALLATION:

1.  Download a current version of Emacs master branch.

2.  Reset the repository to 07/07/2018:  git reset --hard 98463bed07ecc9057094928ffdc2321eaaf3ab52

3.  Apply the attached patch from the root repository directory.

4.  Build a GUI version of Emacs:  X11, NS, or Windows.

5.  To try out built-in fake cursors with Magnar Sveen's library (multiple-cursors), install that package first.

6.  Load or evaluate the contents of crosshairs.el (attached), which includes code modifying a couple of functions used by Magnar Sveen's library.

7.  To try out the crosshairs feature, open a simple buffer (nothing fancy, just code or text) and type:  M-x +-mode

8.  To see an example of crosshairs playing nicely with tab stretches, open up something like simple.el and type:  M-x +-mode.

9.  To see an example of a variety of built-in cursor styles and widths, type:  M-x mc-test

This is still a work in progress ...


[-- Attachment #2: patch_013.diff --]
[-- Type: application/diff, Size: 162904 bytes --]

[-- Attachment #3: crosshairs.el --]
[-- Type: application/el, Size: 37438 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: #22873 (multiple fake cursors); and, #17684 (crosshairs).
  2016-03-01 18:44 bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support) Keith David Bershatsky
                   ` (21 preceding siblings ...)
  2018-07-17 19:09 ` bug#22873: #22873 (multiple fake cursors); and, #17684 (crosshairs) Keith David Bershatsky
@ 2018-08-29  6:39 ` Keith David Bershatsky
  2019-05-03  0:48 ` Keith David Bershatsky
                   ` (8 subsequent siblings)
  31 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2018-08-29  6:39 UTC (permalink / raw)
  To: Eli Zaretskii, Marcin Borkowski, Richard Stallman, John Wiegley,
	Akio Burns
  Cc: 17684, 22873

[-- Attachment #1: Type: text/plain, Size: 1944 bytes --]

Proof concept patch version 014.  Changes include, but are not limited to:

-  Crosshairs now attempts to deal with variable pitch and nonstandard width characters.  This is accomplished by permitting the vertical ruler to intersect a character anywhere along the X axis (vertically aligned with the left of point).  The horizontal ruler now also plays nicer with nonstandard width characters.

-  Debugging messages to stderr are turned on/off with:  M-x mc-stderr.

-  Bug fixes (elimination of an infinite loop; drawing multiple fake cursors only if they are within the bounds of the visible window; miscellaneous others...).

-  Reduced footprint of revisions to core Emacs code, which is now possible by using a few new window pointers:  w->mc.[red, green, blue, fx, fy, h].

INSTALLATION:

1.  Download a current version of Emacs master branch.

2.  Reset the repository to 07/07/2018:  git reset --hard 98463bed07ecc9057094928ffdc2321eaaf3ab52

3.  Apply the attached patch from the root repository directory.

4.  Build a GUI version of Emacs:  X11, NS, or Windows.

5.  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))

6.  Load or evaluate the contents of crosshairs.el (attached), which includes code modifying a couple of functions used by Magnar Sveen's library.

7.  To try out the crosshairs feature, open a simple buffer (nothing fancy, just code or text) and type:  M-x +-mode

8.  To see an example of crosshairs playing nicely with tab stretches, open up something like simple.el and type:  M-x +-mode.

9.  To see an example of a variety of built-in cursor styles and widths, type:  M-x mc-test

This is still a work in progress ...


[-- Attachment #2: crosshairs.el --]
[-- Type: application/el, Size: 37598 bytes --]

[-- Attachment #3: patch.diff --]
[-- Type: application/diff, Size: 176670 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#17684: #22873 (multiple fake cursors); and, #17684 (crosshairs).
  2014-06-03 20:36 bug#17684: 24.4.50; Feature Request -- Vertical Lines to the Left of and Through Characters Keith David Bershatsky
  2018-07-09  5:28 ` bug#17684: #22873 (multiple fake cursors); and, #17684 (crosshairs) Keith David Bershatsky
@ 2018-11-11  3:36 ` Keith David Bershatsky
  2018-11-11 16:51 ` Keith David Bershatsky
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2018-11-11  3:36 UTC (permalink / raw)
  To: Eli Zaretskii, Marcin Borkowski, Richard Stallman, John Wiegley,
	Akio Burns, Alan Third
  Cc: 17684, 22873

[-- Attachment #1: Type: text/plain, Size: 3292 bytes --]

Proof concept patch version 015.  Changes include, but are not limited to:

-  Coordinates for the fake cursors are now obtained by effectively dumping the glyph matrix and looking for the desired glyph; e.g., based upon a particular character position in the buffer, or a particular window relative X.  [The previous versions relied upon moving IT.]

-  Multiple fake cursors and crosshairs are now supported in the inactive window.

-  The foreground filled color of a hollow cursor is now configurable, including, but not limited to when the region inactive, and active region beginning and/or the active region end.

-  Colors of fake cursors in inactive window can be customized to be different than the active window.

-  New fringe indicators when engaging different forms of horizontal scrolling.

-  New fringe indicators when the idle timer for crosshairs is pending.

-  Other miscellaneous new stuff, but not too significant.

-  Miscellaneous bug fixes.

There are miscellaneous changes to the core of Emacs to facilitate generate tracing/debugging information.  Said modifications will eventually be removed.

Due to the fact that I do not presently have a computer set up with MacOS Mojave, I cannot test a current version of Emacs master branch that includes the Mojave changes to nsterm.m made by Alan Third some time ago.  Based upon the help I received from Alan on the Emacs Devel mailing list, it would appear that simply restoring update_window_cursor to its unmodified state will permit drawing crosshairs and multiple fake cursors on a platform of Emacs for MacOS Mojave.  My recollection is that those restrictions were instituted to prevent redisplaying the crosshairs in certain mouseover situations.

SETUP:

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

Step 2:  In the new emacs folder, go back to an Emacs version from 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/11_10_2018__18_53_09_703.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.  If the multiple-cursors package by Magnar Sveen is not already installed, then there are two easy ways to install that package:

   Type:  M-x mc-install

   OR, evaluate the following snippet:

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

-  To try out the crosshairs feature, open a relatively simple buffer (e.g., just code or text) and type:  M-x +-mode

    The default setting is on an idle timer, so just move around or type something to see how it works.

-  To see an example of a variety of built-in cursor styles and widths, type:  M-x mc-test


[-- Attachment #2: 11_10_2018__18_53_09_703.diff --]
[-- Type: application/diff, Size: 318538 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#17684: #22873 (multiple fake cursors); and, #17684 (crosshairs).
  2014-06-03 20:36 bug#17684: 24.4.50; Feature Request -- Vertical Lines to the Left of and Through Characters Keith David Bershatsky
  2018-07-09  5:28 ` bug#17684: #22873 (multiple fake cursors); and, #17684 (crosshairs) Keith David Bershatsky
  2018-11-11  3:36 ` Keith David Bershatsky
@ 2018-11-11 16:51 ` Keith David Bershatsky
  2018-11-21  4:53 ` bug#17684: #22873 (multiple fake cursors); and, #17684 (crosshairs / fill-column) Keith David Bershatsky
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2018-11-11 16:51 UTC (permalink / raw)
  To: Eli Zaretskii, Marcin Borkowski, Richard Stallman, John Wiegley,
	Akio Burns, Alan Third
  Cc: 17684, 22873

[-- Attachment #1: Type: text/plain, Size: 2144 bytes --]

Proof concept patch version 015.001.  Changes include, but are not limited to:

-  Fixed mc-test.  [When switching over from the move IT method to the dump glyph matrix method, cursor_type inadvertently got hard-coded as a BAR_CURSOR instead of respecting the user-defined cursor type/width for multiple fake cursors.]

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

SETUP:

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

Step 2:  In the new emacs folder, go back to an Emacs version from 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/11_11_2018__08_30_42_690.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.  [If the multiple-cursors package is installed, an eval-after-load "multiple-cursors-core" statement within crosshairs.el will redefine a couple of functions and set up a few keyboard shortcuts.]  If the multiple-cursors package by Magnar Sveen is not already installed, then there are two easy ways to install that package:

   Type:  M-x mc-install

   OR, evaluate the following snippet:

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

-  To try out the crosshairs feature, open a relatively simple buffer (e.g., just code or text) and type:  M-x +-mode

    The default setting is on an idle timer, so just move around or type something to see how it works.

-  To see an example of a variety of built-in cursor styles and widths, type:  M-x mc-test


[-- Attachment #2: 11_11_2018__08_30_42_690.diff --]
[-- Type: application/diff, Size: 318577 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#17684: #22873 (multiple fake cursors); and, #17684 (crosshairs / fill-column).
  2014-06-03 20:36 bug#17684: 24.4.50; Feature Request -- Vertical Lines to the Left of and Through Characters Keith David Bershatsky
                   ` (2 preceding siblings ...)
  2018-11-11 16:51 ` Keith David Bershatsky
@ 2018-11-21  4:53 ` Keith David Bershatsky
  2018-12-14  7:11 ` Keith David Bershatsky
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2018-11-21  4:53 UTC (permalink / raw)
  To: Eli Zaretskii, Marcin Borkowski, Richard Stallman, John Wiegley,
	Akio Burns, Alan Third
  Cc: 17684, 22873

[-- Attachment #1: Type: text/plain, Size: 4507 bytes --]

Version 016.000 [11/20/2018]

CHANGELOG:

-  The area of code that prevented crosshairs and other fake cursors from
   working on MacOS Mojave has been fixed.

-  New Feature:  This is the first implementation of a visible fill column
   using fake cursors, which has similar abilities to crosshairs; e.g.,
   draw forthwith whenever the real cursor gets drawn; draw on an idle
   timer; fill column indicator in inactive/active windows have different
   colors; suppress display of fill column indicator in inactive windows
   (if so desired); color of the fill column indicator in active/inactive
   windows is a different color when the cursor is lined up with the fill
   column and crosshairs is active.  Crosshairs incorporates the fill
   column indicator if the variable `+-fill-column' is non-nil; or, there
   is a separate minor-mode called `mc-fill-column-mode' (if so desired).

-  Floating horizontal ruler now increments by glyph->pixel_width instead
   of frame-char-width.  [This avoids visible gaps.]

-  Multiple fake cursors can now be placed at the end of a line when there
   is no `buffer-display-table' entry for a visible EOL glyph.

-  Crosshairs now use the line height instead of the glyph height.  [This
   avoids visible gaps in the vertical ruler of crosshairs.]

-  The border color for images with a fake cursor now match the fake
   cursor color.

-  With the gracious assistance of Eli Z., a test now exists for the situation
   when `draw_glyphs' redraws a tab stretch due to a subsequent character
   with a left overhang.  Additional work needs to be done ... [infra].

-  Only call `update_begin' / `update_end' when the frame was not already
   in the process of being updated.

-  Miscellaneous bug fixes.


SETUP:

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

Step 2:  In the new emacs folder, go back to an Emacs version from 11/16/2018:

git reset --hard 644a308b4e1513e04be9360e1586e14b32ec0159

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

git apply /path/to/the/11_20_2018__18_16_28_577.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.  [If the multiple-cursors package is installed, an eval-after-load "multiple-cursors-core" statement within crosshairs.el will redefine a couple of functions and set up a few keyboard shortcuts.]  If the multiple-cursors package by Magnar Sveen is not already installed, then there are two easy ways to install that package:

   Type:  M-x mc-install

   OR, evaluate the following snippet:

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

-  To try out crosshairs and the visible fill column, type:  M-x +-mode

-  To try out only the visible fill column, type:  M-x mc-fill-column-mode

-  To learn how to use the multiple fake cursors feature, examine the
   interactive function `mc-test'.


TODO:

-  Crosshairs in the inactive windows is causing cursors in the active
   windows to be erased (when the active window drew prior thereto).

-  Face of tab stretch gets extended to window edge on NS, but not on X11
   or NT platforms:
   https://lists.gnu.org/archive/html/emacs-devel/2018-11/msg00316.html

-  Continue working on the section of code within `draw_glyphs' that is
   responsible for redrawing a stretch tab (erasing a fake cursor) when the next
   character has a left overhang.  "	A".  A temporary fix has been instituted
   that simply bypasses the section of code at issue; however, the optimal
   solution will be to let `draw_glyphs' do its thing and then redraw the
   fake cursors along the stretch tab subsequent thereto.

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

-  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.


[-- Attachment #2: 11_20_2018__18_16_28_577.diff --]
[-- Type: application/diff, Size: 377153 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#17684: #22873 (multiple fake cursors); and, #17684 (crosshairs / fill-column).
  2014-06-03 20:36 bug#17684: 24.4.50; Feature Request -- Vertical Lines to the Left of and Through Characters Keith David Bershatsky
                   ` (3 preceding siblings ...)
  2018-11-21  4:53 ` bug#17684: #22873 (multiple fake cursors); and, #17684 (crosshairs / fill-column) Keith David Bershatsky
@ 2018-12-14  7:11 ` Keith David Bershatsky
  2019-04-09  4:03 ` bug#17684: #22873 (multiple fake cursors); and, #17684 (crosshairs) Keith David Bershatsky
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2018-12-14  7:11 UTC (permalink / raw)
  To: Eli Zaretskii, Marcin Borkowski, Richard Stallman, John Wiegley,
	Akio Burns, Alan Third
  Cc: 17684, 22873

[-- Attachment #1: Type: text/plain, Size: 8963 bytes --]

Version 017.000 [12/13/2018]

CHANGELOG:

-  nsterm.m:  Cursors are now drawn subsequent to the expose_frame/window loop
   of dirty rectangles within drawRect.  `update_window_cursor' within
   `expose_frame' is now disabled when HAVE_NS.

-  FRAMED_BOX_CURSOR is a new cursor type that is a variant of the
   FILLED_BOX_CURSOR, which has support for different colors depending upon
   whether it is in the active/inactive window and at the beginning/ending of
   an active region.

-  Visible fill column now takes into consideration the line number pixel-width
   and horizontal scrolling (if any) when calculating the X coordinate.

-  Disabled visible fill column when X coordinate is beyond text area width, and
   when prior to the line number pixel width (or zero if no line numbers) with
   horizontal scrolling in effect.

-  Restricted trace-redisplay messages to just the most relevant functions.

-  Customized a few of the faces to provide better visibility of crosshairs with
   a white background in an Emacs -Q situation.

-  Eliminated the usage of MC_GLYPH_TAB as there are really only two kinds that
   are used:  MC_GLYPH | MC_GLYPHLESS

-  Eliminated a few abort / immediate return of functions that appear to no
   longer be necessary to avoid crashing Emacs.

-  Fixed one cash in the multiple fake cursors section of code when the real
   cursor is not associated with a glyph; i.e., `get_phys_cursor_glyph' == NULL.

-  As to the real fake cursor of crosshairs (intersection of vertical/horizontal
   rulers), when mc-real-fake-cursor is nil/"no"/'no, the BAR_CURSOR now uses
   MC_GLYPHLESS so as not to create a superimposed glyph on top of the MC_GLYPH
   that was placed when drawing the horizontal ruler.

-  Identified a right overhang situation that causes the fake cursor over a
   STRETCH to be erased.  [Additional work is needed projects to be done below.]

-  `mc_get_phys_cursor_geometry' now uses `row->visible_height' without taking
   into consideration the FRAME_LINE_HEIGHT.

-  Added some tracing messages to a couple of functions.

-  Miscellaneous minor bug fixes.


SETUP:

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

Step 2:  In the new emacs folder, go back to an Emacs version from 12/13/2018:

git reset --hard 8ffc0f2dd753879b0795714c29c86082aa9fd155

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

git apply /path/to/the/attached.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.  [If the multiple-cursors package is installed, an eval-after-load "multiple-cursors-core" statement within crosshairs.el will redefine a couple of functions and set up a few keyboard shortcuts.]  If the multiple-cursors package by Magnar Sveen is not already installed, then there are two easy ways to install that package:

   Type:  M-x mc-install

   OR, evaluate the following snippet:

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

-  To try out crosshairs and the visible fill column, type:  M-x +-mode

-  To try out only the visible fill column, type:  M-x mc-fill-column-mode

-  To try out the new cursor-type of a FRAMED_BOX_CURSOR without anything extra,
   evaluate the following snippet -- see the difference between inactive/active
   windows, and also the beginning/ending of an active region selection:

   (setq cursor-type 'framed
         cursor-in-non-selected-windows 'framed)

-  To use the new cursor type of a FRAMED_BOX_CURSOR with crosshairs or multiple
   fake cursors, evaluate the following snippet:

   (setq mc-real-fake-cursor 'framed)

-  To learn how to use the multiple fake cursors feature, examine the
   interactive function `mc-test'.

-  EXAMPLE OF HOW TO USE 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:

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

-  Continue working on the sections of code within `draw_glyphs' that are
   responsible for redrawing a stretch tab (erasing a fake cursor) when the
   previous/next character has a left/right overhang.
   left_overwritten:  "	A"
   right_overwritten (GNU Emacs welcome screen without `buffer-display-table')
   and the real fake cursor is to the immediate right of the word "Tour":
   "Emacs Guided Tour	Overview".

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

-  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.

-  Set up some tests to see what (if anything) needs to be done so that
   these features play nicely with certain overlays and text properties.

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

-  Create a comprehensive list of items to test when modifying these features;
   and, add a test file.

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

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

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


HOW DOES IT WORK?

-  Fake cursors are removed in two (2) locations within `redisplay_internal'
(if the cursor cache exists).  If the frame is not being updated, then call
`update_begin' before removing and call `update_end' when removing is complete.

-  Fake cursors are removed in two (2) locations within `redisplay_window'
(if the cursor cache exists).  If the frame is not being updated, then call
`update_begin' before removing and call `update_end' when removing is complete.

-  Whenever `display_and_set_cursor' is called and not immediately returned,
cursors are calculated and drawn; or, if the cursor cache already exist, then
erase and redraw.  If the frame is not being updated, then call `update_begin'
before drawing/removing and call `update_end' when drawing/removing is complete.

-  The calculations for drawing fake cursors are based upon modified versions
of the functions `dump_glyph_matrix' and `dump_glyph_row', which generate the
correct coordinates for placing the fake cursors.

-  Fake cursors come in two types:  (1) cursor with a glyph on top; (2) cursor
with nothing on top [e.g., floating anywhere on the visible window].

-  There are two basic settings:  (1) draw or erase/redraw forthwith (whenever
the real cursor would ordinarily be drawn); or, (2) draw on an idle-timer and,
if the cursor cache exists, then erase/redraw in certain circumstances when the
real cursor would ordinarily be redrawn.  New calculations and cursor cache
update occur on the initial call of either of the aforementioned two scenarios.

-  All three features (multiple fake cursors, crosshairs, and visible fill
column) operate on the same principal.  There are similar functions for each
feature, with the only main difference being that multiple fake cursors look for
a particular buffer position when dumping the glyph matrix and looping through
each row, whereas crosshairs and visible fill column look for a particular
window relative X coordinate.

-  At this time, there is nothing fancy about multiple fake cursors -- i.e.,
Emacs only looks for a buffer position and creates a fake cursor with the
desired cursor type and cursor color.  Magnar's Lisp library is still the only
mechanism I am aware of that does the magic.  Instead of placing a visible
overlay where fake cursors would ordinarily be created using Magnar's library,
there are a few modifications to his Lisp functions that are contained within
crosshairs.el.  From the list of fake cursor overlays created by Magnar's
library, Emacs gathers the list of buffer positions and then draws built-in fake
cursors that are within the confines of the visible windows.


[-- Attachment #2: 2018_12_13__21_40_08_511.diff --]
[-- Type: application/diff, Size: 398180 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#17684: #22873 (multiple fake cursors); and, #17684 (crosshairs).
  2014-06-03 20:36 bug#17684: 24.4.50; Feature Request -- Vertical Lines to the Left of and Through Characters Keith David Bershatsky
                   ` (4 preceding siblings ...)
  2018-12-14  7:11 ` Keith David Bershatsky
@ 2019-04-09  4:03 ` Keith David Bershatsky
  2019-04-21  5:15 ` Keith David Bershatsky
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2019-04-09  4:03 UTC (permalink / raw)
  To: eliz, mbork, rms, johnw, akioburns, athird; +Cc: 17684, 22873

[-- Attachment #1: Type: text/plain, Size: 5045 bytes --]

This is version 018.000 of a proof concept for multiple fake cursors and crosshairs.

Special thanks to Eli Z. and Alan T. for helping me out on numerous issues over the past few months -- greatly appreciated!!!


VERSION:

- 018.000 [04/08/2019]


CHANGELOG:

- Creation of fake cursors now immediately follows calls to `draw_glyphs'.

- Removal of fake cursors occurs prior to Emacs scrolling the text on the glass
  directly and at the outset of `update_window'.

- The NS port now automatically redraws fake cursors that got erased because they
  were left/right overwritten glyphs, but work still needs to be done on the w32
  and X ports.  The future plan of attack for the w32 and X ports is probably
  similar to the NS port; i.e., left/right overwritten glyphs have their strings
  tagged during `mc_draw_glyphs' and are dealt with on a per port basis when
  FRAME_RIF (f)->mc_scribe_string is called.

- Semi-duplicate functions have been created so as to reduce the number of entry
  points into the core code base of Emacs.  [This approach enables semi- worry
  free tinkering without the risk of breaking something important.]

- Removal of scroll bars no longer erase fake cursors when windows are resized
  or deleted on the NS and w32 ports.  [I didn't see any issues on an X11 build.]

- Numerous bug fixes, some minor and some major.


SETUP:

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

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

git reset --hard a038df77de7b1aa2d73a6478493b8838b59e4982

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

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

Step 4:  ./autogen.sh

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

Step 6:  make

Step 7:  make install


USAGE:

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

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

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

  ;;; TURN OFF FAKE CURSORS:

  (setq mc-conf nil)

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

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

  Type:  M-x mc-install

  OR, evaluate the following snippet:

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


TODO:

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

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

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

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

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

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

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

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

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

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

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


[-- Attachment #2: 2019_04_08__18_56_23_226.diff --]
[-- Type: application/diff, Size: 480489 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#17684: #22873 (multiple fake cursors); and, #17684 (crosshairs).
  2014-06-03 20:36 bug#17684: 24.4.50; Feature Request -- Vertical Lines to the Left of and Through Characters Keith David Bershatsky
                   ` (5 preceding siblings ...)
  2019-04-09  4:03 ` bug#17684: #22873 (multiple fake cursors); and, #17684 (crosshairs) Keith David Bershatsky
@ 2019-04-21  5:15 ` Keith David Bershatsky
  2019-04-29  1:21 ` Keith David Bershatsky
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2019-04-21  5:15 UTC (permalink / raw)
  To: 22873, 17684; +Cc: athird, mbork, rms, johnw, akioburns, agrambot

[-- Attachment #1: Type: text/plain, Size: 5300 bytes --]

VERSION:  019.000 [04/20/2019]


CHANGELOG:

- Fake cursors no longer use Lisp_Object for cache management and to temporarily
  store RGB color data.  Caches and RGB color data are now managed by structs.
  Special thanks to Alex Gramiak and Eli Zaretskii for their generous assistance
  on the Emacs Devel mailing list with those related issues:

  http://lists.gnu.org/archive/html/emacs-devel/2019-04/msg00421.html

  http://lists.gnu.org/archive/html/emacs-devel/2019-04/msg00762.html

- A temporary cache of fake cursors is no longer needed to manage left/right
  overwritten characters.

- As of the last patch (018.000), there has no longer been a need to force a
  frame update when drawing/erasing fake cursors.  As such, the code for forcing
  a frame update has been removed in this new patch (019.000).

- Eliminated a few window pointers previously used to store RGB color data and
  also the screen relative x coordinate of the fill column.  Lisp_Object related
  widow pointers have also been removed in light of new cache management (above).

- The BOX_CURSOR variant known as a framed box cursor is now only available when
  using the multiple fake cursor related features.


SETUP:

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

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

git reset --hard a038df77de7b1aa2d73a6478493b8838b59e4982

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

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

Step 4:  ./autogen.sh

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

Step 6:  make

Step 7:  make install


USAGE:

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

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

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

  ;;; TURN OFF FAKE CURSORS:

  (setq mc-conf nil)

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

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

  Type:  M-x mc-install

  OR, evaluate the following snippet:

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


TODO:

- Do further testing to make sure that garbage collection is now under control.
  Search for any remaining Lisp_Object that can be eliminated and handled purely
  in C.

- *GNU Emacs* welcome screen:  A portion of the hollow box cursor surrounding the
  Emacs logo image is not always being redrawn when moving the cursor over lines
  underneath the image.  This is happening on at least 2 of the 3 relevant ports.

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

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

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

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

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

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

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

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

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

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

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


[-- Attachment #2: 2019_04_20__22_08_31_450.diff --]
[-- Type: application/diff, Size: 481784 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#17684: #22873 (multiple fake cursors); and, #17684 (crosshairs).
  2014-06-03 20:36 bug#17684: 24.4.50; Feature Request -- Vertical Lines to the Left of and Through Characters Keith David Bershatsky
                   ` (6 preceding siblings ...)
  2019-04-21  5:15 ` Keith David Bershatsky
@ 2019-04-29  1:21 ` Keith David Bershatsky
  2019-06-08 23:44 ` Keith David Bershatsky
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2019-04-29  1:21 UTC (permalink / raw)
  To: 22873, 17684

[-- Attachment #1: Type: text/plain, Size: 6846 bytes --]

VERSION: 019.001 [04/28/2019]

CHANGELOG:

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

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

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

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

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

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

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

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

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

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

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

- Verified that garbage collection is under control.

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

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

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


SETUP:

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

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

git reset --hard a038df77de7b1aa2d73a6478493b8838b59e4982

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

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

Step 4:  ./autogen.sh

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

Step 6:  make

Step 7:  make install


USAGE:

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

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

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

  ;;; TURN OFF FAKE CURSORS:

  (setq mc-conf nil)

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

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

  Type:  M-x mc-install

  OR, evaluate the following snippet:

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


TODO:

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

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

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

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

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

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

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

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

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

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

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


[-- Attachment #2: 2019_04_28__14_54_14_311.diff --]
[-- Type: application/diff, Size: 501720 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: #22873 (multiple fake cursors); and, #17684 (crosshairs).
  2016-03-01 18:44 bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support) Keith David Bershatsky
                   ` (22 preceding siblings ...)
  2018-08-29  6:39 ` Keith David Bershatsky
@ 2019-05-03  0:48 ` Keith David Bershatsky
  2019-05-06 18:39 ` Keith David Bershatsky
                   ` (7 subsequent siblings)
  31 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2019-05-03  0:48 UTC (permalink / raw)
  To: 22873, 17684

[-- Attachment #1: Type: text/plain, Size: 5105 bytes --]

VERSION:  019.002 [05/02/2019]


CHANGELOG:

- Eliminated the usage of a Lisp_Object within `mc_update_text_area' in favor of
  an array of structs.  [Every Lisp_Object that is eliminated will reduce the
  need for garbage collection.]

- Eliminated `mc/save-window-scroll' when using the multiple-crosshairs library
  written by Magnar Sveen.  [Said function caused non-selected windows to be
  updated during redisplay, resulting in undue slowdown.]

- Miscellaneous changes regarding when/what stderr messages are to appear when
  running M-x trace-redisplay; and, changed the name of the function responsible
  for erasing fake cursors and resetting the cache:  `mc_pre_scroll_clean'.
  Eliminated the message to run "M-x mc-install" when `crosshairs.el` loads.


SETUP:

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

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

git reset --hard a038df77de7b1aa2d73a6478493b8838b59e4982

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

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

Step 4:  ./autogen.sh

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

Step 6:  make

Step 7:  make install


USAGE:

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

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

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

  ;;; TURN OFF FAKE CURSORS:

  (setq mc-conf nil)

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

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

  Type:  M-x mc-install

  OR, evaluate the following snippet:

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


TODO:

- Add support for `ch_inactive_windows' and `fc_inactive_windows'.

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

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

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

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

- There is a bug affecting an older version of Emacs for the NS port that causes
  partial line flickering when the same characters are grouped together (;;;;;;)
  and MC_GLYPHLESS cursors are above or below -- having the same background color
  as the frame; e.g., black on black (used to erase a glyphless cursor).  The
  partial flickering is only noticeable with rapid fire; e.g., holding down the
  right/left arrow key.  When changing the color of the glyphless cursor, the
  issue is not present.  [@lawlist has verified that the X and HPOS coordinates
  are accurate.]

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

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

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

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

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

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

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


[-- Attachment #2: 2019_05_02__17_44_54_096.diff --]
[-- Type: application/diff, Size: 502641 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: #22873 (multiple fake cursors); and, #17684 (crosshairs).
  2016-03-01 18:44 bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support) Keith David Bershatsky
                   ` (23 preceding siblings ...)
  2019-05-03  0:48 ` Keith David Bershatsky
@ 2019-05-06 18:39 ` Keith David Bershatsky
  2019-05-28  8:31 ` Keith David Bershatsky
                   ` (6 subsequent siblings)
  31 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2019-05-06 18:39 UTC (permalink / raw)
  To: 22873, 17684

[-- Attachment #1: Type: text/plain, Size: 4459 bytes --]

VERSION:  019.003 [05/06/2019]


CHANGELOG:

- Reduced the number of entry points in dispnew.c to just `update_window'.


SETUP:

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

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

git reset --hard a038df77de7b1aa2d73a6478493b8838b59e4982

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

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

Step 4:  ./autogen.sh

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

Step 6:  make

Step 7:  make install


USAGE:

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

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

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

  ;;; TURN OFF FAKE CURSORS:

  (setq mc-conf nil)

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

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

  Type:  M-x mc-install

  OR, evaluate the following snippet:

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


TODO:

- Add support for `ch_inactive_windows' and `fc_inactive_windows'.

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

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

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

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

- There is a bug affecting an older version of Emacs for the NS port that causes
  partial line flickering when the same characters are grouped together (;;;;;;)
  and MC_GLYPHLESS cursors are above or below -- having the same background color
  as the frame; e.g., black on black (used to erase a glyphless cursor).  The
  partial flickering is only noticeable with rapid fire; e.g., holding down the
  right/left arrow key.  When changing the color of the glyphless cursor, the
  issue is not present.  [@lawlist has verified that the X and HPOS coordinates
  are accurate.]

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

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

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

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

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

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

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


[-- Attachment #2: 2019_05_06__11_31_31_427.diff --]
[-- Type: application/diff, Size: 507400 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: #22873 (multiple fake cursors); and, #17684 (crosshairs).
  2016-03-01 18:44 bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support) Keith David Bershatsky
                   ` (24 preceding siblings ...)
  2019-05-06 18:39 ` Keith David Bershatsky
@ 2019-05-28  8:31 ` Keith David Bershatsky
  2019-06-02  7:29 ` Keith David Bershatsky
                   ` (5 subsequent siblings)
  31 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2019-05-28  8:31 UTC (permalink / raw)
  To: 22873, 17684; +Cc: johnw, mbork, rms, akioburns

[-- Attachment #1: Type: text/plain, Size: 7877 bytes --]

VERSION:  020.000 [05/27/2019]

CHANGELOG:

- Consolidated all caches of fake cursors into one master window struct/matrix,
  which is uncoincidentally somewhat similar in design to the glyph_matrix.

- Removing and drawing fake cursors is now mostly limited to the ones that have
  changed since the previous redisplay.  A dry-run of what the prospective
  `w->current_matrix` will be at tail end of `update_window' is performed at the
  outset thereof -- without actually writing any glyphs to the glass.  During
  the dry-run, a new cache of fake cursors is created and it is compared to the
  old cache of fake cursors.  Anything that is different gets erased and just
  the new ones get drawn.  As to scrolling the text on the glass directly
  _before_ `update_window' is called -- `try_window_reusing_current_matrix' and
  `try_window_id' -- fake cursors are erased from min (r.current_y, r.desired_y)
  to the top of the mode-line, and any fake cursors above the min (supra) remain.

- The multiple fake cursors feature now includes a current column check for each
  visible cursor and odd/even column colors are assigned if the user has not
  specified a color preference in the `mc_conf' for the particular cursor being
  drawn.

- Miscellaneous bug fixes.


SETUP:

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

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

git reset --hard a038df77de7b1aa2d73a6478493b8838b59e4982

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

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

Step 4:  ./autogen.sh

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

Step 6:  make

Step 7:  make install


USAGE:

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

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

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

  ;;; TURN OFF FAKE CURSORS:

  (setq mc-conf nil)

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

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

  Type:  M-x mc-install

  OR, evaluate the following snippet:

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


TODO:

- Free memory of w->mc_matrix whenever its associated window ceases to exist.

- Consider adding support for different colors when fake cursors are _at_ ZV
  versus _beyond_ ZV, including, but not limited to the right fringe bitmaps for
  a cursor at fringe and a cursor beyond the fringe.

- `mc_ns_clip_to_rect' is not working as expected.  `ns_draw_window_cursor' calls
  `ns_clip_to_rect', which does _not_ take `row->clip` into consideration when
  drawing cursors with `NSRectFill'.  When it comes time to draw glyphs on top of
  the box/hollow family of cursors, `row->clip` is taken into consideration by
  `get_glyph_string_clip'.  Fake cursors can be drawn even though the glyphs
  cannot, resulting in hollow/box family of cursors without text.  The issue can
  be reproduced by calling M-x mc-test and then moving the cursor left/right --
  a thick hbar-looking rectangle forms underneath the characters in the boxes.
  [Reproduction of the issue assumes `mc_ns_intersect_rectangles' is enabled.]
  https://lists.gnu.org/archive/html/emacs-devel/2019-04/msg00009.html

- `mc_ns_draw_overwritten' is not working as expected.  It appears that fake
  cursors are drawn outside of the area clipped, sometimes resulting in cursor
  fragments that are drawn in a different window; e.g., a top/bottom window split
  with the top window having crosshairs active.  Initial attempts at calling
  `mc_ns_clip_to_rect' from within `mc_ns_draw_overwritten' produced flickering
  of lines (presumably in the relevant vicinity).

- Add additional support for `ch_inactive_windows' and `fc_inactive_windows'
  when the variables have a `nil` value.  In such a case, the inactive windows
  should not display the crosshairs and/or visible fill column indicator.

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

- Is there any additional meaningful optimization that can be added to the
  three calls of `mc_pre_scroll_clean'?

- NOTE:  As to `mc_scrolling_window', it would appear that there is no tangible
  benefit to rotating the current/prospective cache of fake cursors to compare
  the data before removing the fake cursors.  When scrolling the display, only
  _some_ lines are copied to new locations.  Areas that are not overwritten may
  have fake cursors and those may not necessarily be removed if desired/current
  matrix glyphs are equal.  The test for `GLYPH_EQUAL_P' does not take into
  consideration the existence of a fake cursor, and the glyph (with a fake cursor)
  may not be updated as a result thereof.  As to lines that are not copied,
  portions may be updated and fake cursors would be removed thereby.

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

- There is a bug affecting an older version of Emacs for the NS port that causes
  partial line flickering when the same characters are grouped together (;;;;;;)
  and MC_GLYPHLESS cursors are above or below -- having the same background color
  as the frame; e.g., black on black (used to erase a glyphless cursor).  The
  partial flickering is only noticeable with rapid fire; e.g., holding down the
  right/left arrow key.  When changing the color of the glyphless cursor, the
  issue is not present.  [@lawlist has verified that the X and HPOS coordinates
  are accurate.]

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

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

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

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

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

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

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



[-- Attachment #2: 2019_05_27__21_42_30_553.diff --]
[-- Type: application/diff, Size: 605614 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: #22873 (multiple fake cursors); and, #17684 (crosshairs).
  2016-03-01 18:44 bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support) Keith David Bershatsky
                   ` (25 preceding siblings ...)
  2019-05-28  8:31 ` Keith David Bershatsky
@ 2019-06-02  7:29 ` Keith David Bershatsky
  2019-07-16 19:28 ` Keith David Bershatsky
                   ` (4 subsequent siblings)
  31 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2019-06-02  7:29 UTC (permalink / raw)
  To: 22873, 17684; +Cc: johnw, mbork, rms, akioburns

[-- Attachment #1: Type: text/plain, Size: 7804 bytes --]

VERSION:  021.000 [06/01/2019]

CHANGELOG:

-  Added a new feature to visually distinguish with user-defined colors when a
   fake cursor is on a screen line containing _only_ ZV, or subsequent to a
   screen line containing _only_ ZV, or all screen lines prior to a line
   containing _only_ ZV (if such a line exists), which includes a screen line
   that has characters and ends at ZV (i.e., no final new line).

   SCREENSHOT -- DARK BACKGROUND:

   https://lawlist.com/images/22873_17684__2019_06_01_dark_bg.png

   SCREENSHOT -- LIGHT BACKGROUND:

   https://lawlist.com/images/22873_17684__2019_06_01_light_bg.png

-  `free_window_matrices':  Added a call to free the fake cursor cache matrices.

-  Tweaked how colors are assigned for the MC_FRAMED_BOX when at region begin,
   region end, and in between region begin/end.

-  Fixed a crash caused by NULL glyph when attempting to cache coordinates for
   a right fringe bitmap when cursor is exactly at the right fringe.  When
   coordinates for the real cursor do not correlate to an actual glyph, we use
   the last glyph of the current row instead.

-  Fixed a crash caused by using the built-in region begin/end function, which
   failed when Fmarker_position returned a NULL Lisp_Object -- leading to one of
   those hard to debug bugs; i.e., when garbage collection chokes due to a NULL
   Lisp_Object.  `mc_region_limit' is now used instead.

-  Fixed a bug caused by a failure to have a `fill_column_trump_p` test at the
   tail end of `mc_update_text_area' which is used to suppress the vertical
   crosshairs ruler when the fill column indicator trumps at that exact X.

-  NS port:  Fixed a bug relating to `mc_ns_draw_overwritten' drawing fake
   cursors outside of the clipped area when dealing with STRETCH_GLYPH.

-  NS port:  Created a workaround to deal with the `row->clip' inhibiting the
   drawing of glyphs on the box family of fake cursors in certain circumstances.
   [More work needs to be done, but will likely require help from Emacs Devel.]


SETUP:

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

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

git reset --hard a038df77de7b1aa2d73a6478493b8838b59e4982

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

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

Step 4:  ./autogen.sh

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

Step 6:  make

Step 7:  make install


USAGE:

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

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

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

  ;;; TURN OFF FAKE CURSORS:

  (setq mc-conf nil)

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

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

  Type:  M-x mc-install

  OR, evaluate the following snippet:

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


TODO:

- `ns_draw_window_cursor' calls `ns_clip_to_rect', which does _not_ take
  `row->clip` into consideration when drawing cursors with `NSRectFill'.  When
  it comes time to draw glyphs on top of the box/hollow family of cursors,
  `row->clip` is taken into consideration by `get_glyph_string_clip'.  Fake
  cursors can be drawn even though the glyphs cannot, resulting in hollow/box
  family of cursors without text.  The issue can be reproduced with M-x mc-test.
  [A temporary workaround is to disable `row->clip` while drawing the glyphs.]
  https://lists.gnu.org/archive/html/emacs-devel/2019-04/msg00009.html

- Add additional support for `ch_inactive_windows' and `fc_inactive_windows'
  when the variables have a `nil` value.  In such a case, the inactive windows
  should not display the crosshairs and/or visible fill column indicator.  At the
  present time, fake cursors are drawn in active/inactive windows alike.

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

- Is there any additional meaningful optimization that can be added to the
  three calls of `mc_pre_scroll_clean'?

- NOTE:  As to `mc_scrolling_window', it would appear that there is no tangible
  benefit to rotating the current/prospective cache of fake cursors to compare
  the data before removing the fake cursors.  When scrolling the display, only
  _some_ lines are copied to new locations.  Areas that are not overwritten may
  have fake cursors and those may not necessarily be removed if desired/current
  matrix glyphs are equal.  The test for `GLYPH_EQUAL_P' does not take into
  consideration the existence of a fake cursor, and the glyph (with a fake
  cursor) may not be updated as a result thereof.  As to lines that are not
  copied, portions may be updated and fake cursors would be removed thereby.

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

- There is a bug affecting an older version of Emacs for the NS port that causes
  partial line flickering when the same characters are grouped together (;;;;;;)
  and MC_GLYPHLESS cursors are above or below -- having the same background color
  as the frame; e.g., black on black (used to erase a glyphless cursor).  The
  partial flickering is only noticeable with rapid fire; e.g., holding down the
  right/left arrow key.  When changing the color of the glyphless cursor, the
  issue is not present.  [@lawlist has verified that the X and HPOS coordinates
  are accurate.]

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

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

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

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

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

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

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


[-- Attachment #2: 2019_06_01__22_47_04_513.diff --]
[-- Type: application/diff, Size: 628016 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#17684: #22873 (multiple fake cursors); and, #17684 (crosshairs).
  2014-06-03 20:36 bug#17684: 24.4.50; Feature Request -- Vertical Lines to the Left of and Through Characters Keith David Bershatsky
                   ` (7 preceding siblings ...)
  2019-04-29  1:21 ` Keith David Bershatsky
@ 2019-06-08 23:44 ` Keith David Bershatsky
  2019-06-16  8:07 ` Keith David Bershatsky
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2019-06-08 23:44 UTC (permalink / raw)
  To: 22873, 17684; +Cc: johnw, mbork, rms, akioburns

[-- Attachment #1: Type: text/plain, Size: 7697 bytes --]

VERSION:  021.001 [06/08/2019]


CHANGELOG:

- Fixed bugs in `mc_xfree_cache_matrix', the most significant of which was the
  failure to reset struct members that were not allocated to memory dynamically.

- Fixed bugs in `mc_save_cache_matrix', the most significant of which was that
  some struct members were not being saved.

- Added `mc_traverse_cache_p' to be used in various `for` loops, which ensures
  that a uniform test is used everywhere [which was not previously the case].

- Fixed a bug in `mc_helper' relating to proper bookkeeping of the `vpos_used`
  member in the `mc_matrix'.

- Added `mc_cache_inspector' to help with debugging.

- `mc_set_essentials' is now called only once per `update_window' (at outset).

- Fixed a bug with respect to determining the `row_position` of the cursor row,
  which is the one exception where we consult the previous row in the desired
  matrix instead of consulting the previous row in the current matrix.

- Reduced overall footprint a little bit by restoring `it` struct to its original
  state -- the member `zv_p` is no longer needed by features 17684 / 22873.  The
  code used to record `it` struct member `zv_p` has been removed.  Reduced the
  additional `glyph` struct members to just `hpos`, `bytepos` and `relative_x`
  (which is not needed, but may be useful if debugging).  The code used to record
  the prior `glyph` struct members `x`, `y`, `vpos` and `zv_p` has been removed.

- Miscellaneous cleaning up of unused variables, shortened certain names, and
  tidied up some of the code.  Changed a couple of colors for even-at-zv ....

- Added screenshot of most of the features on all three GUI ports (X11, W32, NS).


SCREENSHOTS (X11, W32, NS):

https://www.lawlist.com/images/22873_17684_light_dark_backgrounds.png


SETUP:

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

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

git reset --hard a038df77de7b1aa2d73a6478493b8838b59e4982

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

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

Step 4:  ./autogen.sh

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

Step 6:  make

Step 7:  make install


USAGE:

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

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

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

  ;;; TURN OFF FAKE CURSORS:

  (setq mc-conf nil)

- To try out both the crosshairs feature and the visible fill column indicator
  feature, type:  M-x +-mode

- To try out just the visible fill column indicator feature, type:  M-x fc-mode

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

  Type:  M-x mc-install

  OR, evaluate the following snippet:

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


TODO:

- `ns_draw_window_cursor' calls `ns_clip_to_rect', which does _not_ take
  `row->clip` into consideration when drawing cursors with `NSRectFill'.  When
  it comes time to draw glyphs on top of the box/hollow family of cursors,
  `row->clip` is taken into consideration by `get_glyph_string_clip'.  Fake
  cursors can be drawn even though the glyphs cannot, resulting in hollow/box
  family of cursors without text.  The issue can be reproduced with M-x mc-test.
  [A temporary workaround is to disable `row->clip` while drawing the glyphs.]
  https://lists.gnu.org/archive/html/emacs-devel/2019-04/msg00009.html

- Add additional support for `ch_inactive_windows' and `fc_inactive_windows'
  when the variables have a `nil` value.  In such a case, the inactive windows
  should not display the crosshairs and/or visible fill column indicator.  At the
  present time, fake cursors are drawn in active/inactive windows alike.

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

- Is there any additional meaningful optimization that can be added to the
  three calls of `mc_pre_scroll_clean'?

- NOTE:  As to `mc_scrolling_window', it would appear that there is no tangible
  benefit to rotating the current/prospective cache of fake cursors to compare
  the data before removing the fake cursors.  When scrolling the display, only
  _some_ lines are copied to new locations.  Areas that are not overwritten may
  have fake cursors and those may not necessarily be removed if desired/current
  matrix glyphs are equal.  The test for `GLYPH_EQUAL_P' does not take into
  consideration the existence of a fake cursor, and the glyph (with a fake
  cursor) may not be updated as a result thereof.  As to lines that are not
  copied, portions may be updated and fake cursors would be removed thereby.

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

- There is a bug affecting an older version of Emacs for the NS port that causes
  partial line flickering when the same characters are grouped together (;;;;;;)
  and MC_GLYPHLESS cursors are above or below -- having the same background color
  as the frame; e.g., black on black (used to erase a glyphless cursor).  The
  partial flickering is only noticeable with rapid fire; e.g., holding down the
  right/left arrow key.  When changing the color of the glyphless cursor, the
  issue is not present.  [@lawlist has verified that the X and HPOS coordinates
  are accurate.]

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

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

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

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

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

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

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


[-- Attachment #2: 2019_06_08__16_37_35_624.diff --]
[-- Type: application/diff, Size: 623950 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#17684: #22873 (multiple fake cursors); and, #17684 (crosshairs).
  2014-06-03 20:36 bug#17684: 24.4.50; Feature Request -- Vertical Lines to the Left of and Through Characters Keith David Bershatsky
                   ` (8 preceding siblings ...)
  2019-06-08 23:44 ` Keith David Bershatsky
@ 2019-06-16  8:07 ` Keith David Bershatsky
  2019-06-24  2:25 ` Keith David Bershatsky
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2019-06-16  8:07 UTC (permalink / raw)
  To: 22873, 17684; +Cc: johnw, mbork, rms, akioburns

[-- Attachment #1: Type: text/plain, Size: 6458 bytes --]

VERSION: 021.002 [06/15/2019]

CHANGELOG:

- `mc_row_position':  Added tests for an empty buffer (not narrowed) and an empty
  buffer (narrowed), both of which will be treated as an AT_ZV situation if VPOS
  is the first text row in the buffer excluding the header-line-format (if any).

- Compacted all of the calls to `mc_redraw_row' so that they are one-liners.

- Miscellaneous tidying up of code; changed a few names of some struct members.


SCREENSHOTS (X11, W32, NS):

https://www.lawlist.com/images/22873_17684_light_dark_backgrounds.png


SETUP:

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

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

git reset --hard a038df77de7b1aa2d73a6478493b8838b59e4982

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

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

Step 4:  ./autogen.sh

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

Step 6:  make

Step 7:  make install


USAGE:

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

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

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

  ;;; TURN OFF FAKE CURSORS:

  (setq mc-conf nil)

- To try out both the crosshairs feature and the visible fill column indicator
  feature, type:  M-x +-mode

- To try out just the visible fill column indicator feature, type:  M-x fc-mode

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

  Type:  M-x mc-install

  OR, evaluate the following snippet:

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


TODO:

- `ns_draw_window_cursor' calls `ns_clip_to_rect', which does _not_ take
  `row->clip` into consideration when drawing cursors with `NSRectFill'.  When
  it comes time to draw glyphs on top of the box/hollow family of cursors,
  `row->clip` is taken into consideration by `get_glyph_string_clip'.  Fake
  cursors can be drawn even though the glyphs cannot, resulting in hollow/box
  family of cursors without text.  The issue can be reproduced with M-x mc-test.
  [A temporary workaround is to disable `row->clip` while drawing the glyphs.]
  https://lists.gnu.org/archive/html/emacs-devel/2019-04/msg00009.html

- Add additional support for `ch_inactive_windows' and `fc_inactive_windows'
  when the variables have a `nil` value.  In such a case, the inactive windows
  should not display the crosshairs and/or visible fill column indicator.  At the
  present time, fake cursors are drawn in active/inactive windows alike.

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

- Is there any additional meaningful optimization that can be added to the
  three calls of `mc_pre_scroll_clean'?

- NOTE:  As to `mc_scrolling_window', it would appear that there is no tangible
  benefit to rotating the current/prospective cache of fake cursors to compare
  the data before removing the fake cursors.  When scrolling the display, only
  _some_ lines are copied to new locations.  Areas that are not overwritten may
  have fake cursors and those may not necessarily be removed if desired/current
  matrix glyphs are equal.  The test for `GLYPH_EQUAL_P' does not take into
  consideration the existence of a fake cursor, and the glyph (with a fake
  cursor) may not be updated as a result thereof.  As to lines that are not
  copied, portions may be updated and fake cursors would be removed thereby.

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

- There is a bug affecting an older version of Emacs for the NS port that causes
  partial line flickering when the same characters are grouped together (;;;;;;)
  and MC_GLYPHLESS cursors are above or below -- having the same background color
  as the frame; e.g., black on black (used to erase a glyphless cursor).  The
  partial flickering is only noticeable with rapid fire; e.g., holding down the
  right/left arrow key.  When changing the color of the glyphless cursor, the
  issue is not present.  [@lawlist has verified that the X and HPOS coordinates
  are accurate.]

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

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

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

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

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

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

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


[-- Attachment #2: 2019_06_15__21_52_03_071.diff --]
[-- Type: application/diff, Size: 623692 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#17684: #22873 (multiple fake cursors); and, #17684 (crosshairs).
  2014-06-03 20:36 bug#17684: 24.4.50; Feature Request -- Vertical Lines to the Left of and Through Characters Keith David Bershatsky
                   ` (9 preceding siblings ...)
  2019-06-16  8:07 ` Keith David Bershatsky
@ 2019-06-24  2:25 ` Keith David Bershatsky
  2019-06-30  5:42 ` Keith David Bershatsky
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2019-06-24  2:25 UTC (permalink / raw)
  To: 22873, 17684; +Cc: johnw, mbork, rms, akioburns

[-- Attachment #1: Type: text/plain, Size: 6594 bytes --]

VERSION:  021.003 [06/23/2019]


CHANGELOG:

- `bottom_vpos' has been removed as a function parameter of `mc_draw_row' and
  `mc_draw_glyphs'.

- Removed the `redisplay_interface' component named `mc_scribe_glyphs'.  Removed
  the function `mc_x_write_glyphs'.  `mc_draw_glyphs' is now called directly from
  `mc_update_text_area'.

- Revised instructions regarding how to use the built-in fake cursors with
  Magnar's library (multiple-cursors).  [Adjusted calls to `mc/built-in-cursors'
  within `crosshairs.el'.]

- Miscellaneous tidying-up of code.


SCREENSHOTS (X11, W32, NS):

https://www.lawlist.com/images/22873_17684_light_dark_backgrounds.png


SETUP:

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

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

git reset --hard a038df77de7b1aa2d73a6478493b8838b59e4982

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

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

Step 4:  ./autogen.sh

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

Step 6:  make

Step 7:  make install


USAGE:

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

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

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

  ;;; TURN OFF FAKE CURSORS:

  (setq mc-conf nil)

- To try out both the crosshairs feature and the visible fill column indicator
  feature, type:  M-x +-mode

- To try out just the visible fill column indicator feature, type:  M-x fc-mode

- To try out built-in fake cursors with Magnar Sveen's multiple-cursors package,
  that package must be installed.  If the multiple-cursors package is already
  installed, then just (require 'crosshairs) and `crosshairs.el` will redefine a
  few of the multiple-cursors functions and set up a few keyboard shortcuts.
  If the multiple-cursors package by Magnar Sveen is not already installed, then
  here are two easy ways to install that package:

  Type:  M-x mc-install

  OR, evaluate the following snippet:

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


TODO:

- `ns_draw_window_cursor' calls `ns_clip_to_rect', which does _not_ take
  `row->clip` into consideration when drawing cursors with `NSRectFill'.  When
  it comes time to draw glyphs on top of the box/hollow family of cursors,
  `row->clip` is taken into consideration by `get_glyph_string_clip'.  Fake
  cursors can be drawn even though the glyphs cannot, resulting in hollow/box
  family of cursors without text.  The issue can be reproduced with M-x mc-test.
  [A temporary workaround is to disable `row->clip` while drawing the glyphs.]
  https://lists.gnu.org/archive/html/emacs-devel/2019-04/msg00009.html

- Add additional support for `ch_inactive_windows' and `fc_inactive_windows'
  when the variables have a `nil` value.  In such a case, the inactive windows
  should not display the crosshairs and/or visible fill column indicator.  At the
  present time, fake cursors are drawn in active/inactive windows alike.

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

- Is there any additional meaningful optimization that can be added to the
  three calls of `mc_pre_scroll_clean'?

- NOTE:  As to `mc_scrolling_window', it would appear that there is no tangible
  benefit to rotating the current/prospective cache of fake cursors to compare
  the data before removing the fake cursors.  When scrolling the display, only
  _some_ lines are copied to new locations.  Areas that are not overwritten may
  have fake cursors and those may not necessarily be removed if desired/current
  matrix glyphs are equal.  The test for `GLYPH_EQUAL_P' does not take into
  consideration the existence of a fake cursor, and the glyph (with a fake
  cursor) may not be updated as a result thereof.  As to lines that are not
  copied, portions may be updated and fake cursors would be removed thereby.

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

- There is a bug affecting an older version of Emacs for the NS port that causes
  partial line flickering when the same characters are grouped together (;;;;;;)
  and MC_GLYPHLESS cursors are above or below -- having the same background color
  as the frame; e.g., black on black (used to erase a glyphless cursor).  The
  partial flickering is only noticeable with rapid fire; e.g., holding down the
  right/left arrow key.  When changing the color of the glyphless cursor, the
  issue is not present.  [@lawlist has verified that the X and HPOS coordinates
  are accurate.]

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

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

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

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

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

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

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


[-- Attachment #2: 2019_06_23__17_05_04_651.diff --]
[-- Type: application/diff, Size: 624692 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#17684: #22873 (multiple fake cursors); and, #17684 (crosshairs).
  2014-06-03 20:36 bug#17684: 24.4.50; Feature Request -- Vertical Lines to the Left of and Through Characters Keith David Bershatsky
                   ` (10 preceding siblings ...)
  2019-06-24  2:25 ` Keith David Bershatsky
@ 2019-06-30  5:42 ` Keith David Bershatsky
  2019-07-31 19:39 ` Keith David Bershatsky
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2019-06-30  5:42 UTC (permalink / raw)
  To: 22873, 17684; +Cc: johnw, mbork, rms, akioburns

[-- Attachment #1: Type: text/plain, Size: 6727 bytes --]

VERSION:  021.004 [06/29/2019]


CHANGELOG:

- Fake cursors can now be suppressed in the inactive windows by setting to `nil'
  the buffer-local variables `mc-inactive-windows', `fc-inactive-windows', and/or
  `ch-inactive-windows'.  The left fringe bitmap indicator that coincides with
  the line containing POINT (if `ch-horizontal-ruler' is non-nil) is drawn in the
  inactive windows regardless of the boolean value of `ch-inactive-windows' --
  this is an intended feature.  The real fake cursor coinciding with the line
  containing POINT for inactive windows is drawn in the inactive windows -- this
  is an intended feature.  [Support for _suppression_ of fake cursors in the
  inactive windows had previously been disabled for an appreciable period of time
  because work needed to be done to ensure fake cursors are drawn correctly when
  `mc/fc/ch-inactive-windows' is non-nil; e.g., different colors for fake cursors
  in the inactive-windows.]

- Miscellaneous tidying-up of some code.


SCREENSHOTS (X11, W32, NS):

https://www.lawlist.com/images/22873_17684_light_dark_backgrounds.png


SETUP:

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

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

git reset --hard a038df77de7b1aa2d73a6478493b8838b59e4982

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

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

Step 4:  ./autogen.sh

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

Step 6:  make

Step 7:  make install


USAGE:

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

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

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

  ;;; TURN OFF FAKE CURSORS:

  (setq mc-conf nil)

- To try out both the crosshairs feature and the visible fill column indicator
  feature, type:  M-x +-mode

- To try out just the visible fill column indicator feature, type:  M-x fc-mode

- To try out built-in fake cursors with Magnar Sveen's multiple-cursors package,
  that package must be installed.  If the multiple-cursors package is already
  installed, then just (require 'crosshairs) and `crosshairs.el` will redefine a
  few of the multiple-cursors functions and set up a few keyboard shortcuts.
  If the multiple-cursors package by Magnar Sveen is not already installed, then
  here are two easy ways to install that package:

  Type:  M-x mc-install

  OR, evaluate the following snippet:

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


TODO:

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

- `ns_draw_window_cursor' calls `ns_clip_to_rect', which does _not_ take
  `row->clip` into consideration when drawing cursors with `NSRectFill'.  When
  it comes time to draw glyphs on top of the box/hollow family of cursors,
  `row->clip` is taken into consideration by `get_glyph_string_clip'.  Fake
  cursors can be drawn even though the glyphs cannot, resulting in hollow/box
  family of cursors without text.  The issue can be reproduced with M-x mc-test.
  [A temporary workaround is to disable `row->clip` while drawing the glyphs.]
  https://lists.gnu.org/archive/html/emacs-devel/2019-04/msg00009.html

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

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

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

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

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

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

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

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

- Is there any additional meaningful optimization that can be added to the
  three calls of `mc_pre_scroll_clean'?

- There is a bug affecting an older version of Emacs for the NS port that causes
  partial line flickering when the same characters are grouped together (;;;;;;)
  and MC_GLYPHLESS cursors are above or below -- having the same background color
  as the frame; e.g., black on black (used to erase a glyphless cursor).  The
  partial flickering is only noticeable with rapid fire; e.g., holding down the
  right/left arrow key.  When changing the color of the glyphless cursor, the
  issue is not present.  [@lawlist has verified that the X and HPOS coordinates
  are accurate.]

- NOTE:  As to `mc_scrolling_window', it would appear that there is no tangible
  benefit to rotating the current/prospective cache of fake cursors to compare
  the data before removing the fake cursors.  When scrolling the display, only
  _some_ lines are copied to new locations.  Areas that are not overwritten may
  have fake cursors and those may not necessarily be removed if desired/current
  matrix glyphs are equal.  The test for `GLYPH_EQUAL_P' does not take into
  consideration the existence of a fake cursor, and the glyph (with a fake
  cursor) may not be updated as a result thereof.  As to lines that are not
  copied, portions may be updated and fake cursors would be removed thereby.


[-- Attachment #2: 2019_06_29__20_23_09_354.diff --]
[-- Type: application/diff, Size: 626151 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: #22873 (multiple fake cursors); and, #17684 (crosshairs).
  2016-03-01 18:44 bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support) Keith David Bershatsky
                   ` (26 preceding siblings ...)
  2019-06-02  7:29 ` Keith David Bershatsky
@ 2019-07-16 19:28 ` Keith David Bershatsky
  2019-07-23  6:01 ` Keith David Bershatsky
                   ` (3 subsequent siblings)
  31 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2019-07-16 19:28 UTC (permalink / raw)
  To: 22873, 17684; +Cc: johnw, mbork, rms, akioburns

[-- Attachment #1: Type: text/plain, Size: 7257 bytes --]

VERSION: 022.000 [07/14/2019]


CHANGELOG:

- Fast forward from 04/08/2019 to 07/14/2019; i.e., the attached patch applies to
  a recent version of the master branch as of 07/14/2019.  Each GUI port has
  been lightly tested to verify features 17684/22873 work as expected.

- Added a new member of the `mc_contents` struct to record the `row_position`,
  which is now used (in part) by `mc_update_window_erase' to determine whether
  an AT_ZV / POST_ZV fake cursor is the same as the previous loop -- disregarding
  lack of equality of the `*.bytepos` and `*.charpos` struct members.  An example
  where this is helpful is when a user adds / removes characters from the buffer,
  but does not add / remove a row.

- As to features 17684/22873, removed all calls to CHECK_BUFFER.  None of the
  buffer lisp objects are coming from the user (outside of C), so a `BUFFERP'
  check of `w->contents` is sufficient.

- Added screen recordings of features 17684/22873.

- Miscellaneous tidying-up of code.


VIDEOS:

w32:  https://youtu.be/r3BdJVlsAnQ

ns:  https://youtu.be/bc1h8jtbXmw

x11:  https://youtu.be/aCIFhD2Xz5s


SCREENSHOTS:

https://www.lawlist.com/images/22873_17684_light_dark_backgrounds.png


SETUP:

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

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

git reset --hard ac57c5093829ee09084c562bbbc1c412179be13d

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

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

Step 4:  ./autogen.sh

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

Step 6:  make

Step 7:  make install


USAGE:

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

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

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

  ;;; TURN OFF FAKE CURSORS:

  (setq mc-conf nil)

- To try out both the crosshairs feature and the visible fill column indicator
  feature, type:  M-x +-mode

- To try out just the visible fill column indicator feature, type:  M-x fc-mode

- To try out built-in fake cursors with Magnar Sveen's multiple-cursors package,
  that package must be installed.  If the multiple-cursors package is already
  installed, then just (require 'crosshairs) and `crosshairs.el` will redefine a
  few of the multiple-cursors functions and set up a few keyboard shortcuts.
  If the multiple-cursors package by Magnar Sveen is not already installed, then
  here are two easy ways to install that package:

  Type:  M-x mc-install

  OR, evaluate the following snippet:

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


TODO:

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

  (progn
    (defun test ()
    (interactive)
      (let ((ov (make-overlay (point) (1+ (point)) nil t t)))
        (overlay-put ov 'face '(:foreground "red"))))
    (global-set-key [f5] 'test)
    (split-window-horizontally)
    (switch-to-buffer (get-buffer-create "foo"))
    (setq bidi-display-reordering nil)
    (setq-local auto-hscroll-mode 'current-line)
    (dotimes (i 80)
      (insert (char-to-string (+ 65 i)))))

- `ns_draw_window_cursor' calls `ns_clip_to_rect', which does _not_ take
  `row->clip` into consideration when drawing cursors with `NSRectFill'.  When
  it comes time to draw glyphs on top of the box/hollow family of cursors,
  `row->clip` is taken into consideration by `get_glyph_string_clip'.  Fake
  cursors can be drawn even though the glyphs cannot, resulting in hollow/box
  family of cursors without text.  The issue can be reproduced with M-x mc-test.
  [A temporary workaround is to disable `row->clip` while drawing the glyphs.]
  https://lists.gnu.org/archive/html/emacs-devel/2019-04/msg00009.html

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

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

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

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

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

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

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

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

- Is there any additional meaningful optimization that can be added to the
  three calls of `mc_pre_scroll_clean'?

- There is a bug affecting an older version of Emacs for the NS port that causes
  partial line flickering when the same characters are grouped together (;;;;;;)
  and MC_GLYPHLESS cursors are above or below -- having the same background color
  as the frame; e.g., black on black (used to erase a glyphless cursor).  The
  partial flickering is only noticeable with rapid fire; e.g., holding down the
  right/left arrow key.  When changing the color of the glyphless cursor, the
  issue is not present.  [@lawlist has verified that the X and HPOS coordinates
  are accurate.]

- NOTE:  As to `mc_scrolling_window', it would appear that there is no tangible
  benefit to rotating the current/prospective cache of fake cursors to compare
  the data before removing the fake cursors.  When scrolling the display, only
  _some_ lines are copied to new locations.  Areas that are not overwritten may
  have fake cursors and those may not necessarily be removed if desired/current
  matrix glyphs are equal.  The test for `GLYPH_EQUAL_P' does not take into
  consideration the existence of a fake cursor, and the glyph (with a fake
  cursor) may not be updated as a result thereof.  As to lines that are not
  copied, portions may be updated and fake cursors would be removed thereby.


[-- Attachment #2: 2019_07_16__12_05_58_696.diff --]
[-- Type: application/diff, Size: 643256 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: #22873 (multiple fake cursors); and, #17684 (crosshairs).
  2016-03-01 18:44 bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support) Keith David Bershatsky
                   ` (27 preceding siblings ...)
  2019-07-16 19:28 ` Keith David Bershatsky
@ 2019-07-23  6:01 ` Keith David Bershatsky
  2019-08-23  5:19 ` Keith David Bershatsky
                   ` (2 subsequent siblings)
  31 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2019-07-23  6:01 UTC (permalink / raw)
  To: 22873, 17684; +Cc: johnw, mbork, rms, akioburns

[-- Attachment #1: Type: text/plain, Size: 6792 bytes --]

VERSION: 022.001 [07/22/2019]


CHANGELOG:

- `mc_update_window_erase' no longer sets the `same_p` struct member to `false`,
  as this was undoing all of the work that had previously been done to discover
  and set `same_p` to `true` in previous loops through the caches of fake cursors.
  Although this bug may have been somewhat difficult for the naked eye to see,
  the fix will improve the overall performance in some situations by reducing the
  need to erase and redraw certain fake cursors.

- Miscellaneous tidying-up of code.


VIDEOS:

w32:  https://youtu.be/r3BdJVlsAnQ

ns:  https://youtu.be/bc1h8jtbXmw

x11:  https://youtu.be/aCIFhD2Xz5s


SCREENSHOTS:

https://www.lawlist.com/images/22873_17684_light_dark_backgrounds.png


SETUP:

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

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

git reset --hard ac57c5093829ee09084c562bbbc1c412179be13d

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

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

Step 4:  ./autogen.sh

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

Step 6:  make

Step 7:  make install


USAGE:

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

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

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

  ;;; TURN OFF FAKE CURSORS:

  (setq mc-conf nil)

- To try out both the crosshairs feature and the visible fill column indicator
  feature, type:  M-x +-mode

- To try out just the visible fill column indicator feature, type:  M-x fc-mode

- To try out built-in fake cursors with Magnar Sveen's multiple-cursors package,
  that package must be installed.  If the multiple-cursors package is already
  installed, then just (require 'crosshairs) and `crosshairs.el` will redefine a
  few of the multiple-cursors functions and set up a few keyboard shortcuts.
  If the multiple-cursors package by Magnar Sveen is not already installed, then
  here are two easy ways to install that package:

  Type:  M-x mc-install

  OR, evaluate the following snippet:

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


TODO:

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

  (progn
    (defun test ()
    (interactive)
      (let ((ov (make-overlay (point) (1+ (point)) nil t t)))
        (overlay-put ov 'face '(:foreground "red"))))
    (global-set-key [f5] 'test)
    (split-window-horizontally)
    (switch-to-buffer (get-buffer-create "foo"))
    (setq bidi-display-reordering nil)
    (setq-local auto-hscroll-mode 'current-line)
    (dotimes (i 80)
      (insert (char-to-string (+ 65 i)))))

- `ns_draw_window_cursor' calls `ns_clip_to_rect', which does _not_ take
  `row->clip` into consideration when drawing cursors with `NSRectFill'.  When
  it comes time to draw glyphs on top of the box/hollow family of cursors,
  `row->clip` is taken into consideration by `get_glyph_string_clip'.  Fake
  cursors can be drawn even though the glyphs cannot, resulting in hollow/box
  family of cursors without text.  The issue can be reproduced with M-x mc-test.
  [A temporary workaround is to disable `row->clip` while drawing the glyphs.]
  https://lists.gnu.org/archive/html/emacs-devel/2019-04/msg00009.html

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

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

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

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

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

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

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

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

- Is there any additional meaningful optimization that can be added to the
  three calls of `mc_pre_scroll_clean'?

- There is a bug affecting an older version of Emacs for the NS port that causes
  partial line flickering when the same characters are grouped together (;;;;;;)
  and MC_GLYPHLESS cursors are above or below -- having the same background color
  as the frame; e.g., black on black (used to erase a glyphless cursor).  The
  partial flickering is only noticeable with rapid fire; e.g., holding down the
  right/left arrow key.  When changing the color of the glyphless cursor, the
  issue is not present.  [@lawlist has verified that the X and HPOS coordinates
  are accurate.]

- NOTE:  As to `mc_scrolling_window', it would appear that there is no tangible
  benefit to rotating the current/prospective cache of fake cursors to compare
  the data before removing the fake cursors.  When scrolling the display, only
  _some_ lines are copied to new locations.  Areas that are not overwritten may
  have fake cursors and those may not necessarily be removed if desired/current
  matrix glyphs are equal.  The test for `GLYPH_EQUAL_P' does not take into
  consideration the existence of a fake cursor, and the glyph (with a fake
  cursor) may not be updated as a result thereof.  As to lines that are not
  copied, portions may be updated and fake cursors would be removed thereby.


[-- Attachment #2: 2019_07_22__21_18_46_990.diff --]
[-- Type: application/diff, Size: 642748 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#17684: #22873 (multiple fake cursors); and, #17684 (crosshairs).
  2014-06-03 20:36 bug#17684: 24.4.50; Feature Request -- Vertical Lines to the Left of and Through Characters Keith David Bershatsky
                   ` (11 preceding siblings ...)
  2019-06-30  5:42 ` Keith David Bershatsky
@ 2019-07-31 19:39 ` Keith David Bershatsky
  2019-10-18  1:12 ` bug#17684: #22873 (multiple fake cursors); and, #17684 (crosshairs / fill-column) Keith David Bershatsky
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2019-07-31 19:39 UTC (permalink / raw)
  To: 22873, 17684; +Cc: johnw, mbork, rms, akioburns

[-- Attachment #1: Type: text/plain, Size: 9134 bytes --]

VERSION: 022.002 [07/31/2019]


CHANGELOG:

- Replaced optional debugging messages to STDERR with the variable `mc_stderr_p'
  instead of using `trace_redisplay_p'.

- `mc_update_window_erase' no longer excludes left/right fringe bitmaps from the
  `same_p` determination.  `mc_helper' now contains exceptions for the left/right
  fringe bitmap indicators, ensuring they are reset even if they are `same_p`.

- Added a NOTES section to this introductory commentary, including, a summary
  explaining generally the purpose of the dryrun in `update_window'.

- Removed `mc_rotate_matrix' and `mc_reverse_vpos'.

- Miscellaneous tidying-up of code.


VIDEOS:

w32:  https://youtu.be/r3BdJVlsAnQ

ns:  https://youtu.be/bc1h8jtbXmw

x11:  https://youtu.be/aCIFhD2Xz5s


SCREENSHOTS:

https://www.lawlist.com/images/22873_17684_light_dark_backgrounds.png


SETUP:

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

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

git reset --hard ac57c5093829ee09084c562bbbc1c412179be13d

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

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

Step 4:  ./autogen.sh

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

Step 6:  make

Step 7:  make install


USAGE:

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

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

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

  ;;; TURN OFF FAKE CURSORS:

  (setq mc-conf nil)

- To try out both the crosshairs feature and the visible fill column indicator
  feature, type:  M-x +-mode

- To try out just the visible fill column indicator feature, type:  M-x fc-mode

- To try out built-in fake cursors with Magnar Sveen's multiple-cursors package,
  that package must be installed.  If the multiple-cursors package is already
  installed, then just (require 'crosshairs) and `crosshairs.el` will redefine a
  few of the multiple-cursors functions and set up a few keyboard shortcuts.
  If the multiple-cursors package by Magnar Sveen is not already installed, then
  here are two easy ways to install that package:

  Type:  M-x mc-install

  OR, evaluate the following snippet:

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


TODO:

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

  (progn
    (defun test ()
    (interactive)
      (let ((ov (make-overlay (point) (1+ (point)) nil t t)))
        (overlay-put ov 'face '(:foreground "red"))))
    (global-set-key [f5] 'test)
    (split-window-horizontally)
    (switch-to-buffer (get-buffer-create "foo"))
    (setq bidi-display-reordering nil)
    (setq-local auto-hscroll-mode 'current-line)
    (dotimes (i 80)
      (insert (char-to-string (+ 65 i)))))

- `ns_draw_window_cursor' calls `ns_clip_to_rect', which does _not_ take
  `row->clip` into consideration when drawing cursors with `NSRectFill'.  When
  it comes time to draw glyphs on top of the box/hollow family of cursors,
  `row->clip` is taken into consideration by `get_glyph_string_clip'.  Fake
  cursors can be drawn even though the glyphs cannot, resulting in hollow/box
  family of cursors without text.  The issue can be reproduced with M-x mc-test.
  [A temporary workaround is to disable `row->clip` while drawing the glyphs.]
  https://lists.gnu.org/archive/html/emacs-devel/2019-04/msg00009.html

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

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

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

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

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

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

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

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

- Is there any additional meaningful optimization that can be added to the
  three calls of `mc_pre_scroll_clean'?

- There is a bug affecting an older version of Emacs for the NS port that causes
  partial line flickering when the same characters are grouped together (;;;;;;)
  and MC_GLYPHLESS cursors are above or below -- having the same background color
  as the frame; e.g., black on black (used to erase a glyphless cursor).  The
  partial flickering is only noticeable with rapid fire; e.g., holding down the
  right/left arrow key.  When changing the color of the glyphless cursor, the
  issue is not present.  [@lawlist has verified that the X and HPOS coordinates
  are accurate.]


NOTES:

- Our journey begins at the outset of `update_window' when
  `mc_update_window_dryrun' performs a `!draw_p` simulation to create a new
  cache of fake cursors that are stored in the `w->mc_matrix`.  The cache from
  the previous redisplay is copied to a temporary `mc_matrix` under the name of
  `old_matrix`.  At the tail end of `mc_update_window_dryrun',
  `mc_update_window_erase' compares the new `w->mc_matrix` with the `old_matrix`
  to determine which fake cursors are the same -- setting the `same_p` boolean
  struct member accordingly for each applicable fake cursor within the
  `w->mc_matrix`.  All fake cursors in the `old_matrix` that are `!same_p` get
  erased at this juncture.  [Fn 1.]  After the dryrun is complete,
  `update_window' does the real thing -- `draw_p`.  As to the `from_where`
  situations of SKIPPED, POST_CHANGED, UNCHANGED, and SET_CURSOR_TWO,
  `mc_helper' compares the incoming tentative fake cursor with the
  `w->mc_matrix` to see if it has previously been marked as `same_p` -- if it is
  `!same_p`, then the fake cursor is drawn and we `return`.  Fake cursors that
  have a `cursor_type` of MC_LEFT_FRINGE_BITMAP or MC_RIGHT_FRINGE_BITMAP are
  always reset even if they are `same_p`.  As to the `from_where` situations of
  SCRIBE_ONE, SCRIBE_TWO, SCRIBE_THREE, and NOWHERE, `mc_helper' always causes
  fake cursors to be drawn (because new glyphs were written to the glass, or the
  area to the right of the display line was cleared) and we `return`.
. Fn. 1:  Even though writing new glyphs to the glass (SCRIBE_ONE, SCRIBE_TWO,
  and SCRIBE_THREE) would erase fake cursors within those boundaries, it is
  still necessary to erase `!same_p` fake cursors prior thereto.  This is
  because `scrolling_window' occurs before new glyphs are written and
  `rif->scroll_run_hook' may copy one or more rows to other areas of the glass.
  It is not worth the effort to programmatically track both the _copied_ fake
  cursors and the _original_ fake cursors from the previous redisplay cycle,
  whose glyphs may remain where they are in the current redisplay cycle because
  they satisfy the `GLYPH_EQUAL_P' test.

- As to `mc_scrolling_window', it would appear that there is no tangible
  benefit to rotating the current/prospective cache of fake cursors to compare
  the data before removing the fake cursors.  When scrolling the display, only
  _some_ lines are copied to new locations.  Areas that are not overwritten may
  have fake cursors and those may not necessarily be removed if desired/current
  matrix glyphs are equal.  The test for `GLYPH_EQUAL_P' does not take into
  consideration the existence of a fake cursor, and the glyph (with a fake
  cursor) may not be updated as a result thereof.  As to lines that are not
  copied, portions may be updated and fake cursors would be removed thereby.
  `mc_rotate_matrix' and `mc_reverse_vpos' were removed with patch v. 022.002.


[-- Attachment #2: 2019_07_31__12_36_32_978.diff --]
[-- Type: application/diff, Size: 642876 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: #22873 (multiple fake cursors); and, #17684 (crosshairs).
  2016-03-01 18:44 bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support) Keith David Bershatsky
                   ` (28 preceding siblings ...)
  2019-07-23  6:01 ` Keith David Bershatsky
@ 2019-08-23  5:19 ` Keith David Bershatsky
  2019-10-17 21:08 ` bug#22873: #22873 (multiple fake cursors); and, #17684 (crosshairs / fill-column) Keith David Bershatsky
  2020-03-04  9:03 ` Keith David Bershatsky
  31 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2019-08-23  5:19 UTC (permalink / raw)
  To: 22873, 17684; +Cc: johnw, mbork, rms, akioburns

[-- Attachment #1: Type: text/plain, Size: 10533 bytes --]

VERSION: 022.003 [08/22/2019]


CHANGELOG:

- Fixed a bug preventing the visible fill column indicator from displaying on
  continuation lines when a partially visible glyph is straddling the window
  body width limit (aka text_area_width).

- Fringe bitmap faces are now handled with `lookup_derived_face' instead of
  `lookup_named_face' so that the background color of the fringe will be taken
  into consideration (if it is different than the default background face).

- `mc_draw_erase_hybrid':  No need to call `mc_draw_fringe_bitmap' -- setting the
  rows with the necessary fringe bitmap data ensures `draw_row_fringe_bitmaps'
  will handle everything when needed.

- `mc_update_window_erase':  Fixed a couple of warnings during the build of Emacs
  relating to `fprintf' arguments not matching the expected %d\int format.

- Revisions to the NOTES section of this commentary.

- Miscellaneous tidying-up of code.


VIDEOS:

w32:  https://youtu.be/r3BdJVlsAnQ

ns:  https://youtu.be/bc1h8jtbXmw

x11:  https://youtu.be/aCIFhD2Xz5s


SCREENSHOTS:

https://www.lawlist.com/images/22873_17684_light_dark_backgrounds.png


SETUP:

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

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

git reset --hard ac57c5093829ee09084c562bbbc1c412179be13d

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

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

Step 4:  ./autogen.sh

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

Step 6:  make

Step 7:  make install


USAGE:

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

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

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

  ;;; TURN OFF FAKE CURSORS:

  (setq mc-conf nil)

- To try out both the crosshairs feature and the visible fill column indicator
  feature, type:  M-x +-mode

- To try out just the visible fill column indicator feature, type:  M-x fc-mode

- To try out built-in fake cursors with Magnar Sveen's multiple-cursors package,
  that package must be installed.  If the multiple-cursors package is already
  installed, then just (require 'crosshairs) and `crosshairs.el` will redefine a
  few of the multiple-cursors functions and set up a few keyboard shortcuts.
  If the multiple-cursors package by Magnar Sveen is not already installed, then
  here are two easy ways to install that package:

  Type:  M-x mc-install

  OR, evaluate the following snippet:

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


NOTES:

- Our journey begins at the outset of `update_window' when
  `mc_update_window_dryrun' performs a `!draw_p` simulation to create a new
  cache of fake cursors that are stored in the `w->mc_matrix`.  The cache of
  fake cursors from the previous redisplay is copied to a temporary `mc_matrix`
  under the name of `old_matrix`.  `mc_update_text_area' (used for `!draw_p` /
  `draw_p` situations) calls `mc_draw_glyphs' (writes glyphs to the glass)
  followed by `mc_draw_row' (writes fake cursors to the glass immediately
  thereafter).  At the tail end of `mc_update_window_dryrun',
  `mc_update_window_erase' compares the new `w->mc_matrix` with the `old_matrix`
  to determine which fake cursors are the same -- setting the `same_p` boolean
  struct member accordingly for each applicable fake cursor within the
  `w->mc_matrix`.  All fake cursors in the `old_matrix` that are `!same_p` get
  erased at this juncture.  [Fn 1.]  After the dryrun is complete,
  `update_window' does the real thing -- `draw_p`.  As to the `from_where`
  situations of SKIPPED, POST_CHANGED, UNCHANGED, and SET_CURSOR_TWO,
  `mc_helper' compares the incoming tentative fake cursor with the
  `w->mc_matrix` to see if it has previously been marked as `same_p` -- if it is
  `!same_p`, then the fake cursor is drawn and we `return`.  Fake cursors that
  have a `cursor_type` of MC_LEFT_FRINGE_BITMAP or MC_RIGHT_FRINGE_BITMAP are
  always reset even if they are `same_p`.  As to the `from_where` situations of
  SCRIBE_ONE, SCRIBE_TWO, SCRIBE_THREE, and NOWHERE, `mc_helper' always causes
  fake cursors to be drawn (because new glyphs were written to the glass, or the
  area to the right of the display line was cleared) and we `return`.

. Fn. 1:  Even though writing new glyphs to the glass (SCRIBE_ONE, SCRIBE_TWO,
  and SCRIBE_THREE) would erase fake cursors within those boundaries, it is
  still necessary to erase `!same_p` fake cursors prior thereto.  This is
  because `scrolling_window' occurs before new glyphs are written and
  `rif->scroll_run_hook' may copy one or more rows to other areas of the glass.
  It is not worth the effort to programmatically track both the _copied_ fake
  cursors and the _original_ fake cursors from the previous redisplay cycle,
  whose glyphs may remain where they are in the current redisplay cycle because
  they satisfy the `GLYPH_EQUAL_P' test.

- The rest of our journey takes place wherever `draw_glyphs' would ordinarily be
  called, excluding `update_text_area'.  If features 17684/22873 are active,
  `mc_redraw_row' calls `mc_draw_glyphs' (writes glyphs to the glass) and fake
  cursors are written to the glass immediately thereafter (if the coordinates
  coincide with prerecorded data in the `w->mc_matrix`).  The functions
  containing the aforementioned calls are:
  . `gui_insert_glyphs'
  . `gui_fix_overlapping_area'
  . `draw_row_with_mouse_face'
  . `expose_area'
  . `expose_line'
  . `redraw_overlapped_rows' [which has been incorporated into `update_window']

- As to `mc_scrolling_window', it would appear that there is no tangible
  benefit to rotating the current/prospective cache of fake cursors to compare
  the data before removing the fake cursors.  When scrolling the display, only
  _some_ lines are copied to new locations.  Areas that are not overwritten may
  have fake cursors and those may not necessarily be removed if desired/current
  matrix glyphs are equal.  The test for `GLYPH_EQUAL_P' does not take into
  consideration the existence of a fake cursor, and the glyph (with a fake
  cursor) may not be updated as a result thereof.  As to lines that are not
  copied, portions may be updated and fake cursors would be removed thereby.
  `mc_rotate_matrix' and `mc_reverse_vpos' were removed with patch v. 022.002.

- NS:  As of 09/28/2018 (7946445962372c4255180af45cb7c857f1b0b5fa), the NS port
  no longer does anything useful during `update_window' except mark dirty
  rectangles.  All drawing is now done when the MacOS calls `drawRect', which in
  turn calls `expose_frame'.


TODO:

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

  (progn
    (defun test ()
    (interactive)
      (let ((ov (make-overlay (point) (1+ (point)) nil t t)))
        (overlay-put ov 'face '(:foreground "red"))))
    (global-set-key [f5] 'test)
    (split-window-horizontally)
    (switch-to-buffer (get-buffer-create "foo"))
    (setq bidi-display-reordering nil)
    (setq-local auto-hscroll-mode 'current-line)
    (dotimes (i 80)
      (insert (char-to-string (+ 65 i)))))

- `ns_draw_window_cursor' calls `ns_clip_to_rect', which does _not_ take
  `row->clip` into consideration when drawing cursors with `NSRectFill'.  When
  it comes time to draw glyphs on top of the box/hollow family of cursors,
  `row->clip` is taken into consideration by `get_glyph_string_clip'.  Fake
  cursors can be drawn even though the glyphs cannot, resulting in hollow/box
  family of cursors without text.  The issue can be reproduced with M-x mc-test.
  [A temporary workaround is to disable `row->clip` while drawing the glyphs.]
  https://lists.gnu.org/archive/html/emacs-devel/2019-04/msg00009.html

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

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

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

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

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

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

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

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

- Is there any additional meaningful optimization that can be added to the
  three calls of `mc_pre_scroll_clean'?

- There is a bug affecting an older version of Emacs for the NS port that causes
  partial line flickering when the same characters are grouped together (;;;;;;)
  and MC_GLYPHLESS cursors are above or below -- having the same background color
  as the frame; e.g., black on black (used to erase a glyphless cursor).  The
  partial flickering is only noticeable with rapid fire; e.g., holding down the
  right/left arrow key.  When changing the color of the glyphless cursor, the
  issue is not present.  [@lawlist has verified that the X and HPOS coordinates
  are accurate.]


[-- Attachment #2: 2019_08_22__20_16_49_786.diff --]
[-- Type: application/diff, Size: 643339 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: #22873 (multiple fake cursors); and, #17684 (crosshairs / fill-column).
  2016-03-01 18:44 bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support) Keith David Bershatsky
                   ` (29 preceding siblings ...)
  2019-08-23  5:19 ` Keith David Bershatsky
@ 2019-10-17 21:08 ` Keith David Bershatsky
  2020-03-04  9:03 ` Keith David Bershatsky
  31 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2019-10-17 21:08 UTC (permalink / raw)
  To: 22873, 17684; +Cc: johnw, mbork, rms, akioburns

[-- Attachment #1: Type: text/plain, Size: 10337 bytes --]

VERSION: 022.004 [10/17/2019]


CHANGELOG:

- HORIZONTAL_RULER:  Fixed a bug in `mc_engine' when a STRETCH_GLYPH is the last
  glyph of the display line and the floating horizontal ruler needs to extend all
  the way to the window edge.  [The `fx` coordinate needed to be advanced.]

- Fixed a bug that occasionally erased the real fake cursor and sometimes the
  characters to the left/right thereof when overlapping exists.  This was due to
  `display_and_set_cursor' being called when one or more of the fake cursor caches
   was still populated, even though the relevant buffer-local variables were nil.
  [A check has been added to ascertain whether any of the caches are populated.]

- Miscellaneous tidying-up of code.


VIDEOS:

w32:  https://youtu.be/r3BdJVlsAnQ

ns:  https://youtu.be/bc1h8jtbXmw

x11:  https://youtu.be/aCIFhD2Xz5s


SCREENSHOTS:

https://www.lawlist.com/images/22873_17684_light_dark_backgrounds.png


SETUP:

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

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

git reset --hard ac57c5093829ee09084c562bbbc1c412179be13d

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

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

Step 4:  ./autogen.sh

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

Step 6:  make

Step 7:  make install


USAGE:

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

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

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

  ;;; TURN OFF FAKE CURSORS:

  (setq mc-conf nil)

- To try out both the crosshairs feature and the visible fill column indicator
  feature, type:  M-x +-mode

- To try out just the visible fill column indicator feature, type:  M-x fc-mode

- To try out built-in fake cursors with Magnar Sveen's multiple-cursors package,
  that package must be installed.  If the multiple-cursors package is already
  installed, then just (require 'crosshairs) and `crosshairs.el` will redefine a
  few of the multiple-cursors functions and set up a few keyboard shortcuts.
  If the multiple-cursors package by Magnar Sveen is not already installed, then
  here are two easy ways to install that package:

  Type:  M-x mc-install

  OR, evaluate the following snippet:

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


NOTES:

- Our journey begins at the outset of `update_window' when
  `mc_update_window_dryrun' performs a `!draw_p` simulation to create a new
  cache of fake cursors that are stored in the `w->mc_matrix`.  The cache of
  fake cursors from the previous redisplay is copied to a temporary `mc_matrix`
  under the name of `old_matrix`.  `mc_update_text_area' (used for `!draw_p` /
  `draw_p` situations) calls `mc_draw_glyphs' (writes glyphs to the glass)
  followed by `mc_draw_row' (writes fake cursors to the glass immediately
  thereafter).  At the tail end of `mc_update_window_dryrun',
  `mc_update_window_erase' compares the new `w->mc_matrix` with the `old_matrix`
  to determine which fake cursors are the same -- setting the `same_p` boolean
  struct member accordingly for each applicable fake cursor within the
  `w->mc_matrix`.  All fake cursors in the `old_matrix` that are `!same_p` get
  erased at this juncture.  [Fn 1.]  After the dryrun is complete,
  `update_window' does the real thing -- `draw_p`.  As to the `from_where`
  situations of SKIPPED, POST_CHANGED, UNCHANGED, and SET_CURSOR_TWO,
  `mc_helper' compares the incoming tentative fake cursor with the
  `w->mc_matrix` to see if it has previously been marked as `same_p` -- if it is
  `!same_p`, then the fake cursor is drawn and we `return`.  Fake cursors that
  have a `cursor_type` of MC_LEFT_FRINGE_BITMAP or MC_RIGHT_FRINGE_BITMAP are
  always reset even if they are `same_p`.  As to the `from_where` situations of
  SCRIBE_ONE, SCRIBE_TWO, SCRIBE_THREE, and NOWHERE, `mc_helper' always causes
  fake cursors to be drawn (because new glyphs were written to the glass, or the
  area to the right of the display line was cleared) and we `return`.

. Fn. 1:  Even though writing new glyphs to the glass (SCRIBE_ONE, SCRIBE_TWO,
  and SCRIBE_THREE) would erase fake cursors within those boundaries, it is
  still necessary to erase `!same_p` fake cursors prior thereto.  This is
  because `scrolling_window' occurs before new glyphs are written and
  `rif->scroll_run_hook' may copy one or more rows to other areas of the glass.
  It is not worth the effort to programmatically track both the _copied_ fake
  cursors and the _original_ fake cursors from the previous redisplay cycle,
  whose glyphs may remain where they are in the current redisplay cycle because
  they satisfy the `GLYPH_EQUAL_P' test.

- The rest of our journey takes place wherever `draw_glyphs' would ordinarily be
  called, excluding `update_text_area'.  If features 17684/22873 are active,
  `mc_redraw_row' calls `mc_draw_glyphs' (writes glyphs to the glass) and fake
  cursors are written to the glass immediately thereafter (if the coordinates
  coincide with prerecorded data in the `w->mc_matrix`).  The functions
  containing the aforementioned calls are:
  . `gui_insert_glyphs'
  . `gui_fix_overlapping_area'
  . `draw_row_with_mouse_face'
  . `expose_area'
  . `expose_line'
  . `redraw_overlapped_rows' [which has been incorporated into `update_window']

- As to `mc_scrolling_window', it would appear that there is no tangible
  benefit to rotating the current/prospective cache of fake cursors to compare
  the data before removing the fake cursors.  When scrolling the display, only
  _some_ lines are copied to new locations.  Areas that are not overwritten may
  have fake cursors and those may not necessarily be removed if desired/current
  matrix glyphs are equal.  The test for `GLYPH_EQUAL_P' does not take into
  consideration the existence of a fake cursor, and the glyph (with a fake
  cursor) may not be updated as a result thereof.  As to lines that are not
  copied, portions may be updated and fake cursors would be removed thereby.
  `mc_rotate_matrix' and `mc_reverse_vpos' were removed with patch v. 022.002.

- NS:  As of 09/28/2018 (7946445962372c4255180af45cb7c857f1b0b5fa), the NS port
  no longer does anything useful during `update_window' except mark dirty
  rectangles.  All drawing is now done when the MacOS calls `drawRect', which in
  turn calls `expose_frame'.


TODO:

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

  (progn
    (defun test ()
    (interactive)
      (let ((ov (make-overlay (point) (1+ (point)) nil t t)))
        (overlay-put ov 'face '(:foreground "red"))))
    (global-set-key [f5] 'test)
    (split-window-horizontally)
    (switch-to-buffer (get-buffer-create "foo"))
    (setq bidi-display-reordering nil)
    (setq-local auto-hscroll-mode 'current-line)
    (dotimes (i 80)
      (insert (char-to-string (+ 65 i)))))

- `ns_draw_window_cursor' calls `ns_clip_to_rect', which does _not_ take
  `row->clip` into consideration when drawing cursors with `NSRectFill'.  When
  it comes time to draw glyphs on top of the box/hollow family of cursors,
  `row->clip` is taken into consideration by `get_glyph_string_clip'.  Fake
  cursors can be drawn even though the glyphs cannot, resulting in hollow/box
  family of cursors without text.  The issue can be reproduced with M-x mc-test.
  [A temporary workaround is to disable `row->clip` while drawing the glyphs.]
  https://lists.gnu.org/archive/html/emacs-devel/2019-04/msg00009.html

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

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

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

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

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

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

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

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

- Is there any additional meaningful optimization that can be added to the
  three calls of `mc_pre_scroll_clean'?

- There is a bug affecting an older version of Emacs for the NS port that causes
  partial line flickering when the same characters are grouped together (;;;;;;)
  and MC_GLYPHLESS cursors are above or below -- having the same background color
  as the frame; e.g., black on black (used to erase a glyphless cursor).  The
  partial flickering is only noticeable with rapid fire; e.g., holding down the
  right/left arrow key.  When changing the color of the glyphless cursor, the
  issue is not present.  [@lawlist has verified that the X and HPOS coordinates
  are accurate.]


[-- Attachment #2: 2019_10_17__13_42_27_237.diff --]
[-- Type: application/diff, Size: 643092 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#17684: #22873 (multiple fake cursors); and, #17684 (crosshairs / fill-column).
  2014-06-03 20:36 bug#17684: 24.4.50; Feature Request -- Vertical Lines to the Left of and Through Characters Keith David Bershatsky
                   ` (12 preceding siblings ...)
  2019-07-31 19:39 ` Keith David Bershatsky
@ 2019-10-18  1:12 ` Keith David Bershatsky
  2019-11-18  6:58 ` Keith David Bershatsky
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2019-10-18  1:12 UTC (permalink / raw)
  To: 22873, 17684

[-- Attachment #1: Type: text/plain, Size: 295 bytes --]

VERSION: 022.004 [10/17/2019]

See previous post:

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22873#170

The attached patch supersedes the patch attached to the previous post.  This new patch contains the modification to display_and_set_cursor, which is described in the CHANGELOG section.



[-- Attachment #2: 2019_10_17__18_06_25_414.diff --]
[-- Type: application/diff, Size: 643398 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#17684: #22873 (multiple fake cursors); and, #17684 (crosshairs / fill-column).
  2014-06-03 20:36 bug#17684: 24.4.50; Feature Request -- Vertical Lines to the Left of and Through Characters Keith David Bershatsky
                   ` (13 preceding siblings ...)
  2019-10-18  1:12 ` bug#17684: #22873 (multiple fake cursors); and, #17684 (crosshairs / fill-column) Keith David Bershatsky
@ 2019-11-18  6:58 ` Keith David Bershatsky
  2020-01-27  7:39 ` Keith David Bershatsky
  2020-05-02 20:50 ` Keith David Bershatsky
  16 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2019-11-18  6:58 UTC (permalink / raw)
  To: 22873, 17684; +Cc: johnw, mbork, rms, akioburns

[-- Attachment #1: Type: text/plain, Size: 10580 bytes --]

VERSION: 022.005 [11/17/2019]


CHANGELOG:

- Fixed a bug affecting the NS port relating to redrawing fake cursors on left/
  right overwritten glyphs.  When `mc_update_window_erase' calls `mc_erase_cursor',
  the window cache of fake cursors has already been updated even though the
  window contents have not.  As such, it is necessary to use the `old_cache'
  (saved fake cursor cache from the previous command loop) to determine which
  fake cursors must be redrawn.  [Prior to this bug fix, the updated cache of
  fake cursors (i.e., `w->mc_matrix`) was used when determining which fake
  cursors to redraw on the left/right overwritten glyphs.]  As to the W32 port
  and the X11 port, support for redrawing fake cursors on left/right overwritten
  glyphs is still on the "todo list".  However, `mc_w32_draw_glyph_string' and
  `mc_x_draw_glyph_string' have now been updated to include an extra argument
  for the `mc_matrix`.

- Miscellaneous tidying-up of code.


VIDEOS:

w32:  https://youtu.be/r3BdJVlsAnQ

ns:  https://youtu.be/bc1h8jtbXmw

x11:  https://youtu.be/aCIFhD2Xz5s


SCREENSHOTS:

https://www.lawlist.com/images/22873_17684_light_dark_backgrounds.png


SETUP:

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

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

git reset --hard ac57c5093829ee09084c562bbbc1c412179be13d

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

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

Step 4:  ./autogen.sh

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

Step 6:  make

Step 7:  make install


USAGE:

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

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

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

  ;;; TURN OFF FAKE CURSORS:

  (setq mc-conf nil)

- To try out both the crosshairs feature and the visible fill column indicator
  feature, type:  M-x +-mode

- To try out just the visible fill column indicator feature, type:  M-x fc-mode

- To try out built-in fake cursors with Magnar Sveen's multiple-cursors package,
  that package must be installed.  If the multiple-cursors package is already
  installed, then just (require 'crosshairs) and `crosshairs.el` will redefine a
  few of the multiple-cursors functions and set up a few keyboard shortcuts.
  If the multiple-cursors package by Magnar Sveen is not already installed, then
  here are two easy ways to install that package:

  Type:  M-x mc-install

  OR, evaluate the following snippet:

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


NOTES:

- Our journey begins at the outset of `update_window' when
  `mc_update_window_dryrun' performs a `!draw_p` simulation to create a new
  cache of fake cursors that are stored in the `w->mc_matrix`.  The cache of
  fake cursors from the previous redisplay is copied to a temporary `mc_matrix`
  under the name of `old_matrix`.  `mc_update_text_area' (used for `!draw_p` /
  `draw_p` situations) calls `mc_draw_glyphs' (writes glyphs to the glass)
  followed by `mc_draw_row' (writes fake cursors to the glass immediately
  thereafter).  At the tail end of `mc_update_window_dryrun',
  `mc_update_window_erase' compares the new `w->mc_matrix` with the `old_matrix`
  to determine which fake cursors are the same -- setting the `same_p` boolean
  struct member accordingly for each applicable fake cursor within the
  `w->mc_matrix`.  All fake cursors in the `old_matrix` that are `!same_p` get
  erased at this juncture.  [Fn 1.]  After the dryrun is complete,
  `update_window' does the real thing -- `draw_p`.  As to the `from_where`
  situations of SKIPPED, POST_CHANGED, UNCHANGED, and SET_CURSOR_TWO,
  `mc_helper' compares the incoming tentative fake cursor with the
  `w->mc_matrix` to see if it has previously been marked as `same_p` -- if it is
  `!same_p`, then the fake cursor is drawn and we `return`.  Fake cursors that
  have a `cursor_type` of MC_LEFT_FRINGE_BITMAP or MC_RIGHT_FRINGE_BITMAP are
  always reset even if they are `same_p`.  As to the `from_where` situations of
  SCRIBE_ONE, SCRIBE_TWO, SCRIBE_THREE, and NOWHERE, `mc_helper' always causes
  fake cursors to be drawn (because new glyphs were written to the glass, or the
  area to the right of the display line was cleared) and we `return`.

. Fn. 1:  Even though writing new glyphs to the glass (SCRIBE_ONE, SCRIBE_TWO,
  and SCRIBE_THREE) would erase fake cursors within those boundaries, it is
  still necessary to erase `!same_p` fake cursors prior thereto.  This is
  because `scrolling_window' occurs before new glyphs are written and
  `rif->scroll_run_hook' may copy one or more rows to other areas of the glass.
  It is not worth the effort to programmatically track both the _copied_ fake
  cursors and the _original_ fake cursors from the previous redisplay cycle,
  whose glyphs may remain where they are in the current redisplay cycle because
  they satisfy the `GLYPH_EQUAL_P' test.

- The rest of our journey takes place wherever `draw_glyphs' would ordinarily be
  called, excluding `update_text_area'.  If features 17684/22873 are active,
  `mc_redraw_row' calls `mc_draw_glyphs' (writes glyphs to the glass) and fake
  cursors are written to the glass immediately thereafter (if the coordinates
  coincide with prerecorded data in the `w->mc_matrix`).  The functions
  containing the aforementioned calls are:
  . `gui_insert_glyphs'
  . `gui_fix_overlapping_area'
  . `draw_row_with_mouse_face'
  . `expose_area'
  . `expose_line'
  . `redraw_overlapped_rows' [which has been incorporated into `update_window']

- As to `mc_scrolling_window', it would appear that there is no tangible
  benefit to rotating the current/prospective cache of fake cursors to compare
  the data before removing the fake cursors.  When scrolling the display, only
  _some_ lines are copied to new locations.  Areas that are not overwritten may
  have fake cursors and those may not necessarily be removed if desired/current
  matrix glyphs are equal.  The test for `GLYPH_EQUAL_P' does not take into
  consideration the existence of a fake cursor, and the glyph (with a fake
  cursor) may not be updated as a result thereof.  As to lines that are not
  copied, portions may be updated and fake cursors would be removed thereby.
  `mc_rotate_matrix' and `mc_reverse_vpos' were removed with patch v. 022.002.

- NS:  As of 09/28/2018 (7946445962372c4255180af45cb7c857f1b0b5fa), the NS port
  no longer does anything useful during `update_window' except mark dirty
  rectangles.  All drawing is now done when the MacOS calls `drawRect', which in
  turn calls `expose_frame'.


TODO:

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

  (progn
    (defun test ()
    (interactive)
      (let ((ov (make-overlay (point) (1+ (point)) nil t t)))
        (overlay-put ov 'face '(:foreground "red"))))
    (global-set-key [f5] 'test)
    (split-window-horizontally)
    (switch-to-buffer (get-buffer-create "foo"))
    (setq bidi-display-reordering nil)
    (setq-local auto-hscroll-mode 'current-line)
    (dotimes (i 80)
      (insert (char-to-string (+ 65 i)))))

- `ns_draw_window_cursor' calls `ns_clip_to_rect', which does _not_ take
  `row->clip` into consideration when drawing cursors with `NSRectFill'.  When
  it comes time to draw glyphs on top of the box/hollow family of cursors,
  `row->clip` is taken into consideration by `get_glyph_string_clip'.  Fake
  cursors can be drawn even though the glyphs cannot, resulting in hollow/box
  family of cursors without text.  The issue can be reproduced with M-x mc-test.
  [A temporary workaround is to disable `row->clip` while drawing the glyphs.]
  https://lists.gnu.org/archive/html/emacs-devel/2019-04/msg00009.html

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

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

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

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

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

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

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

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

- Is there any additional meaningful optimization that can be added to the
  three calls of `mc_pre_scroll_clean'?

- There is a bug affecting an older version of Emacs for the NS port that causes
  partial line flickering when the same characters are grouped together (;;;;;;)
  and MC_GLYPHLESS cursors are above or below -- having the same background color
  as the frame; e.g., black on black (used to erase a glyphless cursor).  The
  partial flickering is only noticeable with rapid fire; e.g., holding down the
  right/left arrow key.  When changing the color of the glyphless cursor, the
  issue is not present.  [@lawlist has verified that the X and HPOS coordinates
  are accurate.]


[-- Attachment #2: 2019_11_17__20_26_22_702.diff --]
[-- Type: application/diff, Size: 644302 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#17684: #22873 (multiple fake cursors); and, #17684 (crosshairs / fill-column).
  2014-06-03 20:36 bug#17684: 24.4.50; Feature Request -- Vertical Lines to the Left of and Through Characters Keith David Bershatsky
                   ` (14 preceding siblings ...)
  2019-11-18  6:58 ` Keith David Bershatsky
@ 2020-01-27  7:39 ` Keith David Bershatsky
  2020-05-02 20:50 ` Keith David Bershatsky
  16 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2020-01-27  7:39 UTC (permalink / raw)
  To: 22873, 17684; +Cc: johnw, mbork, rms, akioburns

[-- Attachment #1: Type: text/plain, Size: 9563 bytes --]

VERSION: 022.006 [01/26/2020]


CHANGELOG:

- Fixed a bug in `mc_engine' that erroneously permitted an attempt to draw a
  floating fake cursors (horizontal ruler) when the WD (width) had a negative
  value.  It is now properly suppressed when the preceding character is MC_GLYPH.

- crosshairs.el:  The variable `+-fill-column' is now buffer-local.  Renamed the
  variable `+-parens-p' to `+-parens-highlight'.

- The setting of `w->mc.lnum_pixel_width` within `maybe_produce_line_number' is
  now conditioned upon (it->area == TEXT_AREA && IT_CHARPOS (*it) == wstart.charpos):

  https://lists.gnu.org/archive/html/emacs-devel/2019-12/msg00232.html

- Miscellaneous tidying-up of code.


VIDEOS:

w32:  https://youtu.be/r3BdJVlsAnQ

ns:  https://youtu.be/bc1h8jtbXmw

x11:  https://youtu.be/aCIFhD2Xz5s


SCREENSHOTS:

https://www.lawlist.com/images/22873_17684_light_dark_backgrounds.png


SETUP:

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

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

git reset --hard ac57c5093829ee09084c562bbbc1c412179be13d

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

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

Step 4:  ./autogen.sh

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

Step 6:  make

Step 7:  make install


USAGE:

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

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

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

  ;;; TURN OFF FAKE CURSORS:

  (setq mc-conf nil)

- To try out both the crosshairs feature and the visible fill column indicator
  feature, type:  M-x +-mode

- To try out just the visible fill column indicator feature, type:  M-x fc-mode

- To try out built-in fake cursors with Magnar Sveen's multiple-cursors package,
  that package must be installed.  If the multiple-cursors package is already
  installed, then just (require 'crosshairs) and `crosshairs.el` will redefine a
  few of the multiple-cursors functions and set up a few keyboard shortcuts.
  If the multiple-cursors package by Magnar Sveen is not already installed, then
  here are two easy ways to install that package:

  Type:  M-x mc-install

  OR, evaluate the following snippet:

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


NOTES:

- Our journey begins at the outset of `update_window' when
  `mc_update_window_dryrun' performs a `!draw_p` simulation to create a new
  cache of fake cursors that are stored in the `w->mc_matrix`.  The cache of
  fake cursors from the previous redisplay is copied to a temporary `mc_matrix`
  under the name of `old_matrix`.  `mc_update_text_area' (used for `!draw_p` /
  `draw_p` situations) calls `mc_draw_glyphs' (writes glyphs to the glass)
  followed by `mc_draw_row' (writes fake cursors to the glass immediately
  thereafter).  At the tail end of `mc_update_window_dryrun',
  `mc_update_window_erase' compares the new `w->mc_matrix` with the `old_matrix`
  to determine which fake cursors are the same -- setting the `same_p` boolean
  struct member accordingly for each applicable fake cursor within the
  `w->mc_matrix`.  All fake cursors in the `old_matrix` that are `!same_p` get
  erased at this juncture.  [Fn 1.]  After the dryrun is complete,
  `update_window' does the real thing -- `draw_p`.  As to the `from_where`
  situations of SKIPPED, POST_CHANGED, UNCHANGED, and SET_CURSOR_TWO,
  `mc_helper' compares the incoming tentative fake cursor with the
  `w->mc_matrix` to see if it has previously been marked as `same_p` -- if it is
  `!same_p`, then the fake cursor is drawn and we `return`.  Fake cursors that
  have a `cursor_type` of MC_LEFT_FRINGE_BITMAP or MC_RIGHT_FRINGE_BITMAP are
  always reset even if they are `same_p`.  As to the `from_where` situations of
  SCRIBE_ONE, SCRIBE_TWO, SCRIBE_THREE, and NOWHERE, `mc_helper' always causes
  fake cursors to be drawn (because new glyphs were written to the glass, or the
  area to the right of the display line was cleared) and we `return`.

. Fn. 1:  Even though writing new glyphs to the glass (SCRIBE_ONE, SCRIBE_TWO,
  and SCRIBE_THREE) would erase fake cursors within those boundaries, it is
  still necessary to erase `!same_p` fake cursors prior thereto.  This is
  because `scrolling_window' occurs before new glyphs are written and
  `rif->scroll_run_hook' may copy one or more rows to other areas of the glass.
  It is not worth the effort to programmatically track both the _copied_ fake
  cursors and the _original_ fake cursors from the previous redisplay cycle,
  whose glyphs may remain where they are in the current redisplay cycle because
  they satisfy the `GLYPH_EQUAL_P' test.

- The rest of our journey takes place wherever `draw_glyphs' would ordinarily be
  called, excluding `update_text_area'.  If features 17684/22873 are active,
  `mc_redraw_row' calls `mc_draw_glyphs' (writes glyphs to the glass) and fake
  cursors are written to the glass immediately thereafter (if the coordinates
  coincide with prerecorded data in the `w->mc_matrix`).  The functions
  containing the aforementioned calls are:
  . `gui_insert_glyphs'
  . `gui_fix_overlapping_area'
  . `draw_row_with_mouse_face'
  . `expose_area'
  . `expose_line'
  . `redraw_overlapped_rows' [which has been incorporated into `update_window']

- As to `mc_scrolling_window', it would appear that there is no tangible
  benefit to rotating the current/prospective cache of fake cursors to compare
  the data before removing the fake cursors.  When scrolling the display, only
  _some_ lines are copied to new locations.  Areas that are not overwritten may
  have fake cursors and those may not necessarily be removed if desired/current
  matrix glyphs are equal.  The test for `GLYPH_EQUAL_P' does not take into
  consideration the existence of a fake cursor, and the glyph (with a fake
  cursor) may not be updated as a result thereof.  As to lines that are not
  copied, portions may be updated and fake cursors would be removed thereby.
  `mc_rotate_matrix' and `mc_reverse_vpos' were removed with patch v. 022.002.

- NS:  As of 09/28/2018 (7946445962372c4255180af45cb7c857f1b0b5fa), the NS port
  no longer does anything useful during `update_window' except mark dirty
  rectangles.  All drawing is now done when the MacOS calls `drawRect', which in
  turn calls `expose_frame'.


TODO:

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

  (progn
    (defun test ()
    (interactive)
      (let ((ov (make-overlay (point) (1+ (point)) nil t t)))
        (overlay-put ov 'face '(:foreground "red"))))
    (global-set-key [f5] 'test)
    (split-window-horizontally)
    (switch-to-buffer (get-buffer-create "foo"))
    (setq bidi-display-reordering nil)
    (setq-local auto-hscroll-mode 'current-line)
    (dotimes (i 80)
      (insert (char-to-string (+ 65 i)))))

- `ns_draw_window_cursor' calls `ns_clip_to_rect', which does _not_ take
  `row->clip` into consideration when drawing cursors with `NSRectFill'.  When
  it comes time to draw glyphs on top of the box/hollow family of cursors,
  `row->clip` is taken into consideration by `get_glyph_string_clip'.  Fake
  cursors can be drawn even though the glyphs cannot, resulting in hollow/box
  family of cursors without text.  The issue can be reproduced with M-x mc-test.
  [A temporary workaround is to disable `row->clip` while drawing the glyphs.]
  https://lists.gnu.org/archive/html/emacs-devel/2019-04/msg00009.html

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

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

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

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

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

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

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

- Is there any additional meaningful optimization that can be added to the
  three calls of `mc_pre_scroll_clean'?

- There is a bug affecting an older version of Emacs for the NS port that causes
  partial line flickering when the same characters are grouped together (;;;;;;)
  and MC_GLYPHLESS cursors are above or below -- having the same background color
  as the frame; e.g., black on black (used to erase a glyphless cursor).  The
  partial flickering is only noticeable with rapid fire; e.g., holding down the
  right/left arrow key.  When changing the color of the glyphless cursor, the
  issue is not present.  [@lawlist has verified that the X and HPOS coordinates
  are accurate.]


[-- Attachment #2: 2020_01_26__21_06_44_685.diff --]
[-- Type: application/diff, Size: 640815 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#22873: #22873 (multiple fake cursors); and, #17684 (crosshairs / fill-column).
  2016-03-01 18:44 bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support) Keith David Bershatsky
                   ` (30 preceding siblings ...)
  2019-10-17 21:08 ` bug#22873: #22873 (multiple fake cursors); and, #17684 (crosshairs / fill-column) Keith David Bershatsky
@ 2020-03-04  9:03 ` Keith David Bershatsky
  31 siblings, 0 replies; 83+ messages in thread
From: Keith David Bershatsky @ 2020-03-04  9:03 UTC (permalink / raw)
  To: 22873, 17684; +Cc: mbork, rms, johnw, akioburns

[-- Attachment #1: Type: text/plain, Size: 9393 bytes --]

VERSION:  022.007 [03/03/2020]


CHANGELOG:

- nsterm.m:  Bug fix in `mc_ns_draw_window_cursor' relating to a situation where
  the `cursor_glyph` is NULL and the face_id is invalid.  In such a situation,
  we now use the DEFAULT_FACE_ID.

- Pursuant to the written request of Drew Adams on 01-27-2020 to change the name
  of the "crosshairs.el" Lisp file to something else, said file has been changed
  to the file name of "+-mode.el".

- Miscellaneous tidying-up of code.


VIDEOS:

w32:  https://youtu.be/r3BdJVlsAnQ

ns:  https://youtu.be/bc1h8jtbXmw

x11:  https://youtu.be/aCIFhD2Xz5s


SCREENSHOTS:

https://www.lawlist.com/images/22873_17684_light_dark_backgrounds.png


SETUP:

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

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

git reset --hard ac57c5093829ee09084c562bbbc1c412179be13d

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

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

Step 4:  ./autogen.sh

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

Step 6:  make

Step 7:  make install


USAGE:

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

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

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

  ;;; TURN OFF FAKE CURSORS:

  (setq mc-conf nil)

- To try out both the crosshairs feature and the visible fill column indicator
  feature, type:  M-x +-mode

- To try out just the visible fill column indicator feature, type:  M-x fc-mode

- To try out built-in fake cursors with Magnar Sveen's multiple-cursors package,
  that package must be installed.  If the multiple-cursors package is already
  installed, then just (require '+-mode) and `+-mode.el` will redefine a
  few of the multiple-cursors functions and set up a few keyboard shortcuts.
  If the multiple-cursors package by Magnar Sveen is not already installed, then
  here are two easy ways to install that package:

  Type:  M-x mc-install

  OR, evaluate the following snippet:

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


NOTES:

- Our journey begins at the outset of `update_window' when
  `mc_update_window_dryrun' performs a `!draw_p` simulation to create a new
  cache of fake cursors that are stored in the `w->mc_matrix`.  The cache of
  fake cursors from the previous redisplay is copied to a temporary `mc_matrix`
  under the name of `old_matrix`.  `mc_update_text_area' (used for `!draw_p` /
  `draw_p` situations) calls `mc_draw_glyphs' (writes glyphs to the glass)
  followed by `mc_draw_row' (writes fake cursors to the glass immediately
  thereafter).  At the tail end of `mc_update_window_dryrun',
  `mc_update_window_erase' compares the new `w->mc_matrix` with the `old_matrix`
  to determine which fake cursors are the same -- setting the `same_p` boolean
  struct member accordingly for each applicable fake cursor within the
  `w->mc_matrix`.  All fake cursors in the `old_matrix` that are `!same_p` get
  erased at this juncture.  [Fn 1.]  After the dryrun is complete,
  `update_window' does the real thing -- `draw_p`.  As to the `from_where`
  situations of SKIPPED, POST_CHANGED, UNCHANGED, and SET_CURSOR_TWO,
  `mc_helper' compares the incoming tentative fake cursor with the
  `w->mc_matrix` to see if it has previously been marked as `same_p` -- if it is
  `!same_p`, then the fake cursor is drawn and we `return`.  Fake cursors that
  have a `cursor_type` of MC_LEFT_FRINGE_BITMAP or MC_RIGHT_FRINGE_BITMAP are
  always reset even if they are `same_p`.  As to the `from_where` situations of
  SCRIBE_ONE, SCRIBE_TWO, SCRIBE_THREE, and NOWHERE, `mc_helper' always causes
  fake cursors to be drawn (because new glyphs were written to the glass, or the
  area to the right of the display line was cleared) and we `return`.

. Fn. 1:  Even though writing new glyphs to the glass (SCRIBE_ONE, SCRIBE_TWO,
  and SCRIBE_THREE) would erase fake cursors within those boundaries, it is
  still necessary to erase `!same_p` fake cursors prior thereto.  This is
  because `scrolling_window' occurs before new glyphs are written and
  `rif->scroll_run_hook' may copy one or more rows to other areas of the glass.
  It is not worth the effort to programmatically track both the _copied_ fake
  cursors and the _original_ fake cursors from the previous redisplay cycle,
  whose glyphs may remain where they are in the current redisplay cycle because
  they satisfy the `GLYPH_EQUAL_P' test.

- The rest of our journey takes place wherever `draw_glyphs' would ordinarily be
  called, excluding `update_text_area'.  If features 17684/22873 are active,
  `mc_redraw_row' calls `mc_draw_glyphs' (writes glyphs to the glass) and fake
  cursors are written to the glass immediately thereafter (if the coordinates
  coincide with prerecorded data in the `w->mc_matrix`).  The functions
  containing the aforementioned calls are:
  . `gui_insert_glyphs'
  . `gui_fix_overlapping_area'
  . `draw_row_with_mouse_face'
  . `expose_area'
  . `expose_line'
  . `redraw_overlapped_rows' [which has been incorporated into `update_window']

- As to `mc_scrolling_window', it would appear that there is no tangible
  benefit to rotating the current/prospective cache of fake cursors to compare
  the data before removing the fake cursors.  When scrolling the display, only
  _some_ lines are copied to new locations.  Areas that are not overwritten may
  have fake cursors and those may not necessarily be removed if desired/current
  matrix glyphs are equal.  The test for `GLYPH_EQUAL_P' does not take into
  consideration the existence of a fake cursor, and the glyph (with a fake
  cursor) may not be updated as a result thereof.  As to lines that are not
  copied, portions may be updated and fake cursors would be removed thereby.
  `mc_rotate_matrix' and `mc_reverse_vpos' were removed with patch v. 022.002.

- NS:  As of 09/28/2018 (7946445962372c4255180af45cb7c857f1b0b5fa), the NS port
  no longer does anything useful during `update_window' except mark dirty
  rectangles.  All drawing is now done when the MacOS calls `drawRect', which in
  turn calls `expose_frame'.  This was done to add support for MacOS Mojave ....


TODO:

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

  (progn
    (defun test ()
    (interactive)
      (let ((ov (make-overlay (point) (1+ (point)) nil t t)))
        (overlay-put ov 'face '(:foreground "red"))))
    (global-set-key [f5] 'test)
    (split-window-horizontally)
    (switch-to-buffer (get-buffer-create "foo"))
    (setq bidi-display-reordering nil)
    (setq-local auto-hscroll-mode 'current-line)
    (dotimes (i 80)
      (insert (char-to-string (+ 65 i)))))

- `ns_draw_window_cursor' calls `ns_clip_to_rect', which does _not_ take
  `row->clip` into consideration when drawing cursors with `NSRectFill'.  When
  it comes time to draw glyphs on top of the box/hollow family of cursors,
  `row->clip` is taken into consideration by `get_glyph_string_clip'.  Fake
  cursors can be drawn even though the glyphs cannot, resulting in hollow/box
  family of cursors without text.  The issue can be reproduced with M-x mc-test.
  [A temporary workaround is to disable `row->clip` while drawing the glyphs.]
  https://lists.gnu.org/archive/html/emacs-devel/2019-04/msg00009.html

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

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

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

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

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

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

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

- Is there any additional meaningful optimization that can be added to the
  three calls of `mc_pre_scroll_clean'?

- There is a bug affecting an older version of Emacs for the NS port that causes
  partial line flickering when the same characters are grouped together (;;;;;;)
  and MC_GLYPHLESS cursors are above or below -- having the same background color
  as the frame; e.g., black on black (used to erase a glyphless cursor).  The
  partial flickering is only noticeable with rapid fire; e.g., holding down the
  right/left arrow key.  When changing the color of the glyphless cursor, the
  issue is not present.  [@lawlist has verified that the X and HPOS coordinates
  are accurate.]


[-- Attachment #2: 2020_03_03__22_21_51_685.diff --]
[-- Type: application/diff, Size: 640805 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#17684: #22873 (multiple fake cursors); and, #17684 (crosshairs / fill-column).
  2014-06-03 20:36 bug#17684: 24.4.50; Feature Request -- Vertical Lines to the Left of and Through Characters Keith David Bershatsky
                   ` (15 preceding siblings ...)
  2020-01-27  7:39 ` Keith David Bershatsky
@ 2020-05-02 20:50 ` Keith David Bershatsky
  2020-10-01  3:00   ` bug#17684: bug#22873: " Lars Ingebrigtsen
  16 siblings, 1 reply; 83+ messages in thread
From: Keith David Bershatsky @ 2020-05-02 20:50 UTC (permalink / raw)
  To: 22873, 17684; +Cc: mbork, rms, johnw, akioburns

[-- Attachment #1: Type: text/plain, Size: 12014 bytes --]

VERSION:  022.008 [05/02/2020]


CHANGELOG:

- Calculate and set it->lnum when both NILP (Vdisplay_line_numbers) and features
  22873 / 17684 are active.  Line numbers are now recorded in the struct of each
  glyph:  glyph->lnum = it->lnum.  The cache of multiple fake cursors has been
  revised to also record the lnum of each fake cursor.  The recorded lnum is used
  to test for a `same_p` fake cursor situation; i.e., whether fake cursors should
  be erased and/or redrawn.

. The lnum is needed for an apparently uncommon, but nevertheless reproducible
  situation wherein a screen line is added/deleted and there are two or more
  subsequent consecutive lines having the same content; and, the character(s)
  added/deleted is/are the same size/shape of the subsequent consecutive screen
  lines.  `mc_update_window_erase' will erase a fake cursor on one of those
  subsequent consecutive lines depending upon whether the a screen line above is
  added/deleted.  With the unique exception of the recorded lnum, all other data
  in the cache of fake cursors will be identical as to one of those subsequent
  consecutive screen lines.

. EXAMPLE (word-wrap is non-nil) -- modification of the first paragraph by adding/
  deleting the word "boy" causes the screen line containing only the word group
  "fudge." to be added/deleted.  The fake cursor for the first _or_ second line
  containing "~//" will be erased, but the fake cursor for said line will not be
  redrawn by `mc_helper' unless the lnum data was previously used by
  `mc_update_window_erase' to make a the `same_p` determination.  In other words,
  the fake cursor at isue would be `same_p` _without_ using the lnum data, but
  is `!same_p` when we use the lnum data.

  Every good boy | deserves fudge.  Every good boy deserves fudge.  Every good ↩
  boy deserves fudge.| Every good boy deserves fudge.  Every good boy deserves ↩
  fudge.         |
                 |
  ~//            |   <=== This fake cursor IF adding the whole word "boy" with redo;
  ~//            |   <=== or, this fake cursor IF deleting the whole word "boy".

. The performance hit is zero when built-in line numbers are active, but perhaps
  mildly detectable when built-in line numbers are turned off.  Although line
  numbers are not being generated on the glass in the latter situation, Emacs will
  nevertheless be calling `display_count_lines_visually/logically' at the same
  locations as if the built-in line numbers were turned on.

. When `mc_update_text_area' processes the line containing the fake cursor that
  needs to be redrawn, the line is deemed to be UNCHANGED.  `clear_end_of_line'
  is not triggered and no floating fake cursors are redrawn based thereon.  This
  analysis was helpful in narrowing down the issue to the need for the lnum data
  as described hereinabove.


VIDEOS:

w32:  https://youtu.be/r3BdJVlsAnQ

ns:  https://youtu.be/bc1h8jtbXmw

x11:  https://youtu.be/aCIFhD2Xz5s


SCREENSHOTS:

https://www.lawlist.com/images/22873_17684_light_dark_backgrounds.png


SETUP:

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

Step 2:  Due to lack of free time available to dedicate to the development of
         features 22873 / 17684, applicability of the patch to the master branch
         is frozen at 07/14/2019:  ac57c5093829ee09084c562bbbc1c412179be13d

         In the new emacs repository folder, execute a hard reset to 07/14/2019:

         git reset --hard ac57c5093829ee09084c562bbbc1c412179be13d

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

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

Step 4:  ./autogen.sh

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

Step 6:  make

Step 7:  make install


USAGE:

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

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

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

  ;;; TURN OFF FAKE CURSORS:

  (setq mc-conf nil)

- To try out both the crosshairs feature and the visible fill column indicator
  feature, type:  M-x +-mode

- To try out just the visible fill column indicator feature, type:  M-x fc-mode

- To try out built-in fake cursors with Magnar Sveen's multiple-cursors package,
  that package must be installed.  If the multiple-cursors package is already
  installed, then just (require '+-mode) and `+-mode.el` will redefine a
  few of the multiple-cursors functions and set up a few keyboard shortcuts.
  If the multiple-cursors package by Magnar Sveen is not already installed, then
  here are two easy ways to install that package:

  Type:  M-x mc-install

  OR, evaluate the following snippet:

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


NOTES:

- Our journey begins at the outset of `update_window' when
  `mc_update_window_dryrun' performs a `!draw_p` simulation to create a new
  cache of fake cursors that are stored in the `w->mc_matrix`.  The cache of
  fake cursors from the previous redisplay is copied to a temporary `mc_matrix`
  under the name of `old_matrix`.  `mc_update_text_area' (used for `!draw_p` /
  `draw_p` situations) calls `mc_draw_glyphs' (writes glyphs to the glass)
  followed by `mc_draw_row' (writes fake cursors to the glass immediately
  thereafter).  At the tail end of `mc_update_window_dryrun',
  `mc_update_window_erase' compares the new `w->mc_matrix` with the `old_matrix`
  to determine which fake cursors are the same -- setting the `same_p` boolean
  struct member accordingly for each applicable fake cursor within the
  `w->mc_matrix`.  All fake cursors in the `old_matrix` that are `!same_p` get
  erased at this juncture.  [Fn 1.]  After the dryrun is complete,
  `update_window' does the real thing -- `draw_p`.  As to the `from_where`
  situations of SKIPPED, POST_CHANGED, UNCHANGED, and SET_CURSOR_TWO,
  `mc_helper' compares the incoming tentative fake cursor with the
  `w->mc_matrix` to see if it has previously been marked as `same_p` -- if it is
  `!same_p`, then the fake cursor is drawn and we `return`.  Fake cursors that
  have a `cursor_type` of MC_LEFT_FRINGE_BITMAP or MC_RIGHT_FRINGE_BITMAP are
  always reset even if they are `same_p`.  As to the `from_where` situations of
  SCRIBE_ONE, SCRIBE_TWO, SCRIBE_THREE, and NOWHERE, `mc_helper' always causes
  fake cursors to be drawn (because new glyphs were written to the glass, or the
  area to the right of the display line was cleared) and we `return`.

. Fn. 1:  Even though writing new glyphs to the glass (SCRIBE_ONE, SCRIBE_TWO,
  and SCRIBE_THREE) would erase fake cursors within those boundaries, it is
  still necessary to erase `!same_p` fake cursors prior thereto.  This is
  because `scrolling_window' occurs before new glyphs are written and
  `rif->scroll_run_hook' may copy one or more rows to other areas of the glass.
  It is not worth the effort to programmatically track both the _copied_ fake
  cursors and the _original_ fake cursors from the previous redisplay cycle,
  whose glyphs may remain where they are in the current redisplay cycle because
  they satisfy the `GLYPH_EQUAL_P' test.

- The rest of our journey takes place wherever `draw_glyphs' would ordinarily be
  called, excluding `update_text_area'.  If features 17684/22873 are active,
  `mc_redraw_row' calls `mc_draw_glyphs' (writes glyphs to the glass) and fake
  cursors are written to the glass immediately thereafter (if the coordinates
  coincide with prerecorded data in the `w->mc_matrix`).  The functions
  containing the aforementioned calls are:
  . `gui_insert_glyphs'
  . `gui_fix_overlapping_area'
  . `draw_row_with_mouse_face'
  . `expose_area'
  . `expose_line'
  . `redraw_overlapped_rows' [which has been incorporated into `update_window']

- As to `mc_scrolling_window', it would appear that there is no tangible
  benefit to rotating the current/prospective cache of fake cursors to compare
  the data before removing the fake cursors.  When scrolling the display, only
  _some_ lines are copied to new locations.  Areas that are not overwritten may
  have fake cursors and those may not necessarily be removed if desired/current
  matrix glyphs are equal.  The test for `GLYPH_EQUAL_P' does not take into
  consideration the existence of a fake cursor, and the glyph (with a fake
  cursor) may not be updated as a result thereof.  As to lines that are not
  copied, portions may be updated and fake cursors would be removed thereby.
  `mc_rotate_matrix' and `mc_reverse_vpos' were removed with patch v. 022.002.

- NS:  As of 09/28/2018 (7946445962372c4255180af45cb7c857f1b0b5fa), the NS port
  no longer does anything useful during `update_window' except mark dirty
  rectangles.  All drawing is now done when the MacOS calls `drawRect', which in
  turn calls `expose_frame'.  This was done to add support for MacOS Mojave ....


TODO:

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

  (progn
    (defun test ()
    (interactive)
      (let ((ov (make-overlay (point) (1+ (point)) nil t t)))
        (overlay-put ov 'face '(:foreground "red"))))
    (global-set-key [f5] 'test)
    (split-window-horizontally)
    (switch-to-buffer (get-buffer-create "foo"))
    (setq bidi-display-reordering nil)
    (setq-local auto-hscroll-mode 'current-line)
    (dotimes (i 80)
      (insert (char-to-string (+ 65 i)))))

- `ns_draw_window_cursor' calls `ns_clip_to_rect', which does _not_ take
  `row->clip` into consideration when drawing cursors with `NSRectFill'.  When
  it comes time to draw glyphs on top of the box/hollow family of cursors,
  `row->clip` is taken into consideration by `get_glyph_string_clip'.  Fake
  cursors can be drawn even though the glyphs cannot, resulting in hollow/box
  family of cursors without text.  The issue can be reproduced with M-x mc-test.
  [A temporary workaround is to disable `row->clip` while drawing the glyphs.]
  https://lists.gnu.org/archive/html/emacs-devel/2019-04/msg00009.html

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

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

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

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

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

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

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

- Is there any additional meaningful optimization that can be added to the
  three calls of `mc_pre_scroll_clean'?

- There is a bug affecting an older version of Emacs for the NS port that causes
  partial line flickering when the same characters are grouped together (;;;;;;)
  and MC_GLYPHLESS cursors are above or below -- having the same background color
  as the frame; e.g., black on black (used to erase a glyphless cursor).  The
  partial flickering is only noticeable with rapid fire; e.g., holding down the
  right/left arrow key.  When changing the color of the glyphless cursor, the
  issue is not present.  [@lawlist has verified that the X and HPOS coordinates
  are accurate.]


[-- Attachment #2: 2020_05_02__13_04_51_850.diff --]
[-- Type: application/diff, Size: 651100 bytes --]

^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#17684: bug#22873: #22873 (multiple fake cursors); and, #17684 (crosshairs / fill-column).
  2020-05-02 20:50 ` Keith David Bershatsky
@ 2020-10-01  3:00   ` Lars Ingebrigtsen
  2020-10-01  3:54     ` Keith David Bershatsky
  0 siblings, 1 reply; 83+ messages in thread
From: Lars Ingebrigtsen @ 2020-10-01  3:00 UTC (permalink / raw)
  To: Keith David Bershatsky; +Cc: mbork, 22873, johnw, akioburns, 17684, rms

Keith David Bershatsky <esq@lawlist.com> writes:

> VERSION:  022.008 [05/02/2020]
>
> CHANGELOG:
>
> +(defgroup +-mode nil
> +  "Faces for the vertical ruler."
> +  :group 'convenience)

This is a huge patch set, and I have not tried it.  It seems like the
general consensus is that, yes, we would like to have multiple cursors,
but I'm not sure what this has to do with crosshairs?  I've just lightly
skimmed this thread, though...

Anyway, I'm not sure what the status is here.  The naming standard
doesn't seem to follow Emacs convention -- there's a mode called
`+-mode', for instance, which would have to be renamed...

Keith, is this still a work in progress, or is it something you think is
ready to go, and would like a code review on?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#17684: bug#22873: #22873 (multiple fake cursors); and, #17684 (crosshairs / fill-column).
  2020-10-01  3:00   ` bug#17684: bug#22873: " Lars Ingebrigtsen
@ 2020-10-01  3:54     ` Keith David Bershatsky
  2020-10-01 16:21       ` Lars Ingebrigtsen
  0 siblings, 1 reply; 83+ messages in thread
From: Keith David Bershatsky @ 2020-10-01  3:54 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: mbork, 22873, johnw, akioburns, 17684, rms

Thank you, Lars, for having a look at feature requests 22873 and 17684.  The crosshairs feature to track the cursor position (17684) was the motivation for implementing the framework to create multiple fake cursors (22873); i.e., the crosshairs, and visible fill-column indicator that can intersect through characters at any pixel X coordinate are, are all drawn with fake cursors.  The draft proof concept works for GUI versions of Emacs on X11, Windows and OSX.  I haven't done anything much since 07/14/2019 except fix some bugs, some important, some minor.  Drew Adams contacted me several months ago and requested that I change `crosshairs.el` to anything else since he has a crosshairs library on wiki, and he didn't want any potential confusion.  There is nothing better I could think of as a name for the 17684 Lisp library and since crosshairs goes against the wishes of Drew, I just went ahead and changed the name to +-mode.el, because the plus sign looks like a crosshairs, and I use the plus sign as the mode-line minor-mode lighter.

22873 (multiple cursors) is presently just a framework to generate fake cursors anywhere on the window-body.  Nothing has been written yet to perform any type of user command/function action at each location of fake cursors.  I have been using 22873 to replace the visual overlays used by Magnar Sveen in his Lisp implementation of multiple-cursors; i.e., instead of visible overlays, Emacs generates a fake cursor at each location (which can change cursor colors and cursor shapes, if so desired, such as yellow for an even column and red for an odd column).

Emacs was set up by the forefathers with some window pointers to temporarily save values, such as the coordinates of the real cursor.  I felt this was somewhat confusing and it seemed to me like an "afterthought" (an after the fact implementation) to avoid the need to add new arguments to existing functions in order to pass the values needed.  Without modifying the existing system as to the real cursor, I did away with all that as it applies to fake cursors by creating additional arguments in the relevant new functions to pass the values where needed.

The matrix of multiple fake cursors is somewhat complex, at least for me, and was implemented with the generous help of Alex Gramiak on the Emacs Devel mailing list; including, but not limited to dynamic memory management for the caches of fake cursors.  This did away with all of the problems I had previously encountered with a slow-down due to constant garbage collection for having too many Lisp Objects.  Based upon the help provided by Alex G., features 17684/22873 are now really pretty darn fast in my opinion.

Eli Z. has been very kind and generous with his time over the years to help me through most of the hard issues that I encountered, and with his help, the Emacs Devel team even fixed a few bugs in the master along the way (which I helped discover while working on 17684/22873).

In the comments at the outset of the most recent post to 17684/22873, there is a "todo list" and also some notes regarding how these features work.

In order to reduce as much as possible any modifications to existing functions in the core of Emacs, I copied a lot of those functions functions, changed their names, added additional arguments as needed (supra), and modified some of the body as needed.

Others on the Emacs Devel team may undoubtedly have an entirely different viewpoint / approach regarding the implementation of multiple fake cursors, but it was something that I felt I could not live without, so I went ahead and created something that I have been using on a daily basis for the past couple of years (perhaps a little longer).  I also use Magnar's multiple-cursors library several times a day, and feature 22873 replaces his visible overlays with fake cursors.

I do not know what would be needed to bring 17684 / 22873 current from 07/14/2019 (master branch) to the present date.  The last time I brought 17684/22873 forward to the then current date of 07/14/2019, I encountered one or more bugs in the master branch and it took a few weeks to resolve -- which fix(es) would have been impossible without the help of Eli Z. and a few others in the Emacs Devel.  If, by chance, I encounter undiscovered bugs in the master branch that pose significant obstacles to moving forward to the current commit date, then it could take several weeks; it just depends ...  This stuff is pretty complex for me, and I would even have to study what I previously did to refresh my memory again regarding how everything works as it relates to 17684/22873.

Recently, things at my day job have picked back up again and I haven't had a whole lot of free time lately.

There are links to some screenshots of 17684/22873 and a few videos of those features running on the different OS platforms if anyone would like to take a look -- the links are in the most recent post to 17684/22873.

Thanks,

Keith

On Sep 30, 2020, at 8:00 PM, Lars Ingebrigtsen wrote:

> Keith David Bershatsky <esq@lawlist.com> writes:
> 
>> VERSION:  022.008 [05/02/2020]
>> 
>> CHANGELOG:
>> 
>> +(defgroup +-mode nil
>> +  "Faces for the vertical ruler."
>> +  :group 'convenience)
> 
> This is a huge patch set, and I have not tried it.  It seems like the
> general consensus is that, yes, we would like to have multiple cursors,
> but I'm not sure what this has to do with crosshairs?  I've just lightly
> skimmed this thread, though...
> 
> Anyway, I'm not sure what the status is here.  The naming standard
> doesn't seem to follow Emacs convention -- there's a mode called
> `+-mode', for instance, which would have to be renamed...
> 
> Keith, is this still a work in progress, or is it something you think is
> ready to go, and would like a code review on?
> 
> -- 
> (domestic pets only, the antidote for overdose, milk.)
>   bloggy blog: http://lars.ingebrigtsen.no






^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#17684: bug#22873: #22873 (multiple fake cursors); and, #17684 (crosshairs / fill-column).
  2020-10-01  3:54     ` Keith David Bershatsky
@ 2020-10-01 16:21       ` Lars Ingebrigtsen
  2020-10-01 17:00         ` Drew Adams
  0 siblings, 1 reply; 83+ messages in thread
From: Lars Ingebrigtsen @ 2020-10-01 16:21 UTC (permalink / raw)
  To: Keith David Bershatsky; +Cc: mbork, 22873, johnw, akioburns, 17684, rms

Thanks for the explanation.  Some comments:

Keith David Bershatsky <esq@lawlist.com> writes:

> Drew Adams contacted me several months ago and requested that I change
> `crosshairs.el` to anything else since he has a crosshairs library on
> wiki, and he didn't want any potential confusion.  There is nothing
> better I could think of as a name for the 17684 Lisp library and since
> crosshairs goes against the wishes of Drew, I just went ahead and
> changed the name to +-mode.el, because the plus sign looks like a
> crosshairs, and I use the plus sign as the mode-line minor-mode
> lighter.

Well, +-mode is not acceptable as an Emacs library name, unfortunately.
The concept is usually "cross hairs", so cross-hairs.el would be fine.

> 22873 (multiple cursors) is presently just a framework to generate
> fake cursors anywhere on the window-body.  Nothing has been written
> yet to perform any type of user command/function action at each
> location of fake cursors.

Ah, I see.

> In order to reduce as much as possible any modifications to existing
> functions in the core of Emacs, I copied a lot of those functions
> functions, changed their names, added additional arguments as needed
> (supra), and modified some of the body as needed.

If this is to be included in Emacs, that duplication has to be resolved,
though.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 83+ messages in thread

* bug#17684: bug#22873: #22873 (multiple fake cursors); and, #17684 (crosshairs / fill-column).
  2020-10-01 16:21       ` Lars Ingebrigtsen
@ 2020-10-01 17:00         ` Drew Adams
  0 siblings, 0 replies; 83+ messages in thread
From: Drew Adams @ 2020-10-01 17:00 UTC (permalink / raw)
  To: Lars Ingebrigtsen, Keith David Bershatsky
  Cc: mbork, 22873, johnw, akioburns, 17684, rms

> > Drew Adams contacted me several months ago and requested that I change
> > `crosshairs.el` to anything else since he has a crosshairs library on
> > wiki, and he didn't want any potential confusion.  There is nothing
> > better I could think of as a name for the 17684 Lisp library and since
> > crosshairs goes against the wishes of Drew, I just went ahead and
> > changed the name to +-mode.el, because the plus sign looks like a
> > crosshairs, and I use the plus sign as the mode-line minor-mode
> > lighter.
> 
> Well, +-mode is not acceptable as an Emacs library name, unfortunately.
> The concept is usually "cross hairs", so cross-hairs.el would be fine.

I object to cross-hairs.el, as well.  Just as confusing
as using the same name, crosshairs.el.  (Sometimes less
confusing, sometimes more confusing - it introduces
another way to confuse the two).

And "the concept is usually 'cross hairs'" is wrong.
What concept?  Application of the term "cross hairs" to
this context is something I did, but the indication of
row and column by two orthogonal lines through the cell
is not typically called "cross hairs".

X and Y axes in analytic geometry aren't called "cross
hairs".

I take it as a compliment that "cross hairs" fits this
Emacs use case, but using that term for this doesn't
spring to mind spontaneously, I think.

I have no objection to referring to the feature/behavior
as showing cross hairs.  My objection is only about the
library name.  If you want to stay with the notion of
cross hairs, yaybe use a synonym for the library name,
such as "reticule".  Or maybe use an abbreviation -
crshairs.el or some such.

The aim should be to find a name that won't cause users
to confuse the two libraries.  That's all.





^ permalink raw reply	[flat|nested] 83+ messages in thread

end of thread, other threads:[~2020-10-01 17:00 UTC | newest]

Thread overview: 83+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-01 18:44 bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support) Keith David Bershatsky
2016-03-03  6:30 ` bug#22873: Can we support multiple Cursors? John Wiegley
2016-03-03  6:30 ` John Wiegley
2016-03-03  6:54   ` bug#22873: " Marcin Borkowski
2016-03-03  6:54   ` Marcin Borkowski
2016-03-03 11:20     ` bug#22873: " Richard Stallman
2016-03-03 15:05       ` Marcin Borkowski
2016-03-04  9:19         ` Richard Stallman
2016-03-04  9:19         ` Richard Stallman
2016-03-04 14:59           ` Stefan Monnier
2016-03-04 22:18             ` Magnar Sveen
2016-03-05  2:16               ` Stefan Monnier
2016-03-05 13:00                 ` Richard Stallman
2016-03-06  4:47                 ` John Wiegley
2016-03-06 20:30                 ` Clément Pit--Claudel
2016-03-08  4:53                   ` Stefan Monnier
2016-03-06 20:33               ` Clément Pit--Claudel
2016-03-08  4:55                 ` Stefan Monnier
2016-03-05 12:58             ` Richard Stallman
2016-03-03 15:05       ` Marcin Borkowski
2016-03-03 11:20     ` Richard Stallman
2016-03-04 23:16 ` Keith David Bershatsky
2016-03-05  6:59   ` Marcin Borkowski
2016-03-09  6:50   ` Keith David Bershatsky
2016-03-09  6:27 ` Keith David Bershatsky
2016-03-09  6:45   ` Keith David Bershatsky
2016-03-09 16:03   ` Eli Zaretskii
2016-03-09 18:30 ` Keith David Bershatsky
2016-03-11  7:18 ` Keith David Bershatsky
2016-03-14 18:35 ` Keith David Bershatsky
2016-03-14 18:49   ` Eli Zaretskii
2016-03-14 22:38 ` Keith David Bershatsky
2016-03-16  8:00 ` Keith David Bershatsky
2016-03-18  4:00 ` Keith David Bershatsky
2016-03-26 23:58   ` John Wiegley
2016-03-29  3:45 ` Keith David Bershatsky
2016-03-29 14:58   ` Eli Zaretskii
2016-03-29 17:26 ` Keith David Bershatsky
2017-06-25 22:09 ` Keith David Bershatsky
2017-07-30 17:39 ` Keith David Bershatsky
2017-08-11  0:00 ` bug#22873: Can we support multiple cursors? Keith David Bershatsky
2017-08-13 18:19 ` Keith David Bershatsky
2017-08-13 18:36   ` Eli Zaretskii
2017-08-14  3:20 ` Keith David Bershatsky
2017-08-14 15:01   ` Eli Zaretskii
2017-08-14 20:35 ` Keith David Bershatsky
2017-12-27 17:13 ` bug#22873: #22873 (multiple fake cursors); and, #17684 (crosshairs) Keith David Bershatsky
2017-12-27 23:55   ` John Wiegley
2017-12-28  1:20 ` bug#22873: #22873 (multiple fake cursors) Keith David Bershatsky
2017-12-28  1:26 ` Keith David Bershatsky
2018-07-17 19:09 ` bug#22873: #22873 (multiple fake cursors); and, #17684 (crosshairs) Keith David Bershatsky
2018-08-29  6:39 ` Keith David Bershatsky
2019-05-03  0:48 ` Keith David Bershatsky
2019-05-06 18:39 ` Keith David Bershatsky
2019-05-28  8:31 ` Keith David Bershatsky
2019-06-02  7:29 ` Keith David Bershatsky
2019-07-16 19:28 ` Keith David Bershatsky
2019-07-23  6:01 ` Keith David Bershatsky
2019-08-23  5:19 ` Keith David Bershatsky
2019-10-17 21:08 ` bug#22873: #22873 (multiple fake cursors); and, #17684 (crosshairs / fill-column) Keith David Bershatsky
2020-03-04  9:03 ` Keith David Bershatsky
  -- strict thread matches above, loose matches on Subject: below --
2014-06-03 20:36 bug#17684: 24.4.50; Feature Request -- Vertical Lines to the Left of and Through Characters Keith David Bershatsky
2018-07-09  5:28 ` bug#17684: #22873 (multiple fake cursors); and, #17684 (crosshairs) Keith David Bershatsky
2018-11-11  3:36 ` Keith David Bershatsky
2018-11-11 16:51 ` Keith David Bershatsky
2018-11-21  4:53 ` bug#17684: #22873 (multiple fake cursors); and, #17684 (crosshairs / fill-column) Keith David Bershatsky
2018-12-14  7:11 ` Keith David Bershatsky
2019-04-09  4:03 ` bug#17684: #22873 (multiple fake cursors); and, #17684 (crosshairs) Keith David Bershatsky
2019-04-21  5:15 ` Keith David Bershatsky
2019-04-29  1:21 ` Keith David Bershatsky
2019-06-08 23:44 ` Keith David Bershatsky
2019-06-16  8:07 ` Keith David Bershatsky
2019-06-24  2:25 ` Keith David Bershatsky
2019-06-30  5:42 ` Keith David Bershatsky
2019-07-31 19:39 ` Keith David Bershatsky
2019-10-18  1:12 ` bug#17684: #22873 (multiple fake cursors); and, #17684 (crosshairs / fill-column) Keith David Bershatsky
2019-11-18  6:58 ` Keith David Bershatsky
2020-01-27  7:39 ` Keith David Bershatsky
2020-05-02 20:50 ` Keith David Bershatsky
2020-10-01  3:00   ` bug#17684: bug#22873: " Lars Ingebrigtsen
2020-10-01  3:54     ` Keith David Bershatsky
2020-10-01 16:21       ` Lars Ingebrigtsen
2020-10-01 17:00         ` Drew Adams

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.