emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Juan Manuel Macías" <maciaschain@posteo.net>
To: orgmode <emacs-orgmode@gnu.org>
Subject: Re: Footnote tooltips (an attempt)
Date: Tue, 22 Feb 2022 22:15:15 +0000	[thread overview]
Message-ID: <87mtii8s5o.fsf@posteo.net> (raw)
In-Reply-To: <87tucrzfkc.fsf@posteo.net> ("Juan Manuel Macías"'s message of "Tue, 22 Feb 2022 04:32:51 +0000")

I answer myself to comment a couple more things on this question of
footnotes and tooltips. I think my approach is quite poor, and also when
it comes to files with many notes, it takes a long time to create or
update the list of tooltips. So I think I'll give up on' footnote
tooltips. If what it is about is being able to see the content of a
footnote quickly, I have written this other simpler function, which
displays the content of a footnote at point, in the echo area. Since
`<C-h .>' (`display-local-help') is not very useful in a footnote
reference, I recycle the shortcut for my function, if the context is a
footnote reference. I share it here, in case it is useful to someone.

│ (defun my-org-footnote-show-content ()
│   "Displays the content of a footnote at point, in the echo area"
│   (interactive)
│   (if (not (equal (org-element-type (org-element-context)) 'footnote-reference))
│       (error "Not on a footnote reference!")
│     (let* ((elt (org-element-context))
│          (label (org-element-property :label elt))
│          (def (org-with-wide-buffer
│                (org-footnote-goto-definition label)
│                (let* ((e (org-element-context))
│                       (from (org-element-property :contents-begin e))
│                       (to (org-element-property :contents-end e)))
│                  (buffer-substring-no-properties from to)))))
│       (message def))))
│ (defun mi-display-local-help ()
│   (interactive)
│   (if (and (derived-mode-p 'org-mode)
│          (equal (org-element-type (org-element-context)) 'footnote-reference))
│       (my-org-footnote-show-content)
│     (call-interactively 'display-local-help)))
│ (global-set-key (kbd "C-h .") 'mi-display-local-help)

Best regards,

Juan Manuel

Juan Manuel Macías writes:

 Hi all,
> I think sometimes it would be nice to have tooltips in the footnote
> references, so I can see the contents of each footnote definition,
> especially when I'm in a narrowed subtree; so I've tried to write some
> code. I have achieved a "semi-automatic" solution. It doesn't work bad
> at all, but I'm not entirely convinced either. With a minor mode the
> `org-activate-footnote-links' function is overridden, and tooltips content
> for all footnotes in the document are added or updated after a couple of
> actions when you finish writing or editing a footnote:
> `org-edit-src-exit' and `org-mark-ring-goto'. And that's where the
> automatic part ends. Beyond that, tooltips must be updated/added by
> calling the `my-org-fn-make-tooltips' function.
> Here is a short video demo: https://cloud.disroot.org/s/a4gejYc6PSwNWHY
> I attach the code of my poor man's footnote tooltips. Of course, any
> comment and/or feedback is appreciated.
> Best regards,
> Juan Manuel

  reply	other threads:[~2022-02-22 22:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-22  4:32 Footnote tooltips (an attempt) Juan Manuel Macías
2022-02-22 22:15 ` Juan Manuel Macías [this message]
     [not found] <mailman.57.1645549224.6185.emacs-orgmode@gnu.org>
2022-02-22 22:30 ` 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
2022-02-24 16:25               ` 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:

  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=87mtii8s5o.fsf@posteo.net \
    --to=maciaschain@posteo.net \
    --cc=emacs-orgmode@gnu.org \


* 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


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).