(custom-face-value-create): If face name doesn't end with "face", add
[bpt/emacs.git] / lisp / info.el
index 67fdec7..e02ae97 100644 (file)
@@ -97,11 +97,7 @@ A header-line does not scroll with the rest of the buffer."
   :group 'info)
 
 (defface info-header-node
-  '(;; Because header-lines on tty's are usually reverse-video, the
-    ;; normal info-node colors probably won't look good, so just stick
-    ;; with bold-italic
-    (((type tty) (class color)) (:bold t :italic t))
-    (t (:inherit info-node)))
+  '((t (:inherit info-node)))
   "Face for Info nodes in a node header."
   :group 'info)
 
@@ -940,13 +936,15 @@ Bind this in case the user sets it to nil."
 
 (defun Info-set-mode-line ()
   (setq mode-line-buffer-identification
-       (concat
-        "  *Info* ("
-        (file-name-nondirectory (if (stringp Info-current-file)
-                                    Info-current-file
-                                  (or buffer-file-name "")))
-        ") "
-        (or Info-current-node ""))))
+       (nconc (propertized-buffer-identification "%b")
+              (list
+               (concat " ("
+                       (file-name-nondirectory
+                        (if (stringp Info-current-file)
+                            Info-current-file
+                          (or buffer-file-name "")))
+                       ") "
+                       (or Info-current-node ""))))))
 \f
 ;; Skip the node header and make it into a header-line.  This function
 ;; should be called when the node is already narrowed.
