diff options
| author | Juri Linkov | 2005-03-15 10:46:00 +0000 |
|---|---|---|
| committer | Juri Linkov | 2005-03-15 10:46:00 +0000 |
| commit | d457219d26570b1cefb66ccecf80f8a2e82d3949 (patch) | |
| tree | c172267cfcbf2c2e569dcfdd0b324b3706066a44 | |
| parent | ba653a53be2b24701cfa8b7a1ce79bfa9e2fb7f9 (diff) | |
| download | emacs-d457219d26570b1cefb66ccecf80f8a2e82d3949.tar.gz emacs-d457219d26570b1cefb66ccecf80f8a2e82d3949.zip | |
(Info-isearch-initial-node): New internal variable.
(Info-search): Signal an error in isearch mode when search leaves
the initial node. Signal an error when `bound' is non-nil and
nothing was found in the current subfile.
(Info-isearch-search): Remove `condition-case'.
(Info-isearch-wrap): Don't wrap when search failed during leaving
the initial node. If `Info-isearch-search' is nil, wrap around
the current node.
(Info-isearch-start): New fun.
(Info-mode): Add buffer-local hook `Info-isearch-start' to
`isearch-mode-hook'.
| -rw-r--r-- | lisp/info.el | 49 |
1 files changed, 34 insertions, 15 deletions
diff --git a/lisp/info.el b/lisp/info.el index 87ddfa6a55b..b2920bd6ecb 100644 --- a/lisp/info.el +++ b/lisp/info.el | |||
| @@ -210,6 +210,8 @@ top/final node depending on search direction." | |||
| 210 | :type 'boolean | 210 | :type 'boolean |
| 211 | :group 'info) | 211 | :group 'info) |
| 212 | 212 | ||
| 213 | (defvar Info-isearch-initial-node nil) | ||
| 214 | |||
| 213 | (defcustom Info-mode-hook | 215 | (defcustom Info-mode-hook |
| 214 | ;; Try to obey obsolete Info-fontify settings. | 216 | ;; Try to obey obsolete Info-fontify settings. |
| 215 | (unless (and (boundp 'Info-fontify) (null Info-fontify)) | 217 | (unless (and (boundp 'Info-fontify) (null Info-fontify)) |
| @@ -1514,6 +1516,14 @@ If DIRECTION is `backward', search in the reverse direction." | |||
| 1514 | (setq found (point) beg-found (if backward (match-end 0) | 1516 | (setq found (point) beg-found (if backward (match-end 0) |
| 1515 | (match-beginning 0))) | 1517 | (match-beginning 0))) |
| 1516 | (setq give-up t)))))) | 1518 | (setq give-up t)))))) |
| 1519 | |||
| 1520 | (when (and isearch-mode Info-isearch-search | ||
| 1521 | (not Info-isearch-initial-node) | ||
| 1522 | (not bound) | ||
| 1523 | (or give-up (and found (not (and (> found opoint-min) | ||
| 1524 | (< found opoint-max)))))) | ||
| 1525 | (signal 'search-failed (list regexp "initial node"))) | ||
| 1526 | |||
| 1517 | ;; If no subfiles, give error now. | 1527 | ;; If no subfiles, give error now. |
| 1518 | (if give-up | 1528 | (if give-up |
| 1519 | (if (null Info-current-subfile) | 1529 | (if (null Info-current-subfile) |
| @@ -1523,6 +1533,9 @@ If DIRECTION is `backward', search in the reverse direction." | |||
| 1523 | (re-search-forward regexp))) | 1533 | (re-search-forward regexp))) |
| 1524 | (setq found nil))) | 1534 | (setq found nil))) |
| 1525 | 1535 | ||
| 1536 | (if (and bound (not found)) | ||
| 1537 | (signal 'search-failed (list regexp))) | ||
| 1538 | |||
| 1526 | (unless (or found bound) | 1539 | (unless (or found bound) |
| 1527 | (unwind-protect | 1540 | (unwind-protect |
| 1528 | ;; Try other subfiles. | 1541 | ;; Try other subfiles. |
| @@ -1650,25 +1663,28 @@ If DIRECTION is `backward', search in the reverse direction." | |||
| 1650 | (defun Info-isearch-search () | 1663 | (defun Info-isearch-search () |
| 1651 | (if Info-isearch-search | 1664 | (if Info-isearch-search |
| 1652 | (lambda (string &optional bound noerror count) | 1665 | (lambda (string &optional bound noerror count) |
| 1653 | (condition-case nil | 1666 | (if isearch-word |
| 1654 | (if isearch-word | 1667 | (Info-search (concat "\\b" (replace-regexp-in-string |
| 1655 | (Info-search (concat "\\b" (replace-regexp-in-string | 1668 | "\\W+" "\\\\W+" |
| 1656 | "\\W+" "\\\\W+" | 1669 | (replace-regexp-in-string |
| 1657 | (replace-regexp-in-string | 1670 | "^\\W+\\|\\W+$" "" string)) "\\b") |
| 1658 | "^\\W+\\|\\W+$" "" string)) "\\b") | 1671 | bound noerror count |
| 1659 | bound noerror count | 1672 | (unless isearch-forward 'backward)) |
| 1660 | (unless isearch-forward 'backward)) | 1673 | (Info-search (if isearch-regexp string (regexp-quote string)) |
| 1661 | (Info-search (if isearch-regexp string (regexp-quote string)) | 1674 | bound noerror count |
| 1662 | bound noerror count | 1675 | (unless isearch-forward 'backward)) |
| 1663 | (unless isearch-forward 'backward)) | 1676 | (point))) |
| 1664 | (point)) | ||
| 1665 | (error nil))) | ||
| 1666 | (let ((isearch-search-fun-function nil)) | 1677 | (let ((isearch-search-fun-function nil)) |
| 1667 | (isearch-search-fun)))) | 1678 | (isearch-search-fun)))) |
| 1668 | 1679 | ||
| 1669 | (defun Info-isearch-wrap () | 1680 | (defun Info-isearch-wrap () |
| 1670 | (when Info-isearch-search | 1681 | (if Info-isearch-search |
| 1671 | (if isearch-forward (Info-top-node) (Info-final-node)) | 1682 | (if Info-isearch-initial-node |
| 1683 | (progn | ||
| 1684 | (if isearch-forward (Info-top-node) (Info-final-node)) | ||
| 1685 | (goto-char (if isearch-forward (point-min) (point-max)))) | ||
| 1686 | (setq Info-isearch-initial-node Info-current-node) | ||
| 1687 | (setq isearch-wrapped nil)) | ||
| 1672 | (goto-char (if isearch-forward (point-min) (point-max))))) | 1688 | (goto-char (if isearch-forward (point-min) (point-max))))) |
| 1673 | 1689 | ||
| 1674 | (defun Info-isearch-push-state () | 1690 | (defun Info-isearch-push-state () |
| @@ -1680,6 +1696,8 @@ If DIRECTION is `backward', search in the reverse direction." | |||
| 1680 | (string= Info-current-node node)) | 1696 | (string= Info-current-node node)) |
| 1681 | (progn (Info-find-node file node) (sit-for 0)))) | 1697 | (progn (Info-find-node file node) (sit-for 0)))) |
| 1682 | 1698 | ||
| 1699 | (defun Info-isearch-start () | ||
| 1700 | (setq Info-isearch-initial-node nil)) | ||
| 1683 | 1701 | ||
| 1684 | (defun Info-extract-pointer (name &optional errorname) | 1702 | (defun Info-extract-pointer (name &optional errorname) |
| 1685 | "Extract the value of the node-pointer named NAME. | 1703 | "Extract the value of the node-pointer named NAME. |
| @@ -3217,6 +3235,7 @@ Advanced commands: | |||
| 3217 | (setq desktop-save-buffer 'Info-desktop-buffer-misc-data) | 3235 | (setq desktop-save-buffer 'Info-desktop-buffer-misc-data) |
| 3218 | (add-hook 'clone-buffer-hook 'Info-clone-buffer-hook nil t) | 3236 | (add-hook 'clone-buffer-hook 'Info-clone-buffer-hook nil t) |
| 3219 | (add-hook 'change-major-mode-hook 'font-lock-defontify nil t) | 3237 | (add-hook 'change-major-mode-hook 'font-lock-defontify nil t) |
| 3238 | (add-hook 'isearch-mode-hook 'Info-isearch-start nil t) | ||
| 3220 | (set (make-local-variable 'isearch-search-fun-function) | 3239 | (set (make-local-variable 'isearch-search-fun-function) |
| 3221 | 'Info-isearch-search) | 3240 | 'Info-isearch-search) |
| 3222 | (set (make-local-variable 'isearch-wrap-function) | 3241 | (set (make-local-variable 'isearch-wrap-function) |