GNU bug report logs - #3717
M-x man completion

Previous Next

Package: emacs;

Reported by: jidanni <at> jidanni.org

Date: Mon, 29 Jun 2009 20:55:04 UTC

Severity: wishlist

Merged with 4056

Found in version 1:20100118-1

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

Bug is archived. No further changes may be made.

Full log


Message #10 received at 3717 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: jidanni <at> jidanni.org
Cc: 3717 <at> debbugs.gnu.org
Subject: Re: bug#3717: M-x man completion
Date: Tue, 30 Jun 2009 00:02:33 +0200
>>>>> "jidanni" == jidanni  <jidanni <at> jidanni.org> writes:

> severity: wishlist
> I was thinking when M-x man prompts
>   Manual entry (default Neurdsburg):
> wouldn't it be neat if there was completion, just like for
> M-! shell-command...

I use the patch below.  It's very lightly tested.


        Stefan


=== modified file 'lisp/man.el'
--- lisp/man.el	2009-03-07 20:30:47 +0000
+++ lisp/man.el	2009-03-14 03:18:28 +0000
@@ -749,6 +749,22 @@
 ;;;###autoload
 (defalias 'manual-entry 'man)
 
+(defun Man-completion-table (string pred action)
+  (let ((table '()))
+    (with-temp-buffer
+      ;; Actually for my `man' the arg is a regexp.  Don't know how
+      ;; standard that is.  Also, it's not clear what kind of
+      ;; regexp are accepted: under GNU/Linux it seems it's ERE-style,
+      ;; whereas under MacOSX it seems to be BRE-style and
+      ;; doesn't accept backslashes at all.  Let's not bother to
+      ;; quote anything.
+      (call-process "man" nil '(t nil) nil "-k" (concat "^" string))
+      (goto-char (point-min))
+      (while (re-search-forward "^[^ \t\n]+" nil t)
+        (push (match-string 0) table)))
+    ;; The table may contain false positives since the match is made
+    ;; by "man -k" not just on the manpage's name.
+    (complete-with-action action table string pred)))
 
 ;;;###autoload
 (defun man (man-args)
@@ -765,12 +781,13 @@
 `Man-switches' variable, which see."
   (interactive
    (list (let* ((default-entry (Man-default-man-entry))
-		(input (read-string
+		(input (completing-read
 			(format "Manual entry%s"
 				(if (string= default-entry "")
 				    ": "
 				  (format " (default %s): " default-entry)))
-			nil 'Man-topic-history default-entry)))
+                        'Man-completion-table
+			nil nil nil 'Man-topic-history default-entry)))
 	   (if (string= input "")
 	       (error "No man args given")
 	     input))))



This bug report was last modified 15 years and 108 days ago.

Previous Next


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