Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [RFC PATCH v3] vcs_info: choose backend by basedir



Sorry for the delayed replies; I've been offline.  More below.

Aleksandr Mezin wrote on Mon, 02 Nov 2020 05:09 +0600:
> On Thu, Oct 29, 2020 at 7:28 AM Aleksandr Mezin
> <mezin.alexander@xxxxxxxxx> wrote:
> > It's possible to revert to the old behavior of vcs_info, by setting:
> >
> >     zstyle ':vcs_info:*' backend-choice enablement-order
> >  
> 
> Now I'm not sure if an "enum-like" zstyle is a good idea.
> 

Fair question.

> 1) Should I check somewhere that the string value is valid (i.e. it's
> either empty, or one of the predefined strings)?

(This question presumes we'll be keeping the enum-like design, so I'll
presume the same in my answer.)

If possible, please write the code so as to be forward compatible with
any new enum values we may add in the future.  That is, when reviewing,
we'll consider several cases:

- Style isn't set
- Style is set to one of the predefined strings
- Style is set to a string that will be predefined in a future version
  or to an invalid string (the code can't tell the difference)

Less likely cases include:

- The style is set to the empty array («zstyle $pattern $style» with no further arguments)
- The style is set to the empty string («zstyle $pattern $style ''»)
- The style is set to one of the predefined strings, plus some
  additional words

> 2) Extensibility: I don't think there will be another different mode
> that should be controlled by this zstyle. More likely, there will be
> parameters like "prefer non-ancestor vcs directories or not". And IMO
> they should have their own boolean zstyles, and not something like
> `backend-choice closest-vcs-dir-prefer-ancestors`. And even more
> likely, nobody will add anything there

About extensibility, needs for extensibility aren't always foreseen.

As to their own boolean styles, I'm not sure I agree.  zstyle values are
arrays, so we could let parameters be provided in additional words, as
in:
.
    zstyle $pattern $style enablement-order foo=bar
    zstyle $pattern $style closest-.vcs-dir lorem=ipsum

Hmm.  Perhaps it would make more sense to name the style "disk-layout",
and then the extra parameters could be used to choose whether to select
the closest or farthest .${vcs} dir.

Or perhaps an enum really is overkill, as you say.

Frank?

Cheers,

Daniel




Messages sorted by: Reverse Date, Date, Thread, Author