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: Mon, 25 Mar 2024 19:11:41 +0200 Message-ID: <86frwejkxe.fsf@gnu.org> References: <83sf3xgimq.fsf@gnu.org> <83plyzfoe4.fsf@gnu.org> <83plyxca0t.fsf@gnu.org> <8334vrczig.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31940"; 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 Mon Mar 25 18:12:14 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 1ronrq-000888-DW for ged-emacs-devel@m.gmane-mx.org; Mon, 25 Mar 2024 18:12:14 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ronrT-0007yB-Hy; Mon, 25 Mar 2024 13:11:51 -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 1ronrP-0007xl-Hd for emacs-devel@gnu.org; Mon, 25 Mar 2024 13:11:47 -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 1ronrN-0001d4-P9; Mon, 25 Mar 2024 13:11:47 -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=pEzkK1f99hPj6dHfivD7q4N9Fmf4od20ZXNMmgP57rM=; b=JuU1kGkXUFHc SqPQvmx6ITxFPYAK/E/Jt2jE6JbIsJ++ooF7f4pfPKM/kqxG22ktJsWgUxOq/YGDstZ/YBF5xLJ/V ZnLuRJz3tzZYM2Ckedy8bmPaqlqqXpIW2p027/23QC7IL0jNn7qyZXwmQAKpJ0eXfQjmXBCefDira EbUFB8sx7MVJGFxfcupVmsgMZnM9USArjz5NhEOse36bmnH8rO/VCe0mAJf3ZNmjBzvC93FgAbpdj tsDrm4lzsT2zqSRfBq2yeGD5RU+UlcLBTLSY8AW1SZ8Wm9kLq+xkhA6u+exNwQugy2PweD13f6yxB 3QvEJ8gdQQSXn2d0E0yV8w==; In-Reply-To: (message from Vladimir Kazanov on Mon, 25 Mar 2024 15:55:16 +0000) 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:317284 Archived-At: > From: Vladimir Kazanov > Date: Mon, 25 Mar 2024 15:55:16 +0000 > Cc: emacs-devel@gnu.org > > The code in the (note_fringe_highlight) function works outside of the > main (handle_single_display_spec) call. So to get to the :help-echo > string it has to parse into the spec, or a list of specs, or a vector > of specs, effectively duplicating parsing logic in > handle_single_display_spec. This is not nice but doable. > > But every display spec can be wrapped in a (when CONDITION . SPEC) > form. And because (handle_single_display_spec) happens at a time > different from the (note_fringe_highlight) call time we can never be > sure that the condition still holds even if the code reevaluates > CONDITION. The condition is only evaluated at glyph generation time, as for any other display property. When the tooltip should be displayed, the condition is not relevant, since if it were false when the glyphs were generated, you wouldn't have had the fringe bitmap shown in the first place. However, I think there's an easy way of making the implementation easier: just introduce a new overlay property called, say, fringe-help-echo, and put that property on the same text as the display property which produces the fringe. Then the code in note_fringe_highlight should simply check if the text which yielded the fringe bitmap also has this special property on it, and if so, display the tooltip.