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#45054: 27.1; Can get point into the middle of a run of characters with a replacing display spec Date: Sat, 05 Dec 2020 18:18:15 +0200 Message-ID: <83sg8kb514.fsf@gnu.org> References: 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="28136"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 45054@debbugs.gnu.org To: Zack Weinberg Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Dec 05 17:40:51 2020 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 1klac7-0007EA-N4 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 05 Dec 2020 17:40:51 +0100 Original-Received: from localhost ([::1]:37242 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1klac6-0001D8-OW for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 05 Dec 2020 11:40:50 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44664) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1klaH2-0003ac-0O for bug-gnu-emacs@gnu.org; Sat, 05 Dec 2020 11:19:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36542) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1klaH0-00019I-Iy for bug-gnu-emacs@gnu.org; Sat, 05 Dec 2020 11:19:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1klaH0-0003r4-Fd for bug-gnu-emacs@gnu.org; Sat, 05 Dec 2020 11:19:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 05 Dec 2020 16:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45054 X-GNU-PR-Package: emacs Original-Received: via spool by 45054-submit@debbugs.gnu.org id=B45054.160718511814788 (code B ref 45054); Sat, 05 Dec 2020 16:19:02 +0000 Original-Received: (at 45054) by debbugs.gnu.org; 5 Dec 2020 16:18:38 +0000 Original-Received: from localhost ([127.0.0.1]:48088 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1klaGb-0003qR-O6 for submit@debbugs.gnu.org; Sat, 05 Dec 2020 11:18:37 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:54578) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1klaGa-0003q8-EW for 45054@debbugs.gnu.org; Sat, 05 Dec 2020 11:18:36 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:47656) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1klaGV-000117-5o; Sat, 05 Dec 2020 11:18:31 -0500 Original-Received: from [176.228.60.248] (port=4553 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1klaGU-00016j-8d; Sat, 05 Dec 2020 11:18:31 -0500 In-Reply-To: (message from Zack Weinberg on Sat, 5 Dec 2020 10:54:57 -0500) 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" Xref: news.gmane.io gmane.emacs.bugs:195041 Archived-At: > From: Zack Weinberg > Date: Sat, 5 Dec 2020 10:54:57 -0500 > > \ ;; \| > u00B6 ;; \u00B6| > C-a ;; |\u00B6 > M-x fold-demo-mode ;; |¶ > C-d ;; |u00B6 > \ ;; ¶| > x ;; \x|u00B6 > > The bug happens when you type \ for the second time. The font-lock rule > matches again, “\u00B6” is converted to “¶”, and the *visible cursor* is > displaced to after the “¶”, but *point* is still where it was, between > the invisible \ and u characters. Any self-inserting character, like > the ‘x’ shown in the recipe, will be inserted at the actual location of > point, instead of the position of the visible cursor. In the demo, this > causes the font-lock rule to stop matching again. > > Any cursor-motion command while Emacs is in this state, will put point > back in sync with the visible cursor; this can lead to odd but harmless > phenomena, for instance a single C-f doesn’t appear to do anything, > instead of moving the cursor to the next line like it normally would. > (Because point moves within the hidden run of characters, and then gets > displaced to the end of the run, where the visible cursor already is.) > > Questions: > > 1. Is this indeed a bug in Emacs? Probably a bug in adjust_point_for_property. Try your recipe after setting global-disable-point-adjustment non-nil. > 2. Assuming it is, can you suggest a workaround? I’m hoping for a > viable solution within my code that’s compatible at least as far back > as Emacs 24. A workaround in Lisp? Try making the affected text, or some of it, invisible, i.e. give it the 'invisible' text property as well. (I didn't try to test this solution, so I cannot promise it will work.) > 3. I think it would be better UI if the C-d in the recipe deleted the > entire run of text that’s getting hidden (more generally, deletion > commands should behave as if the ¶ is really what’s in the buffer). > I can’t figure out how to implement that, can you suggest anything? Why can't you delete every character around point that has this special property? > 4. Is there a better way to do this sort of visual replacement of runs > of text? This is the first time I’ve done any serious elisp > programming, I might have missed something. Sounds the right way to me (modulo making the text invisible).