Skip to content

Conversation

ilyagr
Copy link
Contributor

@ilyagr ilyagr commented Dec 9, 2023

Previously, you needed to set _ZL_HYPHEN=1 to treat - as a normal
character. Otherwise, it was treated as a Lua regexp special character, see
https://www.lua.org/pil/20.2.html. Note that it is not super-useful to treat
- as a special character; it is almost the same as * and the difference
is not very useful in the context of fuzzy matching.

Now, if _ZL_HYPHEN is not set, z.lua first tries to treat it as a regexp
character. If there are no results (which is likely if the user does not know
it's a special character), z.lua tries again, treating - as a normal
character this time.

If _ZL_HYPHEN=0 or _ZL_HYPHEN=1, z.lua will always treat - as
either a regex symbol or as a normal character (respectively).

Hopefully, this will make the FAQ at
https://github.com/skywind3000/z.lua/wiki/FAQ#how-to-input-a-hyphen---in-the-keyword-
unnecessary. It took me weeks to look into the question of why z home-manager refused to work and to find that FAQ.

I only tested this briefly, but it seems to work.

…ults

Previously, you needed to set `_ZL_HYPHEN=1` to treat `-` as a normal
character.  Otherwise, it was treated as a Lua regexp special character, see
https://www.lua.org/pil/20.2.html. Note that it is not super-useful to treat
`-` as a special character; it is almost the same as `*` and the difference
is not very useful in the context of fuzzy matching.

Now, if `_ZL_HYPHEN` is not set, z.lua first tries to treat it as a regexp
character. If there are no results (which is likely if the user does not know
it's a special character), z.lua tries again, treating `-` as a normal
character this time.

If `_ZL_HYPHEN=0` or `_ZL_HYPHEN=1`, z.lua will always treat `-` as
either a regex symbol or as a normal character (respectively).

Hopefully, this will make the FAQ at
https://github.com/skywind3000/z.lua/wiki/FAQ#how-to-input-a-hyphen---in-the-keyword-
unnecessary.  It took me weeks to look into the question of why `z
home-manager` refused to work and to find that FAQ. 

I only tested this briefly, but it seems to work.
@skywind3000
Copy link
Owner

I believe this is a better solution than current z.lua’s method, will look into it ASAP

@ilyagr
Copy link
Contributor Author

ilyagr commented Dec 9, 2023

Another option would be to merge the two sets of results if _ZL_HYPHEN is not defined. Usually, it would be equivalent; the only question is which is less surprising. I'm happy with either.

@skywind3000 skywind3000 merged commit 9921340 into skywind3000:master Dec 10, 2023
@skywind3000
Copy link
Owner

thanks

@ilyagr ilyagr deleted the hyphens branch December 10, 2023 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants