GNU bug report logs - #73656
30.0.91; icomplete-vertical has no matches for M-x man RET chdir

Previous Next

Package: emacs;

Reported by: Van Ly <van.ly <at> sdf.org>

Date: Sun, 6 Oct 2024 12:44:02 UTC

Severity: normal

Found in version 30.0.91

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Van Ly <van.ly <at> SDF.ORG>
Cc: eliz <at> gnu.org, 73656 <at> debbugs.gnu.org
Subject: bug#73656: 30.0.91; icomplete-vertical has no matches for M-x man RET chdir
Date: Thu, 31 Oct 2024 14:15:55 -0400
[Message part 1 (text/plain, inline)]
>>> +                         (if (eq system-type 'berkeley-unix) "-l")
> As gap filler, the following change does not misbehave on deb or netbsd.

I don't think we need a gap filler.
How 'bout the patch below?


        Stefan
[man.patch (text/x-diff, inline)]
diff --git a/lisp/man.el b/lisp/man.el
index 816c75d749c..ebf4646d133 100644
--- a/lisp/man.el
+++ b/lisp/man.el
@@ -973,6 +973,27 @@ Man-parse-man-k
               (search-forward-regexp "\\=, *\\([^ \t,]+\\)" bound t)))))
     (nreverse table)))
 
+(defvar Man-man-k-flags
+  ;; It's not clear which man page will "always" be available, `man -k man'
+  ;; seems like the safest choice, but `man -k apropos' seems almost as safe
+  ;; and usually returns a much shorter output.
+  (with-temp-buffer
+    (with-demoted-errors "%S" (call-process "man" nil t nil "-k" "apropos"))
+    (let ((lines (count-lines (point-min) (point-max)))
+          (completions (Man-parse-man-k)))
+      (if (>= (length completions) lines)
+          '("-k") ;; "-k" seems to return sane results: look no further!
+        (erase-buffer)
+        ;; Try "-k -l" (bug#73656).
+        (with-demoted-errors "%S" (call-process "man" nil t nil
+                                                "-k" "-l" "apropos"))
+        (let ((lines (count-lines (point-min) (point-max)))
+              (completions (Man-parse-man-k)))
+          (if (>= (length completions) lines)
+              '("-k" "-l") ;; "-k -l" seems to return sane results.
+            '("-k"))))))
+  "List of arguments to pass to get the expected \"man -k\" output.")
+
 (defun Man-completion-table (string pred action)
   (cond
    ;; This ends up returning t for pretty much any string, and hence leads to
@@ -1009,7 +1009,10 @@
                       (ignore-errors
                         (process-file
                          manual-program nil '(t nil) nil
-                         "-k" (concat (when (or Man-man-k-use-anchor
+                         ;; FIXME: When `process-file' runs on a remote hosts,
+                         ;; `Man-man-k-flags' may be wrong.
+                         `(,@Man-man-k-flags
+                           ,(concat (when (or Man-man-k-use-anchor
                                                 (string-equal prefix ""))
                                         "^")
                                       (if (string-equal prefix "")
@@ -1021,7 +1024,7 @@
                                         ;; But we don't have that, and
                                         ;; shell-quote-argument does
                                         ;; the job...
-                                        (shell-quote-argument prefix))))))
+                                      (shell-quote-argument prefix)))))))
               (setq table (Man-parse-man-k)))))
 	;; Cache the table for later reuse.
         (when table

This bug report was last modified 265 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.