Function: Info-tagify
Info-tagify is an autoloaded, interactive and byte-compiled function
defined in informat.el.gz.
Signature
(Info-tagify &optional INPUT-BUFFER-NAME)
Documentation
Create or update Info file tag table in current buffer or in a region.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/informat.el.gz
;;;###autoload
(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.
(let ((omin (point-min))
(omax (point-max))
(nomax (= (point-max) (1+ (buffer-size))))
(opoint (point))
(msg (format "Tagifying %s..."
(cond (input-buffer-name
(format "region in %s" input-buffer-name))
(buffer-file-name
(file-name-nondirectory (buffer-file-name)))
(t "buffer")))))
(message "%s" msg)
(unwind-protect
(progn
(widen)
(goto-char (point-min))
(if (search-forward "\^_\nIndirect:\n" nil t)
(message
"Cannot tagify split info file. Run this before splitting.")
(let (tag-list
refillp
(case-fold-search t)
(regexp
(concat
"\\("
"\\("
"@anchor" ; match-string 2 matches @anchor
"\\)"
"\\(-no\\|-yes\\)" ; match-string 3 matches -no or -yes
"\\("
"-refill"
"\\)"
"\\("
"{"
"\\)"
"\\("
"[^}]+" ; match-string 6 matches arg to anchor
"\\)"
"\\("
"}"
"\\)"
"\\|"
"\\("
"\n\^_\\(\^L\\)?"
"\\)"
"\\("
"\n\\(File:[ \t]*\\([^,\n\t]*\\)[,\t\n]+[ \t\n]*\\)?"
"Node:[ \t]*"
"\\("
"[^,\n\t]*" ; match-string 13 matches arg to node name
"\\)"
"[,\t\n]"
"\\)"
"\\)"
)))
(while (re-search-forward regexp nil t)
(if (string-equal "@anchor" (match-string 2))
(progn
;; kludge lest lose match-data
(if (string-equal "-yes" (match-string 3))
(setq refillp t))
(setq tag-list
(cons (list
(concat "Ref: " (match-string 6))
(match-beginning 0))
tag-list))
(if (eq refillp t)
;; set start and end so texinfo-format-refill works
(let ((texinfo-command-start (match-beginning 0))
(texinfo-command-end (match-end 0)))
(texinfo-format-refill))
(delete-region (match-beginning 0) (match-end 0))))
;; else this is a Node
(setq tag-list
(cons (list
(concat "Node: " (match-string-no-properties 13))
(1+ (match-beginning 10)))
tag-list))))
(goto-char (point-max))
(forward-line -8)
(let ((buffer-read-only nil))
(if (search-forward "\^_\nEnd tag table\n" nil t)
(let ((end (point)))
(search-backward "\nTag table:\n")
(beginning-of-line)
(delete-region (point) end)))
(goto-char (point-max))
(or (bolp)
(newline))
(insert "\^_\f\nTag table:\n")
(if (derived-mode-p '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 (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 "%sdone" msg)))