Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow users to set keys to be bind, before sourcing the script, using environment variables #123

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ericbn
Copy link
Contributor

@ericbn ericbn commented Aug 3, 2021

This will save users from some common boilerplate code in their own .zshrc file.

Fixes #107

README.md Outdated

* `HISTORY_SUBSTRING_SEARCH_VICMD_DOWN_KEYS` is a global array that defines the
VI mode keys to be bind to the `history-substring-search-down` command.
Its default value is `('j')`, which is the code for the `j` key.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's lots of repeating words in the above paragraphs, but I tried to keep the bullets layout. Maybe this could be reformatted as a table?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. I think the repetition is fine. If you really want to reformat this as a table, please make sure to do the same for all other configuration variables too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep the repetition here then, as you're fine with it. I can try a table layout later in a separate PR...

fi
if (( ! $+HISTORY_SUBSTRING_SEARCH_PREFIXED )); then
typeset -g HISTORY_SUBSTRING_SEARCH_PREFIXED=''
fi
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also fixing the issue with WARN_CREATE_GLOBAL, as I commented here: #108 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR #119 seems simpler than this implementation. I'm leaning toward merging it instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, that implementation is simpler. Let me update the PR and use that here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The typeset -g VAR="${VAR:=value}" construct does not seem correct to me, as is does the assignment twice: at ${VAR:=value} and also at typeset -g VAR="value", so I changed it to what seems more correct.

README.md Outdated
@@ -161,6 +130,51 @@ default values.
receive globally unique search results only once, then use this
configuration variable, or use `setopt HIST_IGNORE_ALL_DUPS`.

The following variables must be overridden before having loaded this script
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm hesitant about the "must" requirement here: it's helpful to provide these key arrays to simplify the new-user experience but currently, we don't require users to bind our widgets. They can choose to simply load our plugin and never actually use its functionality. This kind of basic "null" use-case should be preserved, I feel.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, so all these properties will be empty by default, in order to preserve the current "null" use-case. Let me change that and update the README accordingly.

Copy link
Member

@sunaku sunaku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR. Please see my feedback in the code review.

@ericbn
Copy link
Contributor Author

ericbn commented Aug 5, 2021

@sunaku, PR updated.

@ericbn ericbn requested a review from sunaku August 13, 2021 21:54
@ericbn ericbn changed the title Bind keys and allow users to override the default ones Allow users to set keys to be bind, before sourcing the script, using environment variables Aug 23, 2021
This will save users from some common boilerplate code in their own
.zshrc file.

Fixes zsh-users#107
@lnicola
Copy link

lnicola commented Nov 7, 2021

Nit: CONTROL is such a weird way to spell Ctrl.

@ericbn
Copy link
Contributor Author

ericbn commented Nov 7, 2021

It was being spelled as "Control" and "C" and also "^" before. I tried to unify it to a common format ("CONTROL"), as we have other keys in all caps too (e.g. "UP", "DOWN") in the same document.

Fun fact: my keycaps actually spell it as "Control" :- )
keycaps

@sunaku, what do you prefer?

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.

Consider setting up some default key bindings
3 participants