From f9447dc72f8161820785e8f3bebdd3d5c09dc9e7 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sat, 16 May 2020 11:19:45 +0200 Subject: [PATCH] help.fish: fix help for the separate completion page --- share/completions/help.fish | 15 ++++++++------- share/functions/__fish_print_commands.fish | 4 +++- share/functions/help.fish | 4 +++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/share/completions/help.fish b/share/completions/help.fish index 040ef38d3..a171f23ba 100644 --- a/share/completions/help.fish +++ b/share/completions/help.fish @@ -2,7 +2,7 @@ if test -d "$__fish_data_dir/man/man1/" complete -c help -x -a '(__fish_print_commands)' -d 'Help for this command' end -# Help topics +# Help topics in index.html # This was semi-automated with `grep 'class="anchor"' -A1 /usr/share/doc/fish/index.html # It's not fully automated since that requires parsing html with regex, # and since this is by definition in sync - we ship the html, and we ship these completions. @@ -11,12 +11,7 @@ complete -c help -x -a builtin-overview -d 'Builtin commands' complete -c help -x -a cartesian-product -d 'Cartesian Products' complete -c help -x -a color -d 'Setting syntax highlighting colors' complete -c help -x -a combine -d 'Combining different expansions' -complete -c help -x -a completion -d 'How tab-completion works' -complete -c help -x -a completion-func -d 'Useful functions for writing completions' -complete -c help -x -a completion-own -d 'Writing your own completions' -complete -c help -x -a completion-path -d 'Where to put completions' complete -c help -x -a debugging -d 'Debugging fish scripts' -complete -c help -x -a docs -d Help complete -c help -x -a editor -d 'Command line editor' complete -c help -x -a emacs-mode -d 'Emacs mode commands' complete -c help -x -a escapes -d 'Escaping characters' @@ -56,9 +51,10 @@ complete -c help -x -a syntax-function-autoloading -d 'Autoloading functions' complete -c help -x -a syntax-function-wrappers -d 'Defining aliases' complete -c help -x -a syntax-job-control -d 'Job control' complete -c help -x -a syntax-words -d 'Some common words' +complete -c help -x -a tab-completion -d 'How tab-completion works' complete -c help -x -a title -d 'Programmable title' complete -c help -x -a variables -d 'Shell variables' -complete -c help -x -a variables-arrays -d Arrays +complete -c help -x -a variables-lists -d Lists complete -c help -x -a variables-color -d 'Variables for changing highlighting colors' complete -c help -x -a variables-export -d 'Exporting variables' complete -c help -x -a variables-functions -d 'Variable scope for functions' @@ -72,6 +68,11 @@ complete -c help -x -a vi-mode-command -d 'Command mode' complete -c help -x -a vi-mode-insert -d 'Insert mode' complete -c help -x -a vi-mode-visual -d 'Visual mode' +# Completions +complete -c help -x -a completion-own -d 'Writing your own completions' +complete -c help -x -a completion-func -d 'Useful functions for writing completions' +complete -c help -x -a completion-path -d 'Where to put completions' + # Tutorial complete -c help -x -a tutorial -d Tutorial complete -c help -x -a tut_autoload -d 'Autoloading Functions' diff --git a/share/functions/__fish_print_commands.fish b/share/functions/__fish_print_commands.fish index 9eb15c858..0c79f354a 100644 --- a/share/functions/__fish_print_commands.fish +++ b/share/functions/__fish_print_commands.fish @@ -1,7 +1,9 @@ function __fish_print_commands --description "Print a list of documented fish commands" if test -d $__fish_data_dir/man/man1/ for file in $__fish_data_dir/man/man1/**.1* - string replace -r '.*/' '' -- $file | string replace -r '.1(.gz)?$' '' + string replace -r '.*/' '' -- $file | + string replace -r '.1(.gz)?$' '' | + string match -rv '^fish-(?:completions|doc|tutorial|faq)$' end end end diff --git a/share/functions/help.fish b/share/functions/help.fish index 22903cee2..b06fbd42c 100644 --- a/share/functions/help.fish +++ b/share/functions/help.fish @@ -18,7 +18,6 @@ function help --description 'Show help for the fish shell' end end - # # Find a suitable browser for viewing the help pages. # The first thing we try is $fish_help_browser. set -l fish_browser $fish_help_browser @@ -112,6 +111,7 @@ function help --description 'Show help for the fish shell' end end + set -l fish_help_page switch "$fish_help_item" case "." set fish_help_page "cmds/source.html" @@ -119,6 +119,8 @@ function help --description 'Show help for the fish shell' set fish_help_page "index.html#expand" case (__fish_print_commands) set fish_help_page "cmds/$fish_help_item.html" + case 'completion-*' + set fish_help_page "completions.html#$fish_help_item" case 'tut_*' set fish_help_page "tutorial.html#"(string sub -s 5 -- $fish_help_item | string replace -a -- _ -) case tutorial