From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#12456: 24.2.50; Completion in `Info-goto-node' (cross-manual jump) Date: Sat, 15 Dec 2012 17:30:30 +0200 Organization: JURTA Message-ID: <87mwxfl4dl.fsf@mail.jurta.org> References: <83sjaf26jt.fsf@gnu.org> <83boh31lrj.fsf@gnu.org> <87a9wn85fa.fsf@mail.jurta.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1355585764 30031 80.91.229.3 (15 Dec 2012 15:36:04 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 15 Dec 2012 15:36:04 +0000 (UTC) Cc: 12456@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Dec 15 16:36:18 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Tjtmj-0003Q5-Ak for geb-bug-gnu-emacs@m.gmane.org; Sat, 15 Dec 2012 16:36:17 +0100 Original-Received: from localhost ([::1]:42518 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjtmW-0007V5-99 for geb-bug-gnu-emacs@m.gmane.org; Sat, 15 Dec 2012 10:36:04 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:43096) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjtmS-0007Uv-5q for bug-gnu-emacs@gnu.org; Sat, 15 Dec 2012 10:36:02 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TjtmR-0007MR-0a for bug-gnu-emacs@gnu.org; Sat, 15 Dec 2012 10:36:00 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:33963) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjtmQ-0007MM-T5 for bug-gnu-emacs@gnu.org; Sat, 15 Dec 2012 10:35:58 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TjtnS-0007uN-63 for bug-gnu-emacs@gnu.org; Sat, 15 Dec 2012 10:37:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 15 Dec 2012 15:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12456 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 12456-submit@debbugs.gnu.org id=B12456.135558581130384 (code B ref 12456); Sat, 15 Dec 2012 15:37:02 +0000 Original-Received: (at 12456) by debbugs.gnu.org; 15 Dec 2012 15:36:51 +0000 Original-Received: from localhost ([127.0.0.1]:44214 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TjtnG-0007tz-9f for submit@debbugs.gnu.org; Sat, 15 Dec 2012 10:36:51 -0500 Original-Received: from ps18281.dreamhost.com ([69.163.218.105]:57172 helo=ps18281.dreamhostps.com) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tjtn7-0007ta-Bx for 12456@debbugs.gnu.org; Sat, 15 Dec 2012 10:36:44 -0500 Original-Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id C5298451CD60; Sat, 15 Dec 2012 07:35:35 -0800 (PST) In-Reply-To: <87a9wn85fa.fsf@mail.jurta.org> (Juri Linkov's message of "Tue, 18 Sep 2012 23:03:21 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:68561 Archived-At: >>> * "(elisp)" completes to all nodes in the elisp manual. >> >> Yes, that's the part that's not yet implemented. Patch welcome, > > This can be implemented by this patch. The remaining problem is > that it's too slow because it doesn't cache completions of non-current > manuals. Perhaps `Info-build-node-completions' should use `Info-toc-nodes' > that caches node names from all visited manuals. Actually I realized that `Info-toc-nodes' can't be used because it doesn't contain Info anchors whereas `Info-build-node-completions' adds anchors along with references. So to be able to cache completions in non-current manuals requires adding a global variable `Info-file-completions' like in the patch below: === modified file 'lisp/info.el' --- lisp/info.el 2012-12-08 23:12:08 +0000 +++ lisp/info.el 2012-12-15 15:28:17 +0000 @@ -397,6 +395,10 @@ (defvar Info-tag-table-buffer nil (defvar Info-current-file-completions nil "Cached completion list for current Info file.") +(defvar Info-file-completions nil + "Cached completion alist of visited Info files. +Each element of the alist is (FILE . COMPLETIONS)") + (defvar Info-file-supports-index-cookies nil "Non-nil if current Info file supports index cookies.") @@ -1771,12 +1783,20 @@ (defun Info-read-node-name-1 (string pre (substring string 1) predicate code)) - ;; If a file name was given, then any node is fair game. - ((string-match "\\`(" string) - (cond - ((eq code nil) string) - ((eq code t) nil) - (t t))) + ;; If a file name was given, complete nodes in the file. + ((string-match "\\`(\\([^)]+\\))" string) + (let ((file0 (match-string 0 string)) + (file1 (match-string 1 string)) + (node (substring string (match-end 0)))) + (completion-table-with-context + file0 + (apply-partially + (lambda (string pred action) + (complete-with-action + action + (Info-build-node-completions (Info-find-file file1)) + string pred))) + node predicate code))) ;; Otherwise use Info-read-node-completion-table. (t (complete-with-action code Info-read-node-completion-table string predicate)))) @@ -1793,8 +1813,19 @@ (defun Info-read-node-name (prompt) (Info-read-node-name prompt) nodename))) -(defun Info-build-node-completions () +(defun Info-build-node-completions (&optional file) + (if file + (or (cdr (assoc file Info-file-completions)) + (with-temp-buffer + (Info-mode) + (Info-goto-node (format "(%s)Top" file)) + (Info-build-node-completions-1) + (push (cons file Info-current-file-completions) Info-file-completions) + Info-file-completions)) (or Info-current-file-completions + (Info-build-node-completions-1)))) + +(defun Info-build-node-completions-1 () (let ((compl nil) ;; Bind this in case the user sets it to nil. (case-fold-search t) @@ -1826,8 +1857,10 @@ (defun Info-build-node-completions () (setq compl (cons (list (match-string-no-properties 1)) compl)))))))) - (setq compl (cons '("*") compl)) - (set (make-local-variable 'Info-current-file-completions) compl)))) + (setq compl (cons '("*") (nreverse compl))) + (set (make-local-variable 'Info-current-file-completions) compl) + compl)) + (defun Info-restore-point (hl) "If this node has been visited, restore the point value when we left."