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

From: [email-masked]
Date: Wed, 01 Feb 2017 20:08:48 -0500

retitle 16722 [(old?) cygwin] `M-x man' completion doesn't handle broken `man -k' gracefully
quit

I found this post from 2014 explaining that the man package is replaced
by man-db, so the correct incantation is now `mandb' or `mandb -c' for
the first time.

https://cygwin.com/ml/cygwin/2014-07/msg00015.html
https://cygwin.com/faq/faq.html#faq.using.man

I can't reproduce the problem here, as my cygwin's man -k prints only to
stderr in this case.  Does checking exit status help?

--- i/lisp/man.el
+++ w/lisp/man.el
@@ -890,15 +890,18 @@ Man-completion-table
             ;; run differently in Man-getpage-in-background, an error
             ;; here may not necessarily mean that we'll also get an
             ;; error later.
-           (ignore-errors
-             (call-process manual-program nil '(t nil) nil
-                           "-k" (concat (when (or Man-man-k-use-anchor
-                                                  (string-equal prefix ""))
-                                          "^")
-                                        prefix))))
-         (setq table (Man-parse-man-k)))
+           (when (eq 0
+                      (ignore-errors
+                        (call-process
+                         manual-program nil '(t nil) nil
+                         "-k" (concat (when (or Man-man-k-use-anchor
+                                                (string-equal prefix ""))
+                                        "^")
+                                      prefix))))
+              (setq table (Man-parse-man-k)))))
        ;; Cache the table for later reuse.
-       (setq Man-completion-cache (cons prefix table)))
+       (when table
+          (setq Man-completion-cache (cons prefix table))))
       ;; The table may contain false positives since the match is made
       ;; by "man -k" not just on the manpage's name.
       (if section