diff options
| author | Richard M. Stallman | 1994-01-10 22:35:29 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-01-10 22:35:29 +0000 |
| commit | 67bc89ab85ebe95ec783731c61c2bb4419adad7a (patch) | |
| tree | aecf2190cc1eac583817b5a43296d261bcb45b4a | |
| parent | 292a8dff00ddd15a718df631ba413e5745d03798 (diff) | |
| download | emacs-67bc89ab85ebe95ec783731c61c2bb4419adad7a.tar.gz emacs-67bc89ab85ebe95ec783731c61c2bb4419adad7a.zip | |
(Info-follow-reference): If point is not in middle of a
cross-reference but located somewhere on current line, make
cross-reference the `default'. If only one cross-reference
located in node, make it `default'.
| -rw-r--r-- | lisp/info.el | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/lisp/info.el b/lisp/info.el index aa036de6b26..28554ba444c 100644 --- a/lisp/info.el +++ b/lisp/info.el | |||
| @@ -722,8 +722,14 @@ In standalone mode, \\<Info-mode-map>\\[Info-exit] exits Emacs itself." | |||
| 722 | NAME may be an abbreviation of the reference name." | 722 | NAME may be an abbreviation of the reference name." |
| 723 | (interactive | 723 | (interactive |
| 724 | (let ((completion-ignore-case t) | 724 | (let ((completion-ignore-case t) |
| 725 | completions default (start-point (point)) str i) | 725 | completions default alt-default (start-point (point)) str i bol eol) |
| 726 | (save-excursion | 726 | (save-excursion |
| 727 | ;; Store end and beginning of line. | ||
| 728 | (end-of-line) | ||
| 729 | (setq eol (point)) | ||
| 730 | (beginning-of-line) | ||
| 731 | (setq bol (point)) | ||
| 732 | |||
| 727 | (goto-char (point-min)) | 733 | (goto-char (point-min)) |
| 728 | (while (re-search-forward "\\*note[ \n\t]*\\([^:]*\\):" nil t) | 734 | (while (re-search-forward "\\*note[ \n\t]*\\([^:]*\\):" nil t) |
| 729 | (setq str (buffer-substring | 735 | (setq str (buffer-substring |
| @@ -734,6 +740,11 @@ NAME may be an abbreviation of the reference name." | |||
| 734 | (<= (match-beginning 0) start-point) | 740 | (<= (match-beginning 0) start-point) |
| 735 | (<= start-point (point)) | 741 | (<= start-point (point)) |
| 736 | (setq default t)) | 742 | (setq default t)) |
| 743 | ;; See if this one should be the alternate default. | ||
| 744 | (and (null alt-default) | ||
| 745 | (and (<= bol (match-beginning 0)) | ||
| 746 | (<= (point) eol)) | ||
| 747 | (setq alt-default t)) | ||
| 737 | (setq i 0) | 748 | (setq i 0) |
| 738 | (while (setq i (string-match "[ \n\t]+" str i)) | 749 | (while (setq i (string-match "[ \n\t]+" str i)) |
| 739 | (setq str (concat (substring str 0 i) " " | 750 | (setq str (concat (substring str 0 i) " " |
| @@ -741,9 +752,16 @@ NAME may be an abbreviation of the reference name." | |||
| 741 | (setq i (1+ i))) | 752 | (setq i (1+ i))) |
| 742 | ;; Record as a completion and perhaps as default. | 753 | ;; Record as a completion and perhaps as default. |
| 743 | (if (eq default t) (setq default str)) | 754 | (if (eq default t) (setq default str)) |
| 755 | (if (eq alt-default t) (setq alt-default str)) | ||
| 744 | (setq completions | 756 | (setq completions |
| 745 | (cons (cons str nil) | 757 | (cons (cons str nil) |
| 746 | completions)))) | 758 | completions)))) |
| 759 | ;; If no good default was found, try an alternate. | ||
| 760 | (or default | ||
| 761 | (setq default alt-default)) | ||
| 762 | ;; If only one cross-reference found, then make it default. | ||
| 763 | (if (eq (length completions) 1) | ||
| 764 | (setq default (car (car completions)))) | ||
| 747 | (if completions | 765 | (if completions |
| 748 | (let ((input (completing-read (if default | 766 | (let ((input (completing-read (if default |
| 749 | (concat "Follow reference named: (" | 767 | (concat "Follow reference named: (" |