@@ -963,9 +961,10 @@ Bind this in case the user sets it to nil."
 
 (defun Info-goto-node (nodename &optional fork)
   "Go to info node named NAME.  Give just NODENAME or (FILENAME)NODENAME.
-If FORK is non-nil, show the node in a new info buffer.
+If FORK is non-nil (interactively with a prefix arg), show the node in
+a new info buffer.
 If FORK is a string, it is the name to use for the new buffer."
-  (interactive (list (Info-read-node-name "Goto node: ") current-prefix-arg))
+  (interactive (list (Info-read-node-name "Go to node: ") current-prefix-arg))
   (info-initialize)
   (if fork
       (set-buffer
@@ -1369,7 +1368,10 @@ FOOTNOTENAME may be an abbreviation of the reference name."
 
 (defun Info-menu (menu-item &optional fork)
   "Go to node for menu item named (or abbreviated) NAME.
-Completion is allowed, and the menu item point is on is the default."
+Completion is allowed, and the menu item point is on is the default.
+If FORK is non-nil (interactively with a prefix arg), show the node in
+a new info buffer.  If FORK is a string, it is the name to use for the
+new buffer."
   (interactive
    (let ((completions '())
         ;; If point is within a menu item, use that item as the default
@@ -1876,11 +1878,7 @@ ERRORSTRING optional fourth argument, controls action on no match
 Like \\[Info-menu], \\[Info-follow-reference], \\[Info-next], \\[Info-prev] or \\[Info-up] command, depending on where you click.
 At end of the node's text, moves to the next node, or up if none."
   (interactive "e")
-  (let* ((start (event-start click))
-        (window (car start))
-        (pos (car (cdr start))))
-    (select-window window)
-    (goto-char pos))
+  (mouse-set-point click)
   (and (not (Info-try-follow-nearest-node))
        (save-excursion (forward-line 1) (eobp))
        (Info-next-preorder)))
@@ -1987,6 +1985,8 @@ If no reference to follow, moves to the next node, or up if none."
     :help "Go backward one node, considering all as a sequence"]
    ["Forward" Info-forward-node
     :help "Go forward one node, considering all as a sequence"]
+   ["Beginning" beginning-of-buffer
+    :help "Go to beginning of this node"]
    ["Top" Info-top-node
     :help "Go to top node of file"]
    ["Final Node" Info-final-node
@@ -1995,16 +1995,33 @@ If no reference to follow, moves to the next node, or up if none."
    ("Reference" ["You should never see this" report-emacs-bug t])
    ["Search..." Info-search
     :help "Search for regular expression in this Info file"]
-   ["Goto Node..." Info-goto-node
+   ["Go to Node..." Info-goto-node
     :help "Go to a named node"]
-   ["Last" Info-last Info-history
+   ["Last" Info-last :active Info-history
     :help "Go to the last node you were at"]
    ("Index..."
     ["Lookup a String" Info-index
      :help "Look for a string in the index items"]
     ["Next Matching Item" Info-index-next
      :help "Look for another occurrence of previous item"])
-   ["Exit" Info-exit t]))
+   ["Edit" Info-edit :help "Edit contents of this node"
+    :active Info-enable-edit]
+   ["Exit" Info-exit :help "Stop reading Info"]))
+
+
+(defvar info-tool-bar-map
+  (if (display-graphic-p)
+      (let ((tool-bar-map (make-sparse-keymap)))
+       (tool-bar-add-item-from-menu 'Info-exit "close" Info-mode-map)
+       (tool-bar-add-item-from-menu 'Info-prev "left_arrow" Info-mode-map)
+       (tool-bar-add-item-from-menu 'Info-next "right_arrow" Info-mode-map)
+       (tool-bar-add-item-from-menu 'Info-up "up_arrow" Info-mode-map)
+       (tool-bar-add-item-from-menu 'Info-last "undo" Info-mode-map)
+       (tool-bar-add-item-from-menu 'Info-top-node "home" Info-mode-map)
+       (tool-bar-add-item-from-menu 'Info-index "index" Info-mode-map)
+       (tool-bar-add-item-from-menu 'Info-goto-node "jump_to" Info-mode-map)
+       (tool-bar-add-item-from-menu 'Info-search "search" Info-mode-map)
+       tool-bar-map)))
 
 (defvar Info-menu-last-node nil)
 ;; Last node the menu was created for.
@@ -2152,6 +2169,7 @@ Advanced commands:
   (setq Info-tag-table-buffer nil)
   (make-local-variable 'Info-history)
   (make-local-variable 'Info-index-alternatives)
+  (set (make-local-variable 'tool-bar-map) info-tool-bar-map)
   ;; This is for the sake of the invisible text we use handling titles.
   (make-local-variable 'line-move-ignore-invisible)
   (setq line-move-ignore-invisible t)
@@ -2169,12 +2187,11 @@ Advanced commands:
              (with-current-buffer Info-tag-table-buffer
                (copy-marker (marker-position m))))))))
 
-(defvar Info-edit-map nil
+(defvar Info-edit-map (let ((map (make-sparse-keymap)))
+                       (set-keymap-parent map text-mode-map)
+                       (define-key map "\C-c\C-c" 'Info-cease-edit)
+                       map)
   "Local keymap used within `e' command of Info.")
-(if Info-edit-map
-    nil
-  (setq Info-edit-map (nconc (make-sparse-keymap) text-mode-map))
-  (define-key Info-edit-map "\C-c\C-c" 'Info-cease-edit))
 
 ;; Info-edit mode is suitable only for specially formatted data.
 (put 'Info-edit-mode 'mode-class 'special)
@@ -2228,7 +2245,7 @@ Allowed only if variable `Info-enable-edit' is non-nil."
     ("time-stamp" . "autotype") ("quickurl" . "autotype")
     ("tempo" . "autotype") ("hippie-expand" . "autotype")
     ("cvs" . "pcl-cvs")
-    "ebrowse" "cl" "idlwave" "reftex" "widget" "woman")
+    "ebrowse" "eshell" "cl" "idlwave" "reftex" "speedbar" "widget" "woman")
   "List of Info files that describe Emacs commands.
 An element can be a file name, or a list of the form (PREFIX . FILE)
 where PREFIX is a name prefix and FILE is the file to look in.
@@ -2343,20 +2360,29 @@ the variable `Info-file-list-for-emacs'."
           (Info-goto-emacs-command-node command)))))
 \f
 (defface Info-title-1-face
-  '((t (:height 1.2 :inherit Info-title-2-face)))
+  '((((type tty pc) (class color)) (:foreground "yellow" :weight bold))
+    (t (:height 1.2 :inherit Info-title-2-face)))
   "Face for Info titles at level 1."
   :group 'info)
 
 (defface Info-title-2-face
-  '((t (:height 1.2 :inherit Info-title-3-face)))
+  '((((type tty pc) (class color)) (:foreground "lightblue" :weight bold))
+    (t (:height 1.2 :inherit Info-title-3-face)))
   "Face for Info titles at level 2."
   :group 'info)
 
 (defface Info-title-3-face
-  '((t (:height 1.2 :weight bold :inherit variable-pitch)))
+  '((((type tty pc) (class color)) (:weight bold))
+    (t (:height 1.2 :inherit Info-title-4-face)))
   "Face for Info titles at level 3."
   :group 'info)
 
+(defface Info-title-4-face
+  '((((type tty pc) (class color)) (:weight bold))
+    (t (:weight bold :inherit variable-pitch)))
+  "Face for Info titles at level 4."
+  :group 'info)
+
 (defun Info-fontify-node ()
   (save-excursion
     (let ((buffer-read-only nil)
@@ -2376,7 +2402,7 @@ the variable `Info-file-list-for-emacs'."
              (put-text-property nbeg nend 'mouse-face 'highlight)
              (put-text-property tbeg nend
                                 'help-echo
-                                (concat "Goto node "
+                                (concat "Go to node "
                                         (buffer-substring nbeg nend)))
              (let ((fun (cdr (assoc tag '(("Prev" . Info-prev)
                                           ("Next" . Info-next)
@@ -2388,29 +2414,30 @@ the variable `Info-file-list-for-emacs'."
                    (put-text-property tbeg nend 'local-map keymap))))
              ))))
       (goto-char (point-min))
-      (while (re-search-forward "\n\\([^ \t\n].+\\)\n\\(\\*+\\|=+\\|-+\\)$"
+      (while (re-search-forward "\n\\([^ \t\n].+\\)\n\\(\\*+\\|=+\\|-+\\|\\.+\\)$"
                                nil t)
        (let ((c (preceding-char))
              face)
          (cond ((= c ?*) (setq face 'Info-title-1-face))
                ((= c ?=) (setq face 'Info-title-2-face))
-               (t        (setq face 'Info-title-3-face)))
+               ((= c ?-) (setq face 'Info-title-3-face))
+               (t        (setq face 'Info-title-4-face)))
          (put-text-property (match-beginning 1) (match-end 1)
                             'face face))
        ;; This is a serious problem for trying to handle multiple
        ;; frame types at once.  We want this text to be invisible
        ;; on frames that can display the font above.
-       (if (memq (framep (selected-frame)) '(x pc w32))
+       (if (memq (framep (selected-frame)) '(x pc w32 mac))
            (add-text-properties (match-end 1) (match-end 2)
                                 '(invisible t intangible t))))
       (goto-char (point-min))
       (while (re-search-forward "\\*Note[ \n\t]+\\([^:]*\\):" nil t)
        (if (= (char-after (1- (match-beginning 0))) ?\") ; hack
            nil
-         (put-text-property (match-beginning 1) (match-end 1)
-                            'face 'info-xref)
-         (put-text-property (match-beginning 1) (match-end 1)
-                            'mouse-face 'highlight)))
+         (add-text-properties (match-beginning 1) (match-end 1)
+                              '(face info-xref
+                                mouse-face highlight
+                                help-echo "mouse-2: go to this node"))))
       (goto-char (point-min))
       (if (and (search-forward "\n* Menu:" nil t)
               (not (string-match "\\<Index\\>" Info-current-node))
@@ -2423,10 +2450,10 @@ the variable `Info-file-list-for-emacs'."
                  (put-text-property (match-beginning 0)
                                     (1+ (match-beginning 0))
                                     'face 'info-menu-5))
-             (put-text-property (match-beginning 1) (match-end 1)
-                                'face 'info-xref)
-             (put-text-property (match-beginning 1) (match-end 1)
-                                'mouse-face 'highlight))))
+             (add-text-properties (match-beginning 1) (match-end 1)
+                                  '(face info-xref
+                                    mouse-face highlight
+                                    help-echo "mouse-2: go to this node")))))
       (set-buffer-modified-p nil))))
 \f
 
@@ -2493,6 +2520,8 @@ This will add a speedbar major display mode."
   (speedbar-change-initial-expansion-list "Info")
   )
 
+(eval-when-compile (defvar speedbar-attached-frame))
+
 (defun Info-speedbar-hierarchy-buttons (directory depth &optional node)
   "Display an Info directory hierarchy in speedbar.
 DIRECTORY is the current directory in the attached frame.
@@ -2530,7 +2559,7 @@ specific node to expand."
        nil))))
 
 (defun Info-speedbar-goto-node (text node indent)
-  "When user clicks on TEXT, goto an info NODE.
+  "When user clicks on TEXT, go to an info NODE.
 The INDENT level is ignored."
   (select-frame speedbar-attached-frame)
   (let* ((buff (or (get-buffer "*info*")