summaryrefslogtreecommitdiff
path: root/lisp/info.el
diff options
context:
space:
mode:
authorJuri Linkov <juri@jurta.org>2005-03-15 10:46:00 +0000
committerJuri Linkov <juri@jurta.org>2005-03-15 10:46:00 +0000
commitd457219d26570b1cefb66ccecf80f8a2e82d3949 (patch)
treec172267cfcbf2c2e569dcfdd0b324b3706066a44 /lisp/info.el
parentba653a53be2b24701cfa8b7a1ce79bfa9e2fb7f9 (diff)
downloademacs-d457219d26570b1cefb66ccecf80f8a2e82d3949.tar.gz
(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'.
Diffstat (limited to 'lisp/info.el')
-rw-r--r--lisp/info.el49
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."
:type 'boolean
:group 'info)
+(defvar Info-isearch-initial-node nil)
+
(defcustom Info-mode-hook
;; Try to obey obsolete Info-fontify settings.
(unless (and (boundp 'Info-fontify) (null Info-fontify))
@@ -1514,6 +1516,14 @@ If DIRECTION is `backward', search in the reverse direction."
(setq found (point) beg-found (if backward (match-end 0)
(match-beginning 0)))
(setq give-up t))))))
+
+ (when (and isearch-mode Info-isearch-search
+ (not Info-isearch-initial-node)
+ (not bound)
+ (or give-up (and found (not (and (> found opoint-min)
+ (< found opoint-max))))))
+ (signal 'search-failed (list regexp "initial node")))
+
;; If no subfiles, give error now.
(if give-up
(if (null Info-current-subfile)
@@ -1523,6 +1533,9 @@ If DIRECTION is `backward', search in the reverse direction."
(re-search-forward regexp)))
(setq found nil)))
+ (if (and bound (not found))
+ (signal 'search-failed (list regexp)))
+
(unless (or found bound)
(unwind-protect
;; Try other subfiles.
@@ -1650,25 +1663,28 @@ If DIRECTION is `backward', search in the reverse direction."
(defun Info-isearch-search ()
(if Info-isearch-search
(lambda (string &optional bound noerror count)
- (condition-case nil
- (if isearch-word
- (Info-search (concat "\\b" (replace-regexp-in-string
- "\\W+" "\\\\W+"
- (replace-regexp-in-string
- "^\\W+\\|\\W+$" "" string)) "\\b")
- bound noerror count
- (unless isearch-forward 'backward))
- (Info-search (if isearch-regexp string (regexp-quote string))
- bound noerror count
- (unless isearch-forward 'backward))
- (point))
- (error nil)))
+ (if isearch-word
+ (Info-search (concat "\\b" (replace-regexp-in-string
+ "\\W+" "\\\\W+"
+ (replace-regexp-in-string
+ "^\\W+\\|\\W+$" "" string)) "\\b")
+ bound noerror count
+ (unless isearch-forward 'backward))
+ (Info-search (if isearch-regexp string (regexp-quote string))
+ bound noerror count
+ (unless isearch-forward 'backward))
+ (point)))
(let ((isearch-search-fun-function nil))
(isearch-search-fun))))
(defun Info-isearch-wrap ()
- (when Info-isearch-search
- (if isearch-forward (Info-top-node) (Info-final-node))
+ (if Info-isearch-search
+ (if Info-isearch-initial-node
+ (progn
+ (if isearch-forward (Info-top-node) (Info-final-node))
+ (goto-char (if isearch-forward (point-min) (point-max))))
+ (setq Info-isearch-initial-node Info-current-node)
+ (setq isearch-wrapped nil))
(goto-char (if isearch-forward (point-min) (point-max)))))
(defun Info-isearch-push-state ()
@@ -1680,6 +1696,8 @@ If DIRECTION is `backward', search in the reverse direction."
(string= Info-current-node node))
(progn (Info-find-node file node) (sit-for 0))))
+(defun Info-isearch-start ()
+ (setq Info-isearch-initial-node nil))
(defun Info-extract-pointer (name &optional errorname)
"Extract the value of the node-pointer named NAME.
@@ -3217,6 +3235,7 @@ Advanced commands:
(setq desktop-save-buffer 'Info-desktop-buffer-misc-data)
(add-hook 'clone-buffer-hook 'Info-clone-buffer-hook nil t)
(add-hook 'change-major-mode-hook 'font-lock-defontify nil t)
+ (add-hook 'isearch-mode-hook 'Info-isearch-start nil t)
(set (make-local-variable 'isearch-search-fun-function)
'Info-isearch-search)
(set (make-local-variable 'isearch-wrap-function)