From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs 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 Message-ID: <83o7jr0x0v.fsf@gnu.org> References: <5fc075c6-c94b-eacf-6bbd-7d337caa2ee7@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15081"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 64988@debbugs.gnu.org To: Herman@debbugs.gnu.org, =?UTF-8?Q?G=C3=A9za?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Aug 01 14:26:23 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qQoSD-0003fb-Fm for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 01 Aug 2023 14:26:21 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQoRw-0006SY-7b; Tue, 01 Aug 2023 08:26:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qQoRu-0006Rw-Fx for bug-gnu-emacs@gnu.org; Tue, 01 Aug 2023 08:26:02 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQoRu-0000DY-7Y for bug-gnu-emacs@gnu.org; Tue, 01 Aug 2023 08:26:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qQoRu-0000NH-3u for bug-gnu-emacs@gnu.org; Tue, 01 Aug 2023 08:26:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 01 Aug 2023 12:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64988 X-GNU-PR-Package: emacs Original-Received: via spool by 64988-submit@debbugs.gnu.org id=B64988.16908927571421 (code B ref 64988); Tue, 01 Aug 2023 12:26:02 +0000 Original-Received: (at 64988) by debbugs.gnu.org; 1 Aug 2023 12:25:57 +0000 Original-Received: from localhost ([127.0.0.1]:47377 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qQoRo-0000Mq-W9 for submit@debbugs.gnu.org; Tue, 01 Aug 2023 08:25:57 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37952) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qQoRn-0000MZ-5G; Tue, 01 Aug 2023 08:25:55 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qQoRh-0000AP-Cm; Tue, 01 Aug 2023 08:25:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=dDnFp/pd3aOX1g64XVhaQZxyIJV1oYo6oYfNxYwEack=; b=Fw2iJ5u0hGJi2YsJXE3L 7c79c1pMsHM8MnsRHITKMamrcBEGGnJhRN3z4LLL6ayxI8nLaoB9XC8TVfQmLw8rBNIBG3y8aIrkf 4JT9m/3UOWMZpikb9hf+0uWD2TaTzlQtYAdg8WAu7ZBG81b44iNI1z6KkQL1+yimfOfSkDgIDlULj ShX9RX8QZeiJLd4zxcQyIimeRfc6lySiCGBqXs9ihTbIKpAL3mLodxZzAfs+yTsj366rh5pKa1cG+ QoQyk5j4TWv5ClwP2+/60oxWipFBFEdZJ31jHYfltQEWbCGpFzJ/xJvItbB3DrNbRTaRcuRr/Qmxz cW9uFWcPdiTPAA==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qQoRg-0006gq-Om; Tue, 01 Aug 2023 08:25:49 -0400 In-Reply-To: <5fc075c6-c94b-eacf-6bbd-7d337caa2ee7@gmail.com> (Herman@debbugs.gnu.org) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:266447 Archived-At: tags 64988 notabug wontfix thanks > Date: Tue, 1 Aug 2023 12:53:57 +0200 > From: Herman@debbugs.gnu.org, Géza > > 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.