comparison lisp/info.el @ 398:74fd4e045ea6 r21-2-29

Import from CVS: tag r21-2-29
author cvs
date Mon, 13 Aug 2007 11:13:30 +0200
parents 7d59cb494b73
children a86b2b5e0111
comparison
equal deleted inserted replaced
397:f4aeb21a5bad 398:74fd4e045ea6
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."
457 :group 'info-faces) 463 :group 'info-faces)
458 464
459 ;; Is this right for NT? .zip, with -c for to stdout, right? 465 ;; Is this right for NT? .zip, with -c for to stdout, right?
460 (defvar Info-suffix-list '( ("" . nil) 466 (defvar Info-suffix-list '( ("" . nil)
461 (".info" . nil) 467 (".info" . nil)
468 (".info.bz2" . "bzip2 -dc %s")
462 (".info.gz" . "gzip -dc %s") 469 (".info.gz" . "gzip -dc %s")
463 (".info-z" . "gzip -dc %s") 470 (".info-z" . "gzip -dc %s")
464 (".info.Z" . "uncompress -c %s") 471 (".info.Z" . "uncompress -c %s")
465 (".bz2" . "bzip2 -dc %s") 472 (".bz2" . "bzip2 -dc %s")
466 (".gz" . "gzip -dc %s") 473 (".gz" . "gzip -dc %s")
499 506
500 (defvar Info-index-alternatives nil 507 (defvar Info-index-alternatives nil
501 "List of possible matches for last Info-index command.") 508 "List of possible matches for last Info-index command.")
502 (defvar Info-index-first-alternative nil) 509 (defvar Info-index-first-alternative nil)
503 510
504 (defcustom Info-annotations-path '("~/.xemacs/info.notes" 511 (defcustom Info-annotations-path
505 "~/.infonotes" 512 (list
506 "/usr/lib/info.notes") 513 (paths-construct-path (list user-init-directory "info.notes"))
514 (paths-construct-path '("~" ".infonotes"))
515 (paths-construct-path '("usr" "lib" "info.notes")
516 (char-to-string directory-sep-char)))
507 "*Names of files that contain annotations for different Info nodes. 517 "*Names of files that contain annotations for different Info nodes.
508 By convention, the first one should reside in your personal directory. 518 By convention, the first one should reside in your personal directory.
509 The last should be a world-writable \"public\" annotations file." 519 The last should be a world-writable \"public\" annotations file."
510 :type '(repeat file) 520 :type '(repeat file)
511 :group 'info) 521 :group 'info)
1483 nil t nil 1493 nil t nil
1484 'Info-minibuffer-history))) 1494 'Info-minibuffer-history)))
1485 (or (equal tag "") (Info-find-node nil (format "<<%s>>" tag))))) 1495 (or (equal tag "") (Info-find-node nil (format "<<%s>>" tag)))))
1486 1496
1487 ;;;###autoload 1497 ;;;###autoload
1488 (defun Info-visit-file () 1498 (defun Info-visit-file (file)
1489 "Directly visit an info file." 1499 "Directly visit an info file."
1490 (interactive) 1500 (interactive "fVisit Info file: ")
1491 (let* ((insert-default-directory nil) 1501 (Info-find-node (expand-file-name file) "Top"))
1492 (file (read-file-name "Goto Info file: " "" "")))
1493 (or (equal file "") (Info-find-node (expand-file-name file) "Top"))))
1494 1502
1495 (defun Info-restore-point (&optional always) 1503 (defun Info-restore-point (&optional always)
1496 "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."
1497 (interactive "p") 1505 (interactive "p")
1498 (if (or Info-restoring-point always) 1506 (if (or Info-restoring-point always)
1507 (and (nth 2 entry) 1515 (and (nth 2 entry)
1508 (get-buffer-window (current-buffer)) 1516 (get-buffer-window (current-buffer))
1509 (set-window-start (get-buffer-window (current-buffer)) 1517 (set-window-start (get-buffer-window (current-buffer))
1510 (+ (nth 2 entry) (point-min))))) 1518 (+ (nth 2 entry) (point-min)))))
1511 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
1512 (defun Info-read-node-name (prompt &optional default) 1540 (defun Info-read-node-name (prompt &optional default)
1513 (Info-setup-initial) 1541 (Info-setup-initial)
1514 (let* ((completion-ignore-case t) 1542 (let* ((completion-ignore-case t)
1515 (nodename (completing-read prompt 1543 (Info-read-node-completion-table (Info-build-node-completions))
1516 (Info-build-node-completions) 1544 (nodename (completing-read prompt 'Info-read-node-name-1
1517 nil nil nil 1545 nil t nil 'Info-minibuffer-history
1518 'Info-minibuffer-history))) 1546 default)))
1519 (if (equal nodename "") 1547 (if (equal nodename "")
1520 (or default 1548 (or default
1521 (Info-read-node-name prompt)) 1549 (Info-read-node-name prompt))
1522 nodename))) 1550 nodename)))
1523 1551
1570 1598
1571 1599
1572 ;;;###autoload 1600 ;;;###autoload
1573 (defun Info-search (regexp) 1601 (defun Info-search (regexp)
1574 "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."
1575 (interactive "sSearch (regexp): ") 1603 (interactive (list
1576 (if (equal regexp "") 1604 (read-from-minibuffer
1577 (setq regexp Info-last-search) 1605 (if Info-last-search
1578 (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)
1579 (with-search-caps-disable-folding regexp t 1611 (with-search-caps-disable-folding regexp t
1580 (let ((found ()) 1612 (let ((found ())
1581 (onode Info-current-node) 1613 (onode Info-current-node)
1582 (ofile Info-current-file) 1614 (ofile Info-current-file)
1583 (opoint (point)) 1615 (opoint (point))
1650 nil 1682 nil
1651 (error (concat "Node has no " (capitalize (or errorname name))))))))) 1683 (error (concat "Node has no " (capitalize (or errorname name)))))))))
1652 1684
1653 ;; Return the node name in the buffer following point. 1685 ;; Return the node name in the buffer following point.
1654 ;; ALLOWEDCHARS, if non-nil, goes within [...] to make a regexp 1686 ;; ALLOWEDCHARS, if non-nil, goes within [...] to make a regexp
1655 ;; saying which chas may appear in the node name. 1687 ;; saying which chars may appear in the node name.
1656 (defun Info-following-node-name (&optional allowedchars) 1688 (defun Info-following-node-name (&optional allowedchars)
1657 (skip-chars-forward " \t") 1689 (skip-chars-forward " \t")
1658 (buffer-substring 1690 (buffer-substring
1659 (point) 1691 (point)
1660 (progn 1692 (progn
1661 (while (looking-at (concat "[" (or allowedchars "^,\t\n") "]")) 1693 (while (looking-at (concat "[" (or allowedchars "^,\t\n") "]"))
1662 (skip-chars-forward (concat (or allowedchars "^,\t\n") "(")) 1694 (skip-chars-forward (concat (or allowedchars "^,\t\n") "("))
1663 (if (looking-at "(") 1695 (if (looking-at "(")
1664 (skip-chars-forward "^)"))) 1696 (skip-chars-forward "^)")))
1665 (skip-chars-backward " ") 1697 (skip-chars-backward " .")
1666 (point)))) 1698 (point))))
1667 1699
1668 (defun Info-next (&optional n) 1700 (defun Info-next (&optional n)
1669 "Go to the next node of this node. 1701 "Go to the next node of this node.
1670 A positive or negative prefix argument moves by multiple nodes." 1702 A positive or negative prefix argument moves by multiple nodes."
1755 (let ((item (completing-read (if default 1787 (let ((item (completing-read (if default
1756 (concat "Follow reference named: (" 1788 (concat "Follow reference named: ("
1757 default ") ") 1789 default ") ")
1758 "Follow reference named: ") 1790 "Follow reference named: ")
1759 completions nil t nil 1791 completions nil t nil
1760 'Info-minibuffer-history))) 1792 'Info-minibuffer-history
1793 default)))
1761 (if (and (string= item "") default) 1794 (if (and (string= item "") default)
1762 (list default) 1795 (list default)
1763 (list item))) 1796 (list item)))
1764 (error "No cross-references in this node")))) 1797 (error "No cross-references in this node"))))
1765 (let (target i (str (concat "\\*" Info-footnote-tag " " 1798 (let (target i (str (concat "\\*" Info-footnote-tag " "
1839 (forward-char 1) 1872 (forward-char 1)
1840 (setq str 1873 (setq str
1841 (if (looking-at ":") 1874 (if (looking-at ":")
1842 (buffer-substring beg (1- (point))) 1875 (buffer-substring beg (1- (point)))
1843 (skip-chars-forward " \t\n") 1876 (skip-chars-forward " \t\n")
1844 (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)))
1845 (while (setq i (string-match "\n" str i)) 1890 (while (setq i (string-match "\n" str i))
1846 (aset str i ?\ )) 1891 (aset str i ?\ ))
1847 str)) 1892 str))
1848 1893
1849 (defun Info-menu (menu-item) 1894 (defun Info-menu (menu-item)
1882 (completing-read (if default 1927 (completing-read (if default
1883 (format "Menu item (default %s): " 1928 (format "Menu item (default %s): "
1884 default) 1929 default)
1885 "Menu item: ") 1930 "Menu item: ")
1886 completions nil t nil 1931 completions nil t nil
1887 'Info-minibuffer-history))) 1932 'Info-minibuffer-history
1933 default)))
1888 ;; we rely on the fact that completing-read accepts an input 1934 ;; we rely on the fact that completing-read accepts an input
1889 ;; of "" even when the require-match argument is true and "" 1935 ;; of "" even when the require-match argument is true and ""
1890 ;; is not a valid possibility 1936 ;; is not a valid possibility
1891 (if (string= item "") 1937 (if (string= item "")
1892 (if default 1938 (if default
2058 (while (>= (setq n (1- n)) 0) 2104 (while (>= (setq n (1- n)) 0)
2059 (if (pos-visible-in-window-p (point-min)) 2105 (if (pos-visible-in-window-p (point-min))
2060 (progn 2106 (progn
2061 (Info-global-prev) 2107 (Info-global-prev)
2062 (message "Node: %s" Info-current-node) 2108 (message "Node: %s" Info-current-node)
2063 (sit-for 0) 2109 (goto-char (point-max))
2064 ;;(scroll-up 1) ; work around bug in pos-visible-in-window-p 2110 (recenter -1)
2065 ;;(scroll-down 1) 2111 (move-to-window-line 0))
2066 (while (not (pos-visible-in-window-p (point-max)))
2067 (scroll-up)))
2068 (scroll-down))))) 2112 (scroll-down)))))
2069 2113
2070 (defun Info-scroll-prev (arg) 2114 (defun Info-scroll-prev (arg)
2071 (interactive "P") 2115 (interactive "P")
2072 (if Info-auto-advance 2116 (if Info-auto-advance
2073 (if (and (pos-visible-in-window-p (point-min)) 2117 (if (and (pos-visible-in-window-p (point-min))
2074 (not (eq Info-auto-advance t)) 2118 (not (eq Info-auto-advance t))
2075 (not (eq last-command this-command))) 2119 (not (eq last-command this-command)))
2076 (message "Hit %s again to go to previous node" 2120 (message "Hit %s again to go to previous node"
2077 (if (= last-command-char 0) 2121 (if (mouse-event-p last-command-event)
2078 "mouse button" 2122 "mouse button"
2079 (key-description (char-to-string last-command-char)))) 2123 (key-description (event-key last-command-event))))
2080 (Info-page-prev) 2124 (Info-page-prev)
2081 (setq this-command 'Info)) 2125 (setq this-command 'Info))
2082 (scroll-down arg))) 2126 (scroll-down arg)))
2083 2127
2084 (defun Info-index (topic) 2128 (defun Info-index (topic)
2091 Use the `,' command to see the other matches. 2135 Use the `,' command to see the other matches.
2092 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."
2093 (interactive "sIndex topic: ") 2137 (interactive "sIndex topic: ")
2094 (let ((pattern (format "\n\\* \\([^\n:]*%s[^\n:]*\\):[ \t]*%s" 2138 (let ((pattern (format "\n\\* \\([^\n:]*%s[^\n:]*\\):[ \t]*%s"
2095 (regexp-quote topic) 2139 (regexp-quote topic)
2096 "\\([^.\n]*\\)\\.[ t]*\\([0-9]*\\)")) 2140 "\\(.*\\)\\.[ t]*\\([0-9]*\\)$"))
2097 node) 2141 node)
2098 (message "Searching index for `%s'..." topic) 2142 (message "Searching index for `%s'..." topic)
2099 (Info-goto-node "Top") 2143 (Info-goto-node "Top")
2100 (let ((case-fold-search t)) 2144 (let ((case-fold-search t))
2101 (or (search-forward "\n* menu:" nil t) 2145 (or (search-forward "\n* menu:" nil t)