]> code.delx.au - gnu-emacs/blobdiff - lisp/info.el
*** empty log message ***
[gnu-emacs] / lisp / info.el
index 19bb7d0cf31cf6a232a3df47db868eb9ad957d54..560c6bfc7c12894878cd266639eeb7ff755334e7 100644 (file)
@@ -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.
@@ -1187,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)))
@@ -1854,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]*\\)"
@@ -1930,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
@@ -2335,6 +2352,7 @@ Advanced commands:
   (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))
 
@@ -2580,6 +2598,34 @@ 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
@@ -2607,33 +2653,44 @@ the variable `Info-file-list-for-emacs'."
                                   (concat "Go to node "
                                           (buffer-substring nbeg nend)))
                ;; Always set up the text property keymap.
-               ;; It will be used either in the buffer
+               ;; It will either be used in the buffer
                ;; or copied in the 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)
-                     (define-key keymap [header-line down-mouse-1] 'ignore)
-                     (define-key keymap [mouse-2] fun)
-                     (put-text-property tbeg nend 'keymap keymap))))
-                 )))
+               (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)))
-                ;; 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))))
+         (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
-                              (buffer-substring header-beg header-end))))
+                              '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)