emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Juan Manuel Macías" <maciaschain@posteo.net>
To: Ypo <ypuntot@gmail.com>
Cc: orgmode <emacs-orgmode@gnu.org>
Subject: Re: Footnote tooltips (an attempt)
Date: Wed, 23 Feb 2022 02:26:00 +0000	[thread overview]
Message-ID: <87ee3u8gjr.fsf@posteo.net> (raw)
In-Reply-To: <63ab1106-8aa7-4dd1-923b-04ac8fd4470a@gmail.com> (Ypo's message of "Tue, 22 Feb 2022 22:30:22 +0000 (UTC)")

Ypo writes:

> I love it!
> I am going to read your code, Juan Manuel, I won't understand anything
> but that function is very interesting for me, since it could be used
> too with internal links, I suppose.

Org links already have tooltips out of the box. You can also display the
tooltip in the echo area by pressing <C-h .> (`display-local-help').

If you want to try the code from my first post, please replace the
`my-org-fn-make-tooltips' function with this new version, which is much
simpler and doesn't have time-consuming issues to create or update
tooltips.

(However, I find the function I put in my second post more useful (for
my use case: I don't use the mouse very much).

#+begin_src emacs-lisp
  (defun my-org-fn-make-tooltips ()
    (interactive)
    (org-element-map (org-element-parse-buffer) 'footnote-reference
      (lambda (ref)
	(let* ((label (org-element-property :label ref))
	       (label-from (org-element-property :begin ref))
	       (label-to (org-element-property :end ref))
	       (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))))
	       (tooltip def))
	  (add-text-properties label-from label-to
			       `(help-echo
				 ,tooltip))))
      nil nil))
#+end_src

Best regards,

Juan Manuel 


  reply	other threads:[~2022-02-23  2:29 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 [this message]
     [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
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=87ee3u8gjr.fsf@posteo.net \
    --to=maciaschain@posteo.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=ypuntot@gmail.com \
    /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).