comparison lisp/info.el @ 24963:a78f0c2654d6

(Info-search): Don't lose with empty regexp.
author Dave Love <fx@gnu.org>
date Mon, 19 Jul 1999 22:21:44 +0000
parents a6ad37f4f6cb
children 784d7bc2a991
comparison
equal deleted inserted replaced
24962:a6428fea28fd 24963:a78f0c2654d6
956 (interactive "sSearch (regexp): ") 956 (interactive "sSearch (regexp): ")
957 (if transient-mark-mode (deactivate-mark)) 957 (if transient-mark-mode (deactivate-mark))
958 (if (equal regexp "") 958 (if (equal regexp "")
959 (setq regexp Info-last-search) 959 (setq regexp Info-last-search)
960 (setq Info-last-search regexp)) 960 (setq Info-last-search regexp))
961 (let ((found ()) current 961 (when regexp
962 (onode Info-current-node) 962 (let ((found ()) current
963 (ofile Info-current-file) 963 (onode Info-current-node)
964 (opoint (point)) 964 (ofile Info-current-file)
965 (ostart (window-start)) 965 (opoint (point))
966 (osubfile Info-current-subfile)) 966 (ostart (window-start))
967 (save-excursion 967 (osubfile Info-current-subfile))
968 (save-restriction 968 (save-excursion
969 (widen) 969 (save-restriction
970 (if (null Info-current-subfile) 970 (widen)
971 (progn (re-search-forward regexp) (setq found (point))) 971 (if (null Info-current-subfile)
972 (condition-case err
973 (progn (re-search-forward regexp) (setq found (point))) 972 (progn (re-search-forward regexp) (setq found (point)))
974 (search-failed nil))))) 973 (condition-case err
975 (if (not found) ;can only happen in subfile case -- else would have erred 974 (progn (re-search-forward regexp) (setq found (point)))
976 (unwind-protect 975 (search-failed nil)))))
977 (let ((list ())) 976 (if (not found) ;can only happen in subfile case -- else would have erred
978 (save-excursion 977 (unwind-protect
979 (set-buffer (marker-buffer Info-tag-table-marker)) 978 (let ((list ()))
980 (goto-char (point-min)) 979 (save-excursion
981 (search-forward "\n\^_\nIndirect:") 980 (set-buffer (marker-buffer Info-tag-table-marker))
982 (save-restriction
983 (narrow-to-region (point)
984 (progn (search-forward "\n\^_")
985 (1- (point))))
986 (goto-char (point-min)) 981 (goto-char (point-min))
987 (search-forward (concat "\n" osubfile ": ")) 982 (search-forward "\n\^_\nIndirect:")
988 (beginning-of-line) 983 (save-restriction
989 (while (not (eobp)) 984 (narrow-to-region (point)
990 (re-search-forward "\\(^.*\\): [0-9]+$") 985 (progn (search-forward "\n\^_")
991 (goto-char (+ (match-end 1) 2)) 986 (1- (point))))
992 (setq list (cons (cons (read (current-buffer)) 987 (goto-char (point-min))
993 (buffer-substring 988 (search-forward (concat "\n" osubfile ": "))
994 (match-beginning 1) (match-end 1))) 989 (beginning-of-line)
995 list)) 990 (while (not (eobp))
996 (goto-char (1+ (match-end 0)))) 991 (re-search-forward "\\(^.*\\): [0-9]+$")
997 (setq list (nreverse list) 992 (goto-char (+ (match-end 1) 2))
998 current (car (car list)) 993 (setq list (cons (cons (read (current-buffer))
999 list (cdr list)))) 994 (buffer-substring
1000 (while list 995 (match-beginning 1) (match-end 1)))
1001 (message "Searching subfile %s..." (cdr (car list))) 996 list))
1002 (Info-read-subfile (car (car list))) 997 (goto-char (1+ (match-end 0))))
1003 (setq list (cdr list)) 998 (setq list (nreverse list)
1004 ;; (goto-char (point-min)) 999 current (car (car list))
1005 (if (re-search-forward regexp nil t) 1000 list (cdr list))))
1006 (setq found (point) list ()))) 1001 (while list
1007 (if found 1002 (message "Searching subfile %s..." (cdr (car list)))
1008 (message "") 1003 (Info-read-subfile (car (car list)))
1009 (signal 'search-failed (list regexp)))) 1004 (setq list (cdr list))
1010 (if (not found) 1005 ;;; (goto-char (point-min))
1011 (progn (Info-read-subfile osubfile) 1006 (if (re-search-forward regexp nil t)
1012 (goto-char opoint) 1007 (setq found (point) list ())))
1013 (Info-select-node) 1008 (if found
1014 (set-window-start (selected-window) ostart))))) 1009 (message "")
1010 (signal 'search-failed (list regexp))))
1011 (if (not found)
1012 (progn (Info-read-subfile osubfile)
1013 (goto-char opoint)
1014 (Info-select-node)
1015 (set-window-start (selected-window) ostart)))))
1015 (widen) 1016 (widen)
1016 (goto-char found) 1017 (goto-char found)
1017 (Info-select-node) 1018 (Info-select-node)
1018 ;; Use string-equal, not equal, to ignore text props. 1019 ;; Use string-equal, not equal, to ignore text props.
1019 (or (and (string-equal onode Info-current-node) 1020 (or (and (string-equal onode Info-current-node)
1020 (equal ofile Info-current-file)) 1021 (equal ofile Info-current-file))
1021 (setq Info-history (cons (list ofile onode opoint) 1022 (setq Info-history (cons (list ofile onode opoint)
1022 Info-history))))) 1023 Info-history))))))
1023 1024
1024 ;; Extract the value of the node-pointer named NAME. 1025 ;; Extract the value of the node-pointer named NAME.
1025 ;; If there is none, use ERRORNAME in the error message; 1026 ;; If there is none, use ERRORNAME in the error message;
1026 ;; if ERRORNAME is nil, just return nil. 1027 ;; if ERRORNAME is nil, just return nil.
1027 (defun Info-extract-pointer (name &optional errorname) 1028 (defun Info-extract-pointer (name &optional errorname)