diff options
| author | Richard M. Stallman | 1994-06-10 21:00:53 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-06-10 21:00:53 +0000 |
| commit | e8adde3fd1c3b403d6adc6e20e749c6aabe084d1 (patch) | |
| tree | 9f4feb052d7cc881c829ac3fee04107e510901f7 | |
| parent | 18ae44fc255300f82889746a99f5b805c35749f3 (diff) | |
| download | emacs-e8adde3fd1c3b403d6adc6e20e749c6aabe084d1.tar.gz emacs-e8adde3fd1c3b403d6adc6e20e749c6aabe084d1.zip | |
(Info-complete-menu-item): New function.
(Info-menu): Use it to speed completion.
| -rw-r--r-- | lisp/info.el | 78 |
1 files changed, 58 insertions, 20 deletions
diff --git a/lisp/info.el b/lisp/info.el index b12278056a6..212ca311b08 100644 --- a/lisp/info.el +++ b/lisp/info.el | |||
| @@ -833,12 +833,56 @@ NAME may be an abbreviation of the reference name." | |||
| 833 | (aset str i ?\ )) | 833 | (aset str i ?\ )) |
| 834 | str)) | 834 | str)) |
| 835 | 835 | ||
| 836 | ;; No one calls this and Info-menu-item doesn't exist. | 836 | ;; No one calls this. |
| 837 | ;;(defun Info-menu-item-sequence (list) | 837 | ;;(defun Info-menu-item-sequence (list) |
| 838 | ;; (while list | 838 | ;; (while list |
| 839 | ;; (Info-menu-item (car list)) | 839 | ;; (Info-menu (car list)) |
| 840 | ;; (setq list (cdr list)))) | 840 | ;; (setq list (cdr list)))) |
| 841 | 841 | ||
| 842 | (defun Info-complete-menu-item (string predicate action) | ||
| 843 | (let ((case-fold-search t)) | ||
| 844 | (cond ((eq action nil) | ||
| 845 | (let (completions | ||
| 846 | (pattern (concat "\n\\* \\(" | ||
| 847 | (regexp-quote string) | ||
| 848 | "[^:\t\n]*\\):"))) | ||
| 849 | (save-excursion | ||
| 850 | (set-buffer Info-complete-menu-buffer) | ||
| 851 | (goto-char (point-min)) | ||
| 852 | (while (re-search-forward pattern nil t) | ||
| 853 | (setq completions (cons (cons (format "%s" | ||
| 854 | (buffer-substring | ||
| 855 | (match-beginning 1) | ||
| 856 | (match-end 1))) | ||
| 857 | (match-beginning 1)) | ||
| 858 | completions)))) | ||
| 859 | (try-completion string completions predicate))) | ||
| 860 | ((eq action t) | ||
| 861 | (let (completions | ||
| 862 | (pattern (concat "\n\\* \\(" | ||
| 863 | (regexp-quote string) | ||
| 864 | "[^:\t\n]*\\):"))) | ||
| 865 | (save-excursion | ||
| 866 | (set-buffer Info-complete-menu-buffer) | ||
| 867 | (goto-char (point-min)) | ||
| 868 | (while (re-search-forward pattern nil t) | ||
| 869 | (setq completions (cons (cons (format "%s" | ||
| 870 | (buffer-substring | ||
| 871 | (match-beginning 1) | ||
| 872 | (match-end 1))) | ||
| 873 | (match-beginning 1)) | ||
| 874 | completions)))) | ||
| 875 | (all-completions string completions predicate))) | ||
| 876 | (t | ||
| 877 | (save-excursion | ||
| 878 | (set-buffer Info-complete-menu-buffer) | ||
| 879 | (goto-char (point-min)) | ||
| 880 | (re-search-forward (concat "\n\\* " | ||
| 881 | (regexp-quote string) | ||
| 882 | ":") | ||
| 883 | nil t)))))) | ||
| 884 | |||
| 885 | |||
| 842 | (defun Info-menu (menu-item) | 886 | (defun Info-menu (menu-item) |
| 843 | "Go to node for menu item named (or abbreviated) NAME. | 887 | "Go to node for menu item named (or abbreviated) NAME. |
| 844 | Completion is allowed, and the menu item point is on is the default." | 888 | Completion is allowed, and the menu item point is on is the default." |
| @@ -852,30 +896,24 @@ Completion is allowed, and the menu item point is on is the default." | |||
| 852 | (goto-char (point-min)) | 896 | (goto-char (point-min)) |
| 853 | (if (not (search-forward "\n* menu:" nil t)) | 897 | (if (not (search-forward "\n* menu:" nil t)) |
| 854 | (error "No menu in this node")) | 898 | (error "No menu in this node")) |
| 855 | (while (re-search-forward | 899 | (setq beg (point)) |
| 856 | "\n\\* \\([^:\t\n]*\\):" nil t) | 900 | (and (< (point) p) |
| 857 | (if (and (null default) | 901 | (save-excursion |
| 858 | (prog1 (if last (< last p) nil) | 902 | (goto-char p) |
| 859 | (setq last (match-beginning 0))) | 903 | (end-of-line) |
| 860 | (<= p last)) | 904 | (re-search-backward "\n\\* \\([^:\t\n]*\\):" beg t) |
| 861 | (setq default (car (car completions)))) | 905 | (setq default (format "%s" (buffer-substring |
| 862 | (setq completions (cons (cons (buffer-substring | 906 | (match-beginning 1) |
| 863 | (match-beginning 1) | 907 | (match-end 1))))))) |
| 864 | (match-end 1)) | ||
| 865 | (match-beginning 1)) | ||
| 866 | completions))) | ||
| 867 | (if (and (null default) last | ||
| 868 | (< last p) | ||
| 869 | (<= p (progn (end-of-line) (point)))) | ||
| 870 | (setq default (car (car completions))))) | ||
| 871 | (let ((item nil)) | 908 | (let ((item nil)) |
| 872 | (while (null item) | 909 | (while (null item) |
| 873 | (setq item (let ((completion-ignore-case t)) | 910 | (setq item (let ((completion-ignore-case t) |
| 911 | (Info-complete-menu-buffer (current-buffer))) | ||
| 874 | (completing-read (if default | 912 | (completing-read (if default |
| 875 | (format "Menu item (default %s): " | 913 | (format "Menu item (default %s): " |
| 876 | default) | 914 | default) |
| 877 | "Menu item: ") | 915 | "Menu item: ") |
| 878 | completions nil t))) | 916 | 'Info-complete-menu-item nil t))) |
| 879 | ;; we rely on the fact that completing-read accepts an input | 917 | ;; we rely on the fact that completing-read accepts an input |
| 880 | ;; of "" even when the require-match argument is true and "" | 918 | ;; of "" even when the require-match argument is true and "" |
| 881 | ;; is not a valid possibility | 919 | ;; is not a valid possibility |