-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
TL;DR: No completions for man pages with aliases are shown using BSD's mandoc.
Environment
❯ echo $version
3.3.1
~
❯ uname -a
Linux poweriglu 5.13.19_1 #1 SMP Sat Sep 18 18:18:26 UTC 2021 x86_64 GNU/Linux
~
❯ echo $TERM
rxvt-unicode-256color
~
❯ cat /etc/os-release | grep "^NAME"
NAME="void"
mdocml (mandoc) version: 1.14.5
I also tried a FreeBSD virtual machine and found the same behaviour.
Problem description and reproduction
Man pages with aliases are not completed, for example man apr<tab> only completes to man aprofutil but does not offer a completion option for apropos although the man page exists and is indexed. More precisely, no pages with aliases are shown.
Reason
__fish_complete_man.fish works on the output of apropos which in the case of BSD's mandoc has the following form.
❯ apropos true
true(1) - do nothing, successfully
❯ apropos apropos
apropos, whatis, mandoc-apropos, mandoc-whatis(1) - search manual page databases
❯ apropos infocmp
infocmp(1, 1M, 1m) - compare or print out terminfo descriptions
The implementation doesn't work for the second example and it doesn't show the section for infocmp.
Further remarks
Looking at the code for the four different apropos implementations, it is not quite clear to me what the intended behaviour is. The BSD version tries to iterate over the aliases while the others seem to just print the first name. Giving completions for all aliases is far more user-friendly IMO.
Fix
I've written a possible fix for BSD's apropos, which, for the following (imaginary) apropos output creates the three lines shown below.
❯ apropos abc
xyz, abc, abcdef(1, 2X) - hello world
xyz, 1, 2X: hello world
abc, 1, 2X: hello world
abcdef, 1, 2X: hello world
This would yield the two compltions for man ab<tab>:
abc (1, 2X: hello world)
abcdef (1, 2X: hello world)
