unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: Stefan Monnier <monnier@IRO.UMontreal.CA>
Cc: 12456@debbugs.gnu.org
Subject: bug#12456: 24.2.50; Completion in `Info-goto-node' (cross-manual jump)
Date: Sat, 15 Dec 2012 17:30:30 +0200	[thread overview]
Message-ID: <87mwxfl4dl.fsf@mail.jurta.org> (raw)
In-Reply-To: <87a9wn85fa.fsf@mail.jurta.org> (Juri Linkov's message of "Tue, 18 Sep 2012 23:03:21 +0300")

>>> * "(elisp)<TAB>" 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))
+
 \f
 (defun Info-restore-point (hl)
   "If this node has been visited, restore the point value when we left."






  reply	other threads:[~2012-12-15 15:30 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-16 17:59 bug#12456: 24.2.50; Completion in `Info-goto-node' (cross-manual jump) Dani Moncayo
2012-09-16 19:39 ` Dani Moncayo
2012-09-17 21:12 ` Stefan Monnier
2012-09-18  6:23   ` Eli Zaretskii
2012-09-18 12:22     ` Stefan Monnier
2012-09-18 13:52       ` Eli Zaretskii
2012-09-18 14:26         ` Dani Moncayo
2012-09-18 16:57           ` Stefan Monnier
2012-09-18 20:03             ` Juri Linkov
2012-12-15 15:30               ` Juri Linkov [this message]
2012-12-27 20:42                 ` Juri Linkov
2012-12-27 21:37                   ` Dani Moncayo
2012-12-27 21:57                     ` Juri Linkov
2012-12-28 23:57                       ` Juri Linkov
2012-12-29  0:24                         ` Dani Moncayo
2012-12-29 21:59                           ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mwxfl4dl.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=12456@debbugs.gnu.org \
    --cc=monnier@IRO.UMontreal.CA \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).