From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 12 14:24:31 2012 Received: (at submit) by debbugs.gnu.org; 12 Dec 2012 19:24:31 +0000 Received: from localhost ([127.0.0.1]:39402 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tiruw-0003jX-Ad for submit@debbugs.gnu.org; Wed, 12 Dec 2012 14:24:31 -0500 Received: from eggs.gnu.org ([208.118.235.92]:49321) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tirus-0003jP-TO for submit@debbugs.gnu.org; Wed, 12 Dec 2012 14:24:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tiru0-0004wo-7o for submit@debbugs.gnu.org; Wed, 12 Dec 2012 14:23:38 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-101.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD,USER_IN_WHITELIST autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:51214) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tiru0-0004wi-4b for submit@debbugs.gnu.org; Wed, 12 Dec 2012 14:23:32 -0500 Received: from eggs.gnu.org ([208.118.235.92]:60625) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tirtr-0008Fu-Hu for bug-gnu-emacs@gnu.org; Wed, 12 Dec 2012 14:23:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tirtg-0004sf-Ue for bug-gnu-emacs@gnu.org; Wed, 12 Dec 2012 14:23:23 -0500 Received: from mx09.lb01.inode.at ([62.99.145.9]:59476 helo=mx.inode.at) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tirtg-0004s0-Fc for bug-gnu-emacs@gnu.org; Wed, 12 Dec 2012 14:23:12 -0500 Received: from [91.119.206.19] (port=11862 helo=iznogoud.viz) by smartmx-09.inode.at with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1Tirtd-0005m4-Gm; Wed, 12 Dec 2012 20:23:09 +0100 Received: from wolfgang by iznogoud.viz with local (Exim 4.80.1 (FreeBSD)) (envelope-from ) id 1TirtZ-0000b2-Rg; Wed, 12 Dec 2012 20:23:05 +0100 From: Wolfgang Jenkner To: bug-gnu-emacs@gnu.org Subject: 24.3.50; [PATCH] man page completion support beyond man-db Date: Wed, 12 Dec 2012 20:16:45 +0100 Message-ID: <856247krc6.fsf@iznogoud.viz> User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.118.235.17 X-Spam-Score: -6.9 (------) X-Debbugs-Envelope-To: submit Cc: Kevin Ryde X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) In lisp/man.el, completion of man pages and sections depends on parsing the output of `man -k'. As a bonus, this method provides short descriptions in the form of tooltips in the *Completions* buffer. However, the code only handles the `man -k' output format peculiar to the man-db package, which, even on GNU/Linux, is not the only one used for this purpose. For example, Slackware seems to use man-1.6g, whose `man -k' output can have an additional reference in square brackets between the page name and the section, so that man topic completion does work in this case, but neither sections nor descriptions are parsed. The situation is even worse for FreeBSD, where multiple comma-separated page names can be shown on the same line (which is arguably against the spirit of POSIX man(1p), but that's not quite clear and doesn't help much). The last major discussion of man completion issues seems to be bug#3717, through which I skimmed, but there doesn't seem to be anything related to this kind of portability. There is, however, some prior code in the `man-completion-cache' function in ftp://download.tuxfamily.org/user42/man-completion.el to deal with this problem. In particular, it handles the example boot-scripts (7) [boot] - General description of boot sequence where the present patch would miss the section. However, I don't know of a man program which actually produces this format (man-1.6g has the reference in square brackets /preceding/ the section). Otherwise, the following patch, which I'd like to install, should handle more formats. It mainly adds a single separate function for parsing various formats. There's also an ert test with examples for what I described above and other formats found on the web. Wolfgang === modified file 'lisp/man.el' --- lisp/man.el 2012-08-15 16:29:11 +0000 +++ lisp/man.el 2012-12-12 16:00:11 +0000 @@ -780,6 +780,57 @@ ;; but apparently that's not the case in all cases, so let's add a cache. "Cache of completion table of the form (PREFIX . TABLE).") +(defvar Man-keyword-completion-twiddle + (cond + ;; man-db-* or man-*. + ((memq system-type '(gnu gnu/linux gnu/kfreebsd)) + "^") + (t + "")) + "A string prepended to the keyword passed to `man -k' for completion. +This should usually be an extended regular expression. + +Actually, unwanted page names are weeded out anyway, so with an +empty string here we will always get correct results, but things +may take a bit longer.") + +(defun Man-parse-apropos (&optional table) + "Parse `man -k' output, prepend page names to TABLE and return that. + +The current buffer should contain the output of a command of the +form `man -k keyword', which is traditionally also available with +apropos(1). + +While POSIX man(1p) is a bit vague about what to expect here, +this function tries to parse some commonly used formats, which +can be described in the following informal way, with square brackets +indicating optional parts and whitespace being interpreted +somewhat loosely. + +foo[, bar [, ...]] [other stuff] (sec) - description +foo(sec)[, bar(sec) [, ...]] [other stuff] - description + +For more details and some regression tests, please see +test/automated/man-tests.el in the emacs bzr repository." + (goto-char (point-min)) + (while (search-forward-regexp "^\\([^ \t,\n]+\\)\\(.*?\\)\ +\\(?:[ \t]\\(([^ \t,\n]+?)\\)\\)?\\(?:[ \t]+- ?\\(.*\\)\\)?$" nil t) + (let ((section (match-string 3)) + (description (match-string 4)) + (bound (match-end 2)) + (continue (goto-char (match-end 1)))) + (while continue + ;; The first regexp grouping may already match the section + ;; tacked on to the name, which is ok since for the formats we + ;; claim to support the third (non-shy) grouping does not + ;; match in this case, i.e., section is nil. + (push (propertize (concat (match-string 1) section) + 'help-echo description) + table) + (setq continue (search-forward-regexp "\\=, *\\([^ \t,]+\\)" + bound t))))) + table) + (defun Man-completion-table (string pred action) (cond ;; This ends up returning t for pretty much any string, and hence leads to @@ -813,12 +864,9 @@ ;; error later. (ignore-errors (call-process manual-program nil '(t nil) nil - "-k" (concat "^" prefix)))) - (goto-char (point-min)) - (while (re-search-forward "^\\([^ \t\n]+\\)\\(?: ?\\((.+?)\\)\\(?:[ \t]+- \\(.*\\)\\)?\\)?" nil t) - (push (propertize (concat (match-string 1) (match-string 2)) - 'help-echo (match-string 3)) - table))) + "-k" (concat Man-keyword-completion-twiddle + prefix)))) + (setq table (Man-parse-apropos table))) ;; Cache the table for later reuse. (setq Man-completion-cache (cons prefix table))) ;; The table may contain false positives since the match is made === added file 'test/automated/man-tests.el' --- test/automated/man-tests.el 1970-01-01 00:00:00 +0000 +++ test/automated/man-tests.el 2012-12-08 17:10:24 +0000 @@ -0,0 +1,118 @@ +;;; man-tests.el --- Test suite for man. + +;; Copyright (C) 2012 Free Software Foundation, Inc. + +;; Author: Wolfgang Jenkner +;; Keywords: help, internal, unix + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Code: + +(require 'ert) +(require 'man) + +(defconst man-tests-parse-apropos-tests + '(;; GNU/Linux: man-db-2.6.1 + ("\ +sin (3) - sine function +sinf (3) - sine function +sinl (3) - sine function" + . (#("sinl(3)" 0 7 (help-echo "sine function")) #("sinf(3)" 0 7 (help-echo "sine function")) #("sin(3)" 0 6 (help-echo "sine function")))) + ;; GNU/Linux: man-1.6g + ("\ +sin (3) - sine function +sinf [sin] (3) - sine function +sinl [sin] (3) - sine function" + . (#("sinl(3)" 0 7 (help-echo "sine function")) #("sinf(3)" 0 7 (help-echo "sine function")) #("sin(3)" 0 6 (help-echo "sine function")))) + ;; FreeBSD 9 + ("\ +sin(3), sinf(3), sinl(3) - sine functions" + . (#("sinl(3)" 0 7 (help-echo "sine functions")) #("sinf(3)" 0 7 (help-echo "sine functions")) #("sin(3)" 0 6 (help-echo "sine functions")))) + ;; SunOS, Solaris + ;; http://docs.oracle.com/cd/E19455-01/805-6331/usradm-7/index.html + ;; SunOS 4 + ("\ +tset, reset (1) - establish or restore terminal characteristics" + . (#("reset(1)" 0 8 (help-echo "establish or restore terminal characteristics")) #("tset(1)" 0 7 (help-echo "establish or restore terminal characteristics")))) + ;; SunOS 5.7, Solaris + ("\ +reset tset (1b) - establish or restore terminal characteristics +tset tset (1b) - establish or restore terminal characteristics" + . (#("tset(1b)" 0 7 (help-echo "establish or restore terminal characteristics")) #("reset(1b)" 0 8 (help-echo "establish or restore terminal characteristics")))) + ;; Minix 3 + ;; http://www.minix3.org/manpages/html5/whatis.html + ("\ +cawf, nroff (1) - C version of the nroff-like, Amazingly Workable (text) Formatter +whatis (5) - database of online manual pages" + . (#("whatis(5)" 0 9 (help-echo "database of online manual pages")) #("nroff(1)" 0 8 (help-echo "C version of the nroff-like, Amazingly Workable (text) Formatter")) #("cawf(1)" 0 7 (help-echo "C version of the nroff-like, Amazingly Workable (text) Formatter")))) + ;; HP-UX + ;; http://docstore.mik.ua/manuals/hp-ux/en/B2355-60130/man.1.html + ;; Assuming that the line break in the zgrep description was + ;; introduced by the man page formatting. + ("\ +grep, egrep, fgrep (1) - search a file for a pattern +zgrep(1) - search possibly compressed files for a regular expression" + . (#("zgrep(1)" 0 8 (help-echo "search possibly compressed files for a regular expression")) #("fgrep(1)" 0 8 (help-echo "search a file for a pattern")) #("egrep(1)" 0 8 (help-echo "search a file for a pattern")) #("grep(1)" 0 7 (help-echo "search a file for a pattern")))) + ;; AIX + ;; http://pic.dhe.ibm.com/infocenter/aix/v7r1/topic/com.ibm.aix.cmds/doc/aixcmds6/whatis.htm + ("\ +ls(1) -Displays the contents of a directory." + . (#("ls(1)" 0 5 (help-echo "Displays the contents of a directory.")))) + ;; https://www.ibm.com/developerworks/mydeveloperworks/blogs/cgaix/entry/catman_0703_102_usr_lbin_mkwhatis_the_error_number_is_1?lang=en + ("\ +loopmount(1) - Associate an image file to a loopback device." + . (#("loopmount(1)" 0 12 (help-echo "Associate an image file to a loopback device.")))) + ) + "List of tests for `Man-parse-apropos'. +Each element is a cons cell whose car is a string containing +man -k output. That should result in the table which is stored +in the cdr of the element.") + +(defun man-tests-name-equal-p (name description string) + (and (equal name string) + (not (next-single-property-change 0 'help-echo string)) + (equal (get-text-property 0 'help-echo string) description))) + +(defun man-tests-parse-apropos-test-case (test) + (let ((temp-buffer (get-buffer-create " *test-man*")) + (apropos-output (car test))) + (unwind-protect + (save-window-excursion + (with-current-buffer temp-buffer + (erase-buffer) + (insert apropos-output) + (let ((result (Man-parse-apropos)) + (checklist (cdr test))) + (while (and checklist result + (man-tests-name-equal-p + (car checklist) + (get-text-property 0 'help-echo + (car checklist)) + (pop result))) + (pop checklist)) + (and (null checklist) (null result))))) + (and (buffer-name temp-buffer) + (kill-buffer temp-buffer))))) + +(ert-deftest man-tests () + "Test man." + (dolist (test man-tests-parse-apropos-tests) + (should (man-tests-parse-apropos-test-case test)))) + +(provide 'man-tests) + +;;; man-tests.el ends here From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 12 14:32:31 2012 Received: (at 13160) by debbugs.gnu.org; 12 Dec 2012 19:32:31 +0000 Received: from localhost ([127.0.0.1]:39409 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tis2g-0003wG-RC for submit@debbugs.gnu.org; Wed, 12 Dec 2012 14:32:31 -0500 Received: from fencepost.gnu.org ([208.118.235.10]:43510) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tis2f-0003wA-2l for 13160@debbugs.gnu.org; Wed, 12 Dec 2012 14:32:30 -0500 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1Tis1q-00087j-GG; Wed, 12 Dec 2012 14:31:38 -0500 From: Glenn Morris To: Wolfgang Jenkner Subject: Re: bug#13160: 24.3.50; [PATCH] man page completion support beyond man-db References: <856247krc6.fsf@iznogoud.viz> X-Spook: doctrine mindwar Exon Shell EuroFed industrial X-Ran: 0I8MXW?\sd\o_3}FhUfG5CLA~+S<7|OB4:y;`b_N);Sn'~1m9AiC;X)Y^mL|J)>!~k|544 X-Hue: cyan X-Debbugs-No-Ack: yes X-Attribution: GM Date: Wed, 12 Dec 2012 14:31:38 -0500 In-Reply-To: <856247krc6.fsf@iznogoud.viz> (Wolfgang Jenkner's message of "Wed, 12 Dec 2012 20:16:45 +0100") Message-ID: User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -4.2 (----) X-Debbugs-Envelope-To: 13160 Cc: 13160@debbugs.gnu.org, Kevin Ryde X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.0 (-----) Wolfgang Jenkner wrote: > In lisp/man.el, completion of man pages and sections depends on parsing > the output of `man -k'. As a bonus, this method provides short > descriptions in the form of tooltips in the *Completions* buffer. IMO it should just search MANPATH, like bash_completion does. http://debbugs.gnu.org/cgi/bugreport.cgi?bug=10712#11 This is perhaps a separate issue, but would avoid all of this: > However, the code only handles the `man -k' output format peculiar to > the man-db package, which, even on GNU/Linux, is not the only one used > for this purpose. > > For example, Slackware seems to use man-1.6g, whose `man -k' output can > have an additional reference in square brackets between the page name > and the section, so that man topic completion does work in this case, > but neither sections nor descriptions are parsed. > > The situation is even worse for FreeBSD, where multiple comma-separated > page names can be shown on the same line (which is arguably against the > spirit of POSIX man(1p), but that's not quite clear and doesn't help > much). From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 12 15:31:36 2012 Received: (at 13160) by debbugs.gnu.org; 12 Dec 2012 20:31:36 +0000 Received: from localhost ([127.0.0.1]:39493 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tisxs-0006Hk-3G for submit@debbugs.gnu.org; Wed, 12 Dec 2012 15:31:36 -0500 Received: from ironport2-out.teksavvy.com ([206.248.154.182]:36373) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tisxq-0006Hd-2O for 13160@debbugs.gnu.org; Wed, 12 Dec 2012 15:31:34 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EAG6Zu09soXOY/2dsb2JhbABEtBGBCIIVAQEEAVYjBQsLDiYSFBgNJIgcBQu5fpBEA4hCjWiNCYFYgwc X-IronPort-AV: E=Sophos;i="4.75,637,1330923600"; d="scan'208";a="209717877" Received: from 108-161-115-152.dsl.teksavvy.com (HELO pastel.home) ([108.161.115.152]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 12 Dec 2012 15:30:45 -0500 Received: by pastel.home (Postfix, from userid 20848) id C76A34E020; Wed, 12 Dec 2012 15:30:44 -0500 (EST) From: Stefan Monnier To: Glenn Morris Subject: Re: bug#13160: 24.3.50; [PATCH] man page completion support beyond man-db Message-ID: References: <856247krc6.fsf@iznogoud.viz> Date: Wed, 12 Dec 2012 15:30:44 -0500 In-Reply-To: (Glenn Morris's message of "Wed, 12 Dec 2012 14:31:38 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 13160 Cc: 13160@debbugs.gnu.org, Wolfgang Jenkner , Kevin Ryde X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) > IMO it should just search MANPATH, like bash_completion does. > http://debbugs.gnu.org/cgi/bugreport.cgi?bug=10712#11 That just gives you a different set of problems (basically that different `man' construct their MANPATH from different places). Stefan From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 14 16:21:16 2012 Received: (at 13160) by debbugs.gnu.org; 14 Dec 2012 21:21:16 +0000 Received: from localhost ([127.0.0.1]:42966 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tjcgx-0005kk-8s for submit@debbugs.gnu.org; Fri, 14 Dec 2012 16:21:16 -0500 Received: from mailout1-13.pacific.net.au ([125.255.80.132]:53336 helo=mailout3-syd3.pacific.net.au) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tjcgq-0005kY-3v for 13160@debbugs.gnu.org; Fri, 14 Dec 2012 16:21:09 -0500 Received: from mailproxy3-syd3.pacific.net.au (mailproxy3-syd3.pacific.net.au [61.8.2.164]) by mailout3-syd3.pacific.net.au (Postfix) with ESMTP id 4C7186B8334; Sat, 15 Dec 2012 08:19:56 +1100 (EST) Received: from blah.blah (unknown [203.26.175.108]) by mailproxy3-syd3.pacific.net.au (Postfix) with ESMTP id A0F13578072; Sat, 15 Dec 2012 08:19:55 +1100 (EST) Received: from gg by blah.blah with local (Exim 4.80) (envelope-from ) id 1Tjcfn-0001JO-QX; Sat, 15 Dec 2012 08:19:59 +1100 From: Kevin Ryde To: 13160@debbugs.gnu.org Subject: Re: 24.3.50; [PATCH] man page completion support beyond man-db References: <856247krc6.fsf@iznogoud.viz> Date: Sat, 15 Dec 2012 08:19:59 +1100 In-Reply-To: <856247krc6.fsf@iznogoud.viz> (Wolfgang Jenkner's message of "Wed, 12 Dec 2012 20:16:45 +0100") Message-ID: <87sj78fi0w.fsf@blah.blah> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.8 (/) X-Debbugs-Envelope-To: 13160 Cc: Wolfgang Jenkner X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -0.5 (/) Stefan Monnier writes: > > different `man' construct their MANPATH from different places). Yes. There's a bit in woman.el to attempt it and even /etc/manpath.conf. But that misses aliases when the page lists two names in its NAME part. In debian there's normally symlinks for such, but it's possible they're only in the man index extracted by "lexgrog". I reckoned it better to ask "man" what pages it knows, if it can give its index in a reasonable way. The "whatis" program might be an alternative, or it might be the same. Wolfgang Jenkner writes: > > boot-scripts (7) [boot] - General description of boot sequence Some version of man-db printed that for me, but the aliases or the output have changed now. > +(defvar Man-keyword-completion-twiddle > + (cond > + ;; man-db-* or man-*. > + ((memq system-type '(gnu gnu/linux gnu/kfreebsd)) > + "^") > + (t > + "")) You'd much prefer to avoid that. For a start `system-type' is probably unreliable to distinguish the flavour of man. The outputs look close enough / different enough for a single parse/split/etc. > +tset, reset (1) - establish or restore terminal characteristics" Thanks, I'll see if I can recognise some of those for my stuff too. From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 14 16:36:50 2012 Received: (at 13160) by debbugs.gnu.org; 14 Dec 2012 21:36:50 +0000 Received: from localhost ([127.0.0.1]:42977 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tjcw6-00067U-EP for submit@debbugs.gnu.org; Fri, 14 Dec 2012 16:36:50 -0500 Received: from mx14.lb01.inode.at ([62.99.145.16]:8468 helo=mx.inode.at) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tjcw3-00067M-Uv for 13160@debbugs.gnu.org; Fri, 14 Dec 2012 16:36:49 -0500 Received: from [91.119.206.19] (port=2445 helo=iznogoud.viz) by smartmx-14.inode.at with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1Tjcv5-00064P-HZ; Fri, 14 Dec 2012 22:35:47 +0100 Received: from wolfgang by iznogoud.viz with local (Exim 4.80.1 (FreeBSD)) (envelope-from ) id 1Tjcv1-0000hH-OQ; Fri, 14 Dec 2012 22:35:43 +0100 From: Wolfgang Jenkner To: Kevin Ryde Subject: Re: bug#13160: 24.3.50; [PATCH] man page completion support beyond man-db References: <856247krc6.fsf@iznogoud.viz> <87sj78fi0w.fsf@blah.blah> Date: Fri, 14 Dec 2012 22:35:43 +0100 In-Reply-To: <87sj78fi0w.fsf@blah.blah> (Kevin Ryde's message of "Sat, 15 Dec 2012 08:19:59 +1100") Message-ID: <85ip84qpu8.fsf@iznogoud.viz> User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.8 (/) X-Debbugs-Envelope-To: 13160 Cc: 13160@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -0.0 (/) On Fri, Dec 14 2012, Kevin Ryde wrote: >> +(defvar Man-keyword-completion-twiddle >> + (cond >> + ;; man-db-* or man-*. >> + ((memq system-type '(gnu gnu/linux gnu/kfreebsd)) >> + "^") >> + (t >> + "")) > > You'd much prefer to avoid that. For a start `system-type' is probably > unreliable to distinguish the flavour of man. The outputs look close > enough / different enough for a single parse/split/etc. It's not used for parsing, it's only prepended to the search string passed to `man -k'. And I'd happily ditch it since, as the doc string indicates, it's not really necessary, but I'm not sure about performance implications. Thanks for the comments, Wolfgang From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 14 20:00:08 2012 Received: (at 13160) by debbugs.gnu.org; 15 Dec 2012 01:00:08 +0000 Received: from localhost ([127.0.0.1]:43089 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tjg6q-0002Lu-1d for submit@debbugs.gnu.org; Fri, 14 Dec 2012 20:00:08 -0500 Received: from mailout1-13.pacific.net.au ([125.255.80.132]:41948 helo=mailout3-syd3.pacific.net.au) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tjg6m-0002LN-Rb for 13160@debbugs.gnu.org; Fri, 14 Dec 2012 20:00:06 -0500 Received: from mailproxy3-syd3.pacific.net.au (mailproxy3-syd3.pacific.net.au [61.8.2.164]) by mailout3-syd3.pacific.net.au (Postfix) with ESMTP id 281CC6B81BB; Sat, 15 Dec 2012 11:59:02 +1100 (EST) Received: from blah.blah (unknown [203.26.175.108]) by mailproxy3-syd3.pacific.net.au (Postfix) with ESMTP id AF129578073; Sat, 15 Dec 2012 11:59:01 +1100 (EST) Received: from gg by blah.blah with local (Exim 4.80) (envelope-from ) id 1Tjg5q-0005CQ-Qq; Sat, 15 Dec 2012 11:59:06 +1100 From: Kevin Ryde To: Wolfgang Jenkner Subject: Re: bug#13160: 24.3.50; [PATCH] man page completion support beyond man-db References: <856247krc6.fsf@iznogoud.viz> <87sj78fi0w.fsf@blah.blah> <85ip84qpu8.fsf@iznogoud.viz> Date: Sat, 15 Dec 2012 11:59:06 +1100 In-Reply-To: <85ip84qpu8.fsf@iznogoud.viz> (Wolfgang Jenkner's message of "Fri, 14 Dec 2012 22:35:43 +0100") Message-ID: <87ehisf7vp.fsf@blah.blah> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.8 (/) X-Debbugs-Envelope-To: 13160 Cc: 13160@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -0.0 (/) Wolfgang Jenkner writes: > > It's not used for parsing, it's only prepended to the search string > passed to `man -k'. Ah. I even had a note in my bit about that. Yes. Daniel Pittman I think it was reported that on macos man -k '' empty string gives no output, hence "^". From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 16 13:12:10 2012 Received: (at 13160) by debbugs.gnu.org; 16 Dec 2012 18:12:10 +0000 Received: from localhost ([127.0.0.1]:45599 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TkIh7-0003iY-4V for submit@debbugs.gnu.org; Sun, 16 Dec 2012 13:12:10 -0500 Received: from mx21.lb01.inode.at ([62.99.145.23]:63345 helo=mx.inode.at) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TkIh3-0003iQ-IO for 13160@debbugs.gnu.org; Sun, 16 Dec 2012 13:12:08 -0500 Received: from [91.119.206.19] (port=15204 helo=iznogoud.viz) by smartmx-21.inode.at with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1TkIfu-0003nW-FQ; Sun, 16 Dec 2012 19:10:54 +0100 Received: from wolfgang by iznogoud.viz with local (Exim 4.80.1 (FreeBSD)) (envelope-from ) id 1TkIfq-0000R3-Mq; Sun, 16 Dec 2012 19:10:50 +0100 From: Wolfgang Jenkner To: Kevin Ryde Subject: Re: bug#13160: 24.3.50; [PATCH] man page completion support beyond man-db Date: Sun, 16 Dec 2012 19:07:11 +0100 References: <856247krc6.fsf@iznogoud.viz> <87sj78fi0w.fsf@blah.blah> <85ip84qpu8.fsf@iznogoud.viz> <87ehisf7vp.fsf@blah.blah> Message-ID: <8562416f6d.fsf@iznogoud.viz> User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 13160 Cc: 13160@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On Sat, Dec 15 2012, Kevin Ryde wrote: > Wolfgang Jenkner writes: >> >> It's not used for parsing, it's only prepended to the search string >> passed to `man -k'. > > Ah. I even had a note in my bit about that. Yes. Daniel Pittman I > think it was reported that on macos man -k '' empty string gives no > output, hence "^". Right, the empty string deserves special attention, also because it has the potential to mess up the cache. Thanks for reminding me of this. So, here's an updated patch (there's no change in the parsing code proper). Wolfgang 2012-12-16 Wolfgang Jenkner Support man page completion for more man programs. * man.el (Man-parse-apropos): New function. (Man-keyword-completion-anchor): New variable. (Man-completion-table): Use them to replace man-db specific code for parsing `man -k' output. Filter the list returned by Man-parse-apropos before caching it in the cdr of Man-completion-cache. Also, don't add to the cache indefinitely, just replace it with the freshly parsed table. Handle completion of the empty string carefully. 2012-12-16 Wolfgang Jenkner * automated/man-tests.el: New file. === modified file 'lisp/man.el' --- lisp/man.el 2012-08-15 16:29:11 +0000 +++ lisp/man.el 2012-12-16 03:22:20 +0000 @@ -780,6 +780,59 @@ ;; but apparently that's not the case in all cases, so let's add a cache. "Cache of completion table of the form (PREFIX . TABLE).") +(defvar Man-keyword-completion-anchor + (cond + ;; man-db-* or man-*. + ((memq system-type '(gnu gnu/linux gnu/kfreebsd)) + "^") + (t + "")) + "A string prepended to the keyword passed to `man -k' for completion. +This should usually be an extended regular expression (but it +need not be an anchor in the ERE sense). + +Actually, unwanted page names are weeded out anyway, so with an +empty string here we will always get correct results, but things +may take a bit longer.") + +(defun Man-parse-apropos () + "Parse `man -k' output and return the list of page names. + +The current buffer should contain the output of a command of the +form `man -k keyword', which is traditionally also available with +apropos(1). + +While POSIX man(1p) is a bit vague about what to expect here, +this function tries to parse some commonly used formats, which +can be described in the following informal way, with square brackets +indicating optional parts and whitespace being interpreted +somewhat loosely. + +foo[, bar [, ...]] [other stuff] (sec) - description +foo(sec)[, bar(sec) [, ...]] [other stuff] - description + +For more details and some regression tests, please see +test/automated/man-tests.el in the emacs bzr repository." + (goto-char (point-min)) + (let (table) + (while (search-forward-regexp "^\\([^ \t,\n]+\\)\\(.*?\\)\ +\\(?:[ \t]\\(([^ \t,\n]+?)\\)\\)?\\(?:[ \t]+- ?\\(.*\\)\\)?$" nil t) + (let ((section (match-string 3)) + (description (match-string 4)) + (bound (match-end 2)) + (continue (goto-char (match-end 1)))) + (while continue + ;; The first regexp grouping may already match the section + ;; tacked on to the name, which is ok since for the formats we + ;; claim to support the third (non-shy) grouping does not + ;; match in this case, i.e., section is nil. + (push (propertize (concat (match-string 1) section) + 'help-echo description) + table) + (setq continue (search-forward-regexp "\\=, *\\([^ \t,]+\\)" + bound t))))) + (nreverse table))) + (defun Man-completion-table (string pred action) (cond ;; This ends up returning t for pretty much any string, and hence leads to @@ -811,16 +864,26 @@ ;; 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 "^" prefix)))) - (goto-char (point-min)) - (while (re-search-forward "^\\([^ \t\n]+\\)\\(?: ?\\((.+?)\\)\\(?:[ \t]+- \\(.*\\)\\)?\\)?" nil t) - (push (propertize (concat (match-string 1) (match-string 2)) - 'help-echo (match-string 3)) - table))) - ;; Cache the table for later reuse. - (setq Man-completion-cache (cons prefix table))) + (ignore-errors + (call-process manual-program nil '(t nil) nil + "-k" (if (string-equal prefix "") + "^" + (concat Man-keyword-completion-anchor + prefix))))) + (setq table (Man-parse-apropos))) + ;; Weed out unwanted page names. + (dolist (comp (prog1 table (setq table nil))) + (if (string-prefix-p prefix comp) + (push comp table))) + ;; Cache the table for later reuse. + (if (or (not (string-equal prefix "")) + ;; Believe that we have valid completions of the empty + ;; string, if there are at least three of them. + ;; Otherwise, `table' is likely the result of parsing + ;; an error message. + (cddr table)) + (setq Man-completion-cache (cons prefix table)) + (setq table nil))) ;; The table may contain false positives since the match is made ;; by "man -k" not just on the manpage's name. (if section === added file 'test/automated/man-tests.el' --- test/automated/man-tests.el 1970-01-01 00:00:00 +0000 +++ test/automated/man-tests.el 2012-12-16 03:31:53 +0000 @@ -0,0 +1,118 @@ +;;; man-tests.el --- Test suite for man. + +;; Copyright (C) 2012 Free Software Foundation, Inc. + +;; Author: Wolfgang Jenkner +;; Keywords: help, internal, unix + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Code: + +(require 'ert) +(require 'man) + +(defconst man-tests-parse-apropos-tests + '(;; GNU/Linux: man-db-2.6.1 + ("\ +sin (3) - sine function +sinf (3) - sine function +sinl (3) - sine function" + . (#("sin(3)" 0 6 (help-echo "sine function")) #("sinf(3)" 0 7 (help-echo "sine function")) #("sinl(3)" 0 7 (help-echo "sine function")))) + ;; GNU/Linux: man-1.6g + ("\ +sin (3) - sine function +sinf [sin] (3) - sine function +sinl [sin] (3) - sine function" + . (#("sin(3)" 0 6 (help-echo "sine function")) #("sinf(3)" 0 7 (help-echo "sine function")) #("sinl(3)" 0 7 (help-echo "sine function")))) + ;; FreeBSD 9 + ("\ +sin(3), sinf(3), sinl(3) - sine functions" + . (#("sin(3)" 0 6 (help-echo "sine functions")) #("sinf(3)" 0 7 (help-echo "sine functions")) #("sinl(3)" 0 7 (help-echo "sine functions")))) + ;; SunOS, Solaris + ;; http://docs.oracle.com/cd/E19455-01/805-6331/usradm-7/index.html + ;; SunOS 4 + ("\ +tset, reset (1) - establish or restore terminal characteristics" + . (#("tset(1)" 0 7 (help-echo "establish or restore terminal characteristics")) #("reset(1)" 0 8 (help-echo "establish or restore terminal characteristics")))) + ;; SunOS 5.7, Solaris + ("\ +reset tset (1b) - establish or restore terminal characteristics +tset tset (1b) - establish or restore terminal characteristics" + . (#("reset(1b)" 0 8 (help-echo "establish or restore terminal characteristics")) #("tset(1b)" 0 7 (help-echo "establish or restore terminal characteristics")))) + ;; Minix 3 + ;; http://www.minix3.org/manpages/html5/whatis.html + ("\ +cawf, nroff (1) - C version of the nroff-like, Amazingly Workable (text) Formatter +whatis (5) - database of online manual pages" + . (#("cawf(1)" 0 7 (help-echo "C version of the nroff-like, Amazingly Workable (text) Formatter")) #("nroff(1)" 0 8 (help-echo "C version of the nroff-like, Amazingly Workable (text) Formatter")) #("whatis(5)" 0 9 (help-echo "database of online manual pages")))) + ;; HP-UX + ;; http://docstore.mik.ua/manuals/hp-ux/en/B2355-60130/man.1.html + ;; Assuming that the line break in the zgrep description was + ;; introduced by the man page formatting. + ("\ +grep, egrep, fgrep (1) - search a file for a pattern +zgrep(1) - search possibly compressed files for a regular expression" + . (#("grep(1)" 0 7 (help-echo "search a file for a pattern")) #("egrep(1)" 0 8 (help-echo "search a file for a pattern")) #("fgrep(1)" 0 8 (help-echo "search a file for a pattern")) #("zgrep(1)" 0 8 (help-echo "search possibly compressed files for a regular expression")))) + ;; AIX + ;; http://pic.dhe.ibm.com/infocenter/aix/v7r1/topic/com.ibm.aix.cmds/doc/aixcmds6/whatis.htm + ("\ +ls(1) -Displays the contents of a directory." + . (#("ls(1)" 0 5 (help-echo "Displays the contents of a directory.")))) + ;; https://www.ibm.com/developerworks/mydeveloperworks/blogs/cgaix/entry/catman_0703_102_usr_lbin_mkwhatis_the_error_number_is_1?lang=en + ("\ +loopmount(1) - Associate an image file to a loopback device." + . (#("loopmount(1)" 0 12 (help-echo "Associate an image file to a loopback device.")))) + ) + "List of tests for `Man-parse-apropos'. +Each element is a cons cell whose car is a string containing +man -k output. That should result in the table which is stored +in the cdr of the element.") + +(defun man-tests-name-equal-p (name description string) + (and (equal name string) + (not (next-single-property-change 0 'help-echo string)) + (equal (get-text-property 0 'help-echo string) description))) + +(defun man-tests-parse-apropos-test-case (test) + (let ((temp-buffer (get-buffer-create " *test-man*")) + (apropos-output (car test))) + (unwind-protect + (save-window-excursion + (with-current-buffer temp-buffer + (erase-buffer) + (insert apropos-output) + (let ((result (Man-parse-apropos)) + (checklist (cdr test))) + (while (and checklist result + (man-tests-name-equal-p + (car checklist) + (get-text-property 0 'help-echo + (car checklist)) + (pop result))) + (pop checklist)) + (and (null checklist) (null result))))) + (and (buffer-name temp-buffer) + (kill-buffer temp-buffer))))) + +(ert-deftest man-tests () + "Test man." + (dolist (test man-tests-parse-apropos-tests) + (should (man-tests-parse-apropos-test-case test)))) + +(provide 'man-tests) + +;;; man-tests.el ends here From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 22 10:36:25 2012 Received: (at 13160) by debbugs.gnu.org; 22 Dec 2012 15:36:25 +0000 Received: from localhost ([127.0.0.1]:55652 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TmR7f-0003oJ-VB for submit@debbugs.gnu.org; Sat, 22 Dec 2012 10:36:24 -0500 Received: from mx02.lb01.inode.at ([62.99.145.2]:13982 helo=mx.inode.at) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TmR7b-0003o7-IL for 13160@debbugs.gnu.org; Sat, 22 Dec 2012 10:36:22 -0500 Received: from [91.119.206.19] (port=2750 helo=iznogoud.viz) by smartmx-02.inode.at with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1TmR7H-00028p-2p; Sat, 22 Dec 2012 16:35:59 +0100 Received: from wolfgang by iznogoud.viz with local (Exim 4.80.1 (FreeBSD)) (envelope-from ) id 1TmR7D-0000Rw-CV; Sat, 22 Dec 2012 16:35:55 +0100 From: Wolfgang Jenkner To: Kevin Ryde Subject: Re: bug#13160: 24.3.50; [PATCH] man page completion support beyond man-db Date: Sat, 22 Dec 2012 16:27:36 +0100 References: <856247krc6.fsf@iznogoud.viz> <87sj78fi0w.fsf@blah.blah> <85ip84qpu8.fsf@iznogoud.viz> <87ehisf7vp.fsf@blah.blah> <8562416f6d.fsf@iznogoud.viz> Message-ID: <8538yyt7z8.fsf@iznogoud.viz> User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 13160 Cc: 13160@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On Sun, Dec 16 2012, Wolfgang Jenkner wrote: > On Sat, Dec 15 2012, Kevin Ryde wrote: > >> Wolfgang Jenkner writes: >>> >>> It's not used for parsing, it's only prepended to the search string >>> passed to `man -k'. >> >> Ah. I even had a note in my bit about that. Yes. Daniel Pittman I >> think it was reported that on macos man -k '' empty string gives no >> output, hence "^". > > Right, the empty string deserves special attention, also because it has > the potential to mess up the cache. Thanks for reminding me of this. Actually, I think the cache is really the clue here: prepending completions piecemeal to the cache makes only sense if the user consciously avoids completing the empty string because of memory constraints... and even then the cache would have to be a trie or something to be useful. So let's just cache all entries at the first completion attempt. This simplifies things as it seems reasonable to assume that `man -k ^' outputs all entries (I was unsure about this because of bug#10840, but that was likely a red herring). And since the present bug report has been requalified as being of `wishlist' severity I'd like to commit the patch before christmas :-) Wolfgang 2012-12-22 Wolfgang Jenkner * man.el (Man-completion-table): Cache aggressively. Fill the cache all at once, at the first completion. Previously, when a prefix didn't start with the string contained in the car of Man-completion-cache the parsed output of `man -k' was prepended to the cache. Conveniently, the change entails that we don't have to guess the output format of `man -k' in order to pass it a useful regexp. 2012-12-22 Wolfgang Jenkner Support man page completion for more man programs. (Bug#13160) * man.el (Man-parse-apropos): New function. (Man-completion-table): Use it in parsing `man -k' output to replace code peculiar to man-db. Thanks to Kevin Ryde for commenting on a previous version of this. 2012-12-22 Wolfgang Jenkner * automated/man-tests.el: New file. === modified file 'lisp/man.el' --- lisp/man.el 2012-08-15 16:29:11 +0000 +++ lisp/man.el 2012-12-21 22:51:54 +0000 @@ -796,15 +796,11 @@ (when (string-match "\\`\\([[:digit:]].*?\\) " string) (setq section (match-string 1 string)) (setq prefix (substring string (match-end 0)))) - (unless (and Man-completion-cache - (string-prefix-p (car Man-completion-cache) prefix)) + (unless Man-completion-cache (with-temp-buffer (setq default-directory "/") ;; in case inherited doesn't exist - ;; Actually for my `man' the arg is a regexp. - ;; POSIX says it must be ERE and "man-db" seems to agree, - ;; whereas under MacOSX it seems to be BRE-style and doesn't - ;; accept backslashes at all. Let's not bother to - ;; quote anything. + ;; Actually for `man -k' the arg is a regexp and POSIX says + ;; it must be an ERE. Anyway, only the ^ anchor is needed here. (let ((process-environment (copy-sequence process-environment))) (setenv "COLUMNS" "999") ;; don't truncate long names ;; manual-program might not even exist. And since it's @@ -812,15 +808,15 @@ ;; 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 "^" prefix)))) + ;; Get all entries. + (call-process manual-program nil '(t nil) nil "-k" "^"))) (goto-char (point-min)) (while (re-search-forward "^\\([^ \t\n]+\\)\\(?: ?\\((.+?)\\)\\(?:[ \t]+- \\(.*\\)\\)?\\)?" nil t) (push (propertize (concat (match-string 1) (match-string 2)) 'help-echo (match-string 3)) table))) ;; Cache the table for later reuse. - (setq Man-completion-cache (cons prefix table))) + (setq Man-completion-cache (cons "" (nreverse table)))) ;; The table may contain false positives since the match is made ;; by "man -k" not just on the manpage's name. (if section === modified file 'lisp/man.el' --- lisp/man.el 2012-12-21 22:51:54 +0000 +++ lisp/man.el 2012-12-21 22:55:19 +0000 @@ -780,6 +780,44 @@ ;; but apparently that's not the case in all cases, so let's add a cache. "Cache of completion table of the form (PREFIX . TABLE).") +(defun Man-parse-apropos () + "Parse `man -k' output and return the list of page names. + +The current buffer should contain the output of a command of the +form `man -k keyword', which is traditionally also available with +apropos(1). + +While POSIX man(1p) is a bit vague about what to expect here, +this function tries to parse some commonly used formats, which +can be described in the following informal way, with square brackets +indicating optional parts and whitespace being interpreted +somewhat loosely. + +foo[, bar [, ...]] [other stuff] (sec) - description +foo(sec)[, bar(sec) [, ...]] [other stuff] - description + +For more details and some regression tests, please see +test/automated/man-tests.el in the emacs bzr repository." + (goto-char (point-min)) + (let (table) + (while (search-forward-regexp "^\\([^ \t,\n]+\\)\\(.*?\\)\ +\\(?:[ \t]\\(([^ \t,\n]+?)\\)\\)?\\(?:[ \t]+- ?\\(.*\\)\\)?$" nil t) + (let ((section (match-string 3)) + (description (match-string 4)) + (bound (match-end 2)) + (continue (goto-char (match-end 1)))) + (while continue + ;; The first regexp grouping may already match the section + ;; tacked on to the name, which is ok since for the formats we + ;; claim to support the third (non-shy) grouping does not + ;; match in this case, i.e., section is nil. + (push (propertize (concat (match-string 1) section) + 'help-echo description) + table) + (setq continue (search-forward-regexp "\\=, *\\([^ \t,]+\\)" + bound t))))) + (nreverse table))) + (defun Man-completion-table (string pred action) (cond ;; This ends up returning t for pretty much any string, and hence leads to @@ -810,13 +848,9 @@ (ignore-errors ;; Get all entries. (call-process manual-program nil '(t nil) nil "-k" "^"))) - (goto-char (point-min)) - (while (re-search-forward "^\\([^ \t\n]+\\)\\(?: ?\\((.+?)\\)\\(?:[ \t]+- \\(.*\\)\\)?\\)?" nil t) - (push (propertize (concat (match-string 1) (match-string 2)) - 'help-echo (match-string 3)) - table))) - ;; Cache the table for later reuse. - (setq Man-completion-cache (cons "" (nreverse table)))) + ;; Cache the table for later reuse. + (setq Man-completion-cache (cons "" (setq table + (Man-parse-apropos)))))) ;; The table may contain false positives since the match is made ;; by "man -k" not just on the manpage's name. (if section === added file 'test/automated/man-tests.el' --- test/automated/man-tests.el 1970-01-01 00:00:00 +0000 +++ test/automated/man-tests.el 2012-12-21 22:55:19 +0000 @@ -0,0 +1,118 @@ +;;; man-tests.el --- Test suite for man. + +;; Copyright (C) 2012 Free Software Foundation, Inc. + +;; Author: Wolfgang Jenkner +;; Keywords: help, internal, unix + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Code: + +(require 'ert) +(require 'man) + +(defconst man-tests-parse-apropos-tests + '(;; GNU/Linux: man-db-2.6.1 + ("\ +sin (3) - sine function +sinf (3) - sine function +sinl (3) - sine function" + . (#("sin(3)" 0 6 (help-echo "sine function")) #("sinf(3)" 0 7 (help-echo "sine function")) #("sinl(3)" 0 7 (help-echo "sine function")))) + ;; GNU/Linux: man-1.6g + ("\ +sin (3) - sine function +sinf [sin] (3) - sine function +sinl [sin] (3) - sine function" + . (#("sin(3)" 0 6 (help-echo "sine function")) #("sinf(3)" 0 7 (help-echo "sine function")) #("sinl(3)" 0 7 (help-echo "sine function")))) + ;; FreeBSD 9 + ("\ +sin(3), sinf(3), sinl(3) - sine functions" + . (#("sin(3)" 0 6 (help-echo "sine functions")) #("sinf(3)" 0 7 (help-echo "sine functions")) #("sinl(3)" 0 7 (help-echo "sine functions")))) + ;; SunOS, Solaris + ;; http://docs.oracle.com/cd/E19455-01/805-6331/usradm-7/index.html + ;; SunOS 4 + ("\ +tset, reset (1) - establish or restore terminal characteristics" + . (#("tset(1)" 0 7 (help-echo "establish or restore terminal characteristics")) #("reset(1)" 0 8 (help-echo "establish or restore terminal characteristics")))) + ;; SunOS 5.7, Solaris + ("\ +reset tset (1b) - establish or restore terminal characteristics +tset tset (1b) - establish or restore terminal characteristics" + . (#("reset(1b)" 0 8 (help-echo "establish or restore terminal characteristics")) #("tset(1b)" 0 7 (help-echo "establish or restore terminal characteristics")))) + ;; Minix 3 + ;; http://www.minix3.org/manpages/html5/whatis.html + ("\ +cawf, nroff (1) - C version of the nroff-like, Amazingly Workable (text) Formatter +whatis (5) - database of online manual pages" + . (#("cawf(1)" 0 7 (help-echo "C version of the nroff-like, Amazingly Workable (text) Formatter")) #("nroff(1)" 0 8 (help-echo "C version of the nroff-like, Amazingly Workable (text) Formatter")) #("whatis(5)" 0 9 (help-echo "database of online manual pages")))) + ;; HP-UX + ;; http://docstore.mik.ua/manuals/hp-ux/en/B2355-60130/man.1.html + ;; Assuming that the line break in the zgrep description was + ;; introduced by the man page formatting. + ("\ +grep, egrep, fgrep (1) - search a file for a pattern +zgrep(1) - search possibly compressed files for a regular expression" + . (#("grep(1)" 0 7 (help-echo "search a file for a pattern")) #("egrep(1)" 0 8 (help-echo "search a file for a pattern")) #("fgrep(1)" 0 8 (help-echo "search a file for a pattern")) #("zgrep(1)" 0 8 (help-echo "search possibly compressed files for a regular expression")))) + ;; AIX + ;; http://pic.dhe.ibm.com/infocenter/aix/v7r1/topic/com.ibm.aix.cmds/doc/aixcmds6/whatis.htm + ("\ +ls(1) -Displays the contents of a directory." + . (#("ls(1)" 0 5 (help-echo "Displays the contents of a directory.")))) + ;; https://www.ibm.com/developerworks/mydeveloperworks/blogs/cgaix/entry/catman_0703_102_usr_lbin_mkwhatis_the_error_number_is_1?lang=en + ("\ +loopmount(1) - Associate an image file to a loopback device." + . (#("loopmount(1)" 0 12 (help-echo "Associate an image file to a loopback device.")))) + ) + "List of tests for `Man-parse-apropos'. +Each element is a cons cell whose car is a string containing +man -k output. That should result in the table which is stored +in the cdr of the element.") + +(defun man-tests-name-equal-p (name description string) + (and (equal name string) + (not (next-single-property-change 0 'help-echo string)) + (equal (get-text-property 0 'help-echo string) description))) + +(defun man-tests-parse-apropos-test-case (test) + (let ((temp-buffer (get-buffer-create " *test-man*")) + (apropos-output (car test))) + (unwind-protect + (save-window-excursion + (with-current-buffer temp-buffer + (erase-buffer) + (insert apropos-output) + (let ((result (Man-parse-apropos)) + (checklist (cdr test))) + (while (and checklist result + (man-tests-name-equal-p + (car checklist) + (get-text-property 0 'help-echo + (car checklist)) + (pop result))) + (pop checklist)) + (and (null checklist) (null result))))) + (and (buffer-name temp-buffer) + (kill-buffer temp-buffer))))) + +(ert-deftest man-tests () + "Test man." + (dolist (test man-tests-parse-apropos-tests) + (should (man-tests-parse-apropos-test-case test)))) + +(provide 'man-tests) + +;;; man-tests.el ends here From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 22 12:12:07 2012 Received: (at 13160) by debbugs.gnu.org; 22 Dec 2012 17:12:08 +0000 Received: from localhost ([127.0.0.1]:55734 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TmScJ-0006AM-HI for submit@debbugs.gnu.org; Sat, 22 Dec 2012 12:12:07 -0500 Received: from ironport2-out.teksavvy.com ([206.248.154.182]:6730) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TmScH-0006AG-Kb for 13160@debbugs.gnu.org; Sat, 22 Dec 2012 12:12:06 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ai0FAG6Zu09FxLDj/2dsb2JhbABEsEiDSYEIghUBAQQBViMFCwsOJhIUGA0kiBwFugmQRAOIQppxgViDBw X-IronPort-AV: E=Sophos;i="4.75,637,1330923600"; d="scan'208";a="210564627" Received: from 69-196-176-227.dsl.teksavvy.com (HELO pastel.home) ([69.196.176.227]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 22 Dec 2012 12:11:45 -0500 Received: by pastel.home (Postfix, from userid 20848) id D155658EA5; Sat, 22 Dec 2012 12:11:44 -0500 (EST) From: Stefan Monnier To: Wolfgang Jenkner Subject: Re: bug#13160: 24.3.50; [PATCH] man page completion support beyond man-db Message-ID: References: <856247krc6.fsf@iznogoud.viz> <87sj78fi0w.fsf@blah.blah> <85ip84qpu8.fsf@iznogoud.viz> <87ehisf7vp.fsf@blah.blah> <8562416f6d.fsf@iznogoud.viz> <8538yyt7z8.fsf@iznogoud.viz> Date: Sat, 22 Dec 2012 12:11:44 -0500 In-Reply-To: <8538yyt7z8.fsf@iznogoud.viz> (Wolfgang Jenkner's message of "Sat, 22 Dec 2012 16:27:36 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.8 (/) X-Debbugs-Envelope-To: 13160 Cc: 13160@debbugs.gnu.org, Kevin Ryde X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) >>>> It's not used for parsing, it's only prepended to the search string >>>> passed to `man -k'. >>> Ah. I even had a note in my bit about that. Yes. Daniel Pittman I >>> think it was reported that on macos man -k '' empty string gives no >>> output, hence "^". >> Right, the empty string deserves special attention, also because it has >> the potential to mess up the cache. Thanks for reminding me of this. > Actually, I think the cache is really the clue here: prepending > completions piecemeal to the cache makes only sense if the user > consciously avoids completing the empty string because of memory > constraints... and even then the cache would have to be a trie or > something to be useful. I don't consciously avoid it, but I just never hit TAB to complete a manpage name without first typing a few chars. I doubt I'm the only one. On my system "make -k ^" returns about 9K commands of average length 14chars, so that's about 9K * (16B (chars) + 16B (string object) + 2*8B (cons cells)) or more than 400KB (on a 32bit system) or 700KB (on a 64bit system) for that cache. I'm not sure it's such a good idea. Does it fix an actual bug? [ Sorry if it does fix a real bug and this was mentioned somewhere in this thread, but I haven't found the time to read all threads as thoroughly as I'd like. ] > Support man page completion for more man programs. (Bug#13160) > * man.el (Man-parse-apropos): New function. > (Man-completion-table): Use it in parsing `man -k' output to > replace code peculiar to man-db. > Thanks to Kevin Ryde for commenting on a previous version of this. This part of the patch looks OK, feel free to install it. > * automated/man-tests.el: New file. And that as well, of course. Stefan From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 22 12:59:14 2012 Received: (at 13160) by debbugs.gnu.org; 22 Dec 2012 17:59:14 +0000 Received: from localhost ([127.0.0.1]:55788 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TmTLs-0007Lc-H3 for submit@debbugs.gnu.org; Sat, 22 Dec 2012 12:59:14 -0500 Received: from mx06.lb01.inode.at ([62.99.145.6]:15530 helo=mx.inode.at) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TmTLo-0007LT-JW for 13160@debbugs.gnu.org; Sat, 22 Dec 2012 12:59:10 -0500 Received: from [91.119.206.19] (port=13272 helo=iznogoud.viz) by smartmx-06.inode.at with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1TmTLT-0008VG-Gq; Sat, 22 Dec 2012 18:58:47 +0100 Received: from wolfgang by iznogoud.viz with local (Exim 4.80.1 (FreeBSD)) (envelope-from ) id 1TmTLP-000GX8-HZ; Sat, 22 Dec 2012 18:58:43 +0100 From: Wolfgang Jenkner To: Stefan Monnier Subject: Re: bug#13160: 24.3.50; [PATCH] man page completion support beyond man-db References: <856247krc6.fsf@iznogoud.viz> <87sj78fi0w.fsf@blah.blah> <85ip84qpu8.fsf@iznogoud.viz> <87ehisf7vp.fsf@blah.blah> <8562416f6d.fsf@iznogoud.viz> <8538yyt7z8.fsf@iznogoud.viz> Date: Sat, 22 Dec 2012 18:58:43 +0100 In-Reply-To: (Stefan Monnier's message of "Sat, 22 Dec 2012 12:11:44 -0500") Message-ID: <85txrermss.fsf@iznogoud.viz> User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.8 (/) X-Debbugs-Envelope-To: 13160 Cc: 13160@debbugs.gnu.org, Kevin Ryde X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On Sat, Dec 22 2012, Stefan Monnier wrote: > I don't consciously avoid it, but I just never hit TAB to complete > a manpage name without first typing a few chars. I doubt I'm the > only one. > > On my system "make -k ^" returns about 9K commands of average length > 14chars, so that's about 9K * (16B (chars) + 16B (string object) + 2*8B > (cons cells)) or more than 400KB (on a 32bit system) or 700KB (on > a 64bit system) for that cache. I'm not sure it's such a good idea. Worrying about this is the main reason why I posted this, but: On an old system with not much memory you probably won't have much room for man pages either (unless you mount a NFS share). I actually tested this with a slax image under qemu emulating a i486 system with 64M (without hardware supported virtualization) and I saw no problem with it. Of course, qemu can't really emulate processor or memory-access speed, I think, and there were only 1000 man entries or so. I'd love to test this on my old thinkpad 350 with 20M, but it's difficult to install a recent emacs on a 120M hard disk ;-) That said, my main system is reasonable 2009 vintage, has man -k ^ | wc -l 8702 (with the actual entries being roughly the double of that) and the delay is not noticeably longer when caching all entries at the first completion attempt instead of just part of them. > Does it fix an actual bug? [ Sorry if it does fix a real bug and this > was mentioned somewhere in this thread, but I haven't found the time to > read all threads as thoroughly as I'd like. ] My proposed change log entry indicates that the cache handling is rather bogus (complete for "foo" then for "bar" and then for "foo" again and "man -k ^foo" will be run again and the result prepended to the cache). The main reason, however, is that it eliminates any dependency on the particular flavour of `man -k' output, so everything can be done in elisp by the new Man-parse-apropos (I indicated that in the change log entry, too). Wolfgang From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 22 19:16:45 2012 Received: (at 13160) by debbugs.gnu.org; 23 Dec 2012 00:16:45 +0000 Received: from localhost ([127.0.0.1]:56000 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TmZFE-0008B4-K4 for submit@debbugs.gnu.org; Sat, 22 Dec 2012 19:16:45 -0500 Received: from mailout1-13.pacific.net.au ([125.255.80.132]:35959 helo=mailout3-syd3.pacific.net.au) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TmZFB-0008Aq-Cx for 13160@debbugs.gnu.org; Sat, 22 Dec 2012 19:16:43 -0500 Received: from mailproxy3-syd3.pacific.net.au (mailproxy3-syd3.pacific.net.au [61.8.2.164]) by mailout3-syd3.pacific.net.au (Postfix) with ESMTP id BDC6B6B80F9; Sun, 23 Dec 2012 11:16:14 +1100 (EST) Received: from blah.blah (unknown [203.26.175.29]) by mailproxy3-syd3.pacific.net.au (Postfix) with ESMTP id E55E7578089; Sun, 23 Dec 2012 11:16:13 +1100 (EST) Received: from gg by blah.blah with local (Exim 4.80) (envelope-from ) id 1TmZEe-0002ZO-5H; Sun, 23 Dec 2012 11:16:08 +1100 From: Kevin Ryde To: 13160@debbugs.gnu.org Subject: Re: bug#13160: 24.3.50; [PATCH] man page completion support beyond man-db References: <856247krc6.fsf@iznogoud.viz> <87sj78fi0w.fsf@blah.blah> <85ip84qpu8.fsf@iznogoud.viz> <87ehisf7vp.fsf@blah.blah> <8562416f6d.fsf@iznogoud.viz> <8538yyt7z8.fsf@iznogoud.viz> Date: Sun, 23 Dec 2012 11:16:07 +1100 In-Reply-To: <8538yyt7z8.fsf@iznogoud.viz> (Wolfgang Jenkner's message of "Sat, 22 Dec 2012 16:27:36 +0100") Message-ID: <87y5gpfws8.fsf@blah.blah> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.8 (/) X-Debbugs-Envelope-To: 13160 Cc: Wolfgang Jenkner X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -0.0 (/) Wolfgang Jenkner writes: > > So let's just cache all entries at the first completion attempt. I do that for speed and because I have some pagename-at-point stuff which tries some prefix/suffix combinations to make a good guess. Holding everything uses up a fair amount of memory but I never came up with anything better. I only keep the description part of each name if needed for completing-help.el or icicles. I suppose turfing the cache after a timer could reclaim memory. For the cache I also watch /var/cache/man/index.db (configurable) for mtime changes indicating newly installed programs. If like me you download and install to have a look at something then new pagenames happen quite often and an automatic reload is good. With man-db the index.db is a gdbm or whatever database of course. I suppose direct access would be both much less ram and faster, but I don't think man-db advertises it for external use. I never worked out why running man -k isn't already faster than it seems to be -- just the quantity of data being churned by it and then by emacs I suppose. -- Walk without rhythm and it won't attract the worm. From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 23 08:46:58 2012 Received: (at 13160) by debbugs.gnu.org; 23 Dec 2012 13:46:58 +0000 Received: from localhost ([127.0.0.1]:56291 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TmltJ-00060c-Q0 for submit@debbugs.gnu.org; Sun, 23 Dec 2012 08:46:58 -0500 Received: from ironport2-out.teksavvy.com ([206.248.154.182]:54426) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TmltH-00060T-1X for 13160@debbugs.gnu.org; Sun, 23 Dec 2012 08:46:55 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ai0FAG6Zu09FxLDj/2dsb2JhbABEsEiDSYEIghUBAQQBViMFCwsOJhIUGA0kiBwFugmQRAOIQppxgViDBw X-IronPort-AV: E=Sophos;i="4.75,637,1330923600"; d="scan'208";a="210595209" Received: from 69-196-176-227.dsl.teksavvy.com (HELO pastel.home) ([69.196.176.227]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 23 Dec 2012 08:46:29 -0500 Received: by pastel.home (Postfix, from userid 20848) id 3E30058EA5; Sun, 23 Dec 2012 08:46:28 -0500 (EST) From: Stefan Monnier To: Wolfgang Jenkner Subject: Re: bug#13160: 24.3.50; [PATCH] man page completion support beyond man-db Message-ID: References: <856247krc6.fsf@iznogoud.viz> <87sj78fi0w.fsf@blah.blah> <85ip84qpu8.fsf@iznogoud.viz> <87ehisf7vp.fsf@blah.blah> <8562416f6d.fsf@iznogoud.viz> <8538yyt7z8.fsf@iznogoud.viz> <85txrermss.fsf@iznogoud.viz> Date: Sun, 23 Dec 2012 08:46:28 -0500 In-Reply-To: <85txrermss.fsf@iznogoud.viz> (Wolfgang Jenkner's message of "Sat, 22 Dec 2012 18:58:43 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 13160 Cc: 13160@debbugs.gnu.org, Kevin Ryde X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) >> Does it fix an actual bug? [ Sorry if it does fix a real bug and this >> was mentioned somewhere in this thread, but I haven't found the time to >> read all threads as thoroughly as I'd like. ] > My proposed change log entry indicates that the cache handling is rather > bogus (complete for "foo" then for "bar" and then for "foo" again and > "man -k ^foo" will be run again and the result prepended to the cache). Oh, indeed. Fixed with the trivial patch below, tho. > The main reason, however, is that it eliminates any dependency on the > particular flavour of `man -k' output, so everything can be done in > elisp by the new Man-parse-apropos (I indicated that in the change log > entry, too). That indeed the part of the change log I did not understand. How does the "man -k" argument relate to the "output flavor"? Stefan === modified file 'lisp/man.el' --- lisp/man.el 2012-08-16 01:03:53 +0000 +++ lisp/man.el 2012-12-23 13:45:03 +0000 @@ -815,6 +815,7 @@ (call-process manual-program nil '(t nil) nil "-k" (concat "^" prefix)))) (goto-char (point-min)) + (setq table nil) (while (re-search-forward "^\\([^ \t\n]+\\)\\(?: ?\\((.+?)\\)\\(?:[ \t]+- \\(.*\\)\\)?\\)?" nil t) (push (propertize (concat (match-string 1) (match-string 2)) 'help-echo (match-string 3)) From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 23 14:50:29 2012 Received: (at 13160) by debbugs.gnu.org; 23 Dec 2012 19:50:29 +0000 Received: from localhost ([127.0.0.1]:57068 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TmrZ5-0006KE-Cp for submit@debbugs.gnu.org; Sun, 23 Dec 2012 14:50:29 -0500 Received: from mx14.lb01.inode.at ([62.99.145.16]:13943 helo=mx.inode.at) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TmrZ1-0006K3-TG for 13160@debbugs.gnu.org; Sun, 23 Dec 2012 14:50:25 -0500 Received: from [91.119.206.19] (port=13201 helo=iznogoud.viz) by smartmx-14.inode.at with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1TmrYa-0000uY-RA; Sun, 23 Dec 2012 20:49:56 +0100 Received: from wolfgang by iznogoud.viz with local (Exim 4.80.1 (FreeBSD)) (envelope-from ) id 1TmrYW-0000Q8-HA; Sun, 23 Dec 2012 20:49:52 +0100 From: Wolfgang Jenkner To: Stefan Monnier Subject: Re: bug#13160: 24.3.50; [PATCH] man page completion support beyond man-db References: <856247krc6.fsf@iznogoud.viz> <87sj78fi0w.fsf@blah.blah> <85ip84qpu8.fsf@iznogoud.viz> <87ehisf7vp.fsf@blah.blah> <8562416f6d.fsf@iznogoud.viz> <8538yyt7z8.fsf@iznogoud.viz> <85txrermss.fsf@iznogoud.viz> Date: Sun, 23 Dec 2012 20:49:52 +0100 In-Reply-To: (Stefan Monnier's message of "Sun, 23 Dec 2012 08:46:28 -0500") Message-ID: <851uegr1jz.fsf@iznogoud.viz> User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.8 (/) X-Debbugs-Envelope-To: 13160 Cc: 13160@debbugs.gnu.org, Kevin Ryde X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On Sun, Dec 23 2012, Stefan Monnier wrote: >>> Does it fix an actual bug? [ Sorry if it does fix a real bug and this >>> was mentioned somewhere in this thread, but I haven't found the time to >>> read all threads as thoroughly as I'd like. ] >> My proposed change log entry indicates that the cache handling is rather >> bogus (complete for "foo" then for "bar" and then for "foo" again and >> "man -k ^foo" will be run again and the result prepended to the cache). > > Oh, indeed. Fixed with the trivial patch below, tho. Well yes, you nuke the old content, whis is what the previous versions of my patches proposed here do as well, but this can hardly be called a useful cache then. >> The main reason, however, is that it eliminates any dependency on the >> particular flavour of `man -k' output, so everything can be done in >> elisp by the new Man-parse-apropos (I indicated that in the change log >> entry, too). > > That indeed the part of the change log I did not understand. How does > the "man -k" argument relate to the "output flavor"? Well, I wrote in the proposed change log: Conveniently, the change entails that we don't have to guess the output format of `man -k' in order to pass it a useful regexp. The problem is that the page names are not necessarily anchored at the beginning of a summary line (there are examples in the proposed man-tests.el), so we can't always use "man -k ^foo" to find all summary lines for man page names starting with "foo". A previous version of the patch posted here introduced a new variable holding a suitable regexp `anchor', which, however, would depend on the output format of `man -k', its flavour :-) I think that parsing the full listing obtained with `man -k ^' is the best solution, it's just that storing the result in a plain list is not quite optimal, hence my babbling about tries. I can wait with my changes until we've found a better data structure. Wolfgang From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 23 15:59:44 2012 Received: (at 13160) by debbugs.gnu.org; 23 Dec 2012 20:59:44 +0000 Received: from localhost ([127.0.0.1]:57120 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tmse7-0001Jy-LZ for submit@debbugs.gnu.org; Sun, 23 Dec 2012 15:59:44 -0500 Received: from mx02.lb01.inode.at ([62.99.145.2]:3768 helo=mx.inode.at) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tmse6-0001Jq-6W for 13160@debbugs.gnu.org; Sun, 23 Dec 2012 15:59:43 -0500 Received: from [91.119.206.19] (port=9011 helo=iznogoud.viz) by smartmx-02.inode.at with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1Tmsde-0005m2-SS; Sun, 23 Dec 2012 21:59:15 +0100 Received: from wolfgang by iznogoud.viz with local (Exim 4.80.1 (FreeBSD)) (envelope-from ) id 1Tmsda-0000T9-Qd; Sun, 23 Dec 2012 21:59:10 +0100 From: Wolfgang Jenkner To: Stefan Monnier Subject: Re: bug#13160: 24.3.50; [PATCH] man page completion support beyond man-db References: <856247krc6.fsf@iznogoud.viz> <87sj78fi0w.fsf@blah.blah> <85ip84qpu8.fsf@iznogoud.viz> <87ehisf7vp.fsf@blah.blah> <8562416f6d.fsf@iznogoud.viz> <8538yyt7z8.fsf@iznogoud.viz> <85txrermss.fsf@iznogoud.viz> <851uegr1jz.fsf@iznogoud.viz> Date: Sun, 23 Dec 2012 21:59:10 +0100 In-Reply-To: <851uegr1jz.fsf@iznogoud.viz> (Wolfgang Jenkner's message of "Sun, 23 Dec 2012 20:49:52 +0100") Message-ID: <85d2y0pjs1.fsf@iznogoud.viz> User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.8 (/) X-Debbugs-Envelope-To: 13160 Cc: 13160@debbugs.gnu.org, Kevin Ryde X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On Sun, Dec 23 2012, Wolfgang Jenkner wrote: > Well yes, you nuke the old content, whis is what the previous versions > of my patches proposed here do as well, The previous (second) version did, the very first version did not fix this. Wolfgang From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 23 19:00:44 2012 Received: (at 13160) by debbugs.gnu.org; 24 Dec 2012 00:00:44 +0000 Received: from localhost ([127.0.0.1]:57161 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TmvTH-0005dQ-1J for submit@debbugs.gnu.org; Sun, 23 Dec 2012 19:00:43 -0500 Received: from pruche.dit.umontreal.ca ([132.204.246.22]:44096) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TmvTD-0005dH-V4 for 13160@debbugs.gnu.org; Sun, 23 Dec 2012 19:00:40 -0500 Received: from faina.iro.umontreal.ca (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id qBO009is017732; Sun, 23 Dec 2012 19:00:10 -0500 Received: by faina.iro.umontreal.ca (Postfix, from userid 20848) id 10A17B4311; Sun, 23 Dec 2012 19:00:11 -0500 (EST) From: Stefan Monnier To: Wolfgang Jenkner Subject: Re: bug#13160: 24.3.50; [PATCH] man page completion support beyond man-db Message-ID: References: <856247krc6.fsf@iznogoud.viz> <87sj78fi0w.fsf@blah.blah> <85ip84qpu8.fsf@iznogoud.viz> <87ehisf7vp.fsf@blah.blah> <8562416f6d.fsf@iznogoud.viz> <8538yyt7z8.fsf@iznogoud.viz> <85txrermss.fsf@iznogoud.viz> <851uegr1jz.fsf@iznogoud.viz> Date: Sun, 23 Dec 2012 19:00:10 -0500 In-Reply-To: <851uegr1jz.fsf@iznogoud.viz> (Wolfgang Jenkner's message of "Sun, 23 Dec 2012 20:49:52 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV4441=0 X-NAI-Spam-Version: 2.2.0.9309 : core <4441> : streams <879593> : uri <1302201> X-Spam-Score: -0.8 (/) X-Debbugs-Envelope-To: 13160 Cc: 13160@debbugs.gnu.org, Kevin Ryde X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.5 (---) >>>> Does it fix an actual bug? [ Sorry if it does fix a real bug and this >>>> was mentioned somewhere in this thread, but I haven't found the time to >>>> read all threads as thoroughly as I'd like. ] >>> My proposed change log entry indicates that the cache handling is rather >>> bogus (complete for "foo" then for "bar" and then for "foo" again and >>> "man -k ^foo" will be run again and the result prepended to the cache). >> Oh, indeed. Fixed with the trivial patch below, tho. > Well yes, you nuke the old content, whis is what the previous versions > of my patches proposed here do as well, but this can hardly be called > a useful cache then. It can still be very useful: when you do M-x man RET pe TAB r TAB TAB it will only run `man' once instead of 3 or more times. That's the main purpose of the cache. The fact that the cache is preserved between runs of M-x man is probably more a misfeature, since it means that the cache is never refreshed (i.e. gets out of date after "aptitude upgrade"). Stefan From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 23 20:21:24 2012 Received: (at 13160) by debbugs.gnu.org; 24 Dec 2012 01:21:24 +0000 Received: from localhost ([127.0.0.1]:57203 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TmwjM-0007Z9-Al for submit@debbugs.gnu.org; Sun, 23 Dec 2012 20:21:24 -0500 Received: from ironport2-out.teksavvy.com ([206.248.154.182]:30710) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TmwjK-0007Z2-Mu for 13160@debbugs.gnu.org; Sun, 23 Dec 2012 20:21:22 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ai4FAG6Zu09FxLDj/2dsb2JhbABEsEiDSYEIghUBAQQBVhYKAwULCw4fBxIUGA0kLoduBboJjRqDKgOIQppxgViDBw X-IronPort-AV: E=Sophos;i="4.75,637,1330923600"; d="scan'208";a="210617559" Received: from 69-196-176-227.dsl.teksavvy.com (HELO pastel.home) ([69.196.176.227]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 23 Dec 2012 20:20:54 -0500 Received: by pastel.home (Postfix, from userid 20848) id 1E51159067; Sun, 23 Dec 2012 20:20:54 -0500 (EST) From: Stefan Monnier To: Wolfgang Jenkner Subject: Re: bug#13160: 24.3.50; [PATCH] man page completion support beyond man-db Message-ID: References: <856247krc6.fsf@iznogoud.viz> <87sj78fi0w.fsf@blah.blah> <85ip84qpu8.fsf@iznogoud.viz> <87ehisf7vp.fsf@blah.blah> <8562416f6d.fsf@iznogoud.viz> <8538yyt7z8.fsf@iznogoud.viz> <85txrermss.fsf@iznogoud.viz> <851uegr1jz.fsf@iznogoud.viz> Date: Sun, 23 Dec 2012 20:20:53 -0500 In-Reply-To: <851uegr1jz.fsf@iznogoud.viz> (Wolfgang Jenkner's message of "Sun, 23 Dec 2012 20:49:52 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.8 (/) X-Debbugs-Envelope-To: 13160 Cc: 13160@debbugs.gnu.org, Kevin Ryde X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) [ Second part of my reply, sorry I had to leave in a hurry. ] >> That indeed the part of the change log I did not understand. How does >> the "man -k" argument relate to the "output flavor"? > Well, I wrote in the proposed change log: > Conveniently, the change entails that we don't have to guess the > output format of `man -k' in order to pass it a useful regexp. > The problem is that the page names are not necessarily anchored at the > beginning of a summary line (there are examples in the proposed > man-tests.el), so we can't always use "man -k ^foo" to find all summary > lines for man page names starting with "foo". A previous version of the > patch posted here introduced a new variable holding a suitable regexp > `anchor', which, however, would depend on the output format of `man -k', > its flavour :-) Oh, so you're saying that the regexp passed to "man -k" is matched not against plain command names, but against lines of the same shape as the output of "man -k"? IOW, "man -k RE" is barely more than "man -k ^ | grep RE"? Oh, yes, I see that now, indeed (I guess I did know that a some point, but it doesn't even ring a remote bell). > I think that parsing the full listing obtained with `man -k ^' is the > best solution, it's just that storing the result in a plain list is not > quite optimal, hence my babbling about tries. The problem is not only the lookup time (which is usually small enough not to be a problem), but the actual memory use (which slows down GC among other things). My earlier estimate was very optimistic since it didn't take into account the `help-echo' text-property, which more than doubles the size. The easiest is probably to keep the current structure and just drop the ^ if the string is non-empty (we'll get lots more false-positives than with the ^, but we still gain: even for some single letters, like "man -k b", we get less than half as much data as "man -k ^"). Stefan From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 23 21:24:31 2012 Received: (at 13160) by debbugs.gnu.org; 24 Dec 2012 02:24:31 +0000 Received: from localhost ([127.0.0.1]:57279 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TmxiQ-0001Zg-Pu for submit@debbugs.gnu.org; Sun, 23 Dec 2012 21:24:31 -0500 Received: from mx21.lb01.inode.at ([62.99.145.23]:60431 helo=mx.inode.at) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TmxiO-0001ZY-P5 for 13160@debbugs.gnu.org; Sun, 23 Dec 2012 21:24:30 -0500 Received: from [91.119.206.19] (port=12498 helo=iznogoud.viz) by smartmx-21.inode.at with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1Tmxhw-0007JW-8i; Mon, 24 Dec 2012 03:24:00 +0100 Received: from wolfgang by iznogoud.viz with local (Exim 4.80.1 (FreeBSD)) (envelope-from ) id 1Tmxhs-0000jG-8f; Mon, 24 Dec 2012 03:23:56 +0100 From: Wolfgang Jenkner To: Stefan Monnier Subject: Re: bug#13160: 24.3.50; [PATCH] man page completion support beyond man-db References: <856247krc6.fsf@iznogoud.viz> <87sj78fi0w.fsf@blah.blah> <85ip84qpu8.fsf@iznogoud.viz> <87ehisf7vp.fsf@blah.blah> <8562416f6d.fsf@iznogoud.viz> <8538yyt7z8.fsf@iznogoud.viz> <85txrermss.fsf@iznogoud.viz> <851uegr1jz.fsf@iznogoud.viz> Date: Mon, 24 Dec 2012 03:23:55 +0100 In-Reply-To: (Stefan Monnier's message of "Sun, 23 Dec 2012 20:20:53 -0500") Message-ID: <85r4mgqjb8.fsf@iznogoud.viz> User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.8 (/) X-Debbugs-Envelope-To: 13160 Cc: 13160@debbugs.gnu.org, Kevin Ryde X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On Mon, Dec 24 2012, Stefan Monnier wrote: > The easiest is probably to keep the current structure and just drop the > ^ if the string is non-empty (we'll get lots more false-positives than > with the ^, but we still gain: even for some single letters, like > "man -k b", we get less than half as much data as "man -k ^"). You mean, for all man programs? I considered this as well, but I just don't feel like making things worse for the two man programs which are used on GNU-based system, and which do have a single page name per line, and at its beginning (quite reasonably so, and in the spirit of POSIX man(1p), I'd say). So perhaps the second patch I proposed (without the test for valid output of `man -k ^') http://permalink.gmane.org/gmane.emacs.bugs/68605 would be better, after all, even though the Man-keyword-completion-anchor variable is ugly. Wolfgang From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 23 23:35:07 2012 Received: (at 13160) by debbugs.gnu.org; 24 Dec 2012 04:35:08 +0000 Received: from localhost ([127.0.0.1]:57322 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tmzkp-0004eT-HJ for submit@debbugs.gnu.org; Sun, 23 Dec 2012 23:35:07 -0500 Received: from ironport2-out.teksavvy.com ([206.248.154.182]:33550) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tmzkj-0004e7-SD for 13160@debbugs.gnu.org; Sun, 23 Dec 2012 23:35:02 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EAG6Zu09FxLDj/2dsb2JhbABEtBGBCIIVAQEEAVYjBQsLDiYSFBgNJIgcBQu5fpBEA4hCjWiNCYFYgwc X-IronPort-AV: E=Sophos;i="4.75,637,1330923600"; d="scan'208";a="210624816" Received: from 69-196-176-227.dsl.teksavvy.com (HELO fmsmemgm.homelinux.net) ([69.196.176.227]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 23 Dec 2012 23:34:32 -0500 Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 5241FAE071; Sun, 23 Dec 2012 23:34:32 -0500 (EST) From: Stefan Monnier To: Wolfgang Jenkner Subject: Re: bug#13160: 24.3.50; [PATCH] man page completion support beyond man-db Message-ID: References: <856247krc6.fsf@iznogoud.viz> <87sj78fi0w.fsf@blah.blah> <85ip84qpu8.fsf@iznogoud.viz> <87ehisf7vp.fsf@blah.blah> <8562416f6d.fsf@iznogoud.viz> <8538yyt7z8.fsf@iznogoud.viz> <85txrermss.fsf@iznogoud.viz> <851uegr1jz.fsf@iznogoud.viz> <85r4mgqjb8.fsf@iznogoud.viz> Date: Sun, 23 Dec 2012 23:34:32 -0500 In-Reply-To: <85r4mgqjb8.fsf@iznogoud.viz> (Wolfgang Jenkner's message of "Mon, 24 Dec 2012 03:23:55 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.8 (/) X-Debbugs-Envelope-To: 13160 Cc: 13160@debbugs.gnu.org, Kevin Ryde X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -0.5 (/) > You mean, for all man programs? I considered this as well, but I just > don't feel like making things worse for the two man programs which are > used on GNU-based system, and which do have a single page name per line, > and at its beginning (quite reasonably so, and in the spirit of POSIX > man(1p), I'd say). So perhaps the second patch I proposed (without the > test for valid output of `man -k ^') > http://permalink.gmane.org/gmane.emacs.bugs/68605 Hmmm, yes that looks fine. > would be better, after all, even though the > Man-keyword-completion-anchor variable is ugly. We could replace it with a boolean var like `Man--k-anchor-broken', since I think it's a bug for "man -k ^foo" to not match commands that start with a "foo" prefix. Stefan From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 29 19:11:31 2012 Received: (at 13160) by debbugs.gnu.org; 30 Dec 2012 00:11:31 +0000 Received: from localhost ([127.0.0.1]:36472 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tp6V0-0006YP-TS for submit@debbugs.gnu.org; Sat, 29 Dec 2012 19:11:31 -0500 Received: from mailout1-13.pacific.net.au ([125.255.80.132]:37900 helo=mailout3-syd3.pacific.net.au) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tp6Uu-0006YB-FX for 13160@debbugs.gnu.org; Sat, 29 Dec 2012 19:11:26 -0500 Received: from mailproxy3-syd3.pacific.net.au (mailproxy3-syd3.pacific.net.au [61.8.2.164]) by mailout3-syd3.pacific.net.au (Postfix) with ESMTP id 8DA2B6B8352; Sun, 30 Dec 2012 11:10:20 +1100 (EST) Received: from blah.blah (unknown [203.26.175.16]) by mailproxy3-syd3.pacific.net.au (Postfix) with ESMTP id 00908578072; Sun, 30 Dec 2012 11:10:20 +1100 (EST) Received: from gg by blah.blah with local (Exim 4.80) (envelope-from ) id 1Tp6UG-0006bK-M1; Sun, 30 Dec 2012 11:10:44 +1100 From: Kevin Ryde To: Stefan Monnier Subject: Re: bug#13160: 24.3.50; [PATCH] man page completion support beyond man-db References: <856247krc6.fsf@iznogoud.viz> <87sj78fi0w.fsf@blah.blah> <85ip84qpu8.fsf@iznogoud.viz> <87ehisf7vp.fsf@blah.blah> <8562416f6d.fsf@iznogoud.viz> <8538yyt7z8.fsf@iznogoud.viz> <85txrermss.fsf@iznogoud.viz> <851uegr1jz.fsf@iznogoud.viz> Date: Sun, 30 Dec 2012 11:10:44 +1100 In-Reply-To: (Stefan Monnier's message of "Sun, 23 Dec 2012 20:20:53 -0500") Message-ID: <87y5gg762j.fsf@blah.blah> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 13160 Cc: 13160@debbugs.gnu.org, Wolfgang Jenkner X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Stefan Monnier writes: > > "man -k RE" Daniel Pittman I think also reported that on macos the pattern is a plain grep BRE whereas posix says it's supposed to be an egrep ERE. Or some such. If that makes a difference to escaping special chars ... -- "How can you have any pudding if you don't eat your meat." From debbugs-submit-bounces@debbugs.gnu.org Sun Jan 06 14:52:30 2013 Received: (at 13160) by debbugs.gnu.org; 6 Jan 2013 19:52:31 +0000 Received: from localhost ([127.0.0.1]:48354 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TrwGi-0002gX-9r for submit@debbugs.gnu.org; Sun, 06 Jan 2013 14:52:30 -0500 Received: from mx02.lb01.inode.at ([62.99.145.2]:10672 helo=mx.inode.at) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TrwGf-0002gS-RU for 13160@debbugs.gnu.org; Sun, 06 Jan 2013 14:52:27 -0500 Received: from [91.119.206.19] (port=6109 helo=iznogoud.viz) by smartmx-02.inode.at with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1TrwGL-0003bV-AA; Sun, 06 Jan 2013 20:52:05 +0100 Received: from wolfgang by iznogoud.viz with local (Exim 4.80.1 (FreeBSD)) (envelope-from ) id 1TrwGG-0000m7-QB; Sun, 06 Jan 2013 20:52:00 +0100 From: Wolfgang Jenkner To: Stefan Monnier Subject: Re: bug#13160: 24.3.50; [PATCH] man page completion support beyond man-db Date: Sun, 06 Jan 2013 20:27:56 +0100 References: <856247krc6.fsf@iznogoud.viz> <87sj78fi0w.fsf@blah.blah> <85ip84qpu8.fsf@iznogoud.viz> <87ehisf7vp.fsf@blah.blah> <8562416f6d.fsf@iznogoud.viz> <8538yyt7z8.fsf@iznogoud.viz> <85txrermss.fsf@iznogoud.viz> <851uegr1jz.fsf@iznogoud.viz> Message-ID: <85fw2em6n3.fsf@iznogoud.viz> User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 13160 Cc: 13160@debbugs.gnu.org, Kevin Ryde X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On Mon, Dec 24 2012, Stefan Monnier wrote: > The fact that the cache is preserved between runs of M-x man is > probably more a misfeature, since it means that the cache is never > refreshed (i.e. gets out of date after "aptitude upgrade"). Given that and the fact that indefinitely keeping around large lists (like Man-completion-cache holding the completion of an empty prefix) is bad, why not preventing this (the first hunk is the fix you proposed in http://permalink.gmane.org/gmane.emacs.bugs/68945). Wolfgang -- >8 -- Subject: [PATCH] * lisp/man.el (Man-completion-table): Reset cache to nil. (man): Bind Man-completion-cache to nil, thus clarifying that it is not meant to be persistent. (Bug#13160) --- lisp/man.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lisp/man.el b/lisp/man.el index 847917d8..8210d63 100644 --- a/lisp/man.el +++ b/lisp/man.el @@ -815,6 +815,7 @@ POS defaults to `point'." (call-process manual-program nil '(t nil) nil "-k" (concat "^" prefix)))) (goto-char (point-min)) + (setq table nil) (while (re-search-forward "^\\([^ \t\n]+\\)\\(?: ?\\((.+?)\\)\\(?:[ \t]+- \\(.*\\)\\)?\\)?" nil t) (push (propertize (concat (match-string 1) (match-string 2)) 'help-echo (match-string 3)) @@ -891,6 +892,7 @@ names or descriptions. The pattern argument is usually an ;; ("man -k" is case-insensitive similarly, so the ;; table has everything available to complete) (completion-ignore-case t) + Man-completion-cache (input (completing-read (format "Manual entry%s" (if (string= default-entry "") -- 1.8.0.2 From debbugs-submit-bounces@debbugs.gnu.org Sun Jan 06 14:52:40 2013 Received: (at 13160) by debbugs.gnu.org; 6 Jan 2013 19:52:40 +0000 Received: from localhost ([127.0.0.1]:48358 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TrwGt-0002gt-1p for submit@debbugs.gnu.org; Sun, 06 Jan 2013 14:52:39 -0500 Received: from mx21.lb01.inode.at ([62.99.145.23]:53182 helo=mx.inode.at) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TrwGp-0002gi-HL for 13160@debbugs.gnu.org; Sun, 06 Jan 2013 14:52:37 -0500 Received: from [91.119.206.19] (port=14592 helo=iznogoud.viz) by smartmx-21.inode.at with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1TrwGV-00017T-1W; Sun, 06 Jan 2013 20:52:15 +0100 Received: from wolfgang by iznogoud.viz with local (Exim 4.80.1 (FreeBSD)) (envelope-from ) id 1TrwGQ-0000mC-RN; Sun, 06 Jan 2013 20:52:10 +0100 From: Wolfgang Jenkner To: Stefan Monnier Subject: Re: bug#13160: 24.3.50; [PATCH] man page completion support beyond man-db Date: Sun, 06 Jan 2013 20:48:06 +0100 References: <856247krc6.fsf@iznogoud.viz> <87sj78fi0w.fsf@blah.blah> <85ip84qpu8.fsf@iznogoud.viz> <87ehisf7vp.fsf@blah.blah> <8562416f6d.fsf@iznogoud.viz> <8538yyt7z8.fsf@iznogoud.viz> <85txrermss.fsf@iznogoud.viz> <851uegr1jz.fsf@iznogoud.viz> <85r4mgqjb8.fsf@iznogoud.viz> Message-ID: <85a9smm6mt.fsf@iznogoud.viz> User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 13160 Cc: 13160@debbugs.gnu.org, Kevin Ryde X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On Mon, Dec 24 2012, Stefan Monnier wrote: > We could replace it with a boolean var like `Man--k-anchor-broken', > since I think it's a bug for "man -k ^foo" to not match commands that > start with a "foo" prefix. With a different name: -- >8 -- Subject: [PATCH] Support man page completion for more man programs. * lisp/man.el (Man-parse-man-k): New function. (Man-man-k-use-anchor): New variable. (Man-completion-table): Use them to replace man-db specific code for parsing `man -k' output. * test/automated/man-tests.el: New file. --- lisp/man.el | 75 +++++++++++++++++++++++----- test/automated/man-tests.el | 118 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 182 insertions(+), 11 deletions(-) create mode 100644 test/automated/man-tests.el diff --git a/lisp/man.el b/lisp/man.el index 8210d63..ee3f507 100644 --- a/lisp/man.el +++ b/lisp/man.el @@ -780,6 +780,56 @@ POS defaults to `point'." ;; but apparently that's not the case in all cases, so let's add a cache. "Cache of completion table of the form (PREFIX . TABLE).") +(defvar Man-man-k-use-anchor + ;; man-db or man-1.* + (memq system-type '(gnu gnu/linux gnu/kfreebsd)) + "If non-nil prepend ^ to the prefix passed to \"man -k\" for completion. +The value should be nil if \"man -k ^PREFIX\" may omit some man +pages whose names start with PREFIX. + +Currently, the default value depends on `system-type' and is +non-nil where the standard man programs are known to behave +properly. Setting the value to nil always gives correct results +but computing the list of completions may take a bit longer.") + +(defun Man-parse-man-k () + "Parse \"man -k\" output and return the list of page names. + +The current buffer should contain the output of a command of the +form \"man -k keyword\", which is traditionally also available with +apropos(1). + +While POSIX man(1p) is a bit vague about what to expect here, +this function tries to parse some commonly used formats, which +can be described in the following informal way, with square brackets +indicating optional parts and whitespace being interpreted +somewhat loosely. + +foo[, bar [, ...]] [other stuff] (sec) - description +foo(sec)[, bar(sec) [, ...]] [other stuff] - description + +For more details and some regression tests, please see +test/automated/man-tests.el in the emacs bzr repository." + (goto-char (point-min)) + (let (table) + (while (search-forward-regexp "^\\([^ \t,\n]+\\)\\(.*?\\)\ +\\(?:[ \t]\\(([^ \t,\n]+?)\\)\\)?\\(?:[ \t]+- ?\\(.*\\)\\)?$" nil t) + (let ((section (match-string 3)) + (description (match-string 4)) + (bound (match-end 2)) + (continue (goto-char (match-end 1)))) + (while continue + ;; The first regexp grouping may already match the section + ;; tacked on to the name, which is ok since for the formats we + ;; claim to support the third (non-shy) grouping does not + ;; match in this case, i.e., section is nil. + (push (propertize (concat (match-string 1) section) + 'help-echo description) + table) + (setq continue (search-forward-regexp "\\=, *\\([^ \t,]+\\)" + bound t))))) + (nreverse table))) + (defun Man-completion-table (string pred action) (cond ;; This ends up returning t for pretty much any string, and hence leads to @@ -811,17 +861,20 @@ POS defaults to `point'." ;; 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 "^" prefix)))) - (goto-char (point-min)) - (setq table nil) - (while (re-search-forward "^\\([^ \t\n]+\\)\\(?: ?\\((.+?)\\)\\(?:[ \t]+- \\(.*\\)\\)?\\)?" nil t) - (push (propertize (concat (match-string 1) (match-string 2)) - 'help-echo (match-string 3)) - table))) - ;; Cache the table for later reuse. - (setq Man-completion-cache (cons prefix table))) + (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))) + (unless Man-man-k-use-anchor + ;; Weed out unwanted page names. + (dolist (comp (prog1 table (setq table nil))) + (if (string-prefix-p prefix comp) + (push comp table)))) + ;; Cache the table for later reuse. + (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 diff --git a/test/automated/man-tests.el b/test/automated/man-tests.el new file mode 100644 index 0000000..8a2ec95 --- /dev/null +++ b/test/automated/man-tests.el @@ -0,0 +1,118 @@ +;;; man-tests.el --- Test suite for man. + +;; Copyright (C) 2013 Free Software Foundation, Inc. + +;; Author: Wolfgang Jenkner +;; Keywords: help, internal, unix + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Code: + +(require 'ert) +(require 'man) + +(defconst man-tests-parse-man-k-tests + '(;; GNU/Linux: man-db-2.6.1 + ("\ +sin (3) - sine function +sinf (3) - sine function +sinl (3) - sine function" + . (#("sin(3)" 0 6 (help-echo "sine function")) #("sinf(3)" 0 7 (help-echo "sine function")) #("sinl(3)" 0 7 (help-echo "sine function")))) + ;; GNU/Linux: man-1.6g + ("\ +sin (3) - sine function +sinf [sin] (3) - sine function +sinl [sin] (3) - sine function" + . (#("sin(3)" 0 6 (help-echo "sine function")) #("sinf(3)" 0 7 (help-echo "sine function")) #("sinl(3)" 0 7 (help-echo "sine function")))) + ;; FreeBSD 9 + ("\ +sin(3), sinf(3), sinl(3) - sine functions" + . (#("sin(3)" 0 6 (help-echo "sine functions")) #("sinf(3)" 0 7 (help-echo "sine functions")) #("sinl(3)" 0 7 (help-echo "sine functions")))) + ;; SunOS, Solaris + ;; http://docs.oracle.com/cd/E19455-01/805-6331/usradm-7/index.html + ;; SunOS 4 + ("\ +tset, reset (1) - establish or restore terminal characteristics" + . (#("tset(1)" 0 7 (help-echo "establish or restore terminal characteristics")) #("reset(1)" 0 8 (help-echo "establish or restore terminal characteristics")))) + ;; SunOS 5.7, Solaris + ("\ +reset tset (1b) - establish or restore terminal characteristics +tset tset (1b) - establish or restore terminal characteristics" + . (#("reset(1b)" 0 8 (help-echo "establish or restore terminal characteristics")) #("tset(1b)" 0 7 (help-echo "establish or restore terminal characteristics")))) + ;; Minix 3 + ;; http://www.minix3.org/manpages/html5/whatis.html + ("\ +cawf, nroff (1) - C version of the nroff-like, Amazingly Workable (text) Formatter +whatis (5) - database of online manual pages" + . (#("cawf(1)" 0 7 (help-echo "C version of the nroff-like, Amazingly Workable (text) Formatter")) #("nroff(1)" 0 8 (help-echo "C version of the nroff-like, Amazingly Workable (text) Formatter")) #("whatis(5)" 0 9 (help-echo "database of online manual pages")))) + ;; HP-UX + ;; http://docstore.mik.ua/manuals/hp-ux/en/B2355-60130/man.1.html + ;; Assuming that the line break in the zgrep description was + ;; introduced by the man page formatting. + ("\ +grep, egrep, fgrep (1) - search a file for a pattern +zgrep(1) - search possibly compressed files for a regular expression" + . (#("grep(1)" 0 7 (help-echo "search a file for a pattern")) #("egrep(1)" 0 8 (help-echo "search a file for a pattern")) #("fgrep(1)" 0 8 (help-echo "search a file for a pattern")) #("zgrep(1)" 0 8 (help-echo "search possibly compressed files for a regular expression")))) + ;; AIX + ;; http://pic.dhe.ibm.com/infocenter/aix/v7r1/topic/com.ibm.aix.cmds/doc/aixcmds6/whatis.htm + ("\ +ls(1) -Displays the contents of a directory." + . (#("ls(1)" 0 5 (help-echo "Displays the contents of a directory.")))) + ;; https://www.ibm.com/developerworks/mydeveloperworks/blogs/cgaix/entry/catman_0703_102_usr_lbin_mkwhatis_the_error_number_is_1?lang=en + ("\ +loopmount(1) - Associate an image file to a loopback device." + . (#("loopmount(1)" 0 12 (help-echo "Associate an image file to a loopback device.")))) + ) + "List of tests for `Man-parse-man-k'. +Each element is a cons cell whose car is a string containing +man -k output. That should result in the table which is stored +in the cdr of the element.") + +(defun man-tests-name-equal-p (name description string) + (and (equal name string) + (not (next-single-property-change 0 'help-echo string)) + (equal (get-text-property 0 'help-echo string) description))) + +(defun man-tests-parse-man-k-test-case (test) + (let ((temp-buffer (get-buffer-create " *test-man*")) + (man-k-output (car test))) + (unwind-protect + (save-window-excursion + (with-current-buffer temp-buffer + (erase-buffer) + (insert man-k-output) + (let ((result (Man-parse-man-k)) + (checklist (cdr test))) + (while (and checklist result + (man-tests-name-equal-p + (car checklist) + (get-text-property 0 'help-echo + (car checklist)) + (pop result))) + (pop checklist)) + (and (null checklist) (null result))))) + (and (buffer-name temp-buffer) + (kill-buffer temp-buffer))))) + +(ert-deftest man-tests () + "Test man." + (dolist (test man-tests-parse-man-k-tests) + (should (man-tests-parse-man-k-test-case test)))) + +(provide 'man-tests) + +;;; man-tests.el ends here -- 1.8.0.2 From debbugs-submit-bounces@debbugs.gnu.org Thu Jan 10 10:02:06 2013 Received: (at 13160-done) by debbugs.gnu.org; 10 Jan 2013 15:02:06 +0000 Received: from localhost ([127.0.0.1]:54292 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TtJds-0002QE-Ty for submit@debbugs.gnu.org; Thu, 10 Jan 2013 10:02:05 -0500 Received: from ironport2-out.teksavvy.com ([206.248.154.182]:40459) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TtJdq-0002Pj-Sr for 13160-done@debbugs.gnu.org; Thu, 10 Jan 2013 10:02:03 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhsHAG6Zu0+4rw8T/2dsb2JhbABEgXuuTYNJgQiCFQEBBAFWIwULCw4JHRIUGA0WDogcBboJkEQDiEKacYFYgwc X-IronPort-AV: E=Sophos;i="4.75,637,1330923600"; d="scan'208";a="212223354" Received: from 184-175-15-19.dsl.teksavvy.com (HELO pastel.home) ([184.175.15.19]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 10 Jan 2013 10:01:55 -0500 Received: by pastel.home (Postfix, from userid 20848) id 3B47659230; Thu, 10 Jan 2013 10:01:55 -0500 (EST) From: Stefan Monnier To: Wolfgang Jenkner Subject: Re: bug#13160: 24.3.50; [PATCH] man page completion support beyond man-db Message-ID: References: <856247krc6.fsf@iznogoud.viz> <87sj78fi0w.fsf@blah.blah> <85ip84qpu8.fsf@iznogoud.viz> <87ehisf7vp.fsf@blah.blah> <8562416f6d.fsf@iznogoud.viz> <8538yyt7z8.fsf@iznogoud.viz> <85txrermss.fsf@iznogoud.viz> <851uegr1jz.fsf@iznogoud.viz> <85r4mgqjb8.fsf@iznogoud.viz> <85a9smm6mt.fsf@iznogoud.viz> Date: Thu, 10 Jan 2013 10:01:54 -0500 In-Reply-To: <85a9smm6mt.fsf@iznogoud.viz> (Wolfgang Jenkner's message of "Sun, 06 Jan 2013 20:48:06 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 13160-done Cc: 13160-done@debbugs.gnu.org, Kevin Ryde X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) > Subject: [PATCH] Support man page completion for more man programs. * > lisp/man.el (Man-parse-man-k): New function. (Man-man-k-use-anchor): New > variable. (Man-completion-table): Use them to replace man-db specific code > for parsing `man -k' output. Thanks, installed (along with the previous cache-flush patch and with a few minor changes, mostly not trimming the extraneous entries we get if the anchor is not used). Stefan From unknown Sun Jun 22 11:45:07 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 08 Feb 2013 12:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator