all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Spencer Baugh via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Romain Ouabdelkader <romain.ouabdelkader@gmail.com>
Cc: "Eli Zaretskii" <eliz@gnu.org>,
	73863@debbugs.gnu.org, "João Távora" <joaotavora@gmail.com>
Subject: bug#73863: 30.0.91; Unexpected cursor movement with flymake-show-diagnostics-at-end-of-line
Date: Tue, 12 Nov 2024 16:38:43 -0500	[thread overview]
Message-ID: <ierr07gt9ng.fsf@janestreet.com> (raw)
In-Reply-To: <CAJ8YToY2YBSsMzc6oc3fCcwUNNHCDT3CY7ifHfFFPF2yhSBJJg@mail.gmail.com> (Romain Ouabdelkader's message of "Sun, 20 Oct 2024 17:01:44 +0200")

Romain Ouabdelkader <romain.ouabdelkader@gmail.com> writes:
> Sorry, I realized I wasn't clear about the behavior I was expecting.
>
> I would expect the cursor behavior to remain consistent whether diagnostics are present or not, especially since diagnostics can
> appear and disappear during editing.
>
> For example:
> Screenshot 2024-10-20 at 16.56.48.png
> Here, when press C-n once, I expect the cursor to go here:
> Screenshot 2024-10-20 at 16.57.59.png
>
> I.e. the behavior would be the same as if there were no diagnostics in the buffer.
> I'm not sure if that's actually feasible or if there is an issue with this behavior.

I think that's indeed the ideal.

> I tried your patch but it makes the cursor go on the diagnostic which i find surprising, I believe the cursor should not be able to
> move into a diagnostic:
> Screenshot 2024-10-20 at 17.00.18.png
>
> What do you think? 

I think this behavior is bad, so I don't think this is a good patch.
Note especially that C-e puts point after the diagnostic, then DEL
deletes characters before the diagnostic!  Unexpected and confusing IMO.

That's equivalent to the behavior without the 'cursor property: point
goes to the end of the displayed diagnostic, both on C-e and C-n.

There are two conflicting issues here:

A. Having "point is at EOL" be displayed as "the cursor is after the
   diagnostic" is unacceptable because it means DEL deletes characters at
   a distance, and other similar bad issues.

   So we want "point is at EOL" to be displayed as "the cursor is before
   the diagnostic", which the existing 'cursor property achieves.

B. (vertical-motion 1) tries to move the cursor to after the diagnostic,
   since that's the next screen line.  Then the cursor property displays
   the cursor back to before the diagnostic.  Since that ends up moving
   point to the end of the current line, which is the same visual line,
   this is unexpected.

A is more important than B, so if we want to fix B we can't break A.

Here's a self-contained demonstration without flymake:

(with-current-buffer (get-buffer-create "*overlay-demonstration*")
  (erase-buffer)
  (remove-overlays)
  (insert (make-string 80 ?x))
  (save-excursion
    (newline)
    (insert (make-string 80 ?y)))
  (let ((ol (make-overlay (point) (1+ (point))))
        (s (propertize (make-string 80 ?s) 'face 'warning)))
    (put-text-property 0 1 'cursor t s)
    (overlay-put ol 'before-string s))
  (delete-other-windows)
  (let ((win (split-window-right -62)))
    (set-window-buffer win (current-buffer)))
  (other-window 1))

If you run this then you'll observe behavior B when moving with C-n and
C-p.

There's actually another symmetric issue to B: after moving to the end
of the line with C-e, if you hit C-p that moves to the start of the
current screen line, instead of moving to the previous screen line.
This is because vertical-motion acts as if the cursor is on screen line
3, when it's actually on screen line 2 because of the 'cursor property.

Arguably this is a bug in vertical-motion: if you run (vertical-motion
1) or (vertical-motion -1) in the appropriate places, it returns 1 or
-1, claiming that it moved by a screen line even though it actually
stayed on the same screen line.

I'm not sure how to fix this.  IMO, vertical-motion should try harder to
move by screen lines.

In the C-p case, there's an obviously correct thing to do: move to the
same column of the previous screen line.  But for some reason,
vertical-motion doesn't do it: it stays on the same screen line.  Maybe
fixing this should start there?





  parent reply	other threads:[~2024-11-12 21:38 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-18 15:09 bug#73863: 30.0.91; Unexpected cursor movement with flymake-show-diagnostics-at-end-of-line Romain Ouabdelkader
2024-10-18 16:08 ` Eli Zaretskii
2024-10-18 16:24   ` Romain Ouabdelkader
2024-10-18 18:31     ` Eli Zaretskii
2024-10-18 19:10       ` Romain Ouabdelkader
2024-10-19 13:15         ` Eli Zaretskii
2024-10-19 13:41           ` Romain Ouabdelkader
2024-10-20  7:25             ` Eli Zaretskii
2024-10-20  9:28               ` João Távora
2024-10-20 11:22                 ` Eli Zaretskii
2024-10-20 11:38                   ` João Távora
2024-10-20 11:49                     ` Eli Zaretskii
2024-10-20 14:42                       ` João Távora
2024-10-20 15:01                         ` Romain Ouabdelkader
2024-10-20 15:49                           ` Eli Zaretskii
2024-10-20 16:23                             ` Eli Zaretskii
2024-11-12 21:38                           ` Spencer Baugh via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-11-13 14:45                             ` Eli Zaretskii
2024-11-30  9:45                               ` Eli Zaretskii
2024-10-20 15:31                         ` Eli Zaretskii
2024-10-20 15:39                           ` João Távora
2024-10-20 16:30                             ` Eli Zaretskii
2024-10-20 16:58                               ` João Távora
2024-10-20 17:50                                 ` Eli Zaretskii
2024-10-20 18:05                                   ` João Távora
2024-10-20 18:28                                     ` Eli Zaretskii
2024-10-20 19:18                                       ` João Távora
2024-10-27 10:56                   ` Eli Zaretskii
2024-10-30 23:57                     ` Romain Ouabdelkader
2024-10-31  7:40                       ` Eli Zaretskii
2024-10-31 19:18                         ` Romain Ouabdelkader
2024-10-18 19:16       ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-18 19:25         ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ierr07gt9ng.fsf@janestreet.com \
    --to=bug-gnu-emacs@gnu.org \
    --cc=73863@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=joaotavora@gmail.com \
    --cc=romain.ouabdelkader@gmail.com \
    --cc=sbaugh@janestreet.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.