diff options
| author | Richard M. Stallman | 1996-09-01 20:43:10 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1996-09-01 20:43:10 +0000 |
| commit | 75a209d4bc0e1b1a0a2f7400bf7aac5a24fca554 (patch) | |
| tree | 44a6fa6a3a6f7465b52a51cf8ff1144de45d5828 | |
| parent | 4cc36b1786ad1d18c6e754e2636f14e2ccc69577 (diff) | |
| download | emacs-75a209d4bc0e1b1a0a2f7400bf7aac5a24fca554.tar.gz emacs-75a209d4bc0e1b1a0a2f7400bf7aac5a24fca554.zip | |
Add menu items and xrefs to the menu bar menu.
(Info-check-pointer): New function.
(Info-mode-menu): New menu.
(Info-menu-last-node): New variable.
(Info-menu-update): New function.
(Info-mode): Add `Info-menu-update' to `activate-menubar-hook'.
| -rw-r--r-- | lisp/info.el | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/lisp/info.el b/lisp/info.el index 28755da156e..84066c5afd0 100644 --- a/lisp/info.el +++ b/lisp/info.el | |||
| @@ -1553,6 +1553,92 @@ If no reference to follow, moves to the next node, or up if none." | |||
| 1553 | (define-key Info-mode-map "\177" 'Info-scroll-down) | 1553 | (define-key Info-mode-map "\177" 'Info-scroll-down) |
| 1554 | (define-key Info-mode-map [mouse-2] 'Info-mouse-follow-nearest-node) | 1554 | (define-key Info-mode-map [mouse-2] 'Info-mouse-follow-nearest-node) |
| 1555 | ) | 1555 | ) |
| 1556 | |||
| 1557 | (defun Info-check-pointer (item) | ||
| 1558 | ;; Non-nil if ITEM is present in this node. | ||
| 1559 | (condition-case nil | ||
| 1560 | (Info-extract-pointer item) | ||
| 1561 | (error nil))) | ||
| 1562 | |||
| 1563 | (easy-menu-define Info-mode-menu Info-mode-map | ||
| 1564 | "Menu for info files." | ||
| 1565 | '("Info" | ||
| 1566 | ["Up" Info-up (Info-check-pointer "up")] | ||
| 1567 | ["Next" Info-next (Info-check-pointer "next")] | ||
| 1568 | ["Previous" Info-prev (Info-check-pointer "prev[ious]*")] | ||
| 1569 | ("Menu item" ["You should never see this" report-emacs-bug t]) | ||
| 1570 | ("Reference" ["You should never see this" report-emacs-bug t]) | ||
| 1571 | ["Search..." Info-search t] | ||
| 1572 | ["Goto node..." Info-goto-node t] | ||
| 1573 | ["Last" Info-last Info-history] | ||
| 1574 | ["Exit" Info-exit t])) | ||
| 1575 | |||
| 1576 | (defvar Info-menu-last-node nil) | ||
| 1577 | ;; Last node the menu was created for. | ||
| 1578 | |||
| 1579 | (defun Info-menu-update () | ||
| 1580 | ;; Update the Info menu for the current node. | ||
| 1581 | (condition-case nil | ||
| 1582 | (if (or (not (eq major-mode 'Info-mode)) | ||
| 1583 | (eq Info-current-node Info-menu-last-node)) | ||
| 1584 | () | ||
| 1585 | ;; Update menu menu. | ||
| 1586 | (let* ((Info-complete-menu-buffer (current-buffer)) | ||
| 1587 | (items (nreverse (condition-case nil | ||
| 1588 | (Info-complete-menu-item | ||
| 1589 | "" (lambda (e) t) t) | ||
| 1590 | (error nil)))) | ||
| 1591 | entries current | ||
| 1592 | (number 0)) | ||
| 1593 | (while (and items (< number 9)) | ||
| 1594 | (setq current (car items) | ||
| 1595 | items (cdr items) | ||
| 1596 | number (1+ number)) | ||
| 1597 | (setq entries (cons `[,current | ||
| 1598 | (Info-menu ,current) | ||
| 1599 | :keys ,(format "%d" number)] | ||
| 1600 | entries))) | ||
| 1601 | (if items | ||
| 1602 | (setq entries (cons ["Other..." Info-menu t] entries))) | ||
| 1603 | (or entries | ||
| 1604 | (setq entries (list ["No menu" nil nil]))) | ||
| 1605 | (easy-menu-change '("Info") "Menu item" (nreverse entries))) | ||
| 1606 | ;; Update reference menu. Code stolen from `Info-follow-reference'. | ||
| 1607 | (let ((items nil) | ||
| 1608 | str i entries current | ||
| 1609 | (number 0)) | ||
| 1610 | (save-excursion | ||
| 1611 | (goto-char (point-min)) | ||
| 1612 | (while (re-search-forward "\\*note[ \n\t]*\\([^:]*\\):" nil t) | ||
| 1613 | (setq str (buffer-substring | ||
| 1614 | (match-beginning 1) | ||
| 1615 | (1- (point)))) | ||
| 1616 | (setq i 0) | ||
| 1617 | (while (setq i (string-match "[ \n\t]+" str i)) | ||
| 1618 | (setq str (concat (substring str 0 i) " " | ||
| 1619 | (substring str (match-end 0)))) | ||
| 1620 | (setq i (1+ i))) | ||
| 1621 | (setq items | ||
| 1622 | (cons str items)))) | ||
| 1623 | (while (and items (< number 9)) | ||
| 1624 | (setq current (car items) | ||
| 1625 | items (cdr items) | ||
| 1626 | number (1+ number)) | ||
| 1627 | (setq entries (cons `[,current | ||
| 1628 | (Info-follow-reference ,current) | ||
| 1629 | t] | ||
| 1630 | entries))) | ||
| 1631 | (if items | ||
| 1632 | (setq entries (cons ["Other..." Info-follow-reference t] | ||
| 1633 | entries))) | ||
| 1634 | (or entries | ||
| 1635 | (setq entries (list ["No references" nil nil]))) | ||
| 1636 | (easy-menu-change '("Info") "Reference" (nreverse entries))) | ||
| 1637 | ;; Update last seen node. | ||
| 1638 | (setq Info-menu-last-node (current-buffer))) | ||
| 1639 | ;; Try to avoid entering infinite beep mode in case of errors. | ||
| 1640 | (error (ding)))) | ||
| 1641 | |||
| 1556 | 1642 | ||
| 1557 | ;; Info mode is suitable only for specially formatted data. | 1643 | ;; Info mode is suitable only for specially formatted data. |
| 1558 | (put 'info-mode 'mode-class 'special) | 1644 | (put 'info-mode 'mode-class 'special) |
| @@ -1605,6 +1691,8 @@ Advanced commands: | |||
| 1605 | (setq major-mode 'Info-mode) | 1691 | (setq major-mode 'Info-mode) |
| 1606 | (setq mode-name "Info") | 1692 | (setq mode-name "Info") |
| 1607 | (use-local-map Info-mode-map) | 1693 | (use-local-map Info-mode-map) |
| 1694 | (make-local-hook 'activate-menubar-hook) | ||
| 1695 | (add-hook 'activate-menubar-hook 'Info-menu-update nil t) | ||
| 1608 | (set-syntax-table text-mode-syntax-table) | 1696 | (set-syntax-table text-mode-syntax-table) |
| 1609 | (setq local-abbrev-table text-mode-abbrev-table) | 1697 | (setq local-abbrev-table text-mode-abbrev-table) |
| 1610 | (setq case-fold-search t) | 1698 | (setq case-fold-search t) |