comparison lisp/info.el @ 22951:19b3899582b4

Bind case-fold-search to t in many functions.
author Richard M. Stallman <rms@gnu.org>
date Sat, 08 Aug 1998 21:27:22 +0000
parents 18839ab53285
children 60f63c8a3837
comparison
equal deleted inserted replaced
22950:606be1490be7 22951:19b3899582b4
378 (or (eq major-mode 'Info-mode) 378 (or (eq major-mode 'Info-mode)
379 (Info-mode)) 379 (Info-mode))
380 (widen) 380 (widen)
381 (setq Info-current-node nil) 381 (setq Info-current-node nil)
382 (unwind-protect 382 (unwind-protect
383 (progn 383 ;; Bind case-fold-search in case the user sets it to nil.
384 (let ((case-fold-search t))
384 ;; Switch files if necessary 385 ;; Switch files if necessary
385 (or (null filename) 386 (or (null filename)
386 (equal Info-current-file filename) 387 (equal Info-current-file filename)
387 (let ((buffer-read-only nil)) 388 (let ((buffer-read-only nil))
388 (setq Info-current-file nil 389 (setq Info-current-file nil
544 (setcar (nthcdr 4 (cdr elt)) 0) 545 (setcar (nthcdr 4 (cdr elt)) 0)
545 (equal (cdr elt) curr))) 546 (equal (cdr elt) curr)))
546 Info-dir-file-attributes)))) 547 Info-dir-file-attributes))))
547 (insert Info-dir-contents) 548 (insert Info-dir-contents)
548 (let ((dirs Info-directory-list) 549 (let ((dirs Info-directory-list)
550 ;; Bind this in case the user sets it to nil.
551 (case-fold-search t)
549 buffers buffer others nodes dirs-done) 552 buffers buffer others nodes dirs-done)
550 553
551 (setq Info-dir-file-attributes nil) 554 (setq Info-dir-file-attributes nil)
552 555
553 ;; Search the directory list for the directory file. 556 ;; Search the directory list for the directory file.
716 (if (numberp nodepos) 719 (if (numberp nodepos)
717 (+ (- nodepos lastfilepos) (point))))) 720 (+ (- nodepos lastfilepos) (point)))))
718 721
719 ;; Select the info node that point is in. 722 ;; Select the info node that point is in.
720 (defun Info-select-node () 723 (defun Info-select-node ()
721 (save-excursion 724 ;; Bind this in case the user sets it to nil.
722 ;; Find beginning of node. 725 (let ((case-fold-search t))
723 (search-backward "\n\^_") 726 (save-excursion
724 (forward-line 2) 727 ;; Find beginning of node.
725 ;; Get nodename spelled as it is in the node. 728 (search-backward "\n\^_")
726 (re-search-forward "Node:[ \t]*") 729 (forward-line 2)
727 (setq Info-current-node 730 ;; Get nodename spelled as it is in the node.
728 (buffer-substring-no-properties (point) 731 (re-search-forward "Node:[ \t]*")
729 (progn 732 (setq Info-current-node
730 (skip-chars-forward "^,\t\n") 733 (buffer-substring-no-properties (point)
731 (point)))) 734 (progn
732 (Info-set-mode-line) 735 (skip-chars-forward "^,\t\n")
733 ;; Find the end of it, and narrow. 736 (point))))
734 (beginning-of-line) 737 (Info-set-mode-line)
735 (let (active-expression) 738 ;; Find the end of it, and narrow.
736 (narrow-to-region (point) 739 (beginning-of-line)
737 (if (re-search-forward "\n[\^_\f]" nil t) 740 (let (active-expression)
738 (prog1 741 (narrow-to-region (point)
739 (1- (point)) 742 (if (re-search-forward "\n[\^_\f]" nil t)
740 (if (looking-at "[\n\^_\f]*execute: ") 743 (prog1
741 (progn 744 (1- (point))
742 (goto-char (match-end 0)) 745 (if (looking-at "[\n\^_\f]*execute: ")
743 (setq active-expression 746 (progn
744 (read (current-buffer)))))) 747 (goto-char (match-end 0))
745 (point-max))) 748 (setq active-expression
746 (if Info-enable-active-nodes (eval active-expression)) 749 (read (current-buffer))))))
747 (if Info-fontify (Info-fontify-node)) 750 (point-max)))
748 (run-hooks 'Info-selection-hook)))) 751 (if Info-enable-active-nodes (eval active-expression))
752 (if Info-fontify (Info-fontify-node))
753 (run-hooks 'Info-selection-hook)))))
749 754
750 (defun Info-set-mode-line () 755 (defun Info-set-mode-line ()
751 (setq mode-line-buffer-identification 756 (setq mode-line-buffer-identification
752 (concat 757 (concat
753 " Info: (" 758 " Info: ("
807 (Info-read-node-name prompt)) 812 (Info-read-node-name prompt))
808 nodename))) 813 nodename)))
809 814
810 (defun Info-build-node-completions () 815 (defun Info-build-node-completions ()
811 (or Info-current-file-completions 816 (or Info-current-file-completions
812 (let ((compl nil)) 817 (let ((compl nil)
818 ;; Bind this in case the user sets it to nil.
819 (case-fold-search t))
813 (save-excursion 820 (save-excursion
814 (save-restriction 821 (save-restriction
815 (if (marker-buffer Info-tag-table-marker) 822 (if (marker-buffer Info-tag-table-marker)
816 (let ((marker Info-tag-table-marker)) 823 (let ((marker Info-tag-table-marker))
817 (set-buffer (marker-buffer marker)) 824 (set-buffer (marker-buffer marker))
922 929
923 ;; Extract the value of the node-pointer named NAME. 930 ;; Extract the value of the node-pointer named NAME.
924 ;; If there is none, use ERRORNAME in the error message; 931 ;; If there is none, use ERRORNAME in the error message;
925 ;; if ERRORNAME is nil, just return nil. 932 ;; if ERRORNAME is nil, just return nil.
926 (defun Info-extract-pointer (name &optional errorname) 933 (defun Info-extract-pointer (name &optional errorname)
927 (save-excursion 934 ;; Bind this in case the user sets it to nil.
928 (goto-char (point-min)) 935 (let ((case-fold-search t))
929 (forward-line 1) 936 (save-excursion
930 (if (re-search-backward (concat name ":") nil t) 937 (goto-char (point-min))
931 (progn 938 (forward-line 1)
932 (goto-char (match-end 0)) 939 (if (re-search-backward (concat name ":") nil t)
933 (Info-following-node-name)) 940 (progn
934 (if (eq errorname t) 941 (goto-char (match-end 0))
935 nil 942 (Info-following-node-name))
936 (error "Node has no %s" (capitalize (or errorname name))))))) 943 (if (eq errorname t)
944 nil
945 (error "Node has no %s" (capitalize (or errorname name))))))))
937 946
938 ;; Return the node name in the buffer following point. 947 ;; Return the node name in the buffer following point.
939 ;; ALLOWEDCHARS, if non-nil, goes within [...] to make a regexp 948 ;; ALLOWEDCHARS, if non-nil, goes within [...] to make a regexp
940 ;; saying which chars may appear in the node name. 949 ;; saying which chars may appear in the node name.
941 (defun Info-following-node-name (&optional allowedchars) 950 (defun Info-following-node-name (&optional allowedchars)
993 (defun Info-follow-reference (footnotename) 1002 (defun Info-follow-reference (footnotename)
994 "Follow cross reference named NAME to the node it refers to. 1003 "Follow cross reference named NAME to the node it refers to.
995 NAME may be an abbreviation of the reference name." 1004 NAME may be an abbreviation of the reference name."
996 (interactive 1005 (interactive
997 (let ((completion-ignore-case t) 1006 (let ((completion-ignore-case t)
1007 (case-fold-search t)
998 completions default alt-default (start-point (point)) str i bol eol) 1008 completions default alt-default (start-point (point)) str i bol eol)
999 (save-excursion 1009 (save-excursion
1000 ;; Store end and beginning of line. 1010 ;; Store end and beginning of line.
1001 (end-of-line) 1011 (end-of-line)
1002 (setq eol (point)) 1012 (setq eol (point))
1051 "Follow reference named: ") 1061 "Follow reference named: ")
1052 completions nil t))) 1062 completions nil t)))
1053 (list (if (equal input "") 1063 (list (if (equal input "")
1054 default input))) 1064 default input)))
1055 (error "No cross-references in this node")))) 1065 (error "No cross-references in this node"))))
1056 (let (target beg i (str (concat "\\*note " (regexp-quote footnotename)))) 1066 (let (target beg i (str (concat "\\*note " (regexp-quote footnotename)))
1067 (case-fold-search t))
1057 (while (setq i (string-match " " str i)) 1068 (while (setq i (string-match " " str i))
1058 (setq str (concat (substring str 0 i) "[ \t\n]+" (substring str (1+ i)))) 1069 (setq str (concat (substring str 0 i) "[ \t\n]+" (substring str (1+ i))))
1059 (setq i (+ i 6))) 1070 (setq i (+ i 6)))
1060 (save-excursion 1071 (save-excursion
1061 (goto-char (point-min)) 1072 (goto-char (point-min))
1188 ;; name you can only go to the node of the first with this command. 1199 ;; name you can only go to the node of the first with this command.
1189 (Info-goto-node (Info-extract-menu-item menu-item))) 1200 (Info-goto-node (Info-extract-menu-item menu-item)))
1190 1201
1191 (defun Info-extract-menu-item (menu-item) 1202 (defun Info-extract-menu-item (menu-item)
1192 (setq menu-item (regexp-quote menu-item)) 1203 (setq menu-item (regexp-quote menu-item))
1193 (save-excursion 1204 (let ((case-fold-search t))
1194 (goto-char (point-min)) 1205 (save-excursion
1195 (or (search-forward "\n* menu:" nil t) 1206 (goto-char (point-min))
1196 (error "No menu in this node")) 1207 (or (search-forward "\n* menu:" nil t)
1197 (or (re-search-forward (concat "\n\\* +" menu-item ":") nil t) 1208 (error "No menu in this node"))
1198 (re-search-forward (concat "\n\\* +" menu-item) nil t) 1209 (or (re-search-forward (concat "\n\\* +" menu-item ":") nil t)
1199 (error "No such item in menu")) 1210 (re-search-forward (concat "\n\\* +" menu-item) nil t)
1200 (beginning-of-line) 1211 (error "No such item in menu"))
1201 (forward-char 2) 1212 (beginning-of-line)
1202 (Info-extract-menu-node-name))) 1213 (forward-char 2)
1214 (Info-extract-menu-node-name))))
1203 1215
1204 ;; If COUNT is nil, use the last item in the menu. 1216 ;; If COUNT is nil, use the last item in the menu.
1205 (defun Info-extract-menu-counting (count) 1217 (defun Info-extract-menu-counting (count)
1206 (save-excursion 1218 (let ((case-fold-search t))
1207 (goto-char (point-min)) 1219 (save-excursion
1208 (or (search-forward "\n* menu:" nil t) 1220 (goto-char (point-min))
1209 (error "No menu in this node")) 1221 (or (search-forward "\n* menu:" nil t)
1210 (if count 1222 (error "No menu in this node"))
1211 (or (search-forward "\n* " nil t count) 1223 (if count
1212 (error "Too few items in menu")) 1224 (or (search-forward "\n* " nil t count)
1213 (while (search-forward "\n* " nil t) 1225 (error "Too few items in menu"))
1214 nil)) 1226 (while (search-forward "\n* " nil t)
1215 (Info-extract-menu-node-name))) 1227 nil))
1228 (Info-extract-menu-node-name))))
1216 1229
1217 (defun Info-nth-menu-item () 1230 (defun Info-nth-menu-item ()
1218 "Go to the node of the Nth menu item. 1231 "Go to the node of the Nth menu item.
1219 N is the digit argument used to invoke this command." 1232 N is the digit argument used to invoke this command."
1220 (interactive) 1233 (interactive)
1422 1435
1423 (defun Info-next-reference (&optional recur) 1436 (defun Info-next-reference (&optional recur)
1424 "Move cursor to the next cross-reference or menu item in the node." 1437 "Move cursor to the next cross-reference or menu item in the node."
1425 (interactive) 1438 (interactive)
1426 (let ((pat "\\*note[ \n\t]*\\([^:]*\\):\\|^\\* .*:") 1439 (let ((pat "\\*note[ \n\t]*\\([^:]*\\):\\|^\\* .*:")
1427 (old-pt (point))) 1440 (old-pt (point))
1441 (case-fold-search t))
1428 (or (eobp) (forward-char 1)) 1442 (or (eobp) (forward-char 1))
1429 (or (re-search-forward pat nil t) 1443 (or (re-search-forward pat nil t)
1430 (progn 1444 (progn
1431 (goto-char (point-min)) 1445 (goto-char (point-min))
1432 (or (re-search-forward pat nil t) 1446 (or (re-search-forward pat nil t)
1441 1455
1442 (defun Info-prev-reference (&optional recur) 1456 (defun Info-prev-reference (&optional recur)
1443 "Move cursor to the previous cross-reference or menu item in the node." 1457 "Move cursor to the previous cross-reference or menu item in the node."
1444 (interactive) 1458 (interactive)
1445 (let ((pat "\\*note[ \n\t]*\\([^:]*\\):\\|^\\* .*:") 1459 (let ((pat "\\*note[ \n\t]*\\([^:]*\\):\\|^\\* .*:")
1446 (old-pt (point))) 1460 (old-pt (point))
1461 (case-fold-search t))
1447 (or (re-search-backward pat nil t) 1462 (or (re-search-backward pat nil t)
1448 (progn 1463 (progn
1449 (goto-char (point-max)) 1464 (goto-char (point-max))
1450 (or (re-search-backward pat nil t) 1465 (or (re-search-backward pat nil t)
1451 (progn 1466 (progn
1469 (interactive "sIndex topic: ") 1484 (interactive "sIndex topic: ")
1470 (let ((orignode Info-current-node) 1485 (let ((orignode Info-current-node)
1471 (rnode nil) 1486 (rnode nil)
1472 (pattern (format "\n\\* +\\([^\n:]*%s[^\n:]*\\):[ \t]*\\([^.\n]*\\)\\.[ \t]*\\([0-9]*\\)" 1487 (pattern (format "\n\\* +\\([^\n:]*%s[^\n:]*\\):[ \t]*\\([^.\n]*\\)\\.[ \t]*\\([0-9]*\\)"
1473 (regexp-quote topic))) 1488 (regexp-quote topic)))
1474 node) 1489 node
1490 (case-fold-search t))
1475 (Info-goto-node "Top") 1491 (Info-goto-node "Top")
1476 (or (search-forward "\n* menu:" nil t) 1492 (or (search-forward "\n* menu:" nil t)
1477 (error "No index")) 1493 (error "No index"))
1478 (or (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t) 1494 (or (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t)
1479 (error "No index")) 1495 (error "No index"))
1544 "(Press `,' for more)" 1560 "(Press `,' for more)"
1545 "(Only match)"))) 1561 "(Only match)")))
1546 1562
1547 (defun Info-find-index-name (name) 1563 (defun Info-find-index-name (name)
1548 "Move point to the place within the current node where NAME is defined." 1564 "Move point to the place within the current node where NAME is defined."
1549 (if (or (re-search-forward (format 1565 (let ((case-fold-search t))
1550 "[a-zA-Z]+: %s\\( \\|$\\)" 1566 (if (or (re-search-forward (format
1551 (regexp-quote name)) nil t) 1567 "[a-zA-Z]+: %s\\( \\|$\\)"
1552 (search-forward (format "`%s'" name) nil t) 1568 (regexp-quote name)) nil t)
1553 (and (string-match "\\`.*\\( (.*)\\)\\'" name) 1569 (search-forward (format "`%s'" name) nil t)
1554 (search-forward 1570 (and (string-match "\\`.*\\( (.*)\\)\\'" name)
1555 (format "`%s'" (substring name 0 (match-beginning 1))) 1571 (search-forward
1556 nil t)) 1572 (format "`%s'" (substring name 0 (match-beginning 1)))
1557 (search-forward name nil t)) 1573 nil t))
1558 (beginning-of-line) 1574 (search-forward name nil t))
1559 (goto-char (point-min)))) 1575 (beginning-of-line)
1576 (goto-char (point-min)))))
1560 1577
1561 (defun Info-undefined () 1578 (defun Info-undefined ()
1562 "Make command be undefined in Info." 1579 "Make command be undefined in Info."
1563 (interactive) 1580 (interactive)
1564 (ding)) 1581 (ding))
1603 enclosed in braces around POS. 1620 enclosed in braces around POS.
1604 SIG optional fourth argument, controls action on no match 1621 SIG optional fourth argument, controls action on no match
1605 nil: return nil 1622 nil: return nil
1606 t: beep 1623 t: beep
1607 a string: signal an error, using that string." 1624 a string: signal an error, using that string."
1608 (save-excursion 1625 (let ((case-fold-search t))
1609 (goto-char pos) 1626 (save-excursion
1610 ;; First look for a match for START that goes across POS. 1627 (goto-char pos)
1611 (while (and (not (bobp)) (> (point) (- pos (length start))) 1628 ;; First look for a match for START that goes across POS.
1612 (not (looking-at start))) 1629 (while (and (not (bobp)) (> (point) (- pos (length start)))
1613 (forward-char -1)) 1630 (not (looking-at start)))
1614 ;; If we did not find one, search back for START 1631 (forward-char -1))
1615 ;; (this finds only matches that end at or before POS). 1632 ;; If we did not find one, search back for START
1616 (or (looking-at start) 1633 ;; (this finds only matches that end at or before POS).
1617 (progn 1634 (or (looking-at start)
1618 (goto-char pos) 1635 (progn
1619 (re-search-backward start (max (point-min) (- pos 200)) 'yes))) 1636 (goto-char pos)
1620 (let (found) 1637 (re-search-backward start (max (point-min) (- pos 200)) 'yes)))
1621 (while (and (re-search-forward all (min (point-max) (+ pos 200)) 'yes) 1638 (let (found)
1622 (not (setq found (and (<= (match-beginning 0) pos) 1639 (while (and (re-search-forward all (min (point-max) (+ pos 200)) 'yes)
1623 (> (match-end 0) pos)))))) 1640 (not (setq found (and (<= (match-beginning 0) pos)
1624 (if (and found (<= (match-beginning 0) pos) 1641 (> (match-end 0) pos))))))
1625 (> (match-end 0) pos)) 1642 (if (and found (<= (match-beginning 0) pos)
1626 (buffer-substring (match-beginning 1) (match-end 1)) 1643 (> (match-end 0) pos))
1627 (cond ((null errorstring) 1644 (buffer-substring (match-beginning 1) (match-end 1))
1628 nil) 1645 (cond ((null errorstring)
1629 ((eq errorstring t) 1646 nil)
1630 (beep) 1647 ((eq errorstring t)
1631 nil) 1648 (beep)
1632 (t 1649 nil)
1633 (error "No %s around position %d" errorstring pos))))))) 1650 (t
1651 (error "No %s around position %d" errorstring pos))))))))
1634 1652
1635 (defun Info-mouse-follow-nearest-node (click) 1653 (defun Info-mouse-follow-nearest-node (click)
1636 "\\<Info-mode-map>Follow a node reference near point. 1654 "\\<Info-mode-map>Follow a node reference near point.
1637 Like \\[Info-menu], \\[Info-follow-reference], \\[Info-next], \\[Info-prev] or \\[Info-up] command, depending on where you click. 1655 Like \\[Info-menu], \\[Info-follow-reference], \\[Info-next], \\[Info-prev] or \\[Info-up] command, depending on where you click.
1638 At end of the node's text, moves to the next node, or up if none." 1656 At end of the node's text, moves to the next node, or up if none."
1776 (setq entries (list ["No menu" nil nil]))) 1794 (setq entries (list ["No menu" nil nil])))
1777 (easy-menu-change '("Info") "Menu item" (nreverse entries))) 1795 (easy-menu-change '("Info") "Menu item" (nreverse entries)))
1778 ;; Update reference menu. Code stolen from `Info-follow-reference'. 1796 ;; Update reference menu. Code stolen from `Info-follow-reference'.
1779 (let ((items nil) 1797 (let ((items nil)
1780 str i entries current 1798 str i entries current
1781 (number 0)) 1799 (number 0)
1800 (case-fold-search t))
1782 (save-excursion 1801 (save-excursion
1783 (goto-char (point-min)) 1802 (goto-char (point-min))
1784 (while (re-search-forward "\\*note[ \n\t]*\\([^:]*\\):" nil t) 1803 (while (re-search-forward "\\*note[ \n\t]*\\([^:]*\\):" nil t)
1785 (setq str (buffer-substring 1804 (setq str (buffer-substring
1786 (match-beginning 1) 1805 (match-beginning 1)
2059 :type '(repeat (list character face face)) 2078 :type '(repeat (list character face face))
2060 :group 'info) 2079 :group 'info)
2061 2080
2062 (defun Info-fontify-node () 2081 (defun Info-fontify-node ()
2063 (save-excursion 2082 (save-excursion
2064 (let ((buffer-read-only nil)) 2083 (let ((buffer-read-only nil)
2084 (case-fold-search t))
2065 (goto-char (point-min)) 2085 (goto-char (point-min))
2066 (when (looking-at "^File: [^,: \t]+,?[ \t]+") 2086 (when (looking-at "^File: [^,: \t]+,?[ \t]+")
2067 (goto-char (match-end 0)) 2087 (goto-char (match-end 0))
2068 (while 2088 (while
2069 (looking-at "[ \t]*\\([^:, \t\n]+\\):[ \t]+\\([^:,\t\n]+\\),?") 2089 (looking-at "[ \t]*\\([^:, \t\n]+\\):[ \t]+\\([^:,\t\n]+\\),?")
2185 DEPTH is the current indentation depth. 2205 DEPTH is the current indentation depth.
2186 NODE is an optional argument that is used to represent the 2206 NODE is an optional argument that is used to represent the
2187 specific node to expand." 2207 specific node to expand."
2188 (if (and (not node) 2208 (if (and (not node)
2189 (save-excursion (goto-char (point-min)) 2209 (save-excursion (goto-char (point-min))
2190 (looking-at "Info Nodes:"))) 2210 (let ((case-fold-search t))
2211 (looking-at "Info Nodes:"))))
2191 ;; Update our "current node" maybe? 2212 ;; Update our "current node" maybe?
2192 nil 2213 nil
2193 ;; We cannot use the generic list code, that depends on all leaves 2214 ;; We cannot use the generic list code, that depends on all leaves
2194 ;; being known at creation time. 2215 ;; being known at creation time.
2195 (if (not node) 2216 (if (not node)
2274 (node (match-string 2 nodespec))) 2295 (node (match-string 2 nodespec)))
2275 (Info-find-node file node)) 2296 (Info-find-node file node))
2276 ;; Scan the created buffer 2297 ;; Scan the created buffer
2277 (goto-char (point-min)) 2298 (goto-char (point-min))
2278 (let ((completions nil) 2299 (let ((completions nil)
2300 (case-fold-search t)
2279 (thisfile (progn (string-match "^(\\([^)]+\\))" nodespec) 2301 (thisfile (progn (string-match "^(\\([^)]+\\))" nodespec)
2280 (match-string 1 nodespec)))) 2302 (match-string 1 nodespec))))
2281 ;; Always skip the first one... 2303 ;; Always skip the first one...
2282 (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t) 2304 (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t)
2283 (while (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t) 2305 (while (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t)
2296 ;;; Info mode node listing 2318 ;;; Info mode node listing
2297 (defun Info-speedbar-buttons (buffer) 2319 (defun Info-speedbar-buttons (buffer)
2298 "Create a speedbar display to help navigation in an Info file. 2320 "Create a speedbar display to help navigation in an Info file.
2299 BUFFER is the buffer speedbar is requesting buttons for." 2321 BUFFER is the buffer speedbar is requesting buttons for."
2300 (if (save-excursion (goto-char (point-min)) 2322 (if (save-excursion (goto-char (point-min))
2301 (not (looking-at "Info Nodes:"))) 2323 (let ((case-fold-search t))
2324 (not (looking-at "Info Nodes:"))))
2302 (erase-buffer)) 2325 (erase-buffer))
2303 (Info-speedbar-hierarchy-buttons nil 0) 2326 (Info-speedbar-hierarchy-buttons nil 0)
2304 ) 2327 )
2305 2328
2306 (provide 'info) 2329 (provide 'info)