minad / marginalia

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

Support prefix as well as suffix, e.g., for icons? #50

Closed mohkale closed 3 years ago

mohkale commented 3 years ago

Is there any intention to add support for specifiying a prefix as well as a suffix?

My use case is that I'm trying to port ivy-bibtex to selectrum with embark and marginalia.

Screenshot_20210118_170733

As you can see the bibtex-completion package already has a desired display format for candidates with authors as a prefix, title and then metadata as a suffix. I could probably implement the suffix annotations by adding to marginalia-annotators-light but there doesn't seem to be support for adding a prefix.

If there isn't I'd apreciate if you could redirect me to other sources that could help. Annotations are a really new feature and there doesn't seem to be very much documentation (that I can find).

minad commented 3 years ago

Yes, potentially there could be support for prefixes via the Emacs 28 affixation function. This is already supported by Selectrum. However I am unsure if the use case you have in mind with authors is really a good fit for prefix annotations. From what I've seen the prefix annotations are more meant to be very short annotations like icons or single character annotations to categorize the candidates. Emacs 28 itself uses this in describe-symbol to add the type of the symbol "v", "f", ... These are the same type letters used by Marginalia if you call describe-symbol. I am personally not very fond of prefixes and don't really see the need. For me it would be okay to only have suffixes since this keeps a clear distinction between candidates and annotations. I consider the distinction as important, since only the candidate part is matched on.

oantolin commented 3 years ago

If you want to be able to match against the author names, they should be a part of the candidates. If you want the author names to be just decoration, not something you can search for, then you can propertize the titles to display as author + title. (Personally, I would prefer to be able match author names.)

mohkale commented 3 years ago

@minad @oantolin

That's a fair point. I really only use ivy-bibtex to quickly insert pdftools links or open associated PDFs. I don't really recall ever using the author to get to an entry but I agree it's probably best to keep it around. Continuing on that point the only real annotation in this situation is the pdf indicator after the year. Everything else still seems like something you can narrow with so I guess it makes sense to just pre-format the entries and pass them as is to completing-read (that's what I'm doing now).

If you'd like to close this issue please go ahead. If I run into any situations which actually justify a prefix annotation I'll open it again. Thank you.

minad commented 3 years ago

Ok I close it for now! If we come up with something which should be a prefix annotation we can open a new issue.

bdarcus commented 3 years ago

Can I bring this up this again, because same use case (not sure it warrants a new issue)?

I was contemplating something like this mockup, where the icons (which indicate where there is note/pdf/link associated with the candidates) are the prefix.

Screenshot from 2021-03-13 15-04-00

Does that make sense then?

And at this point in 2021, with a new package, is affixation the way to go?

If yes, I just need an affixation function to add those icons?

PS - to the OP, I made use of the display property to display different content than the actual search string. But I would still put at least author, title, date in the display, and reserve suffix maybe for secondary metadata (say tags?), that still may be searched.

minad commented 3 years ago

See #59 for a recent discussion of icons. There we add icons using the affixation function based on the completion category. But since most of the work of such an addition is the association with the actual icons, it is out of scope of Marginalia. I don't want to distribute an icon set with Marginalia. There is all-the-icons, which has been proposed in #59. We don't want to introduce a dependency here, icons should better be provided by an all-the-icons-affixation package.

And at this point in 2021, with a new package, is affixation the way to go? If yes, I just need an affixation function to add those icons?

Yes and yes.

bdarcus commented 3 years ago

Gotcha. I was actually thinking my case is really simple, since we're only dealing with three icons, and right, doesn't really need marginalia at all. I was just wanting to confirm I understood the basic path.

bdarcus commented 3 years ago

FYI, in case anyone is interested, I started work on this, using all-the-icons (but not marginalia) here:

https://github.com/bdarcus/bibtex-actions/pull/37