unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Zack Weinberg <zackw@panix.com>
Cc: 45054@debbugs.gnu.org
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	[thread overview]
Message-ID: <83sg8kb514.fsf@gnu.org> (raw)
In-Reply-To: <CAKCAbMhCSesZAM5WMFp_X+CAYCOfDn5fMu2kJQ9JHyDOwZb=7w@mail.gmail.com> (message from Zack Weinberg on Sat, 5 Dec 2020 10:54:57 -0500)

> From: Zack Weinberg <zackw@panix.com>
> 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).





  parent reply	other threads:[~2020-12-05 16:18 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-05 15:54 bug#45054: 27.1; Can get point into the middle of a run of characters with a replacing display spec Zack Weinberg
2020-12-05 15:59 ` Zack Weinberg
2020-12-05 16:18 ` Eli Zaretskii [this message]
2020-12-05 20:00   ` Zack Weinberg
2020-12-05 20:12     ` Eli Zaretskii
2020-12-05 20:30   ` Eli Zaretskii
     [not found]     ` <CAKCAbMipxyka3DNGYOswAewqN8PCGknMdnp3pkAVDi5V-Pcrxg@mail.gmail.com>
2020-12-05 22:12       ` Zack Weinberg
2020-12-06  5:41         ` Eli Zaretskii
2020-12-09 18:56           ` Zack Weinberg
2020-12-09 19:14             ` Eli Zaretskii
2020-12-09 19:20               ` Zack Weinberg
2020-12-09 19:50                 ` Eli Zaretskii

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=83sg8kb514.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=45054@debbugs.gnu.org \
    --cc=zackw@panix.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).