From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#3717: M-x man completion Date: Tue, 30 Jun 2009 00:02:33 +0200 Message-ID: References: <87bpo63gxh.fsf@jidanni.org> Reply-To: Stefan Monnier , 3717@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1246313869 7442 80.91.229.12 (29 Jun 2009 22:17:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 29 Jun 2009 22:17:49 +0000 (UTC) Cc: 3717@emacsbugs.donarmstrong.com To: jidanni@jidanni.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jun 30 00:17:42 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MLPAT-0002fC-88 for geb-bug-gnu-emacs@m.gmane.org; Tue, 30 Jun 2009 00:17:41 +0200 Original-Received: from localhost ([127.0.0.1]:47720 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MLPAS-0004eO-CE for geb-bug-gnu-emacs@m.gmane.org; Mon, 29 Jun 2009 18:17:40 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MLPAL-0004cP-T6 for bug-gnu-emacs@gnu.org; Mon, 29 Jun 2009 18:17:33 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MLPAG-0004ZN-54 for bug-gnu-emacs@gnu.org; Mon, 29 Jun 2009 18:17:32 -0400 Original-Received: from [199.232.76.173] (port=51279 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MLPAF-0004Yz-Jw for bug-gnu-emacs@gnu.org; Mon, 29 Jun 2009 18:17:27 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:40729) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MLPAE-0001Ub-Ty for bug-gnu-emacs@gnu.org; Mon, 29 Jun 2009 18:17:27 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n5TMHOjk018717; Mon, 29 Jun 2009 15:17:25 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.14.3/8.14.3/Submit) id n5TMA50l017273; Mon, 29 Jun 2009 15:10:05 -0700 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Stefan Monnier Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Mon, 29 Jun 2009 22:10:05 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: followup 3717 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 3717-submit@emacsbugs.donarmstrong.com id=B3717.124631295915541 (code B ref 3717); Mon, 29 Jun 2009 22:10:05 +0000 Original-Received: (at 3717) by emacsbugs.donarmstrong.com; 29 Jun 2009 22:02:39 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from smtp-01.vtx.ch (smtp-01.vtx.ch [212.147.0.84]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n5TM2YWZ015536 for <3717@emacsbugs.donarmstrong.com>; Mon, 29 Jun 2009 15:02:35 -0700 Original-Received: from alfajor.home (dyn.144-85-166-002.dsl.vtx.ch [144.85.166.2]) by smtp-01.vtx.ch (VTX Services SA) with ESMTP id 7A3A0280EA; Tue, 30 Jun 2009 00:02:33 +0200 (CEST) Original-Received: by alfajor.home (Postfix, from userid 20848) id 4FF1464346; Tue, 30 Jun 2009 00:02:33 +0200 (CEST) In-Reply-To: <87bpo63gxh.fsf@jidanni.org> (jidanni@jidanni.org's message of "Tue, 30 Jun 2009 04:48:10 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.94 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Resent-Date: Mon, 29 Jun 2009 18:17:32 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:29092 Archived-At: >>>>> "jidanni" == jidanni 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))))