From: Eli Zaretskii <eliz@gnu.org>
To: Herman@debbugs.gnu.org, Géza <geza.herman@gmail.com>
Cc: 64988@debbugs.gnu.org
Subject: bug#64988: 30.0.50; move-to-column can move across lines if there is a text with display property
Date: Tue, 01 Aug 2023 15:25:52 +0300 [thread overview]
Message-ID: <83o7jr0x0v.fsf@gnu.org> (raw)
In-Reply-To: <5fc075c6-c94b-eacf-6bbd-7d337caa2ee7@gmail.com> (Herman@debbugs.gnu.org)
tags 64988 notabug wontfix
thanks
> Date: Tue, 1 Aug 2023 12:53:57 +0200
> From: Herman@debbugs.gnu.org, Géza <geza.herman@gmail.com>
>
> If there is a text with display property in a buffer, then
> move-to-column can move across lines.
>
> Repro:
> * emacs -Q
> * in the scratch buffer, move the cursor to the top, and put an empty
> line at the beginning of the buffer
> * execute 'M-: (put-text-property 1 2 'display "line\n")' (note: it's
> likely that the "\n" causes the problem)
> * notice that the empty line becomes "line"
> * while the cursor still on the first line, execute 'M-: (move-to-column
> 20)'
>
> The last command will move the cursor to the next line at column 16,
> instead of staying at the first line.
>
> Note: I noticed this problem while using this package:
> https://github.com/jdtsmith/indent-bars.
>
> The problem doesn't happen with emacs 28, this is the commit that
> introduced the issue:
>
> 4243747b1b8c3b7e3463822804b32e83febe2878 Fix 'current-column' in the
> presence of display strings
This is a known issue, but it is not a bug, at least not one we know
how to "fix". In general, move-to-column cannot work correctly when
display strings with embedded newlines are involved, because Emacs
cannot place the cursor at the newline in the middle of such a display
string.
The commit to which you point fixed current-column to correctly report
the column where such display strings are involved, at least in the
important cases. That move-to-column changed behavior in those cases
is unfortunate, but I couldn't find any sensible way of dealing with
these cases, because the correct result -- setting the cursor after
the newline embedded in the display string, because column 20 doesn't
exist on that line -- is impossible. (The result that you expected,
which was what Emacs 28 did, i.e. for the cursor to stay at buffer
position 1, is also incorrect, since that position is column 1, not
column 20 and not the last column visible on that line.)
So I'm sorry, but unless someone comes with an idea for how to handle
these situations in a sensible way (and I thought long and hard about
it, but couldn't find such ideas), this will remain a limitation of
move-to-column, and one of the complications introduced by display
strings with embedded newlines in general. The affected packages will
have to adapt to this change in some ways. Since the original code
also produced incorrect results, just different incorrect results, I
don't see this as a serious problem, just as a bug that wasn't fixed,
but changed its buggy behavior.
next prev parent reply other threads:[~2023-08-01 12:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-01 10:53 bug#64988: 30.0.50; move-to-column can move across lines if there is a text with display property Herman, Géza
2023-08-01 12:25 ` Eli Zaretskii [this message]
2023-08-01 12:57 ` Herman, Geza
2023-08-01 13:26 ` Eli Zaretskii
2023-08-01 14:32 ` Herman, Geza
2023-09-02 16:38 ` Stefan Kangas
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83o7jr0x0v.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=64988@debbugs.gnu.org \
--cc=Herman@debbugs.gnu.org \
--cc=geza.herman@gmail.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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).