Mercurial > emacs
comparison lisp/info.el @ 60615:643e6516a779
(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'.
author | Juri Linkov <juri@jurta.org> |
---|---|
date | Tue, 15 Mar 2005 10:46:00 +0000 |
parents | 1bfdd67c0337 |
children | 20a8e6e5ae57 |
comparison
equal
deleted
inserted
replaced
60614:50f2c823523a | 60615:643e6516a779 |
---|---|
207 When isearch fails, it wraps and restarts the search from the | 207 When isearch fails, it wraps and restarts the search from the |
208 top/final node depending on search direction." | 208 top/final node depending on search direction." |
209 :version "22.1" | 209 :version "22.1" |
210 :type 'boolean | 210 :type 'boolean |
211 :group 'info) | 211 :group 'info) |
212 | |
213 (defvar Info-isearch-initial-node nil) | |
212 | 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)) |
216 '(turn-on-font-lock)) | 218 '(turn-on-font-lock)) |
1512 (re-search-backward regexp bound t) | 1514 (re-search-backward regexp bound t) |
1513 (re-search-forward regexp bound t)) | 1515 (re-search-forward regexp bound t)) |
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) |
1520 (let ((search-spaces-regexp Info-search-whitespace-regexp)) | 1530 (let ((search-spaces-regexp Info-search-whitespace-regexp)) |
1521 (if backward | 1531 (if backward |
1522 (re-search-backward regexp) | 1532 (re-search-backward regexp) |
1523 (re-search-forward regexp))) | 1533 (re-search-forward regexp))) |
1524 (setq found nil))) | 1534 (setq found nil))) |
1535 | |
1536 (if (and bound (not found)) | |
1537 (signal 'search-failed (list regexp))) | |
1525 | 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. |
1529 (let ((list ())) | 1542 (let ((list ())) |
1648 (Info-search regexp bound noerror count 'backward)) | 1661 (Info-search regexp bound noerror count 'backward)) |
1649 | 1662 |
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 () |
1675 `(lambda (cmd) | 1691 `(lambda (cmd) |
1676 (Info-isearch-pop-state cmd ,Info-current-file ,Info-current-node))) | 1692 (Info-isearch-pop-state cmd ,Info-current-file ,Info-current-node))) |
1678 (defun Info-isearch-pop-state (cmd file node) | 1694 (defun Info-isearch-pop-state (cmd file node) |
1679 (or (and (string= Info-current-file file) | 1695 (or (and (string= Info-current-file file) |
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. |
1686 If there is none, use ERRORNAME in the error message; | 1704 If there is none, use ERRORNAME in the error message; |
1687 if ERRORNAME is nil, just return nil." | 1705 if ERRORNAME is nil, just return nil." |
3215 (setq line-move-ignore-invisible t) | 3233 (setq line-move-ignore-invisible t) |
3216 (make-local-variable 'desktop-save-buffer) | 3234 (make-local-variable 'desktop-save-buffer) |
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) |
3223 'Info-isearch-wrap) | 3242 'Info-isearch-wrap) |
3224 (set (make-local-variable 'isearch-push-state-function) | 3243 (set (make-local-variable 'isearch-push-state-function) |