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

Show one-line descriptions for functions and builtins using Alt-W #7191

Closed
wants to merge 5 commits into from

Conversation

sudormrfbin
Copy link
Contributor

@sudormrfbin sudormrfbin commented Jul 11, 2020

Description

__fish_whatis_current_token (bound to Alt-W by default) currently prints information only for commands, using whatis. This PR aims to print information for builtins, functions (description specified with -d) and aliases in addition to the current implementation.

Even though man pages exist for builtins (and certain functions like funced), they aren't show by whatis because it isn't in $MANPATH (man works despite this by being overridden by a function; see functions man)

Closes #2083

TODO

  • Print desciptions for:
    • Builtins
    • Functions (and aliases)
  • User-visible changes noted in CHANGELOG.rst

By default __fish_whatis_current_token is bound to ALt-W
@sudormrfbin
Copy link
Contributor Author

Okay, whatis cannot be used to show descriptions for builtins even with setting $MANPATH because it relies on mandb databases, and the fish man pages are not in the db. Functions like funced with man pages are not really affected since they have a description along with the function definition.

@krobelus
Copy link
Member

I guess for builtins it could be like __fish_print_help builtin | awk '/^builtin /{print; exit}'

@sudormrfbin
Copy link
Contributor Author

Functions take precedence over commands now, and descriptions for builtins are also printed.

whatis $tok[1]
whatis $token 2>/dev/null

if test $status -eq 16 # no match found
Copy link
Member

Choose a reason for hiding this comment

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

The value 16 here is a Linux-ism. Looks like macOS and BSD return success even if nothing was found :( I'm not sure what to do - maybe just leave it.

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 changed the code so that commands have least precedence when searching for a description and it doesn't depend onwhatis's exit status.

@krobelus
Copy link
Member

Merged as 0c72e65 with a small fix for Alt-W on [, thanks!

@krobelus krobelus closed this Jul 11, 2020
@krobelus krobelus added this to the fish 3.2.0 milestone Jul 11, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

alt-w doesn't print the description of custom functions
3 participants