annotate.el icon indicating copy to clipboard operation
annotate.el copied to clipboard

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

Open cage2 opened this issue 3 years ago • 8 comments

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.

cage2 avatar Feb 06 '22 13:02 cage2

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

bastibe avatar Feb 07 '22 19:02 bastibe

Hi!!

That looks useful indeed!

I think the same!

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.

I was confused at first (i was remembering the same as you) but if I have read correctly the documentation what you are mentioning here are the fringe indicators:

https://www.gnu.org/software/emacs/manual/html_node/elisp/Fringe-Indicators.html

While the margin are also an unreachable portion of the buffer but can contains arbitrary text (again if i did not checked wrong the documentation).

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

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.

I quite sure you are right, I think we have to try and see the results, i am thinking making this way to display annotations optional, but who knows? Maybe we could like so much the margins that this could be the default in the future, we'll see!

Bye! C.

cage2 avatar Feb 08 '22 18:02 cage2

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!

bastibe avatar Feb 09 '22 08:02 bastibe

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.

cage2 avatar May 26 '22 12:05 cage2

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

bastibe avatar May 30 '22 07:05 bastibe

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.

cage2 avatar Jun 02 '22 09:06 cage2

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!

bastibe avatar Jun 02 '22 11:06 bastibe

Hi!

[...] 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!

Thank you very much! To me this is one of the most appreciated phrase that can be wrote to someone that dedicated a lot of their spare time writing free software! :)

Bye! C.

cage2 avatar Jun 03 '22 10:06 cage2