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.help Subject: Re: Moving point around empty overlays with 'after-text Date: Mon, 10 Apr 2023 08:09:30 +0300 Message-ID: <83lej0l3w5.fsf@gnu.org> References: <9b1654ec-1ac6-4936-860b-2d77dcc4dac7@app.fastmail.com> <28954f0d-205d-b322-4a43-cf4481d1266e@gmail.com> <3a1bb709-d00f-49b8-a2c5-d0ac5b6a82c4@app.fastmail.com> <22b315db-39eb-80b6-1a7c-127f5e703dc1@gmail.com> <2314d321-040a-4466-afdb-4317df7e6584@app.fastmail.com> <01206f38-741a-b75b-4efe-ecf7c70c6d61@gmail.com> <66d58398-8eb5-4d89-8e7c-4400f180448f@app.fastmail.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11629"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Apr 10 07:09:15 2023 Return-path: Envelope-to: geh-help-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 1pljmF-0002tN-I0 for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 10 Apr 2023 07:09:15 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pljlt-0002Ne-Su; Mon, 10 Apr 2023 01:08:53 -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 1pljls-0002NU-66 for help-gnu-emacs@gnu.org; Mon, 10 Apr 2023 01:08:52 -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 1pljlr-0006xY-Co for help-gnu-emacs@gnu.org; Mon, 10 Apr 2023 01:08:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=9rhb3VE8301tPJE/BCkXs3u0psQlyHUuO9fCoRzDt4E=; b=nqbleKKQdvyJ 5JZANBM2SinGb0Y+9ddpdI4lhlPPlUcMhn5B5AbYCtFiRykBAfAwrgu6PJYd4/YX6iWv9GeaetaHP nYVFqfmiqVvbr6YGRXfBSeTjGBWJmOnxjbYuPUuZdF5zz3FuGdtwjCCi6UYNfqe9fNHw62I7ZekRk D+Fv5+2oexTulfg4HyE/CD80Bh+gEcW9ucfyiowpVs8WrWwNNglPTvEDglUW0rxFT5wp5c6kmbS1f y1O6Pkf3mN/+DPv8eu98zQKKQ4/8lC8BpER5jCTYCrcInpHRMcC61jlq1HBdAHAAijjndyUUKdSyW afdgRuXsiLyzKblCg60VdQ==; 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 1pljlq-00020t-IX for help-gnu-emacs@gnu.org; Mon, 10 Apr 2023 01:08:50 -0400 In-Reply-To: <66d58398-8eb5-4d89-8e7c-4400f180448f@app.fastmail.com> (message from Ash on Sun, 09 Apr 2023 20:21:09 -0700) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:143242 Archived-At: > Date: Sun, 09 Apr 2023 20:21:09 -0700 > From: Ash > > When point is on a position with an inlay, the new variable point-is-after-inlay (name subject to bikeshedding) controls where point renders (before if nil, after if t). When inserting text, the inlay moves forward if point-is-after-inlay is nil, and doesn't move if it's t; this means characters appear where you'd expect. How is this different from the front-advance and rear-advance arguments you can specify when creating the overlay. > We add a new (forward-char-respecting-inlay) function that sets point-is-after-inlay to t if point is at the start of an inlay *and* point-is-after-inlay is nil, or increments point if not (and the same for backwards). Possibly add an 'always-respect-inlay' mode that makes forward-char act like this, with the caveat that things might break in strange ways. > > Each inlay has a 'bias' of 'before or 'after that indicates what point-is-before-inlay should be set to when navigating to it 'from afar' or other cases where there's no good heuristic for where to put it; in general, this should correspond to where the text is the inlay is semantically annotating. > > There's probably all kinds of edge cases I haven't thought about, of course. Conversely, an even more general approach that would support multiple inlays in a row would be to have point-is-after-inlay be an *index* (and rename it 'point-inlay-index' or some such). Not sure what a concrete use case for that would be. I think before we invent some new complicated feature we should explore the ones already there. Did you look at how set-minibuffer-message succeeds in setting the cursor? did you try using the same technique? Did you try both before-string and after-string overlays? Did you try non-"empty" overlays, i.e. those whose start and end are not the same buffer position? They can have before-string and after-string properties as well. And that is even before considering whether overlays are the best infrastructure for implementing this stuff in Emacs.