]> code.delx.au - gnu-emacs/blobdiff - lisp/informat.el
(normal-splash-screen, fancy-splash-screens-1): Add a reference to the Lisp
[gnu-emacs] / lisp / informat.el
index e85af0875ecfe3f13b87b85bf4580c57d4ee32bd..96dc018041841133a35133e422f74314ddd67905 100644 (file)
@@ -1,6 +1,7 @@
 ;;; informat.el --- info support functions package for Emacs
 
-;; Copyright (C) 1986 Free Software Foundation, Inc.
+;; Copyright (C) 1986, 2002, 2003, 2004, 2005,
+;;   2006 Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: help
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
+
+;;; Commentary:
+
+;; Nowadays, the Texinfo formatting commands always tagify a buffer
+;; (as does `makeinfo') since @anchor commands need tag tables.
 
 ;;; Code:
 
 (require 'info)
 
 ;;;###autoload
-(defun Info-tagify ()
-  "Create or update Info file tag table in current buffer."
+(defun Info-tagify (&optional input-buffer-name)
+  "Create or update Info file tag table in current buffer or in a region."
   (interactive)
   ;; Save and restore point and restrictions.
   ;; save-restrictions would not work
   ;; because it records the old max relative to the end.
   ;; We record it relative to the beginning.
-  (message "Tagifying %s ..." (file-name-nondirectory (buffer-file-name)))
+  (if input-buffer-name
+      (message "Tagifying region in %s ..." input-buffer-name)
+      (message
+       "Tagifying %s ..."  (file-name-nondirectory (buffer-file-name))))
   (let ((omin (point-min))
        (omax (point-max))
        (nomax (= (point-max) (1+ (buffer-size))))
       (widen)
       (goto-char (point-min))
       (if (search-forward "\^_\nIndirect:\n" nil t)
-          (message "Cannot tagify split info file")
-
+          (message
+           "Cannot tagify split info file.  Run this before splitting.")
         (let (tag-list
               refillp
               (case-fold-search t)
-              (regexp 
+              (regexp
                (concat
                 "\\("
 
                 "\\|"
 
                 "\\("
-                "\n\^_"
+                "\n\^_\\(\^L\\)?"
                 "\\)"
 
                 "\\("
-                "\nFile:[ \t]*\\([^,\n\t]*\\)[,\t\n]+[ \t\n]*"
+                "\n\\(File:[ \t]*\\([^,\n\t]*\\)[,\t\n]+[ \t\n]*\\)?"
                 "Node:[ \t]*"
                 "\\("
-                "[^,\n\t]*"      ; match-string 11 matches arg to node name
+                "[^,\n\t]*"      ; match-string 13 matches arg to node name
                 "\\)"
                 "[,\t\n]"
                 "\\)"
                   (delete-region  (match-beginning 0) (match-end 0))))
               ;; else this is a Node
               (setq tag-list
-                    (cons (list 
-                           (concat "Node: " (match-string 11))
-                           (match-beginning 0))
+                    (cons (list
+                           (concat "Node: " (match-string-no-properties 13))
+                           (1+ (match-beginning 10)))
                           tag-list))))
 
              (goto-char (point-max))
                      (beginning-of-line)
                      (delete-region (point) end)))
                (goto-char (point-max))
+               (or (bolp)
+                   (newline))
                (insert "\^_\f\nTag table:\n")
                (if (eq major-mode 'info-mode)
                    (move-marker Info-tag-table-marker (point)))
                (setq tag-list (nreverse tag-list))
                (while tag-list
                  (insert (car (car tag-list)) ?\177)
-                 (princ (position-bytes (car (cdr (car list))))
-                        (current-buffer))
+                 (princ (car (cdr (car tag-list))) (current-buffer))
                  (insert ?\n)
                  (setq tag-list (cdr tag-list)))
                (insert "\^_\nEnd tag table\n")))))
       (goto-char opoint)
       (narrow-to-region omin (if nomax (1+ (buffer-size))
                               (min omax (point-max))))))
-  (message "Tagifying %s ... done" (file-name-nondirectory (buffer-file-name))))
+  (if input-buffer-name
+      (message "Tagifying region in %s done" input-buffer-name)
+      (message
+       "Tagifying %s done"  (file-name-nondirectory (buffer-file-name)))))
+
 \f
 ;;;###autoload
 (defun Info-split ()
@@ -159,8 +173,7 @@ contains just the tag table and a directory of subfiles."
   (search-forward "\^_")
   (forward-char -1)
   (let ((start (point))
-       (start-byte (position-bytes (point)))
-       (bytes-deleted 0)
+       (chars-deleted 0)
        subfiles
        (subfile-number 1)
        (case-fold-search t)
@@ -182,7 +195,7 @@ contains just the tag table and a directory of subfiles."
        (goto-char (min (+ (point) 50000) (point-max)))
        (search-forward "\^_" nil 'move)
        (setq subfiles
-             (cons (list (+ start-byte bytes-deleted)
+             (cons (list (+ start chars-deleted)
                          (concat (file-name-nondirectory filename)
                                  (format "-%d" subfile-number)))
                    subfiles))
@@ -193,8 +206,7 @@ contains just the tag table and a directory of subfiles."
        (delete-region (1- (point)) (point))
        ;; Back up over the final ^_.
        (forward-char -1)
-       (setq bytes-deleted (+ bytes-deleted (- (position-bytes (point))
-                                               start-byte)))
+       (setq chars-deleted (+ chars-deleted (- (point) start)))
        (delete-region start (point))
        (setq subfile-number (1+ subfile-number))))
     (while subfiles
@@ -266,8 +278,10 @@ Check that every node pointer points to an existing node."
            (forward-line 1)
            (if (re-search-backward regexp beg t)
                (save-restriction
-                 (search-forward "\n\^_" nil 'move)
-                 (narrow-to-region beg (point))
+                 (let ((md (match-data)))
+                   (search-forward "\n\^_" nil 'move)
+                   (narrow-to-region beg (point))
+                   (set-match-data md))
                  (setq Info-validate-thisnode (downcase
                                                (buffer-substring-no-properties
                                                 (match-beginning 1)
@@ -426,7 +440,7 @@ Must be used only with -batch, and kills Emacs on completion.
 Each file will be processed even if an error occurred previously.
 For example, invoke \"emacs -batch -f batch-info-validate $info/ ~/*.info\""
   (if (not noninteractive)
-      (error "batch-info-validate may only be used -batch."))
+      (error "batch-info-validate may only be used -batch"))
   (let ((version-control t)
        (auto-save-default nil)
        (find-file-run-dired nil)
@@ -440,7 +454,7 @@ For example, invoke \"emacs -batch -f batch-info-validate $info/ ~/*.info\""
        (cond ((not (file-exists-p file))
               (message ">> %s does not exist!" file)
               (setq error 1
-                    command-line-args-left (cdr command-line-args-left))) 
+                    command-line-args-left (cdr command-line-args-left)))
              ((file-directory-p file)
               (setq command-line-args-left (nconc (directory-files file)
                                              (cdr command-line-args-left))))
@@ -490,4 +504,5 @@ For example, invoke \"emacs -batch -f batch-info-validate $info/ ~/*.info\""
 
 (provide 'informat)
 
+;;; arch-tag: 581c440e-5be1-4f31-b005-2d5824bbf569
 ;;; informat.el ends here