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.devel Subject: Re: [PATCH] User-defined fringe tooltips (a request for review) Date: Sun, 07 Apr 2024 15:44:26 +0300 Message-ID: <86y19pz6j9.fsf@gnu.org> References: <83sf3xgimq.fsf@gnu.org> <83plyzfoe4.fsf@gnu.org> <83plyxca0t.fsf@gnu.org> <8334vrczig.fsf@gnu.org> <86frwejkxe.fsf@gnu.org> <86il12bxwj.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18170"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Vladimir Kazanov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Apr 07 14:45:21 2024 Return-path: Envelope-to: ged-emacs-devel@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 1rtRth-0004Tw-3p for ged-emacs-devel@m.gmane-mx.org; Sun, 07 Apr 2024 14:45:21 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rtRsv-0007FT-Ct; Sun, 07 Apr 2024 08:44:33 -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 1rtRst-0007F0-71 for emacs-devel@gnu.org; Sun, 07 Apr 2024 08:44:31 -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 1rtRss-0002Fs-Tg; Sun, 07 Apr 2024 08:44:30 -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=DqcibNxD2saL1OT35A9nop04MwoNqbFsNGtO5zbJkVw=; b=bM+MuJayw+c7 iSma+3+yBwmlAWnFSwrK/mQptC3ey1f5GMUtzYUbCHlGgfArHjvv8HaMSxWOI8dUejXs3O/5Dm4JX sGXZJKlE8N+Q987MyiA2TKuyoRpA/Qg10p3iBuzyoQR7ChEY5VL/qxm5Lsj/LpZvujwct+IrCu+Rj o3zIbDxrfxo4utOXWlsfSZh+7Ud6qTCEotFSHpCYkumPAHzCln3zLToWd/Q4TdiF6hKqz+K3ksrgh 72fSlp1nchEZBqkqMjIdEzvsTTLDrca29FMsoFwFoKClVLcpBQ8q852qmRdYkfvU7Q8fhU614XJLq H50jiArhQZTk5ZXEIDQEYw==; In-Reply-To: (message from Vladimir Kazanov on Sun, 7 Apr 2024 12:14:54 +0100) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:317588 Archived-At: > From: Vladimir Kazanov > Date: Sun, 7 Apr 2024 12:14:54 +0100 > Cc: emacs-devel@gnu.org > > > Like I said earlier: I think it would be better to have the tooltip > > text in a separate property, not as part of the 'display' property > > spec. > > > > Also, I don't see a need for recording the positions in the glyph_row > > structure, because finding the glyph that corresponds to buffer/string > > text with that special property is easy enough. > > Done. > > The code in the patch goes through glyphs of the row under a mouse > pointer, finds an object that generated the glyph (glyph->object, > which can be a buffer or a string) and checks if > left-fringe-help/right-fringe-help text properties are defined. > Strings from the properties are then displayed as tooltips. > > This only works for properties of visible text that has glyphs > generated for it. Properties coming from invisible text and > zero-length overlays are not represented as glyphs as much I can see > from the code. Since there can be only one fringe bitmap displayed on each screen line, Lisp programs don't need the left/right-fringe-help to be put on the same positions as the display property that generated the fringe bitmaps. They can place the left/right-fringe-help property on _any_ position within the same screen line. (Of course, to make sure these properties end up on the same screen line as the fringe bitmap, they should be on positions as close as possible to the ones which cause the bitmap to be displayed on the fringe, but that shouldn't be too hard.) So I think the danger of not showing the tooltip due to invisible text or text that didn't produce any glyphs is not a real one, provided that we lift the restriction of having the left/right-fringe-help property on the same positions as the display property which produces the fringe bitmap display. Do you agree? > ;;; Tooltips will NOT be shown > (insert (propertize "foo" 'display '(left-fringe left-arrow warning) > 'left-fringe-help "left tooltip")) > (insert (propertize "foo" 'display '(right-fringe left-arrow warning) > 'right-fringe-help "right tooltip")) > (insert (propertize "foo" 'left-fringe-help "left tooltip")) > > (insert (propertize "foo" 'right-fringe-help "right tooltip")) > > (overlay-put > (make-overlay 1 2) > 'before-string (propertize > "x" > 'left-fringe-help "left tooltip" > 'display '(left-fringe right-arrow warning))) It should be enough to put the left/right-fringe-help property on the character immediately following the display property, to get the tooltip to display in those cases.