Merge remote-tracking branch 'lenormf/fix-4273'

This commit is contained in:
Maxime Coste 2021-09-26 10:56:07 +10:00
commit fb734cb61b

View File

@ -136,29 +136,30 @@ define-command -params 1 -hidden doc-render %{
define-command -params 0..2 \ define-command -params 0..2 \
-shell-script-candidates %{ -shell-script-candidates %{
if [ "$kak_token_to_complete" -eq 0 ]; then case "$kak_token_to_complete" in
find -L \ 0)
"${kak_config}/autoload/" \
"${kak_runtime}/doc/" \
"${kak_runtime}/rc/" \
-type f -name "*.asciidoc" |
sed 's,.*/,,; s/\.[^.]*$//'
elif [ "$kak_token_to_complete" -eq 1 ]; then
page=$(
find -L \ find -L \
"${kak_config}/autoload/" \ "${kak_config}/autoload/" \
"${kak_runtime}/doc/" \ "${kak_runtime}/doc/" \
"${kak_runtime}/rc/" \ "${kak_runtime}/rc/" \
-type f -name "$1.asciidoc" | -type f -name "*.asciidoc" 2>/dev/null |
head -1 sed 's,.*/,,; s/\.[^.]*$//';;
) 1)
if [ -f "${page}" ]; then page=$(
awk ' find -L \
/^==+ +/ { sub(/^==+ +/, ""); print } "${kak_config}/autoload/" \
/^\[\[[^\]]+\]\]/ { sub(/^\[\[/, ""); sub(/\]\].*/, ""); print } "${kak_runtime}/doc/" \
' < $page | tr '[A-Z ]' '[a-z-]' "${kak_runtime}/rc/" \
fi -type f -name "$1.asciidoc" 2>/dev/null |
fi head -1
)
if [ -f "${page}" ]; then
awk '
/^==+ +/ { sub(/^==+ +/, ""); print }
/^\[\[[^\]]+\]\]/ { sub(/^\[\[/, ""); sub(/\]\].*/, ""); print }
' < $page | tr '[A-Z ]' '[a-z-]'
fi;;
esac
} \ } \
doc -docstring %{ doc -docstring %{
doc <topic> [<keyword>]: open a buffer containing documentation about a given topic doc <topic> [<keyword>]: open a buffer containing documentation about a given topic
@ -176,7 +177,7 @@ define-command -params 0..2 \
"${kak_config}/autoload/" \ "${kak_config}/autoload/" \
"${kak_runtime}/doc/" \ "${kak_runtime}/doc/" \
"${kak_runtime}/rc/" \ "${kak_runtime}/rc/" \
-type f -name "$topic.asciidoc" | -type f -name "$topic.asciidoc" 2>/dev/null |
head -1 head -1
) )
if [ -f "${page}" ]; then if [ -f "${page}" ]; then