bastibe/annotate.el

[new feature] using margins to print annotation's text

cage2 opened this issue · 8 comments

cage2 commented

Emacs have, indeed, margins as display property:

https://www.gnu.org/software/emacs/manual/html_node/elisp/Display-Margins.html

Annotations could be displayed there.

Problems:

  • horizontal position (left? Right? Depending of the language?)
  • vertical position (on the first line of the annotated text or on the last?)
  • replace current way of display annotations? Or add this new way of displaying as optional, an in that case, what default?
  • ...

Comments welcome! :)
Bye!
C.

That looks useful indeed! If I remember correctly, however, the margins are a fixed portion of the buffer width. I thought they were mostly used for single-character "annotations", like the little arrow that says a line continues off screen.

So if we enlarge to the margins to print into them, this might restrict the buffer width, and cut off long lines. I might be wrong, though.

The advantage of our current approach is that we can have a long, non-intrusive annotation at the end of a short line, and overflow gracefully for long lines. This flexibility would probably be lost if we print to the margins.

But at any rate, there's nothing wrong with providing both display methods as an option. Perhaps even chosen automatically based on the frame width (and content width?).

cage2 commented

I think there was some discussion about customizable display styles at some point. At the time we were musing different styles such as

  • annotations after the end of the annotated line
  • annotations always on the next (virtual) line
  • annotations at a fixed X-position on the line
  • annotations intelligently choosing a good position (the way we do it now)

And we could add more ideas, like

  • annotations in the margin
  • annotations in the minibuffer only
  • annotations in the tooltip only
  • annotations that pop up if under point
  • annotations in a floating child frame
  • etc.

Anyway, that's all just ideas. It'll be interesting to play with a few variants and see how they behave in practice!

cage2 commented

Hi!

Unfortunately i have bad news for this feature: the text on the margin can not be split in multiple lines, and this is an hard stop for annotate.el to take advantage of Emacs margins. :(

(unless a better idea comes to someone of course! :-) )

Probably we could use margins to display images instead of text, but this needs a bit of investigation.

Bye!
C.

It might be possible to show an icon in the margin, with the annotation in a tooltip. But I'm just thinking out loud here, so this might be a bad idea 😁.

cage2 commented

Hi!

It might be possible to show an icon in the margin, with the annotation in a tooltip. But I'm just thinking out loud here, so this might be a bad idea grin.

As we already have the option to show the annotation in a tooltip (even if this behaviour was incidental! :)) i think would be a wonderful improvement to put an icon/button in the margin that - when pressed- shows the annotations! I definitely want to investigate if such feature is doable!

Bye!
C.

By the way: I don't use annotate.el frequently, as most of our workflows involve integrated tools like gitlab. But yesterday I did a code review for one of my students, and got to use annotate.el for it. It truly is a joy to use! Thank you for maintaining it!

cage2 commented