1407 |
;; (setq list (cdr list)))) |
;; (setq list (cdr list)))) |
1408 |
|
|
1409 |
(defvar Info-complete-menu-buffer) |
(defvar Info-complete-menu-buffer) |
1410 |
|
(defvar Info-complete-next-re nil) |
1411 |
|
(defvar Info-complete-cache nil) |
1412 |
|
|
1413 |
(defun Info-complete-menu-item (string predicate action) |
(defun Info-complete-menu-item (string predicate action) |
1414 |
(let ((completion-ignore-case t) |
(save-excursion |
1415 |
(case-fold-search t)) |
(set-buffer Info-complete-menu-buffer) |
1416 |
(cond ((eq action nil) |
(let ((completion-ignore-case t) |
1417 |
(let (completions |
(case-fold-search t) |
1418 |
(pattern (concat "\n\\* +\\(" |
(orignode Info-current-node) |
1419 |
(regexp-quote string) |
nextnode) |
1420 |
"[^:\t\n]*\\):"))) |
(goto-char (point-min)) |
1421 |
(save-excursion |
(search-forward "\n* Menu:") |
1422 |
(set-buffer Info-complete-menu-buffer) |
(if (not (memq action '(nil t))) |
1423 |
(goto-char (point-min)) |
(re-search-forward |
1424 |
(search-forward "\n* Menu:") |
(concat "\n\\* +" (regexp-quote string) ":") nil t) |
1425 |
(while (re-search-forward pattern nil t) |
(let ((pattern (concat "\n\\* +\\(" |
1426 |
(setq completions |
(regexp-quote string) |
1427 |
(cons (cons (match-string-no-properties 1) |
"[^:\t\n]*\\):")) |
1428 |
(match-beginning 1)) |
completions) |
1429 |
completions)))) |
;; Check the cache. |
1430 |
(try-completion string completions predicate))) |
(if (and (equal (nth 0 Info-complete-cache) Info-current-file) |
1431 |
((eq action t) |
(equal (nth 1 Info-complete-cache) Info-current-node) |
1432 |
(let (completions |
(equal (nth 2 Info-complete-cache) Info-complete-next-re) |
1433 |
(pattern (concat "\n\\* +\\(" |
(let ((prev (nth 3 Info-complete-cache))) |
1434 |
(regexp-quote string) |
(eq t (compare-strings string 0 (length prev) |
1435 |
"[^:\t\n]*\\):"))) |
prev 0 nil t)))) |
1436 |
(save-excursion |
;; We can reuse the previous list. |
1437 |
(set-buffer Info-complete-menu-buffer) |
(setq completions (nth 4 Info-complete-cache)) |
1438 |
(goto-char (point-min)) |
;; The cache can't be used. |
1439 |
(search-forward "\n* Menu:") |
(while |
1440 |
(while (re-search-forward pattern nil t) |
(progn |
1441 |
(setq completions (cons (cons |
(while (re-search-forward pattern nil t) |
1442 |
(match-string-no-properties 1) |
(push (cons (match-string-no-properties 1) |
1443 |
(match-beginning 1)) |
(match-beginning 1)) |
1444 |
completions)))) |
completions)) |
1445 |
(all-completions string completions predicate))) |
;; Check subsequent nodes if applicable. |
1446 |
(t |
(and Info-complete-next-re |
1447 |
(save-excursion |
(setq nextnode (Info-extract-pointer "next" t)) |
1448 |
(set-buffer Info-complete-menu-buffer) |
(string-match Info-complete-next-re nextnode))) |
1449 |
(goto-char (point-min)) |
(Info-goto-node nextnode)) |
1450 |
(search-forward "\n* Menu:") |
;; Go back to the start node (for the next completion). |
1451 |
(re-search-forward (concat "\n\\* +" |
(unless (equal Info-current-node orignode) |
1452 |
(regexp-quote string) |
(Info-goto-node orignode)) |
1453 |
":") |
;; Update the cache. |
1454 |
nil t)))))) |
(setq Info-complete-cache |
1455 |
|
(list Info-current-file Info-current-node |
1456 |
|
Info-complete-next-re string completions))) |
1457 |
|
(if action |
1458 |
|
(all-completions string completions predicate) |
1459 |
|
(try-completion string completions predicate))))))) |
1460 |
|
|
1461 |
|
|
1462 |
(defun Info-menu (menu-item &optional fork) |
(defun Info-menu (menu-item &optional fork) |
1824 |
(error "No cross references in this node") |
(error "No cross references in this node") |
1825 |
(Info-prev-reference t))))) |
(Info-prev-reference t))))) |
1826 |
|
|
1827 |
|
(defun Info-goto-index () |
1828 |
|
(Info-goto-node "Top") |
1829 |
|
(or (search-forward "\n* menu:" nil t) |
1830 |
|
(error "No index")) |
1831 |
|
(or (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t) |
1832 |
|
(error "No index")) |
1833 |
|
(goto-char (match-beginning 1)) |
1834 |
|
(Info-goto-node (Info-extract-menu-node-name))) |
1835 |
|
|
1836 |
(defun Info-index (topic) |
(defun Info-index (topic) |
1837 |
"Look up a string TOPIC in the index for this file. |
"Look up a string TOPIC in the index for this file. |
1838 |
The index is defined as the first node in the top-level menu whose |
The index is defined as the first node in the top level menu whose |
1839 |
name contains the word \"Index\", plus any immediately following |
name contains the word \"Index\", plus any immediately following |
1840 |
nodes whose names also contain the word \"Index\". |
nodes whose names also contain the word \"Index\". |
1841 |
If there are no exact matches to the specified topic, this chooses |
If there are no exact matches to the specified topic, this chooses |
1842 |
the first match which is a case-insensitive substring of a topic. |
the first match which is a case-insensitive substring of a topic. |
1843 |
Use the `,' command to see the other matches. |
Use the `,' command to see the other matches. |
1844 |
Give a blank topic name to go to the Index node itself." |
Give a blank topic name to go to the Index node itself." |
1845 |
(interactive "sIndex topic: ") |
(interactive |
1846 |
|
(list |
1847 |
|
(let ((Info-complete-menu-buffer (clone-buffer)) |
1848 |
|
(Info-complete-next-re "\\<Index\\>")) |
1849 |
|
(unwind-protect |
1850 |
|
(with-current-buffer Info-complete-menu-buffer |
1851 |
|
(Info-goto-index) |
1852 |
|
(completing-read "Index topic: " 'Info-complete-menu-item)) |
1853 |
|
(kill-buffer Info-complete-menu-buffer))))) |
1854 |
(let ((orignode Info-current-node) |
(let ((orignode Info-current-node) |
1855 |
(rnode nil) |
(rnode nil) |
1856 |
(pattern (format "\n\\* +\\([^\n:]*%s[^\n:]*\\):[ \t]*\\([^.\n]*\\)\\.[ \t]*\\([0-9]*\\)" |
(pattern (format "\n\\* +\\([^\n:]*%s[^\n:]*\\):[ \t]*\\([^.\n]*\\)\\.[ \t]*\\([0-9]*\\)" |
1857 |
(regexp-quote topic))) |
(regexp-quote topic))) |
1858 |
node |
node |
1859 |
(case-fold-search t)) |
(case-fold-search t)) |
|
(Info-goto-node "Top") |
|
|
(or (search-forward "\n* menu:" nil t) |
|
|
(error "No index")) |
|
|
(or (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t) |
|
|
(error "No index")) |
|
|
(goto-char (match-beginning 1)) |
|
1860 |
;; Here, and subsequently in this function, |
;; Here, and subsequently in this function, |
1861 |
;; we bind Info-history to nil for internal node-switches |
;; we bind Info-history to nil for internal node-switches |
1862 |
;; so that we don't put junk in the history. |
;; so that we don't put junk in the history. |
1863 |
;; In the first Info-goto-node call, above, we do update the history |
;; In the first Info-goto-node call, above, we do update the history |
1864 |
;; because that is what the user's previous node choice into it. |
;; because that is what the user's previous node choice into it. |
1865 |
(let ((Info-history nil)) |
(let ((Info-history nil)) |
1866 |
(Info-goto-node (Info-extract-menu-node-name))) |
(Info-goto-index)) |
1867 |
(or (equal topic "") |
(or (equal topic "") |
1868 |
(let ((matches nil) |
(let ((matches nil) |
1869 |
(exact nil) |
(exact nil) |
2174 |
;; Update menu menu. |
;; Update menu menu. |
2175 |
(let* ((Info-complete-menu-buffer (current-buffer)) |
(let* ((Info-complete-menu-buffer (current-buffer)) |
2176 |
(items (nreverse (condition-case nil |
(items (nreverse (condition-case nil |
2177 |
(Info-complete-menu-item |
(Info-complete-menu-item "" nil t) |
|
"" (lambda (e) t) t) |
|
2178 |
(error nil)))) |
(error nil)))) |
2179 |
entries current |
entries current |
2180 |
(number 0)) |
(number 0)) |