emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r111354: * lisp/info.el (Info-file-co


From: Juri Linkov
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r111354: * lisp/info.el (Info-file-completions): New variable.
Date: Thu, 27 Dec 2012 22:42:02 +0200
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 111354
fixes bug: http://debbugs.gnu.org/12456
committer: Juri Linkov <address@hidden>
branch nick: trunk
timestamp: Thu 2012-12-27 22:42:02 +0200
message:
  * lisp/info.el (Info-file-completions): New variable.
  (Info-read-node-name-1): Complete node names in the Info file
  when a file name is given.  Call `Info-build-node-completions'
  with a file name.
  (Info-build-node-completions): Add new arg `file'.  When it is
  non-nil, visit it in a temporary buffer and cache its completions in
  `Info-current-file-completions'.  Move most of the function body to
  `Info-build-node-completions-1'.
  (Info-build-node-completions-1): New function with the body from
  `Info-build-node-completions'.
modified:
  lisp/ChangeLog
  lisp/info.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-12-27 20:09:45 +0000
+++ b/lisp/ChangeLog    2012-12-27 20:42:02 +0000
@@ -1,5 +1,18 @@
 2012-12-27  Juri Linkov  <address@hidden>
 
+       * info.el (Info-file-completions): New variable.
+       (Info-read-node-name-1): Complete node names in the Info file
+       when a file name is given.  Call `Info-build-node-completions'
+       with a file name.
+       (Info-build-node-completions): Add new arg `file'.  When it is
+       non-nil, visit it in a temporary buffer and cache its completions in
+       `Info-current-file-completions'.  Move most of the function body to
+       `Info-build-node-completions-1'.
+       (Info-build-node-completions-1): New function with the body from
+       `Info-build-node-completions'.  (Bug#12456)
+
+2012-12-27  Juri Linkov  <address@hidden>
+
        * frame.el (frame-maximization-style): Remove user option.
        (cycle-frame-maximized): Remove function.
        (toggle-frame-maximized): Rewrite and bind to M-<f10>.

=== modified file 'lisp/info.el'
--- a/lisp/info.el      2012-12-08 23:12:08 +0000
+++ b/lisp/info.el      2012-12-27 20:42:02 +0000
@@ -397,6 +397,10 @@
 (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 +1775,20 @@
      (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,41 +1805,54 @@
        (Info-read-node-name prompt)
       nodename)))
 
-(defun Info-build-node-completions ()
-  (or Info-current-file-completions
-      (let ((compl nil)
-           ;; Bind this in case the user sets it to nil.
-           (case-fold-search t)
-           (node-regexp "Node: *\\([^,\n]*\\) *[,\n\t]"))
-       (save-excursion
-         (save-restriction
-           (or Info-tag-table-marker
-               (error "No Info tags found"))
-           (if (marker-buffer Info-tag-table-marker)
-               (let ((marker Info-tag-table-marker))
-                 (set-buffer (marker-buffer marker))
-                 (widen)
-                 (goto-char marker)
-                 (while (re-search-forward "\n\\(Node\\|Ref\\): \\(.*\\)\177" 
nil t)
-                   (setq compl
-                         (cons (list (match-string-no-properties 2))
-                               compl))))
+(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-current-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)
+       (node-regexp "Node: *\\([^,\n]*\\) *[,\n\t]"))
+    (save-excursion
+      (save-restriction
+       (or Info-tag-table-marker
+           (error "No Info tags found"))
+       (if (marker-buffer Info-tag-table-marker)
+           (let ((marker Info-tag-table-marker))
+             (set-buffer (marker-buffer marker))
              (widen)
-             (goto-char (point-min))
-             ;; If the buffer begins with a node header, process that first.
-             (if (Info-node-at-bob-matching node-regexp)
-                 (setq compl (list (match-string-no-properties 1))))
-             ;; Now for the rest of the nodes.
-             (while (search-forward "\n\^_" nil t)
-               (forward-line 1)
-               (let ((beg (point)))
-                 (forward-line 1)
-                 (if (re-search-backward node-regexp beg t)
-                     (setq compl
-                           (cons (list (match-string-no-properties 1))
-                                 compl))))))))
-       (setq compl (cons '("*") compl))
-       (set (make-local-variable 'Info-current-file-completions) compl))))
+             (goto-char marker)
+             (while (re-search-forward "\n\\(Node\\|Ref\\): \\(.*\\)\177" nil 
t)
+               (setq compl
+                     (cons (list (match-string-no-properties 2))
+                           compl))))
+         (widen)
+         (goto-char (point-min))
+         ;; If the buffer begins with a node header, process that first.
+         (if (Info-node-at-bob-matching node-regexp)
+             (setq compl (list (match-string-no-properties 1))))
+         ;; Now for the rest of the nodes.
+         (while (search-forward "\n\^_" nil t)
+           (forward-line 1)
+           (let ((beg (point)))
+             (forward-line 1)
+             (if (re-search-backward node-regexp beg t)
+                 (setq compl
+                       (cons (list (match-string-no-properties 1))
+                             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."


reply via email to

[Prev in Thread] Current Thread [Next in Thread]