emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: John Kitchin <johnrkitchin@gmail.com>
To: "Juan Manuel Macías" <maciaschain@posteo.net>
Cc: orgmode <emacs-orgmode@gnu.org>
Subject: Re: Footnote tooltips (an attempt)
Date: Thu, 24 Feb 2022 08:01:33 -0500	[thread overview]
Message-ID: <CAJ51ETqn1b9m0cezkAcoZbCnXm4n9xKd3StfLjWP589JRU5q-A@mail.gmail.com> (raw)
In-Reply-To: <87pmndrpet.fsf@posteo.net>

[-- Attachment #1: Type: text/plain, Size: 2771 bytes --]

that is a nice solution. I probably should have read the docstring on
org-footnote-get-definition  a little more closely, it has the definition
you need in it!

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 9:04 PM Juan Manuel Macías <maciaschain@posteo.net>
wrote:

> Hi John,
>
> John Kitchin writes:
>
> > 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.
>
> Thank you very much for your comment and code, which has helped me to
> clarify my ideas. Your approach is in a certain way similar to the last
> version of my attempt, which I attached in the previous message: through
> a first function I get the definition of each note, which is returned as
> a text string. And I also override via `advice-add'
> 'org-activate-footnonte-links' with a new function, which is also
> slightly modified, including a variable that gets the tooltip from the
> first function. The problem is that with my approach the tooltip does
> not appear on the fly, but when the next note is added. I think what my
> first function (the one that gets the footnote definition) was missing
> was the three arguments of your first function: `_win _obj position' and
> the (goto-char position), and pass it as a symbol (not as a variable) to
> the second function that overrides org-activate-footnote-links, as you
> do in your code. Modifying my function from your code, it would look
> something like this:
>
> (defun my-org-fn-get-def (_win _obj position)
>   (save-excursion
>     (goto-char position)
>     (let* ((el (org-element-context))
>            (label (org-element-property :label el))
>            (def (nth 3 (org-footnote-get-definition label))))
>       (when def (concat "Footnonte: " def)))))
>
> And it seems that now the tooltips appear instantly, and are updated in
> real time.
>
> Best regards,
>
> Juan Manuel
>

[-- Attachment #2: Type: text/html, Size: 3511 bytes --]

  reply	other threads:[~2022-02-24 13:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.57.1645549224.6185.emacs-orgmode@gnu.org>
2022-02-22 22:30 ` Footnote tooltips (an attempt) Ypo
2022-02-23  2:26   ` Juan Manuel Macías
     [not found]     ` <CAJcAo8tsK5o+789Wv=i6ddiSrM4fDyX8HCvjAgDLXGyLXWRWmQ@mail.gmail.com>
2022-02-23 19:52       ` Juan Manuel Macías
2022-02-23 22:05         ` John Kitchin
2022-02-24  2:04           ` Juan Manuel Macías
2022-02-24 13:01             ` John Kitchin [this message]
2022-02-24 16:25               ` Juan Manuel Macías
2022-02-22  4:32 Juan Manuel Macías
2022-02-22 22:15 ` Juan Manuel Macías

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJ51ETqn1b9m0cezkAcoZbCnXm4n9xKd3StfLjWP589JRU5q-A@mail.gmail.com \
    --to=johnrkitchin@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=maciaschain@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).