diff options
author | Richard M. Stallman <[email protected]> | 1994-01-10 22:35:29 +0000 |
---|---|---|
committer | Richard M. Stallman <[email protected]> | 1994-01-10 22:35:29 +0000 |
commit | 67bc89ab85ebe95ec783731c61c2bb4419adad7a (patch) | |
tree | aecf2190cc1eac583817b5a43296d261bcb45b4a /lisp | |
parent | 292a8dff00ddd15a718df631ba413e5745d03798 (diff) |
(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'.
Diffstat (limited to 'lisp')
-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 aa036de6b2..28554ba444 100644 --- a/lisp/info.el +++ b/lisp/info.el @@ -722,8 +722,14 @@ In standalone mode, \\<Info-mode-map>\\[Info-exit] exits Emacs itself." NAME may be an abbreviation of the reference name." (interactive (let ((completion-ignore-case t) - completions default (start-point (point)) str i) + completions default alt-default (start-point (point)) str i bol eol) (save-excursion + ;; Store end and beginning of line. + (end-of-line) + (setq eol (point)) + (beginning-of-line) + (setq bol (point)) + (goto-char (point-min)) (while (re-search-forward "\\*note[ \n\t]*\\([^:]*\\):" nil t) (setq str (buffer-substring @@ -734,6 +740,11 @@ NAME may be an abbreviation of the reference name." (<= (match-beginning 0) start-point) (<= start-point (point)) (setq default t)) + ;; See if this one should be the alternate default. + (and (null alt-default) + (and (<= bol (match-beginning 0)) + (<= (point) eol)) + (setq alt-default t)) (setq i 0) (while (setq i (string-match "[ \n\t]+" str i)) (setq str (concat (substring str 0 i) " " @@ -741,9 +752,16 @@ NAME may be an abbreviation of the reference name." (setq i (1+ i))) ;; Record as a completion and perhaps as default. (if (eq default t) (setq default str)) + (if (eq alt-default t) (setq alt-default str)) (setq completions (cons (cons str nil) completions)))) + ;; If no good default was found, try an alternate. + (or default + (setq default alt-default)) + ;; If only one cross-reference found, then make it default. + (if (eq (length completions) 1) + (setq default (car (car completions)))) (if completions (let ((input (completing-read (if default (concat "Follow reference named: (" |