From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id cGScEa+wFmJNtwAAgWs5BA (envelope-from ) for ; Wed, 23 Feb 2022 23:09:51 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id GCpLDq+wFmKzQwEAauVa8A (envelope-from ) for ; Wed, 23 Feb 2022 23:09:51 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id A98623B027 for ; Wed, 23 Feb 2022 23:09:50 +0100 (CET) Received: from localhost ([::1]:53426 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nMzpU-0000VQ-PQ for larch@yhetil.org; Wed, 23 Feb 2022 17:09:48 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54136) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMzlC-0004z3-Ge for emacs-orgmode@gnu.org; Wed, 23 Feb 2022 17:05:22 -0500 Received: from [2a00:1450:4864:20::62a] (port=45038 helo=mail-ej1-x62a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nMzl9-0005NT-5e for emacs-orgmode@gnu.org; Wed, 23 Feb 2022 17:05:22 -0500 Received: by mail-ej1-x62a.google.com with SMTP id p14so247871ejf.11 for ; Wed, 23 Feb 2022 14:05:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=De/ORAkX/4X4YGs/1CmTZSwtz20CPCoWse/+aVagf+k=; b=OK2oqRwsuzcBkYvk8sRfz+2OT4DWOusYwWIWk5kgZz27jVxQ5ULpn2Po59wcHOKkZ9 z929cY9lM381WP1/2u2bWad6eLe1XdFAS6h8LJK9SUfJmhRUric+7o2Z/pkDYeuFoKtj Bo7Om1r/Kr6oTgjVyAtTPc5mlcQhUMAcMGQ1wrzKohzpf6yMzXAEI74yKs1bvn3q1viF yoPdzN/8M15CWJljkbc6TzUPjBkYn76z930DplZJ3L0cs3EwZ3ntQL7Nu/CYgemqQAGK 2wRMwUi2aOxaM8sRqHlYIc2T4lxyEKD5qH4FcB/V2+JA/TiqIwVvPx3dT54tzFjpMMDS v1cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=De/ORAkX/4X4YGs/1CmTZSwtz20CPCoWse/+aVagf+k=; b=a9NostSEehSsJO+7RYFxuiITxujz2oUutKQSKY1xzjo/4bD5ZRbBGuOhK1kW/Okb4H D1IhHQaTc3AdRD3WlnVXGEqjC6UIIdt5bpyo42W9ayyKtcMLnbybvQJB0p9oEutKjetK vp7vbnzmQg3y0QVrYtBCL+Os5aSSlqcbp3B4bsd6FfusoLFaK2SZH2SL2T0UCbam8y+t v/R2zTtT3mHLigS5p9rORWOVQLwUwje7AwzZ6hpA6exNn1UH1V9j/xnOm3BJYkwN8a3v HZlwEG2vf+bX3lFOYppYKU2hfactssbggFFurVtLjkcpVCELNpIMo/zDeqqbwIddD5wZ dN4w== X-Gm-Message-State: AOAM532wnalvzSL//N/HQjjh+dnQOwguENzVpopiuD6Ylen2aA7KN0ma GFFgA7whBoClLGTj5C/zXN1pCw4pCzWmZtSeywvte+DPcwlLGQ== X-Google-Smtp-Source: ABdhPJz6AIvBm/0cGzBJmsrTaIwERkl2YVfD8LKFiC0FXEyKPoA7CWs91V/oR64ZOk4U/eLDzmGKMa0+TiaT0o+TmBU= X-Received: by 2002:a17:907:2954:b0:6cf:7634:c6b7 with SMTP id et20-20020a170907295400b006cf7634c6b7mr1228797ejc.683.1645653916448; Wed, 23 Feb 2022 14:05:16 -0800 (PST) MIME-Version: 1.0 References: <63ab1106-8aa7-4dd1-923b-04ac8fd4470a@gmail.com> <87ee3u8gjr.fsf@posteo.net> <87czjdgy2v.fsf@posteo.net> In-Reply-To: <87czjdgy2v.fsf@posteo.net> From: John Kitchin Date: Wed, 23 Feb 2022 17:05:05 -0500 Message-ID: Subject: Re: Footnote tooltips (an attempt) To: =?UTF-8?Q?Juan_Manuel_Mac=C3=ADas?= Content-Type: multipart/alternative; boundary="0000000000001cfa5b05d8b6a9dd" X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::62a (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::62a; envelope-from=johnrkitchin@gmail.com; helo=mail-ej1-x62a.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, HTML_MESSAGE=0.001, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ypo , orgmode Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1645654191; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=De/ORAkX/4X4YGs/1CmTZSwtz20CPCoWse/+aVagf+k=; b=E4Q+6KKizSLzaMHQ4X1Dxl8zE9MqNMd6lm6r81X7fWNhcnEpbsUPOPudaH/8RI9JWWCMyM lbRVZWevwyBi9wADjojeD7Lzhq9zUlzsZ11Tk7plSJLE4OVzu1/F4c11/Fyl/fN/TCpLBd RH9yNrLX9LIyIZJXhrFYivCQZ8h7OOTeHTESvEjo7eHQ2LWPVJTtJjSkAyvwNUu8gFDpGY rLT1AlQaqEeMZ5hFcVcdNPSmU+d4bWyIElgutx8V5lngXRkAsxmbJdo/aAMFCfs/05dG22 /pEO9b9q5VMrdeSh6vdBuMAIMPiaxWYIdElnlwHeEtkwVU/a5AEmUD2YVld3Rg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1645654191; a=rsa-sha256; cv=none; b=CAAPpjvhbHS/y8nsHV2f/xJMaEfsovTUazd6I8QJGXdRfOWrkaqtE0aTBGNxXtLqpI+3uq qIFcXlw/crhqaqXKLNVPIg58r/QB7xg0mlouPBo/hITw5ddgDrkiiNtKWOLeKpnQuJlyTj ahCwJCYehw+4c4qgbJTnksdMXgCk6/YZvCniJ/wCXI0mgMgADqpQllpRO01zsiF+QHg7dg /8L25eaWjhkLK7ZIGc7OhE8owYapO9dLYuuxTpQOEduyWo82+AwOaWusB96LGxUYU9H/7m Iz5vl9N2t/iwTBhcXFyEx+FScpw2frNN30/VSkE7NQWTyueA+zTTaUSwXj8Ynw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=OK2oqRws; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -1.03 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=OK2oqRws; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: A98623B027 X-Spam-Score: -1.03 X-Migadu-Scanner: scn1.migadu.com X-TUID: /M+AoszEV1lJ --0000000000001cfa5b05d8b6a9dd Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I think this might be a simpler approach. what you want (I think) is to leverage font-lock on tooltips to set a help-echo function instead of a string. You can override org-activate-footnote-links with an advice (which makes it easy to undo of you need). The tooltip function then looks up the tooltip when you ask for it. The 3 pieces are below. the first function looks up and returns a tooltip. the second is a lightly modified version of org-activate-footnote-links which just replaces the footnote reference string with the first function. the last piece is the override advice. you could use a minor mode to toggle the advice on and off. #+BEGIN_SRC emacs-lisp (defun footnote-reference-tooltip (_win _obj position) "Get footnote contents" (save-excursion (goto-char position) (let* ((fnf (org-element-context)) (label (org-element-property :label fnf)) (p (nth 1 (org-footnote-get-definition label)))) (when p (goto-char p))) (let ((fnd (org-element-context))) (string-trim (buffer-substring (org-element-property :contents-begin fnd) (org-element-property :contents-end fnd)))))) (defun footnote-tooltip (limit) "Add text properties for footnotes." (let ((fn (org-footnote-next-reference-or-definition limit))) (when fn (let* ((beg (nth 1 fn)) (end (nth 2 fn)) (label (car fn)) (referencep (/=3D (line-beginning-position) beg))) (when (and referencep (nth 3 fn)) (save-excursion (goto-char beg) (search-forward (or label "fn:")) (org-remove-flyspell-overlays-in beg (match-end 0)))) (add-text-properties beg end (list 'mouse-face 'highlight 'keymap org-mouse-map 'help-echo (if referencep #'footnote-reference-tooltip "Footnote definition") 'font-lock-fontified t 'font-lock-multiline t 'face 'org-footnote)))))) (advice-add 'org-activate-footnote-links :override 'footnote-tooltip) #+END_SRC John ----------------------------------- John Kitchin (he/his) Professor Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 http://kitchingroup.cheme.cmu.edu https://pointbreezepubs.gumroad.com/ pycse bookstore On Wed, Feb 23, 2022 at 2:52 PM Juan Manuel Mac=C3=ADas wrote: > Hi Samuel, > > Samuel Wales writes: > > > what a great idea. i am interested in your comments. emacs has lots > > of tooltip-related features. eldoc, help-at-pt, mouse-avoidance, etc. > > you don't want tooltips when your mouse happens to end up over. or > > for your mouse to go haywire just because you ended up over. i ran > > into a lot of confusion with various mechanisms. > > > > [e.g. i like having tooltips in echo area, and don't like eldoc for > > function sigs, and do want cursor/mouse consistency.] > > > > i found that some tooltip features actually break others. just > > wondering if you noticed this and what you think of it. > > I don't have much experience with Emacs tooltips and I haven't studied > them much, because I hardly use the mouse in Emacs :-) But I noticed > that you can also display the content of a tooltip in the echo area, > with `' (`display-local-help'), or even set to non-nil > `help-at-pt-display-when-idle' and evaluate `help-at-pt-set-timer', so > that a tootltip is displayed at point; and in this scenario, they can be > useful to me to quickly have some type of information. > > You can also set this variable to force tooltips always in the echo > area: > > (setq tooltip-use-echo-area t) > > Anyway, I haven't given up on the idea of footnote tooltips yet. Here's > a new version of the code I attached in my first post in this thread, > and I think it's simpler now and works better, though I don't know if it > might have any side effects... Footnote tooltips are activated with the > minor mode `my-org-fn-tooltip-mode'. > > A new demo video: > > https://cloud.disroot.org/s/sBGJjCzbYgYbn5k > > Best regards, > > Juan Manuel > > --0000000000001cfa5b05d8b6a9dd Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I think this might be a simpler approach. what you want (I= think) is to leverage font-lock on tooltips to set a help-echo function in= stead of a string. You can override org-activate-footnote-links with an adv= ice (which makes it easy to undo of you need). The tooltip function then lo= oks up the tooltip when you ask for it. The 3 pieces are below. the first f= unction looks up and returns a tooltip. the second is a lightly modified ve= rsion of org-activate-footnote-links which just replaces the footnote refer= ence string with the first function. the last piece is the override advice.= you could use a minor mode to toggle the advice on and off.

=



#+BEGIN_SRC emacs-lisp
(defu= n footnote-reference-tooltip (_win _obj position)
=C2=A0 "Get footn= ote contents"
=C2=A0 (save-excursion
=C2=A0 =C2=A0 (goto-char po= sition)
=C2=A0 =C2=A0 (let* ((fnf (org-element-context))
=C2=A0 (la= bel (org-element-property :label fnf))
=C2=A0 (p (nth 1 (org-footnote-= get-definition label))))
=C2=A0 =C2=A0 =C2=A0 (when p
(goto-char p))= ) =C2=A0 =C2=A0
=C2=A0 =C2=A0 (let ((fnd (org-element-context)))
=C2= =A0 =C2=A0 =C2=A0 (string-trim
=C2=A0 =C2=A0 =C2=A0 =C2=A0(buffer-substr= ing (org-element-property :contents-begin fnd)
(org-element-property= :contents-end fnd))))))


(defun footnote-tooltip (limit)
=C2= =A0 "Add text properties for footnotes."
=C2=A0 (let ((fn (org= -footnote-next-reference-or-definition limit)))
=C2=A0 =C2=A0 (when fn=C2=A0 =C2=A0 =C2=A0 (let* ((beg (nth 1 fn))
=C2=A0 =C2=A0 (end (nth= 2 fn))
=C2=A0 =C2=A0 (label (car fn))
=C2=A0 =C2=A0 (referencep = (/=3D (line-beginning-position) beg)))
(when (and referencep (nth 3 fn)= )
=C2=A0(save-excursion
=C2=A0 =C2=A0(goto-char beg)
=C2=A0 = =C2=A0(search-forward (or label "fn:"))
=C2=A0 =C2=A0(org-re= move-flyspell-overlays-in beg (match-end 0))))
(add-text-properties beg= end
=C2=A0 =C2=A0 (list 'mouse-face 'highlight
=C2= =A0 'keymap org-mouse-map
=C2=A0 'help-echo
=C2=A0 = (if referencep #'footnote-reference-tooltip
=C2=A0 =C2=A0 "= ;Footnote definition")
=C2=A0 'font-lock-fontified t
= =C2=A0 'font-lock-multiline t
=C2=A0 'face 'org-foot= note))))))

(advice-add 'org-activate-footnote-links :override &#= 39;footnote-tooltip)
#+END_SRC


John

-----------------------------------<= br>John Kitchin (he/his)
Professor
Doherty Hall A207F
Department o= f Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 1521= 3
412-268-7803
http://kitchingroup.cheme.cmu.edu
https://pointbreezepubs.gumroa= d.com/=C2=A0pycse bookstore

=
On Wed= , Feb 23, 2022 at 2:52 PM Juan Manuel Mac=C3=ADas <maciaschain@posteo.net> wrote:
Hi Samuel,

Samuel Wales writes:

> what a great idea.=C2=A0 i am interested in your comments.=C2=A0 emacs= has lots
> of tooltip-related features.=C2=A0 eldoc, help-at-pt, mouse-avoidance,= etc.
> you don't want tooltips when your mouse happens to end up over.=C2= =A0 or
> for your mouse to go haywire just because you ended up over.=C2=A0 i r= an
> into a lot of confusion with various mechanisms.
>
> [e.g. i like having tooltips in echo area, and don't like eldoc fo= r
> function sigs, and do want cursor/mouse consistency.]
>
> i found that some tooltip features actually break others.=C2=A0 just > wondering if you noticed this and what you think of it.

I don't have much experience with Emacs tooltips and I haven't stud= ied
them much, because I hardly use the mouse in Emacs :-) But I noticed
that you can also display the content of a tooltip in the echo area,
with `<C-h .>' (`display-local-help'), or even set to non-nil=
`help-at-pt-display-when-idle' and evaluate `help-at-pt-set-timer',= so
that a tootltip is displayed at point; and in this scenario, they can be useful to me to quickly have some type of information.

You can also set this variable to force tooltips always in the echo
area:

(setq tooltip-use-echo-area t)

Anyway, I haven't given up on the idea of footnote tooltips yet. Here&#= 39;s
a new version of the code I attached in my first post in this thread,
and I think it's simpler now and works better, though I don't know = if it
might have any side effects... Footnote tooltips are activated with the
minor mode `my-org-fn-tooltip-mode'.

A new demo video:

https://cloud.disroot.org/s/sBGJjCzbYgYbn5k

Best regards,

Juan Manuel

--0000000000001cfa5b05d8b6a9dd--