-
Notifications
You must be signed in to change notification settings - Fork 68
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 for custom actions on enter/meta-enter #96
Conversation
The custom actions may be set using zstyle configuration. Configuration is set in the following way: zstyle ':zaw:<source-name>' default "<func-name|action description>" zstyle ':zaw:<source-name>' alt "<func-name|action description>"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feature should be merged, but some implementations are not good :< Please revise them.
zaw.zsh
Outdated
@@ -70,6 +70,29 @@ function zaw-register-src() { | |||
eval "zle -N ${widget_name}" | |||
} | |||
|
|||
function zaw-replace-descriptions-with-action-names() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically, specifying the action by name is not good idea. We should use zstyle ':zaw:git-files' alt zaw-callback-edit-file
style setting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. If I do that I might add some code for action name discovery as well.
zaw.zsh
Outdated
fi | ||
done | ||
zstyle_name="${(L)name// /-}" | ||
zstyle -s ":zaw:${zstyle_name}" default action_default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
action_default
and action_alt
should be local
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two values are required outside the function in the current implementation. I’ll see what I can do.
zaw.zsh
Outdated
;; | ||
select-action) | ||
if [[ ${#actions} -eq 1 ]]; then | ||
action="${actions[1]}" | ||
else | ||
act_descriptions[${actions[(ie)$action_default]}]+=" (Enter)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can change key map of accept-line
and accept-search
using bindkey
. Then the keymap may be different from Enter and Meta-Enter. This marker is then misleading.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah. Did not realise that. I’ll adjust.
I think I've addressed your comments @termoshtt. Thanks for the feedback. |
OK, looks good for me. Thanks your contribution! |
No worries. |
The custom actions may be set using zstyle configuration. Configuration
is set in the following way:
Also add "(Enter)" or "(Meta-enter)" to the description of actions when
selecting an action.
An example:
Now using Enter/Meta-enter will use the actions mentioned above. When tab is hit and an action is being selected, the following will be displayed, highlighting the default/alt actions for future use: