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

Expand abbr explicitly #5762

merged 4 commits into from
Apr 1, 2019

Expand abbr explicitly #5762

merged 4 commits into from
Apr 1, 2019


Copy link

@faho faho commented Mar 24, 2019


Currently, abbrs are expanded if self-insert inserts a space, \r or \n.

That's really quite hacky and stops it from working if space is rebound.

Instead, we implement a "expand-abbr" bind function that can be bound if a key should trigger expansion. By default it is bound for space in the applicable bindings and modes (i.e. vi-insert, emacs). Usually \n or \r are bound to execute anyway so binding that should be unnecessary.

The execute function still triggers expansion because that's a bigger change, though I'd very much like to do it.

Fixes #4898.


  • Changes to fish usage are reflected in user documentation/manpages.
  • Tests have been added for regressions fixed
  • User-visible changes noted in

This can be used to explictly allow expanding abbreviations.
NOTE: This accepts them for space only, we currently also do it for \n
and \r.
@faho faho added this to the fish 3.1.0 milestone Mar 24, 2019
We no longer trigger an abbr implicitly, so we can remove the code
that does it.
@faho faho changed the title Expand abbr explicit Expand abbr explicitly Mar 24, 2019
Copy link
Member Author

faho commented Mar 25, 2019

Also note that the code to expand space isn't beautiful - it's not possible to do purely via bind-functions, because self-insert reads another character, so we can't do expand-abbr or self-insert (also bind-functions have no or).

The alternative is to add a expand-abbr-or-self-insert function, but that seems like such a weird special thing.

Really, the entire bind-function DSL is weird, but I'm not sure how to fix them.

[ci skip]
@faho faho merged commit 0d72912 into fish-shell:master Apr 1, 2019
@faho faho deleted the expand-abbr-explicit branch April 1, 2019 14:07
Copy link

I made self-insert insert its sequence (which is usually empty, but not here) in 18b5663 , which gets us the "beautiful" space binding in e1f46d2

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

Successfully merging this pull request may close these issues.

Abbreviations aren't expanded when space is rebound
2 participants