comparison lisp/info.el @ 438:84b14dcb0985 r21-2-27

Import from CVS: tag r21-2-27
author cvs
date Mon, 13 Aug 2007 11:32:25 +0200
parents 3ecd8885ac67
children 8de8e3f6228a
comparison
equal deleted inserted replaced
437:e2a4e8b94b82 438:84b14dcb0985
435 ;;;###autoload 435 ;;;###autoload
436 (defvar Info-directory-list nil 436 (defvar Info-directory-list nil
437 "List of directories to search for Info documentation files. 437 "List of directories to search for Info documentation files.
438 438
439 The first directory in this list, the \"dir\" file there will become 439 The first directory in this list, the \"dir\" file there will become
440 the (dir)Top node of the Info documentation tree. If you wish to 440 the (dir)Top node of the Info documentation tree.
441 modify the info search path, use `M-x customize-variable, 441
442 Info-directory-list' to do so.") 442 Note: DO NOT use the `customize' interface to change the value of this
443 variable. Its value is created dynamically on each startup, depending
444 on XEmacs packages installed on the system. If you want to change the
445 search path, make the needed modifications on the variable's value
446 from .emacs. For instance:
447
448 (setq Info-directory-list (cons \"~/info\" Info-directory-list))")
443 449
444 (defcustom Info-localdir-heading-regexp 450 (defcustom Info-localdir-heading-regexp
445 "^Locally installed XEmacs Packages:?" 451 "^Locally installed XEmacs Packages:?"
446 "The menu part of localdir files will be inserted below this topic 452 "The menu part of localdir files will be inserted below this topic
447 heading." 453 heading."
1487 nil t nil 1493 nil t nil
1488 'Info-minibuffer-history))) 1494 'Info-minibuffer-history)))
1489 (or (equal tag "") (Info-find-node nil (format "<<%s>>" tag))))) 1495 (or (equal tag "") (Info-find-node nil (format "<<%s>>" tag)))))
1490 1496
1491 ;;;###autoload 1497 ;;;###autoload
1492 (defun Info-visit-file () 1498 (defun Info-visit-file (file)
1493 "Directly visit an info file." 1499 "Directly visit an info file."
1494 (interactive) 1500 (interactive "fVisit Info file: ")
1495 (let* ((insert-default-directory nil) 1501 (Info-find-node (expand-file-name file) "Top"))
1496 (file (read-file-name "Goto Info file: " "" "")))
1497 (or (equal file "") (Info-find-node (expand-file-name file) "Top"))))
1498 1502
1499 (defun Info-restore-point (&optional always) 1503 (defun Info-restore-point (&optional always)
1500 "Restore point to same location it had last time we were in this node." 1504 "Restore point to same location it had last time we were in this node."
1501 (interactive "p") 1505 (interactive "p")
1502 (if (or Info-restoring-point always) 1506 (if (or Info-restoring-point always)
1511 (and (nth 2 entry) 1515 (and (nth 2 entry)
1512 (get-buffer-window (current-buffer)) 1516 (get-buffer-window (current-buffer))
1513 (set-window-start (get-buffer-window (current-buffer)) 1517 (set-window-start (get-buffer-window (current-buffer))
1514 (+ (nth 2 entry) (point-min))))) 1518 (+ (nth 2 entry) (point-min)))))
1515 1519
1520 (defvar Info-read-node-completion-table)
1521
1522 ;; This function is used as the "completion table" while reading a node name.
1523 ;; It does completion using the alist in Info-read-node-completion-table
1524 ;; unless STRING starts with an open-paren.
1525 (defun Info-read-node-name-1 (string predicate code)
1526 (let ((no-completion (and (> (length string) 0) (eq (aref string 0) ?\())))
1527 (cond ((eq code nil)
1528 (if no-completion
1529 string
1530 (try-completion string Info-read-node-completion-table predicate)))
1531 ((eq code t)
1532 (if no-completion
1533 nil
1534 (all-completions string Info-read-node-completion-table predicate)))
1535 ((eq code 'lambda)
1536 (if no-completion
1537 t
1538 (assoc string Info-read-node-completion-table))))))
1539
1516 (defun Info-read-node-name (prompt &optional default) 1540 (defun Info-read-node-name (prompt &optional default)
1517 (Info-setup-initial) 1541 (Info-setup-initial)
1518 (let* ((completion-ignore-case t) 1542 (let* ((completion-ignore-case t)
1519 (nodename (completing-read prompt 1543 (Info-read-node-completion-table (Info-build-node-completions))
1520 (Info-build-node-completions) 1544 (nodename (completing-read prompt 'Info-read-node-name-1
1521 nil nil nil 1545 nil t nil 'Info-minibuffer-history
1522 'Info-minibuffer-history))) 1546 default)))
1523 (if (equal nodename "") 1547 (if (equal nodename "")
1524 (or default 1548 (or default
1525 (Info-read-node-name prompt)) 1549 (Info-read-node-name prompt))
1526 nodename))) 1550 nodename)))
1527 1551
1574 1598
1575 1599
1576 ;;;###autoload 1600 ;;;###autoload
1577 (defun Info-search (regexp) 1601 (defun Info-search (regexp)
1578 "Search for REGEXP, starting from point, and select node it's found in." 1602 "Search for REGEXP, starting from point, and select node it's found in."
1579 (interactive "sSearch (regexp): ") 1603 (interactive (list
1580 (if (equal regexp "") 1604 (read-from-minibuffer
1581 (setq regexp Info-last-search) 1605 (if Info-last-search
1582 (setq Info-last-search regexp)) 1606 (format "Search (regexp, default %s): "
1607 Info-last-search)
1608 "Search (regexp): ")
1609 nil nil nil nil nil Info-last-search)))
1610 (setq Info-last-search regexp)
1583 (with-search-caps-disable-folding regexp t 1611 (with-search-caps-disable-folding regexp t
1584 (let ((found ()) 1612 (let ((found ())
1585 (onode Info-current-node) 1613 (onode Info-current-node)
1586 (ofile Info-current-file) 1614 (ofile Info-current-file)
1587 (opoint (point)) 1615 (opoint (point))
1664 (progn 1692 (progn
1665 (while (looking-at (concat "[" (or allowedchars "^,\t\n") "]")) 1693 (while (looking-at (concat "[" (or allowedchars "^,\t\n") "]"))
1666 (skip-chars-forward (concat (or allowedchars "^,\t\n") "(")) 1694 (skip-chars-forward (concat (or allowedchars "^,\t\n") "("))
1667 (if (looking-at "(") 1695 (if (looking-at "(")
1668 (skip-chars-forward "^)"))) 1696 (skip-chars-forward "^)")))
1669 (skip-chars-backward " ") 1697 (skip-chars-backward " .")
1670 (point)))) 1698 (point))))
1671 1699
1672 (defun Info-next (&optional n) 1700 (defun Info-next (&optional n)
1673 "Go to the next node of this node. 1701 "Go to the next node of this node.
1674 A positive or negative prefix argument moves by multiple nodes." 1702 A positive or negative prefix argument moves by multiple nodes."
1759 (let ((item (completing-read (if default 1787 (let ((item (completing-read (if default
1760 (concat "Follow reference named: (" 1788 (concat "Follow reference named: ("
1761 default ") ") 1789 default ") ")
1762 "Follow reference named: ") 1790 "Follow reference named: ")
1763 completions nil t nil 1791 completions nil t nil
1764 'Info-minibuffer-history))) 1792 'Info-minibuffer-history
1793 default)))
1765 (if (and (string= item "") default) 1794 (if (and (string= item "") default)
1766 (list default) 1795 (list default)
1767 (list item))) 1796 (list item)))
1768 (error "No cross-references in this node")))) 1797 (error "No cross-references in this node"))))
1769 (let (target i (str (concat "\\*" Info-footnote-tag " " 1798 (let (target i (str (concat "\\*" Info-footnote-tag " "
1843 (forward-char 1) 1872 (forward-char 1)
1844 (setq str 1873 (setq str
1845 (if (looking-at ":") 1874 (if (looking-at ":")
1846 (buffer-substring beg (1- (point))) 1875 (buffer-substring beg (1- (point)))
1847 (skip-chars-forward " \t\n") 1876 (skip-chars-forward " \t\n")
1848 (Info-following-node-name (if multi-line "^.,\t" "^.,\t\n")))) 1877 ;; Kludge.
1878 ;; Allow dots in node name not followed by whitespace.
1879 (re-search-forward
1880 (concat "\\(([^)]+)[^."
1881 (if multi-line "" "\n")
1882 "]*\\|\\([^.,\t"
1883 (if multi-line "" "\n")
1884 ;; We consider dots followed by newline as
1885 ;; end of nodename even if multil-line.
1886 ;; Also stops at .). It is generated by @pxref.
1887 ;; Skips sequential dots.
1888 "]\\|\\.+[^ \t\n)]\\)+\\)"))
1889 (match-string 1)))
1849 (while (setq i (string-match "\n" str i)) 1890 (while (setq i (string-match "\n" str i))
1850 (aset str i ?\ )) 1891 (aset str i ?\ ))
1851 str)) 1892 str))
1852 1893
1853 (defun Info-menu (menu-item) 1894 (defun Info-menu (menu-item)
1886 (completing-read (if default 1927 (completing-read (if default
1887 (format "Menu item (default %s): " 1928 (format "Menu item (default %s): "
1888 default) 1929 default)
1889 "Menu item: ") 1930 "Menu item: ")
1890 completions nil t nil 1931 completions nil t nil
1891 'Info-minibuffer-history))) 1932 'Info-minibuffer-history
1933 default)))
1892 ;; we rely on the fact that completing-read accepts an input 1934 ;; we rely on the fact that completing-read accepts an input
1893 ;; of "" even when the require-match argument is true and "" 1935 ;; of "" even when the require-match argument is true and ""
1894 ;; is not a valid possibility 1936 ;; is not a valid possibility
1895 (if (string= item "") 1937 (if (string= item "")
1896 (if default 1938 (if default
2093 Use the `,' command to see the other matches. 2135 Use the `,' command to see the other matches.
2094 Give a blank topic name to go to the Index node itself." 2136 Give a blank topic name to go to the Index node itself."
2095 (interactive "sIndex topic: ") 2137 (interactive "sIndex topic: ")
2096 (let ((pattern (format "\n\\* \\([^\n:]*%s[^\n:]*\\):[ \t]*%s" 2138 (let ((pattern (format "\n\\* \\([^\n:]*%s[^\n:]*\\):[ \t]*%s"
2097 (regexp-quote topic) 2139 (regexp-quote topic)
2098 "\\([^.\n]*\\)\\.[ t]*\\([0-9]*\\)")) 2140 "\\(.*\\)\\.[ t]*\\([0-9]*\\)$"))
2099 node) 2141 node)
2100 (message "Searching index for `%s'..." topic) 2142 (message "Searching index for `%s'..." topic)
2101 (Info-goto-node "Top") 2143 (Info-goto-node "Top")
2102 (let ((case-fold-search t)) 2144 (let ((case-fold-search t))
2103 (or (search-forward "\n* menu:" nil t) 2145 (or (search-forward "\n* menu:" nil t)