From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ash Newsgroups: gmane.emacs.help Subject: Re: Moving point around empty overlays with 'after-text Date: Sun, 09 Apr 2023 20:21:09 -0700 Message-ID: <66d58398-8eb5-4d89-8e7c-4400f180448f@app.fastmail.com> 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> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7326"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Cyrus-JMAP/3.9.0-alpha0-334-g8c072af647-fm-20230330.001-g8c072af6 To: "Platon Pronko" , 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 05:22:10 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 1pli6c-0001i2-4r for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 10 Apr 2023 05:22:10 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pli63-00008E-9D; Sun, 09 Apr 2023 23:21:35 -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 1pli61-00006p-Nr for help-gnu-emacs@gnu.org; Sun, 09 Apr 2023 23:21:34 -0400 Original-Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pli5z-0002hI-Hu for help-gnu-emacs@gnu.org; Sun, 09 Apr 2023 23:21:33 -0400 Original-Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 637A05C0140; Sun, 9 Apr 2023 23:21:30 -0400 (EDT) Original-Received: from imap42 ([10.202.2.92]) by compute3.internal (MEProxy); Sun, 09 Apr 2023 23:21:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=catgirl.ai; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1681096890; x=1681183290; bh=fG oe5Xe4v7U56SO4KvtoPYHPkoLbGLmDE0DhqZU5tU4=; b=uqoNT3Ys4RLKwWCsG5 UqoGweNHXIVIW35eXWJi4OAb4DgTYm497m8ES/Xvw1xAZyvCJGco1vRSV/7D8+Xx TmJSVvUokeyH5fJNnWYgJISXk0gEqQRRHMlQlbnXVcQIVJeejrL1ra5qeg1ZupuO 7/MmpAVnExS3ORVEEitAKqSC7dsWoIeJpj2peQIBjR8+Vz/6i1kR4bw+6A1eJj7e yK68Jov0eh8MQHG9E3UmYHIwIuRXUwArIq8wEUk/iE6xU1WHfXgv1oL8Xn9/Oy3O E4pfnetzezj0w0764BibyFUDiPD8tov2XMRgZ1d8YNqjyuptmM5W0tF6E0zeuKiu 6Tew== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1681096890; x=1681183290; bh=fGoe5Xe4v7U56 SO4KvtoPYHPkoLbGLmDE0DhqZU5tU4=; b=l8JtpY/eMbCgfIGn2YOCpPe9Rqy3u CiJmCqy42AGcK/9szPYezdPXAXyQDHQGM4kVawtbO1r3RrMdgPAh5b2TAG7Ph5tH iFSGbhmLxPeYkyhbUFPsDUoWqw8DxMADz3CNBSQrXA/Uvbhyq3jHZTgAR15VOPSz GPhuwJG/Gl9tOH4CJkrAVbxZhs/u2RpNZ0zb2f9KXsS3gA3CeoN+vYwO4YTEJvyQ P6NtJ4IMw5p8HJg/OOvFtz/TVAkMNePZOzn7PVdcc4i3Tno7ss7NmzI+Di46Y9tb 1AL1wHrE79Ju2wJd7X6mw81Dm4oLMqhXQKfv5hzSyNIRPo0Nf4zk53wpw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdekuddgjedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesrgdtreerreertdenucfhrhhomheptehshhcu oegvgihttdhlsegtrghtghhirhhlrdgriheqnecuggftrfgrthhtvghrnhepffethfduff ehledtueejgfdvlefgudfgfefggfffleduvdetuefgveevfeefveefnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepvgigthdtlhestggrthhgih hrlhdrrghi X-ME-Proxy: Feedback-ID: i98e14743:Fastmail Original-Received: by mailuser.nyi.internal (Postfix, from userid 501) id 0EFFABC007E; Sun, 9 Apr 2023 23:21:30 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface In-Reply-To: <01206f38-741a-b75b-4efe-ecf7c70c6d61@gmail.com> Received-SPF: pass client-ip=66.111.4.29; envelope-from=ext0l@catgirl.ai; helo=out5-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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:143238 Archived-At: On Sun, Apr 9, 2023, at 7:00 PM, Platon Pronko wrote: > On 2023-04-10 04:44, Ash wrote: > > Yeah, I think doing this "right" might require adding a new property to overlays/strings (or giving an existing property a new value) to enable this behavior and modifying C code. Not sure how viable that is or if it's something the devs would want. > > I think it's even worse than adding a property to the overlay. You need common point manipulation functions to account for possibility of inlays, i.e. (point) for position before and after inlay will be returning different values, (forward-char) will correctly advance the point from the left side to the right side of the inlay, etc. > > (on second thought, making (point) return different values for positions around overlays sounds horrifying, because this will break about half of all Elisp code written) > > But inlay hints seem to be a common functionality for any modern IDE nowdays, so it might make sense to support them natively, without making major-mode developers resort to horrible hacks like described before. > > -- > Best regards, > Platon Pronko > PGP 2A62D77A7A2CB94E > You could make it so only these special overlays (I'm going to call them inlay-type overlays or just inlays) have weird behavior with (point), but that'd still make things very complicated and I wouldn't do it. A sketch for what I would do is something like this: 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. 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.