188 |
:type 'boolean |
:type 'boolean |
189 |
:group 'info) |
:group 'info) |
190 |
|
|
191 |
(defcustom Info-search-whitespace-regexp "\\\\(?:\\\\s-+\\\\)" |
(defcustom Info-search-whitespace-regexp "\\(?:\\s-+\\)" |
192 |
"*If non-nil, regular expression to match a sequence of whitespace chars. |
"*If non-nil, regular expression to match a sequence of whitespace chars. |
193 |
This applies to Info search for regular expressions. |
This applies to Info search for regular expressions. |
194 |
You might want to use something like \"[ \\t\\r\\n]+\" instead. |
You might want to use something like \"[ \\t\\r\\n]+\" instead. |
1442 |
(defvar Info-search-case-fold nil |
(defvar Info-search-case-fold nil |
1443 |
"The value of `case-fold-search' from previous `Info-search' command.") |
"The value of `case-fold-search' from previous `Info-search' command.") |
1444 |
|
|
1445 |
(defun Info-search (regexp) |
(defun Info-search (regexp &optional bound noerror count direction) |
1446 |
"Search for REGEXP, starting from point, and select node it's found in." |
"Search for REGEXP, starting from point, and select node it's found in. |
1447 |
|
If DIRECTION is `backward', search in the reverse direction." |
1448 |
(interactive (list (read-string |
(interactive (list (read-string |
1449 |
(if Info-search-history |
(if Info-search-history |
1450 |
(format "Regexp search%s (default `%s'): " |
(format "Regexp search%s (default `%s'): " |
1459 |
(setq regexp (car Info-search-history))) |
(setq regexp (car Info-search-history))) |
1460 |
(when regexp |
(when regexp |
1461 |
(let (found beg-found give-up |
(let (found beg-found give-up |
1462 |
|
(backward (eq direction 'backward)) |
1463 |
(onode Info-current-node) |
(onode Info-current-node) |
1464 |
(ofile Info-current-file) |
(ofile Info-current-file) |
1465 |
(opoint (point)) |
(opoint (point)) |
1466 |
|
(opoint-min (point-min)) |
1467 |
|
(opoint-max (point-max)) |
1468 |
(ostart (window-start)) |
(ostart (window-start)) |
1469 |
(osubfile Info-current-subfile)) |
(osubfile Info-current-subfile)) |
1470 |
(when Info-search-whitespace-regexp |
(when Info-search-whitespace-regexp |
1471 |
(setq regexp (replace-regexp-in-string |
(setq regexp |
1472 |
"[ \t\n]+" Info-search-whitespace-regexp regexp))) |
(mapconcat 'identity (split-string regexp "[ \t\n]+") |
1473 |
|
Info-search-whitespace-regexp))) |
1474 |
(setq Info-search-case-fold case-fold-search) |
(setq Info-search-case-fold case-fold-search) |
1475 |
(save-excursion |
(save-excursion |
1476 |
(save-restriction |
(save-restriction |
1477 |
(widen) |
(widen) |
1478 |
(while (and (not give-up) |
(while (and (not give-up) |
1479 |
(or (null found) |
(or (null found) |
1480 |
(isearch-range-invisible beg-found found))) |
(if backward |
1481 |
(if (re-search-forward regexp nil t) |
(isearch-range-invisible found beg-found) |
1482 |
(setq found (point) beg-found (match-beginning 0)) |
(isearch-range-invisible beg-found found)))) |
1483 |
|
(if (if backward |
1484 |
|
(re-search-backward regexp bound t) |
1485 |
|
(re-search-forward regexp bound t)) |
1486 |
|
(setq found (point) beg-found (if backward (match-end 0) |
1487 |
|
(match-beginning 0))) |
1488 |
(setq give-up t))))) |
(setq give-up t))))) |
1489 |
;; If no subfiles, give error now. |
;; If no subfiles, give error now. |
1490 |
(if give-up |
(if give-up |
1491 |
(if (null Info-current-subfile) |
(if (null Info-current-subfile) |
1492 |
(re-search-forward regexp) |
(if backward |
1493 |
|
(re-search-backward regexp) |
1494 |
|
(re-search-forward regexp)) |
1495 |
(setq found nil))) |
(setq found nil))) |
1496 |
|
|
1497 |
(unless found |
(unless (or found bound) |
1498 |
(unwind-protect |
(unwind-protect |
1499 |
;; Try other subfiles. |
;; Try other subfiles. |
1500 |
(let ((list ())) |
(let ((list ())) |
1510 |
;; Find the subfile we just searched. |
;; Find the subfile we just searched. |
1511 |
(search-forward (concat "\n" osubfile ": ")) |
(search-forward (concat "\n" osubfile ": ")) |
1512 |
;; Skip that one. |
;; Skip that one. |
1513 |
(forward-line 1) |
(forward-line (if backward 0 1)) |
1514 |
;; Make a list of all following subfiles. |
;; Make a list of all following subfiles. |
1515 |
;; Each elt has the form (VIRT-POSITION . SUBFILENAME). |
;; Each elt has the form (VIRT-POSITION . SUBFILENAME). |
1516 |
(while (not (eobp)) |
(while (not (if backward (bobp) (eobp))) |
1517 |
(re-search-forward "\\(^.*\\): [0-9]+$") |
(if backward |
1518 |
|
(re-search-backward "\\(^.*\\): [0-9]+$") |
1519 |
|
(re-search-forward "\\(^.*\\): [0-9]+$")) |
1520 |
(goto-char (+ (match-end 1) 2)) |
(goto-char (+ (match-end 1) 2)) |
1521 |
(setq list (cons (cons (+ (point-min) |
(setq list (cons (cons (+ (point-min) |
1522 |
(read (current-buffer))) |
(read (current-buffer))) |
1523 |
(match-string-no-properties 1)) |
(match-string-no-properties 1)) |
1524 |
list)) |
list)) |
1525 |
(goto-char (1+ (match-end 0)))) |
(goto-char (if backward |
1526 |
|
(1- (match-beginning 0)) |
1527 |
|
(1+ (match-end 0))))) |
1528 |
;; Put in forward order |
;; Put in forward order |
1529 |
(setq list (nreverse list)))) |
(setq list (nreverse list)))) |
1530 |
(while list |
(while list |
1531 |
(message "Searching subfile %s..." (cdr (car list))) |
(message "Searching subfile %s..." (cdr (car list))) |
1532 |
(Info-read-subfile (car (car list))) |
(Info-read-subfile (car (car list))) |
1533 |
|
(if backward (goto-char (point-max))) |
1534 |
(setq list (cdr list)) |
(setq list (cdr list)) |
1535 |
(setq give-up nil found nil) |
(setq give-up nil found nil) |
1536 |
(while (and (not give-up) |
(while (and (not give-up) |
1537 |
(or (null found) |
(or (null found) |
1538 |
(isearch-range-invisible beg-found found))) |
(if backward |
1539 |
(if (re-search-forward regexp nil t) |
(isearch-range-invisible found beg-found) |
1540 |
(setq found (point) beg-found (match-beginning 0)) |
(isearch-range-invisible beg-found found)))) |
1541 |
|
(if (if backward |
1542 |
|
(re-search-backward regexp nil t) |
1543 |
|
(re-search-forward regexp nil t)) |
1544 |
|
(setq found (point) beg-found (if backward (match-end 0) |
1545 |
|
(match-beginning 0))) |
1546 |
(setq give-up t))) |
(setq give-up t))) |
1547 |
(if give-up |
(if give-up |
1548 |
(setq found nil)) |
(setq found nil)) |
1556 |
(goto-char opoint) |
(goto-char opoint) |
1557 |
(Info-select-node) |
(Info-select-node) |
1558 |
(set-window-start (selected-window) ostart))))) |
(set-window-start (selected-window) ostart))))) |
1559 |
(widen) |
|
1560 |
(goto-char found) |
(if (and (string= osubfile Info-current-subfile) |
1561 |
(Info-select-node) |
(> found opoint-min) |
1562 |
|
(< found opoint-max)) |
1563 |
|
;; Search landed in the same node |
1564 |
|
(goto-char found) |
1565 |
|
(widen) |
1566 |
|
(goto-char found) |
1567 |
|
(save-match-data (Info-select-node))) |
1568 |
|
|
1569 |
;; Use string-equal, not equal, to ignore text props. |
;; Use string-equal, not equal, to ignore text props. |
1570 |
(or (and (string-equal onode Info-current-node) |
(or (and (string-equal onode Info-current-node) |
1571 |
(equal ofile Info-current-file)) |
(equal ofile Info-current-file)) |
1572 |
|
(and isearch-mode isearch-wrapped (eq opoint opoint-min)) |
1573 |
(setq Info-history (cons (list ofile onode opoint) |
(setq Info-history (cons (list ofile onode opoint) |
1574 |
Info-history)))))) |
Info-history)))))) |
1575 |
|
|
1586 |
(if Info-search-history |
(if Info-search-history |
1587 |
(Info-search (car Info-search-history)) |
(Info-search (car Info-search-history)) |
1588 |
(call-interactively 'Info-search)))) |
(call-interactively 'Info-search)))) |
1589 |
|
|
1590 |
|
(defun Info-search-backward (regexp &optional bound noerror count) |
1591 |
|
"Search for REGEXP in the reverse direction." |
1592 |
|
(interactive (list (read-string |
1593 |
|
(if Info-search-history |
1594 |
|
(format "Regexp search%s backward (default `%s'): " |
1595 |
|
(if case-fold-search "" " case-sensitively") |
1596 |
|
(car Info-search-history)) |
1597 |
|
(format "Regexp search%s backward: " |
1598 |
|
(if case-fold-search "" " case-sensitively"))) |
1599 |
|
nil 'Info-search-history))) |
1600 |
|
(Info-search regexp bound noerror count 'backward)) |
1601 |
|
|
1602 |
|
(defun Info-isearch-search () |
1603 |
|
(cond |
1604 |
|
(isearch-word |
1605 |
|
(if isearch-forward 'word-search-forward 'word-search-backward)) |
1606 |
|
(isearch-regexp |
1607 |
|
(lambda (regexp bound noerror) |
1608 |
|
(condition-case nil |
1609 |
|
(progn |
1610 |
|
(Info-search regexp bound noerror nil |
1611 |
|
(unless isearch-forward 'backward)) |
1612 |
|
(point)) |
1613 |
|
(error nil)))) |
1614 |
|
(t |
1615 |
|
(if isearch-forward 'search-forward 'search-backward)))) |
1616 |
|
|
1617 |
|
(defun Info-isearch-wrap () |
1618 |
|
(if isearch-regexp |
1619 |
|
(if isearch-forward (Info-top-node) (Info-final-node)) |
1620 |
|
(goto-char (if isearch-forward (point-min) (point-max))))) |
1621 |
|
|
1622 |
|
(defun Info-isearch-push-state () |
1623 |
|
`(lambda (cmd) |
1624 |
|
(Info-isearch-pop-state cmd ,Info-current-file ,Info-current-node))) |
1625 |
|
|
1626 |
|
(defun Info-isearch-pop-state (cmd file node) |
1627 |
|
(or (and (string= Info-current-file file) |
1628 |
|
(string= Info-current-node node)) |
1629 |
|
(progn (Info-find-node file node) (sit-for 0)))) |
1630 |
|
|
1631 |
|
|
1632 |
(defun Info-extract-pointer (name &optional errorname) |
(defun Info-extract-pointer (name &optional errorname) |
1633 |
"Extract the value of the node-pointer named NAME. |
"Extract the value of the node-pointer named NAME. |
3136 |
(setq desktop-save-buffer 'Info-desktop-buffer-misc-data) |
(setq desktop-save-buffer 'Info-desktop-buffer-misc-data) |
3137 |
(add-hook 'clone-buffer-hook 'Info-clone-buffer-hook nil t) |
(add-hook 'clone-buffer-hook 'Info-clone-buffer-hook nil t) |
3138 |
(add-hook 'change-major-mode-hook 'font-lock-defontify nil t) |
(add-hook 'change-major-mode-hook 'font-lock-defontify nil t) |
3139 |
|
(set (make-local-variable 'isearch-search-fun-function) |
3140 |
|
'Info-isearch-search) |
3141 |
|
(set (make-local-variable 'isearch-wrap-function) |
3142 |
|
'Info-isearch-wrap) |
3143 |
|
(set (make-local-variable 'isearch-push-state-function) |
3144 |
|
'Info-isearch-push-state) |
3145 |
|
(set (make-local-variable 'search-whitespace-regexp) |
3146 |
|
Info-search-whitespace-regexp) |
3147 |
(Info-set-mode-line) |
(Info-set-mode-line) |
3148 |
(run-hooks 'Info-mode-hook)) |
(run-hooks 'Info-mode-hook)) |
3149 |
|
|
3525 |
other-tag) |
other-tag) |
3526 |
(when not-fontified-p |
(when not-fontified-p |
3527 |
(when Info-hide-note-references |
(when Info-hide-note-references |
3528 |
;; *Note is often used where *note should have been |
(when (not (eq Info-hide-note-references 'hide)) |
3529 |
(goto-char start) |
;; *Note is often used where *note should have been |
3530 |
(skip-syntax-backward " ") |
(goto-char start) |
3531 |
(setq other-tag |
(skip-syntax-backward " ") |
3532 |
(cond ((memq (char-before) '(nil ?\. ?! ??)) |
(setq other-tag |
3533 |
"See ") |
(cond ((memq (char-before) '(nil ?\. ?! ??)) |
3534 |
((memq (char-before) '(?\, ?\; ?\: ?-)) |
"See ") |
3535 |
"see ") |
((memq (char-before) '(?\, ?\; ?\: ?-)) |
3536 |
((memq (char-before) '(?\( ?\[ ?\{)) |
"see ") |
3537 |
;; Check whether the paren is preceded by |
((memq (char-before) '(?\( ?\[ ?\{)) |
3538 |
;; an end of sentence |
;; Check whether the paren is preceded by |
3539 |
(skip-syntax-backward " (") |
;; an end of sentence |
3540 |
(if (memq (char-before) '(nil ?\. ?! ??)) |
(skip-syntax-backward " (") |
3541 |
"See " |
(if (memq (char-before) '(nil ?\. ?! ??)) |
3542 |
"see ")) |
"See " |
3543 |
((save-match-data (looking-at "\n\n")) |
"see ")) |
3544 |
"See "))) |
((save-match-data (looking-at "\n\n")) |
3545 |
|
"See ")))) |
3546 |
(goto-char next) |
(goto-char next) |
3547 |
(add-text-properties |
(add-text-properties |
3548 |
(match-beginning 1) |
(match-beginning 1) |
3552 |
(if (string-match "\n" (match-string 1)) |
(if (string-match "\n" (match-string 1)) |
3553 |
(+ start1 (match-beginning 0))))) |
(+ start1 (match-beginning 0))))) |
3554 |
(match-end 1)) |
(match-end 1)) |
3555 |
(if (and other-tag (not (eq Info-hide-note-references 'hide))) |
(if other-tag |
3556 |
`(display ,other-tag front-sticky nil rear-nonsticky t) |
`(display ,other-tag front-sticky nil rear-nonsticky t) |
3557 |
'(invisible t front-sticky nil rear-nonsticky t)))) |
'(invisible t front-sticky nil rear-nonsticky t)))) |
3558 |
(add-text-properties |
(add-text-properties |