]> code.delx.au - gnu-emacs/blobdiff - lisp/info.el
(gud-pdb-marker-regexp): Allow : and \ in file name.
[gnu-emacs] / lisp / info.el
index 8d5ae4d3473b89b8a90a5e76e602732bede2432c..560c6bfc7c12894878cd266639eeb7ff755334e7 100644 (file)
@@ -1,6 +1,6 @@
 ;;; info.el --- info package for Emacs
 
-;; Copyright (C) 1985, 86, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001
+;; Copyright (C) 1985, 86, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001, 2002
 ;;  Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
@@ -65,7 +65,7 @@ The Lisp code is executed when the node is selected.")
 (defface info-menu-5
   '((((class color)) (:foreground "red1"))
     (t (:underline t)))
-  "Face for the fifth and nineth `*' in an Info menu."
+  "Face for every third `*' in an Info menu."
   :group 'info)
 
 (defface info-xref
@@ -76,12 +76,12 @@ The Lisp code is executed when the node is selected.")
   :group 'info)
 
 (defcustom Info-fontify-maximum-menu-size 100000
-  "*Maximum size of menu to fontify if `Info-fontify' is non-nil."
+  "*Maximum size of menu to fontify if `font-lock-mode' is non-nil."
   :type 'integer
   :group 'info)
 
 (defcustom Info-use-header-line t
-  "*Non-nil means to put the beginning-of-node links in an emacs header-line.
+  "*Non-nil means to put the beginning-of-node links in an Emacs header-line.
 A header-line does not scroll with the rest of the buffer."
   :type 'boolean
   :group 'info)
@@ -98,7 +98,7 @@ A header-line does not scroll with the rest of the buffer."
 
 (defvar Info-directory-list nil
   "List of directories to search for Info documentation files.
-nil means not yet initialized.  In this case, Info uses the environment
+If nil, meaning not yet initialized, Info uses the environment
 variable INFOPATH to initialize it, or `Info-default-directory-list'
 if there is no INFOPATH variable in the environment.
 
@@ -405,6 +405,11 @@ in all the directories in that path."
        (pop-to-buffer "*info*")
       (Info-directory))))
 
+;;;###autoload
+(defun info-emacs-manual ()
+  (interactive)
+  (info "emacs"))
+
 ;;;###autoload
 (defun info-standalone ()
   "Run Emacs as a standalone Info reader.
@@ -756,9 +761,9 @@ a case-insensitive match is tried."
        (insert Info-dir-contents)
        (goto-char (point-min)))
     (let ((dirs (if Info-additional-directory-list
-                              (append Info-directory-list
-                                      Info-additional-directory-list)
-                            Info-directory-list))
+                   (append Info-directory-list
+                           Info-additional-directory-list)
+                 Info-directory-list))
          ;; Bind this in case the user sets it to nil.
          (case-fold-search t)
          ;; This is set non-nil if we find a problem in some input files.
@@ -999,7 +1004,14 @@ Bind this in case the user sets it to nil."
        (if Info-enable-active-nodes (eval active-expression))
        (Info-fontify-node)
        (if Info-use-header-line
-           (Info-setup-header-line)
+           (progn
+             (setq Info-header-line
+                   (get-text-property (point-min) 'header-line))
+             (setq header-line-format 'Info-header-line)
+;;; It is useful to be able to copy the links line out of the buffer
+;;; with M-w.
+;;;           (narrow-to-region (1+ header-end) (point-max))
+             )
          (setq Info-header-line nil)
          (setq header-line-format nil)) ; so the header line isn't displayed
        (run-hooks 'Info-selection-hook)))))
@@ -1016,29 +1028,6 @@ Bind this in case the user sets it to nil."
                        ") "
                        (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.
-(defun Info-setup-header-line ()
-  (goto-char (point-min))
-  (let* ((case-fold-search t)
-        (header-end (save-excursion (forward-line 1) (1- (point))))
-        ;; If we find neither Next: nor Prev: link, show the entire
-        ;; node header.  Otherwise, don't show the File: and Node:
-        ;; parts, to avoid wasting precious space on information that
-        ;; is available in the mode line.
-        (header-beg (if (re-search-forward
-                         "\\(next\\|prev[ious]*\\): "
-                         header-end t)
-                        (match-beginning 1)
-                      (point))))
-    (set (make-local-variable 'Info-header-line)
-        (buffer-substring header-beg header-end))
-    (setq header-line-format 'Info-header-line)
-;;; It is useful to be able to copy the links line out of the buffer
-;;; with M-w.
-;;;    (narrow-to-region (1+ header-end) (point-max))
-    ))
-\f
 ;; Go to an info node specified with a filename-and-nodename string
 ;; of the sort that is found in pointers in nodes.
 
@@ -1203,18 +1192,22 @@ If FORK is a string, it is the name to use for the new buffer."
                                      (progn (search-forward "\n\^_")
                                             (1- (point))))
                    (goto-char (point-min))
+                   ;; Find the subfile we just searched.
                    (search-forward (concat "\n" osubfile ": "))
-                   (beginning-of-line)
+                   ;; Skip that one.
+                   (forward-line 1)
+                   ;; Make a list of all following subfiles.
+                   ;; Each elt has the form (VIRT-POSITION . SUBFILENAME).
                    (while (not (eobp))
                      (re-search-forward "\\(^.*\\): [0-9]+$")
                      (goto-char (+ (match-end 1) 2))
-                     (setq list (cons (cons (read (current-buffer))
+                     (setq list (cons (cons (+ (point-min)
+                                               (read (current-buffer)))
                                             (match-string-no-properties 1))
                                       list))
                      (goto-char (1+ (match-end 0))))
-                   (setq list (nreverse list)
-                         current (car (car list))
-                         list (cdr list))))
+                   ;; Put in forward order
+                   (setq list (nreverse list))))
                (while list
                  (message "Searching subfile %s..." (cdr (car list)))
                  (Info-read-subfile (car (car list)))
@@ -1870,11 +1863,15 @@ Give a blank topic name to go to the Index node itself."
    (list
     (let ((Info-complete-menu-buffer (clone-buffer))
          (Info-complete-next-re "\\<Index\\>"))
+      (if (equal Info-current-file "dir")
+         (error "The Info directory node has no index; use m to select a manual"))
       (unwind-protect
          (with-current-buffer Info-complete-menu-buffer
            (Info-goto-index)
            (completing-read "Index topic: " 'Info-complete-menu-item))
        (kill-buffer Info-complete-menu-buffer)))))
+  (if (equal Info-current-file "dir")
+      (error "The Info directory node has no index; use m to select a manual"))
   (let ((orignode Info-current-node)
        (rnode nil)
        (pattern (format "\n\\* +\\([^\n:]*%s[^\n:]*\\):[ \t]*\\([^.\n]*\\)\\.[ \t]*\\([0-9]*\\)"
@@ -1946,6 +1943,10 @@ Give a blank topic name to go to the Index node itself."
     (if (or (re-search-forward (format
                                "[a-zA-Z]+: %s\\( \\|$\\)"
                                (regexp-quote name)) nil t)
+           ;; Find a function definition with a return type.
+           (re-search-forward (format
+                                "[a-zA-Z]+: [a-zA-Z0-9_ *&]+ %s\\( \\|$\\)"
+                                (regexp-quote name)) nil t)
            (search-forward (format "`%s'" name) nil t)
            (and (string-match "\\`.*\\( (.*)\\)\\'" name)
                 (search-forward
@@ -2336,8 +2337,6 @@ Advanced commands:
   (setq local-abbrev-table text-mode-abbrev-table)
   (setq case-fold-search t)
   (setq buffer-read-only t)
-  (set (make-local-variable 'font-lock-defaults)
-       '(nil t nil nil nil (font-lock-core-only . t)))
   (make-local-variable 'Info-current-file)
   (make-local-variable 'Info-current-subfile)
   (make-local-variable 'Info-current-node)
@@ -2347,11 +2346,13 @@ Advanced commands:
   (setq Info-tag-table-buffer nil)
   (make-local-variable 'Info-history)
   (make-local-variable 'Info-index-alternatives)
+  (make-local-variable 'Info-header-line)
   (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)
   (add-hook 'clone-buffer-hook 'Info-clone-buffer-hook nil t)
+  (add-hook 'change-major-mode-hook 'font-lock-defontify nil t)
   (Info-set-mode-line)
   (run-hooks 'Info-mode-hook))
 
@@ -2597,19 +2598,40 @@ the variable `Info-file-list-for-emacs'."
        (put-text-property (match-beginning 1) (match-end 1)
                           'font-lock-face 'info-menu-header)))))
 
+(defvar Info-next-link-keymap
+  (let ((keymap (make-sparse-keymap)))
+    (define-key keymap [header-line mouse-1] 'Info-next)
+    (define-key keymap [header-line mouse-2] 'Info-next)
+    (define-key keymap [header-line down-mouse-1] 'ignore)
+    (define-key keymap [mouse-2] 'Info-next)
+    keymap)
+  "Keymap to put on the Next link in the text or the header line.")
+
+(defvar Info-prev-link-keymap
+  (let ((keymap (make-sparse-keymap)))
+    (define-key keymap [header-line mouse-1] 'Info-prev)
+    (define-key keymap [header-line mouse-2] 'Info-prev)
+    (define-key keymap [header-line down-mouse-1] 'ignore)
+    (define-key keymap [mouse-2] 'Info-prev)
+    keymap)
+  "Keymap to put on the Prev link in the text or the header line.")
+
+
+(defvar Info-up-link-keymap
+  (let ((keymap (make-sparse-keymap)))
+    (define-key keymap [header-line mouse-1] 'Info-up)
+    (define-key keymap [header-line mouse-2] 'Info-up)
+    (define-key keymap [header-line down-mouse-1] 'ignore)
+    (define-key keymap [mouse-2] 'Info-up)
+    keymap)
+  "Keymap to put on the Up link in the text or the header line.")
+
 (defun Info-fontify-node ()
   ;; Only fontify the node if it hasn't already been done.  [We pass in
   ;; LIMIT arg to `next-property-change' because it seems to search past
   ;; (point-max).]
-  (unless (and (< (next-property-change (point-min) nil (point-max))
-                 (point-max))
-              ;; But do put the text properties if the local-map property
-              ;; is inconsistent with Info-use-header-line's value.
-              (eq
-               (= (next-single-property-change
-                   (point-min) 'local-map nil (point-max))
-                  (point-max))
-               (null Info-use-header-line)))
+  (unless (< (next-property-change (point-min) nil (point-max))
+            (point-max))
     (save-excursion
       (let ((buffer-read-only nil)
            (case-fold-search t))
@@ -2630,24 +2652,45 @@ the variable `Info-file-list-for-emacs'."
                                   'help-echo
                                   (concat "Go to node "
                                           (buffer-substring nbeg nend)))
-               ;; Don't bind mouse events on the header line if we
-               ;; aren't going to display the header line.
-               (when Info-use-header-line
-                 (let ((fun (cdr (assoc tag '(("Prev" . Info-prev)
-                                              ("Next" . Info-next)
-                                              ("Up" . Info-up))))))
-                   (when fun
-                     (let ((keymap (make-sparse-keymap)))
-                       (define-key keymap [header-line mouse-1] fun)
-                       (define-key keymap [header-line mouse-2] fun)
-                       (put-text-property tbeg nend 'local-map keymap)))))
-               (if (not Info-use-header-line)
-                   ;; In case they switched Info-use-header-line off
-                   ;; in the middle of an Info session, some text
-                   ;; properties may have been left lying around from
-                   ;; past visits of this node.  Remove them.
-                   (remove-text-properties tbeg nend '(local-map nil)))
-                 ))))
+               ;; Always set up the text property keymap.
+               ;; It will either be used in the buffer
+               ;; or copied in the header line.
+               (cond ((equal tag "Prev")
+                      (put-text-property tbeg nend 'keymap
+                                         Info-prev-link-keymap))
+                     ((equal tag "Next")
+                      (put-text-property tbeg nend 'keymap
+                                         Info-next-link-keymap))
+                     ((equal tag "Up")
+                      (put-text-property tbeg nend 'keymap
+                                         Info-up-link-keymap))))))
+         (goto-char (point-min))
+         (let ((header-end (save-excursion (end-of-line) (point)))
+               header)
+           ;; If we find neither Next: nor Prev: link, show the entire
+           ;; node header.  Otherwise, don't show the File: and Node:
+           ;; parts, to avoid wasting precious space on information that
+           ;; is available in the mode line.
+           (if (re-search-forward
+                "\\(next\\|up\\|prev[ious]*\\): "
+                header-end t)
+               (progn
+                 (goto-char (match-beginning 1))
+                 (setq header (buffer-substring (point) header-end)))
+             (if (re-search-forward "node:[ \t]*[^ \t]+[ \t]*" nil t)
+                 (setq header
+                       (concat "No next, prev or up links  --  "
+                               (buffer-substring (point) header-end)))
+               (setq header (buffer-substring (point) header-end))))
+
+           (put-text-property (point-min) (1+ (point-min))
+                              'header-line header)
+           ;; Hide the part of the first line
+           ;; that is in the header, if it is just part.
+           (unless (bobp)
+             ;; Hide the punctuation at the end, too.
+             (skip-chars-backward " \t,")
+             (put-text-property (point) header-end 'invisible t))))
        (goto-char (point-min))
        (while (re-search-forward "\n\\([^ \t\n].+\\)\n\\(\\*+\\|=+\\|-+\\|\\.+\\)$"
                                  nil t)