minad / marginalia

:scroll: marginalia.el - Marginalia in the minibuffer
GNU General Public License v3.0
782 stars 27 forks source link

Annotations with pretty symbols? #88

Closed karthink closed 3 years ago

karthink commented 3 years ago

I'm writing a consult-based interface to reftex for better navigation to labels and inserting references:

2021-07-19-154751_924x644_scrot

(Code here.)

I want to show the equation annotations (which are clippings of the equation around the labels) with prettify-symbols (and subscripts, superscripts, etc) the way they appear in the tex buffer. Any idea how I would go about this? I checked prettify-symbols-mode (in prog-mode.el) to see how turning it on is handled:

(when (setq prettify-symbols--keywords (prettify-symbols--make-keywords))
    (font-lock-add-keywords nil prettify-symbols--keywords)
    (setq-local font-lock-extra-managed-props
                (append font-lock-extra-managed-props
                        '(composition
                          prettify-symbols-start
                          prettify-symbols-end)))
    (when prettify-symbols-unprettify-at-point
      (add-hook 'post-command-hook
                #'prettify-symbols--post-command-hook nil t))
    (font-lock-flush))

I guess this is primarily a question about font-locking in the minibuffer. Ideally I would be done if I could just turn on prettify-symbols-mode locally in the minibuffer for consult-reftex commands, but I don't know how to do that. Is it sufficient to find a way to apply the relevant text properties (composition, prettify-symbols-start and prettify-symbols-end) to the annotation text?

minad commented 3 years ago

Font locking in the minibuffer won't work well since the candidates are shown in an overlay. In order to show the prettified symbols you have to manually apply the transformation in the annotation function. I am looking forward to your reftex package!

karthink commented 3 years ago

Thank you, I thought this would be the case.

Understanding how the composition and other text properties are applied will take me a while. I'll work on other aspects for now and release the package soon, I can always replace the annotation function with the richer one later. I'll close this issue for now.