minad / marginalia

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

Feature request: `marginalia-excluded-files` (similar to `consult-preview-excluded-files`) #157

Closed sdevlin closed 1 year ago

sdevlin commented 1 year ago

The consult.el package offers a customization consult-preview-excluded-files that lets you set a list of regexps to prevent previewing certain files. This is useful in case certain files take a long time to load.

Marginalia's default file annotator annotates local files using values returned from file-attributes. It skips this lookup for remote paths, presumably for performance and/or reliability reasons.

But file-attributes can still be expensive for file paths that appear local, e.g. in the case of a network file system mounted to a local path.

Would it be possible to add a marginalia-excluded-files customization similar to consult-preview-excluded-files to force Marginalia to skip certain files? Alternately, maybe there could be a list like marginalia-annotate-file-functions that could choose to handle annotations for any given file?

Thanks!

minad commented 1 year ago

I think this use case is a bit too special. If your fs is slow, you can disable the annotator via the registry or via marginalia-cycle. An annotator also doesn't involve a lot of code. You can write your own annotator (a small wrapper around the existing file annotator) and register it in marginalia-annotator-registry.

sdevlin commented 1 year ago

Fair enough, thanks for considering it.

minad commented 1 year ago

I believe your proposal of a marginalia-annotate-file-functions is effectively quite similar to what you get if you just add your custom annotator to the marginalia-annotator-registry. Therefore I am happier if we keep things simple. There is nothing wrong with writing custom annotators. Marginalia supports cycling for that reason, so you could keep both variants. If you have special use cases you may also want to add custom fields?