bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#73656: 30.0.91; icomplete-vertical has no matches for M-x man RET ch


From: Van Ly
Subject: bug#73656: 30.0.91; icomplete-vertical has no matches for M-x man RET chdir
Date: Sun, 17 Nov 2024 05:34:35 +0000

Eli Zaretskii <eliz@gnu.org> writes:

> Ping! Can you try this patch?  If it solves the problem, I'd like us
> to install it.



The patch as received, applied works on debian, netbsd.



diff -u /u/van/src/emacs/30.0.91/lisp/man.el.original 
/u/van/src/emacs/30.0.91/lisp/man.el
--- /u/van/src/emacs/30.0.91/lisp/man.el.original       2024-11-11 
03:14:07.625129807 +1100
+++ /u/van/src/emacs/30.0.91/lisp/man.el        2024-11-17 16:22:08.348331007 
+1100
@@ -972,6 +972,27 @@
                     table)
               (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 (and (> lines 0) (>= (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
@@ -1007,9 +1028,13 @@
             ;; error later.
             (when (eq 0
                       (ignore-errors
-                        (process-file
+                        (apply
+                         #'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 +1046,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

Diff finished.  Sun Nov 17 16:29:12 2024


-- 
vl





reply via email to

[Prev in Thread] Current Thread [Next in Thread]