Subject: bug#16722: 24.3.50; `M-x man' does not handle case appropriately

From: Wolfgang Jenkner <[email-masked]>
Date: Sun, 16 Feb 2014 01:28:37 +0100

On Sat, Feb 15 2014, Drew Adams wrote:

>> > M-x man RET
>> > Hitting TAB (with no minibuffer input) completes the empty input
>> > to the two chars `^:'.
>> 
>> This is a consequence of (1) and (2) below; the OP could confirm
>> (1),
>
> If I do `man -k ls' or `man -k "ls"' or `man -k ^l' or `man -k "^l"
> then I get only the message "ls: nothing appropriate" (or the same
> with ^l instead of ls).
>
> However, if (in bash, outside Emacs) I type `man ls' or `man "ls"'
> then I get the normal `man' page output/behavior for `ls'.

Your man pages live in subdirectories of a small number of "root"
directories.  Let's assume that you have only one of those root
directories, say /usr/share/man.  If you type `man ls' the output comes
from a file /usr/share/man/man1/ls.1 (or perhaps from a pre-formatted
file /usr/share/man/cat1/ls.1 or perhaps from one of those with a .gz
suffix or something like that).

However, the output for `man -k ls' comes from a different file (the
same one for all man pages under this root directory), namely
/usr/share/man/whatis (other man packages may use a file with
a different name).

Since `man -k ls' doesn't give a summary for the `ls' man page I think
that

>> (1) `man -k' can't find any whatis database or all those files are
>> empty.

At least it doesn't have an entry for ls.  You should be able to create
this file by running the `makewhatis' command.

>> (2) This particular `man -k' sends "^: nothing appropriate" to
>> stdout and not to stderr (if the distinction is meaningful on
>> cygwin), which is supposed to mean that it's a line "from the
>> summary database", see
>> http://pubs.opengroup.org/onlinepubs/009696799/utilities/man.html
>> 
>> > Thereafter I can do nothing with that.  Whether I type
>> > anything after the `^:' or not, TAB just completes to `^:'.
>> 
>> I think that has been fixed as a by-product of a 2013-01-10 change:
>> 
>> 	(man): Flush the completion cache between uses.
>
> Not sure what you mean, but the behavior is not fixed for me.
> I still get exactly the same behavior I reported, even with Emacs
> builds from only a few days ago.

IIUC, you had the following in mind:

M-x man RET TAB C-g M-x man RET l TAB

used to give `^:' (because the cache of man page name completions was
not flushed between invocations of man).

If you set Man-man-k-use-anchor to t it should give [No match] now.

>> I.e., the behaviour is now described by
>> 
>> > If I instead first type `l' (as in `ls') and then hit TAB, I get
>> > [No match].  It doesn't seem to matter what I type in the minibuffer:
>> > TAB always says [No match].
>> 
>> which seems to be irreproachable in the light of (1) above.
>
> Dunno what that means, but that is still the behavior I see: there
> is no completion for `M-x man'.

As explained above the source for the completions is the `whatis' file
at a man root directory.  As for `irreproachable', I found it funny to
describe the behaviour in "moral" terms, sorry if this was confusing.

Wolfgang