Skip to content

refactor(bash_completion): rename _get_comp_words_by_ref, etc. #886

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

Merged
merged 5 commits into from
Mar 10, 2023

Conversation

akinomyoga
Copy link
Collaborator

I had some pending changes for the naming convention in bash_completion, but let me submit it now.

One thing that I haven't yet decided is whether to strip _by_ref from the new names or not. I think the suffix _by_ref is added to differentiate them from the older versions that output the result to stdout. Now we deprecated these older versions and wouldn't try to prepare the new names _comp_* for these deprecated functions, so there is no need for the differentiation anymore. But perhaps it might still be better to keep the suffix to remind us of the unique convention of these functions that receive variable names in the arguments.

@akinomyoga
Copy link
Collaborator Author

I think this PR introduces conflicts in #870. I guess it is easier to first merge the change in the present version of PR #870, and then process this PR and other TODOs of #870 in separate PRs.

@scop
Copy link
Owner

scop commented Feb 22, 2023

Thanks for this and for considering #870. I completed the "load eagerly (additionally) from in-tree bash_completion.d dir for in-tree setups" TODO in it so we don't lose any functionality temporarily. Agreed the remaining TODOs in it can be addressed separately afterwards.

@akinomyoga akinomyoga marked this pull request as draft February 23, 2023 04:35
@akinomyoga
Copy link
Collaborator Author

akinomyoga commented Feb 23, 2023

I'll make this a Draft until finishing #870. After #870 is merged, I'll rebase this PR.

@akinomyoga akinomyoga force-pushed the refactor-funcname-2 branch 4 times, most recently from 084fe69 to bab3f8d Compare February 26, 2023 05:07
* refactor: `{ => _comp}_upvars`
* refactor: `{ => _comp}__reassemble_comp_words_by_ref`
* refactor: `{ => _comp}__get_cword_at_cursor_by_ref`
* refactor: `{ => _comp}_get_comp_words_by_ref`
* rename `_comp_get{_comp => }_words{_by_ref => }`
* rename `_comp__reassemble{_comp => }_words{_by_ref => }`
* rename `_comp__get_cword_at_cursor{_by_ref => }`
@akinomyoga akinomyoga marked this pull request as ready for review February 26, 2023 05:57
@akinomyoga
Copy link
Collaborator Author

I have rebased it.

I also moved the deprecated function _get_pword to bash_completion.d/000_bash_completion_compat (c2a87cc) and updated the codebase not to use the deprecated _get_cword and _get_pword (a2d8ac2).

It seemed shfmt and shellcheck were not applied to bash_completion.d/000_bash_completion_compat, so I added it in commit c43aead. I just enabled the file name of [0-9][0-9][0-9]_*, but it could accept arbitrary filenames, or another option could be to rename 000_bash_completion_compat{ => .sh or .bash} and enable the files of the name bash_completion.d/*.{bash,sh}.

e76ca14 is a suggestion for simplifying the function names.

Copy link
Owner

@scop scop left a comment

Choose a reason for hiding this comment

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

Nice!

@scop scop merged commit b577711 into scop:master Mar 10, 2023
scop added a commit that referenced this pull request Mar 10, 2023
Mainly for easy allowlisting and backup avoidance in pre-commit configs.

#886 (comment)
@scop
Copy link
Owner

scop commented Mar 10, 2023

or another option could be to rename 000_bash_completion_compat{ => .sh or .bash} and enable the files of the name bash_completion.d/*.{bash,sh}.

I like this, implementation with just *.bash in #899

@akinomyoga akinomyoga deleted the refactor-funcname-2 branch March 11, 2023 01:09
scop added a commit that referenced this pull request Mar 12, 2023
Mainly for easy allowlisting and backup avoidance in pre-commit configs.

#886 (comment)
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