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