diff options
| author | Karl Heuer | 1999-04-26 05:58:59 +0000 |
|---|---|---|
| committer | Karl Heuer | 1999-04-26 05:58:59 +0000 |
| commit | 8bdf4b20dd4aca8909d1c661896479f73326caf8 (patch) | |
| tree | 5a48acfb19222c43454e9581fc53cb08f2c6725b | |
| parent | f1b6f8a15741dd1bcde20b152b0ca3c70cb4d173 (diff) | |
| download | emacs-8bdf4b20dd4aca8909d1c661896479f73326caf8.tar.gz emacs-8bdf4b20dd4aca8909d1c661896479f73326caf8.zip | |
(Info-find-node): Position properly after finding anchor.
| -rw-r--r-- | lisp/info.el | 70 |
1 files changed, 46 insertions, 24 deletions
diff --git a/lisp/info.el b/lisp/info.el index bec7d0ac96d..396f4fad9ea 100644 --- a/lisp/info.el +++ b/lisp/info.el | |||
| @@ -400,7 +400,8 @@ In standalone mode, \\<Info-mode-map>\\[Info-exit] exits Emacs itself." | |||
| 400 | (setq Info-current-node nil) | 400 | (setq Info-current-node nil) |
| 401 | (unwind-protect | 401 | (unwind-protect |
| 402 | ;; Bind case-fold-search in case the user sets it to nil. | 402 | ;; Bind case-fold-search in case the user sets it to nil. |
| 403 | (let ((case-fold-search t)) | 403 | (let ((case-fold-search t) |
| 404 | anchorpos) | ||
| 404 | ;; Switch files if necessary | 405 | ;; Switch files if necessary |
| 405 | (or (null filename) | 406 | (or (null filename) |
| 406 | (equal Info-current-file filename) | 407 | (equal Info-current-file filename) |
| @@ -465,29 +466,35 @@ In standalone mode, \\<Info-mode-map>\\[Info-exit] exits Emacs itself." | |||
| 465 | ;; *Or* the same, but in an indirect subfile. | 466 | ;; *Or* the same, but in an indirect subfile. |
| 466 | 467 | ||
| 467 | ;; Search file for a suitable node. | 468 | ;; Search file for a suitable node. |
| 468 | (let ((guesspos (point-min)) | 469 | (let ((guesspos (point-min)) |
| 469 | (regexp | 470 | (regexp |
| 470 | (concat "\\(Node:\\|Ref:\\) *" | 471 | (concat "\\(Node:\\|Ref:\\) *\\(" |
| 471 | (regexp-quote nodename) | 472 | (regexp-quote nodename) |
| 472 | " *[,\t\n\177]"))) | 473 | "\\) *[,\t\n\177]")) |
| 474 | (nodepos nil)) | ||
| 473 | 475 | ||
| 474 | ;; First, search a tag table, if any | 476 | ;; First, search a tag table, if any |
| 475 | (if (marker-position Info-tag-table-marker) | 477 | (if (marker-position Info-tag-table-marker) |
| 476 | 478 | (let ((found-in-tag-table t) | |
| 477 | (let (found-in-tag-table | ||
| 478 | found-anchor | 479 | found-anchor |
| 479 | found-mode | 480 | found-mode |
| 480 | (m Info-tag-table-marker)) | 481 | (m Info-tag-table-marker)) |
| 481 | (save-excursion | 482 | (save-excursion |
| 482 | (set-buffer (marker-buffer m)) | 483 | (set-buffer (marker-buffer m)) |
| 483 | (goto-char m) | 484 | (goto-char m) |
| 484 | (beginning-of-line) ; so re-search will work. | 485 | (beginning-of-line) ; so re-search will work. |
| 485 | 486 | ||
| 486 | ;; Search tag table | 487 | ;; Search tag table |
| 487 | (setq found-in-tag-table | 488 | (catch 'foo |
| 488 | (re-search-forward regexp nil t) | 489 | (while (re-search-forward regexp nil t) |
| 489 | found-anchor | 490 | (setq found-anchor |
| 490 | (string-equal "Ref:" (match-string 1))) | 491 | (string-equal "Ref:" (match-string 1))) |
| 492 | (or nodepos (setq nodepos (point)) | ||
| 493 | (if (string-equal (match-string 2) nodename) | ||
| 494 | (throw 'foo t)))) | ||
| 495 | (if nodepos | ||
| 496 | (goto-char nodepos) | ||
| 497 | (setq found-in-tag-table nil))) | ||
| 491 | (if found-in-tag-table | 498 | (if found-in-tag-table |
| 492 | (setq guesspos (1+ (read (current-buffer))))) | 499 | (setq guesspos (1+ (read (current-buffer))))) |
| 493 | (setq found-mode major-mode)) | 500 | (setq found-mode major-mode)) |
| @@ -506,7 +513,8 @@ In standalone mode, \\<Info-mode-map>\\[Info-exit] exits Emacs itself." | |||
| 506 | (setq guesspos (Info-read-subfile guesspos))))) | 513 | (setq guesspos (Info-read-subfile guesspos))))) |
| 507 | 514 | ||
| 508 | ;; Handle anchor | 515 | ;; Handle anchor |
| 509 | (if found-anchor (goto-char guesspos) | 516 | (if found-anchor |
| 517 | (goto-char (setq anchorpos guesspos)) | ||
| 510 | 518 | ||
| 511 | ;; Else we may have a node, which we search for: | 519 | ;; Else we may have a node, which we search for: |
| 512 | (goto-char (max (point-min) | 520 | (goto-char (max (point-min) |
| @@ -517,6 +525,7 @@ In standalone mode, \\<Info-mode-map>\\[Info-exit] exits Emacs itself." | |||
| 517 | ;; First, check whether the node is right | 525 | ;; First, check whether the node is right |
| 518 | ;; where we are, in case the buffer begins | 526 | ;; where we are, in case the buffer begins |
| 519 | ;; with a node. | 527 | ;; with a node. |
| 528 | (setq nodepos nil) | ||
| 520 | (or (Info-node-at-bob-matching regexp) | 529 | (or (Info-node-at-bob-matching regexp) |
| 521 | (catch 'foo | 530 | (catch 'foo |
| 522 | (while (search-forward "\n\^_" nil t) | 531 | (while (search-forward "\n\^_" nil t) |
| @@ -524,17 +533,25 @@ In standalone mode, \\<Info-mode-map>\\[Info-exit] exits Emacs itself." | |||
| 524 | (let ((beg (point))) | 533 | (let ((beg (point))) |
| 525 | (forward-line 1) | 534 | (forward-line 1) |
| 526 | (if (re-search-backward regexp beg t) | 535 | (if (re-search-backward regexp beg t) |
| 527 | (progn | 536 | (if (string-equal (match-string 2) nodename) |
| 528 | (beginning-of-line) | 537 | (progn |
| 529 | (throw 'foo t))))) | 538 | (beginning-of-line) |
| 530 | (error | 539 | (throw 'foo t)) |
| 531 | "No such anchor in tag table or node in tag table or file: %s" | 540 | (or nodepos |
| 532 | nodename))))) | 541 | (setq nodepos (point))))))) |
| 542 | (if nodepos | ||
| 543 | (progn | ||
| 544 | (goto-char nodepos) | ||
| 545 | (beginning-of-line)) | ||
| 546 | (error | ||
| 547 | "No such anchor in tag table or node in tag table or file: %s" | ||
| 548 | nodename)))))) | ||
| 533 | (goto-char (max (point-min) (- guesspos 1000))) | 549 | (goto-char (max (point-min) (- guesspos 1000))) |
| 534 | ;; Now search from our advised position (or from beg of buffer) | 550 | ;; Now search from our advised position (or from beg of buffer) |
| 535 | ;; to find the actual node. | 551 | ;; to find the actual node. |
| 536 | ;; First, check whether the node is right where we are, in case | 552 | ;; First, check whether the node is right where we are, in case |
| 537 | ;; the buffer begins with a node. | 553 | ;; the buffer begins with a node. |
| 554 | (setq nodepos nil) | ||
| 538 | (or (Info-node-at-bob-matching regexp) | 555 | (or (Info-node-at-bob-matching regexp) |
| 539 | (catch 'foo | 556 | (catch 'foo |
| 540 | (while (search-forward "\n\^_" nil t) | 557 | (while (search-forward "\n\^_" nil t) |
| @@ -542,10 +559,15 @@ In standalone mode, \\<Info-mode-map>\\[Info-exit] exits Emacs itself." | |||
| 542 | (let ((beg (point))) | 559 | (let ((beg (point))) |
| 543 | (forward-line 1) | 560 | (forward-line 1) |
| 544 | (if (re-search-backward regexp beg t) | 561 | (if (re-search-backward regexp beg t) |
| 545 | (throw 'foo t)))) | 562 | (if (string-equal (match-string 2) nodename) |
| 546 | (error "No such node: %s" nodename))))) | 563 | (throw 'foo t) |
| 564 | (or nodepos | ||
| 565 | (setq nodepos (point))))))) | ||
| 566 | (if nodepos | ||
| 567 | (goto-char nodepos) | ||
| 568 | (error "No such node: %s" nodename)))))) | ||
| 547 | (Info-select-node) | 569 | (Info-select-node) |
| 548 | (goto-char (point-min)))) | 570 | (goto-char (or anchorpos (point-min))))) |
| 549 | ;; If we did not finish finding the specified node, | 571 | ;; If we did not finish finding the specified node, |
| 550 | ;; go back to the previous one. | 572 | ;; go back to the previous one. |
| 551 | (or Info-current-node no-going-back (null Info-history) | 573 | (or Info-current-node no-going-back (null Info-history) |