diff options
| author | Juri Linkov | 2012-12-27 22:42:02 +0200 |
|---|---|---|
| committer | Juri Linkov | 2012-12-27 22:42:02 +0200 |
| commit | 313f39aa03cc40ddc4faea08636c74bfa52ec099 (patch) | |
| tree | 2b8066dc0bd728aaf3247a1a136304811f95d5b9 | |
| parent | a45b76475ee930497cca375432b44aa0def77fa0 (diff) | |
| download | emacs-313f39aa03cc40ddc4faea08636c74bfa52ec099.tar.gz emacs-313f39aa03cc40ddc4faea08636c74bfa52ec099.zip | |
* 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'.
Fixes: debbugs:12456
| -rw-r--r-- | lisp/ChangeLog | 13 | ||||
| -rw-r--r-- | lisp/info.el | 105 |
2 files changed, 78 insertions, 40 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 747662ee468..34cb50bb44c 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,18 @@ | |||
| 1 | 2012-12-27 Juri Linkov <juri@jurta.org> | 1 | 2012-12-27 Juri Linkov <juri@jurta.org> |
| 2 | 2 | ||
| 3 | * info.el (Info-file-completions): New variable. | ||
| 4 | (Info-read-node-name-1): Complete node names in the Info file | ||
| 5 | when a file name is given. Call `Info-build-node-completions' | ||
| 6 | with a file name. | ||
| 7 | (Info-build-node-completions): Add new arg `file'. When it is | ||
| 8 | non-nil, visit it in a temporary buffer and cache its completions in | ||
| 9 | `Info-current-file-completions'. Move most of the function body to | ||
| 10 | `Info-build-node-completions-1'. | ||
| 11 | (Info-build-node-completions-1): New function with the body from | ||
| 12 | `Info-build-node-completions'. (Bug#12456) | ||
| 13 | |||
| 14 | 2012-12-27 Juri Linkov <juri@jurta.org> | ||
| 15 | |||
| 3 | * frame.el (frame-maximization-style): Remove user option. | 16 | * frame.el (frame-maximization-style): Remove user option. |
| 4 | (cycle-frame-maximized): Remove function. | 17 | (cycle-frame-maximized): Remove function. |
| 5 | (toggle-frame-maximized): Rewrite and bind to M-<f10>. | 18 | (toggle-frame-maximized): Rewrite and bind to M-<f10>. |
diff --git a/lisp/info.el b/lisp/info.el index 4c7bb981afc..19f9212f88a 100644 --- a/lisp/info.el +++ b/lisp/info.el | |||
| @@ -397,6 +397,10 @@ Marker points nowhere if file has no tag table.") | |||
| 397 | (defvar Info-current-file-completions nil | 397 | (defvar Info-current-file-completions nil |
| 398 | "Cached completion list for current Info file.") | 398 | "Cached completion list for current Info file.") |
| 399 | 399 | ||
| 400 | (defvar Info-file-completions nil | ||
| 401 | "Cached completion alist of visited Info files. | ||
| 402 | Each element of the alist is (FILE . COMPLETIONS)") | ||
| 403 | |||
| 400 | (defvar Info-file-supports-index-cookies nil | 404 | (defvar Info-file-supports-index-cookies nil |
| 401 | "Non-nil if current Info file supports index cookies.") | 405 | "Non-nil if current Info file supports index cookies.") |
| 402 | 406 | ||
| @@ -1771,12 +1775,20 @@ See `completing-read' for a description of arguments and usage." | |||
| 1771 | (substring string 1) | 1775 | (substring string 1) |
| 1772 | predicate | 1776 | predicate |
| 1773 | code)) | 1777 | code)) |
| 1774 | ;; If a file name was given, then any node is fair game. | 1778 | ;; If a file name was given, complete nodes in the file. |
| 1775 | ((string-match "\\`(" string) | 1779 | ((string-match "\\`(\\([^)]+\\))" string) |
| 1776 | (cond | 1780 | (let ((file0 (match-string 0 string)) |
| 1777 | ((eq code nil) string) | 1781 | (file1 (match-string 1 string)) |
| 1778 | ((eq code t) nil) | 1782 | (node (substring string (match-end 0)))) |
| 1779 | (t t))) | 1783 | (completion-table-with-context |
| 1784 | file0 | ||
| 1785 | (apply-partially | ||
| 1786 | (lambda (string pred action) | ||
| 1787 | (complete-with-action | ||
| 1788 | action | ||
| 1789 | (Info-build-node-completions (Info-find-file file1)) | ||
| 1790 | string pred))) | ||
| 1791 | node predicate code))) | ||
| 1780 | ;; Otherwise use Info-read-node-completion-table. | 1792 | ;; Otherwise use Info-read-node-completion-table. |
| 1781 | (t (complete-with-action | 1793 | (t (complete-with-action |
| 1782 | code Info-read-node-completion-table string predicate)))) | 1794 | code Info-read-node-completion-table string predicate)))) |
| @@ -1793,41 +1805,54 @@ in the current Info file, or \"(FILENAME)NODENAME\"." | |||
| 1793 | (Info-read-node-name prompt) | 1805 | (Info-read-node-name prompt) |
| 1794 | nodename))) | 1806 | nodename))) |
| 1795 | 1807 | ||
| 1796 | (defun Info-build-node-completions () | 1808 | (defun Info-build-node-completions (&optional file) |
| 1797 | (or Info-current-file-completions | 1809 | (if file |
| 1798 | (let ((compl nil) | 1810 | (or (cdr (assoc file Info-file-completions)) |
| 1799 | ;; Bind this in case the user sets it to nil. | 1811 | (with-temp-buffer |
| 1800 | (case-fold-search t) | 1812 | (Info-mode) |
| 1801 | (node-regexp "Node: *\\([^,\n]*\\) *[,\n\t]")) | 1813 | (Info-goto-node (format "(%s)Top" file)) |
| 1802 | (save-excursion | 1814 | (Info-build-node-completions-1) |
| 1803 | (save-restriction | 1815 | (push (cons file Info-current-file-completions) Info-file-completions) |
| 1804 | (or Info-tag-table-marker | 1816 | Info-current-file-completions)) |
| 1805 | (error "No Info tags found")) | 1817 | (or Info-current-file-completions |
| 1806 | (if (marker-buffer Info-tag-table-marker) | 1818 | (Info-build-node-completions-1)))) |
| 1807 | (let ((marker Info-tag-table-marker)) | 1819 | |
| 1808 | (set-buffer (marker-buffer marker)) | 1820 | (defun Info-build-node-completions-1 () |
| 1809 | (widen) | 1821 | (let ((compl nil) |
| 1810 | (goto-char marker) | 1822 | ;; Bind this in case the user sets it to nil. |
| 1811 | (while (re-search-forward "\n\\(Node\\|Ref\\): \\(.*\\)\177" nil t) | 1823 | (case-fold-search t) |
| 1812 | (setq compl | 1824 | (node-regexp "Node: *\\([^,\n]*\\) *[,\n\t]")) |
| 1813 | (cons (list (match-string-no-properties 2)) | 1825 | (save-excursion |
| 1814 | compl)))) | 1826 | (save-restriction |
| 1827 | (or Info-tag-table-marker | ||
| 1828 | (error "No Info tags found")) | ||
| 1829 | (if (marker-buffer Info-tag-table-marker) | ||
| 1830 | (let ((marker Info-tag-table-marker)) | ||
| 1831 | (set-buffer (marker-buffer marker)) | ||
| 1815 | (widen) | 1832 | (widen) |
| 1816 | (goto-char (point-min)) | 1833 | (goto-char marker) |
| 1817 | ;; If the buffer begins with a node header, process that first. | 1834 | (while (re-search-forward "\n\\(Node\\|Ref\\): \\(.*\\)\177" nil t) |
| 1818 | (if (Info-node-at-bob-matching node-regexp) | 1835 | (setq compl |
| 1819 | (setq compl (list (match-string-no-properties 1)))) | 1836 | (cons (list (match-string-no-properties 2)) |
| 1820 | ;; Now for the rest of the nodes. | 1837 | compl)))) |
| 1821 | (while (search-forward "\n\^_" nil t) | 1838 | (widen) |
| 1822 | (forward-line 1) | 1839 | (goto-char (point-min)) |
| 1823 | (let ((beg (point))) | 1840 | ;; If the buffer begins with a node header, process that first. |
| 1824 | (forward-line 1) | 1841 | (if (Info-node-at-bob-matching node-regexp) |
| 1825 | (if (re-search-backward node-regexp beg t) | 1842 | (setq compl (list (match-string-no-properties 1)))) |
| 1826 | (setq compl | 1843 | ;; Now for the rest of the nodes. |
| 1827 | (cons (list (match-string-no-properties 1)) | 1844 | (while (search-forward "\n\^_" nil t) |
| 1828 | compl)))))))) | 1845 | (forward-line 1) |
| 1829 | (setq compl (cons '("*") compl)) | 1846 | (let ((beg (point))) |
| 1830 | (set (make-local-variable 'Info-current-file-completions) compl)))) | 1847 | (forward-line 1) |
| 1848 | (if (re-search-backward node-regexp beg t) | ||
| 1849 | (setq compl | ||
| 1850 | (cons (list (match-string-no-properties 1)) | ||
| 1851 | compl)))))))) | ||
| 1852 | (setq compl (cons '("*") (nreverse compl))) | ||
| 1853 | (set (make-local-variable 'Info-current-file-completions) compl) | ||
| 1854 | compl)) | ||
| 1855 | |||
| 1831 | 1856 | ||
| 1832 | (defun Info-restore-point (hl) | 1857 | (defun Info-restore-point (hl) |
| 1833 | "If this node has been visited, restore the point value when we left." | 1858 | "If this node has been visited, restore the point value when we left." |