From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Vladimir Kazanov Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] User-defined fringe tooltips (a request for review) Date: Sat, 23 Dec 2023 13:28:48 +0000 Message-ID: References: <83sf3xgimq.fsf@gnu.org> <83plyzfoe4.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7046"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Dec 23 14:29:55 2023 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 1rH24g-0001jI-6X for ged-emacs-devel@m.gmane-mx.org; Sat, 23 Dec 2023 14:29:54 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rH23u-0004tm-AD; Sat, 23 Dec 2023 08:29:06 -0500 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 1rH23s-0004rz-6y for emacs-devel@gnu.org; Sat, 23 Dec 2023 08:29:05 -0500 Original-Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rH23q-0003wL-IE; Sat, 23 Dec 2023 08:29:03 -0500 Original-Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-50e6a806e4aso1312025e87.1; Sat, 23 Dec 2023 05:29:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703338140; x=1703942940; darn=gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Aqc4oC/rAYqRvjP7ft8UI3D/PHmjqX05gGXRKeWU98U=; b=dCD7uvh/mIVhumr7dZvudMVSFZ3y4I9GAjNWmdgrW1xbEHG5cyXbwvV6pf7OZl9VUP rD9Djj0R9/j6pn/WLmhRyWWcFNT4L1QLFeEUdJf57nqAdpSKa2ij78O31GXO7QtEViy+ RciEQX/AC+9IfUH3xy+BAMHne5Kf2rqbc0u88k9YYsZXsddnNaQXaMNc/Xpo9YqzjcY8 tCpRTZrk7VGwWc7GSLpyKibRQXVd54j42RRMBT6QqZDy1JPnQu/PtJvqhHmcVpGkEnxG VJxo4yH3Tv/jP70JT7sQeBVMgv6GZI0XUZGpwOuK+1+e7o1D+V07a8M100/vusRMPp8T Hy7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703338140; x=1703942940; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Aqc4oC/rAYqRvjP7ft8UI3D/PHmjqX05gGXRKeWU98U=; b=iJwPpv0rJcrTIvZgiz3V9KirIS84OgoEKue1yMxgl4nIrbvXyEyQXv1k0cMbp4buYg 1WOZi1P7A2E+2pPMWhsxmQIPAPs5jUq9934adbglKJUaiqsvKfVURHEvP664gsuUv1LF d/pg8Om9wNs5eDu4zKozvmkrmth9yM6KXBSi1piPQ4v3+NirbkewWOXgCmAa/iKSVt6l lx945Ndk88Jdl0/0heKLNNcwGmNewARZ5h4NCQm2jfdB/X7xOF3qS8xhcGGeYgx1pp7R Bi4y/IYBQOIA8WTyYzfs29nLgt/kmpf1VbDFLoXATUCt/rKHQq1r6ngxaEfBaK6TZ8jV OW/w== X-Gm-Message-State: AOJu0YxV7um2WqwtyNXJuEeDhq06aSBwt3lcGYkXh17OQaKV58IJQgwO hkJAsnxc2iQiM8P7PKjjmt1uFnaOpAVaRO49PpYiRYMlDg== X-Google-Smtp-Source: AGHT+IGA9kpb7pXyujAEPXEcSCfbXOMKH6v0D+yDirxYsrcJBt5QB2rrl2Hhp9LtbUdznz0nk3YoJHjpQNsWRuYoveo= X-Received: by 2002:ac2:4c07:0:b0:50e:75f2:5590 with SMTP id t7-20020ac24c07000000b0050e75f25590mr143571lfq.111.1703338139338; Sat, 23 Dec 2023 05:28:59 -0800 (PST) In-Reply-To: <83plyzfoe4.fsf@gnu.org> Received-SPF: pass client-ip=2a00:1450:4864:20::136; envelope-from=vekazanov@gmail.com; helo=mail-lf1-x136.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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:314101 Archived-At: So I've spent some time playing with various buffer text arrangements and looking into iterator code. Quite a read, I must say! > > for (glyph = row->glyphs[TEXT_AREA]; > glyph < row->glyphs[TEXT_AREA] + row->used[TEXT_AREA]; > glyph++) > > Just iterating through glyphs doesn't work as glyphs do not reflect charpos'es within invisible parts of the buffer. If a left-fringe/right-fringe display property is specified then the text is invisible so there's no glyph having that charpos. The iterator handles all of that, of course, this is why I didn't have to take it into account the first time. The way I see things now: the code has to iterate all charpos in the right order, including invisible ones, and also check for display properties in overlays. A glyph_row has information on where the row starts and ends (row->start and row->end). I want to do the following in note_mouse_highlight: /* Get to the current glyph row */ struct glyph_row *row = MATRIX_ROW (w->current_matrix, vpos); Lisp_Object left_caption = Qnil, right_caption = Qnil; ptrdiff_t charpos; ptrdiff_t charpos_start = row->start.pos.charpos; ptrdiff_t charpos_end = row->end.pos.charpos; for (charpos = charpos_start; charpos <= charpos_end; charpos++) { /* This can be either in text props or overlays, so check both */ Lisp_Object spec = get_char_property_and_overlay (make_fixnum (charpos), Qdisplay, Qnil, NULL); /* ... parse the spec... */ } > If Fget_text_property returns non-nil for the 'display' property, you > will then need to look at the value and see whether it specifies a > help-echo for the fringe; if it does, extract the string and assign it > to 'help_echo_string'. I've just realized that what you have in mind is reusing the standard 'help-echo property? The one used for tooltips on the text itself? This might not work in all cases as some major modes remove top-level help-echo properties for some reason - I didn't look into it thoroughly. Either way, I'd need to test this thoroughly, I suspect there might be interesting corner cases. Thanks -- Regards, Vladimir Kazanov