diff options
| author | Richard M. Stallman | 1998-07-02 07:46:15 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-07-02 07:46:15 +0000 |
| commit | c69bfc1490da909ef6805b2802dcc60fc1b7f412 (patch) | |
| tree | 4c16cb7d9f0cbf84fd697b2554f3172e6a598ba8 | |
| parent | a22f0735054f72beead54113b8663da20c7a06e1 (diff) | |
| download | emacs-c69bfc1490da909ef6805b2802dcc60fc1b7f412.tar.gz emacs-c69bfc1490da909ef6805b2802dcc60fc1b7f412.zip | |
(Info-tagify): Handle tags for @anchor.
| -rw-r--r-- | lisp/informat.el | 104 |
1 files changed, 78 insertions, 26 deletions
diff --git a/lisp/informat.el b/lisp/informat.el index 36a9bf11134..e85af0875ec 100644 --- a/lisp/informat.el +++ b/lisp/informat.el | |||
| @@ -28,7 +28,7 @@ | |||
| 28 | 28 | ||
| 29 | ;;;###autoload | 29 | ;;;###autoload |
| 30 | (defun Info-tagify () | 30 | (defun Info-tagify () |
| 31 | "Create or update Info-file tag table in current buffer." | 31 | "Create or update Info file tag table in current buffer." |
| 32 | (interactive) | 32 | (interactive) |
| 33 | ;; Save and restore point and restrictions. | 33 | ;; Save and restore point and restrictions. |
| 34 | ;; save-restrictions would not work | 34 | ;; save-restrictions would not work |
| @@ -40,27 +40,79 @@ | |||
| 40 | (nomax (= (point-max) (1+ (buffer-size)))) | 40 | (nomax (= (point-max) (1+ (buffer-size)))) |
| 41 | (opoint (point))) | 41 | (opoint (point))) |
| 42 | (unwind-protect | 42 | (unwind-protect |
| 43 | (progn | 43 | (progn |
| 44 | (widen) | 44 | (widen) |
| 45 | (goto-char (point-min)) | 45 | (goto-char (point-min)) |
| 46 | (if (search-forward "\^_\nIndirect:\n" nil t) | 46 | (if (search-forward "\^_\nIndirect:\n" nil t) |
| 47 | (message "Cannot tagify split info file") | 47 | (message "Cannot tagify split info file") |
| 48 | (let ((regexp "Node:[ \t]*\\([^,\n\t]*\\)[,\t\n]") | 48 | |
| 49 | (case-fold-search t) | 49 | (let (tag-list |
| 50 | list) | 50 | refillp |
| 51 | (while (search-forward "\n\^_" nil t) | 51 | (case-fold-search t) |
| 52 | ;; We want the 0-origin character position of the ^_. | 52 | (regexp |
| 53 | ;; That is the same as the Emacs (1-origin) position | 53 | (concat |
| 54 | ;; of the newline before it. | 54 | "\\(" |
| 55 | (let ((beg (match-beginning 0))) | 55 | |
| 56 | (forward-line 2) | 56 | |
| 57 | (if (re-search-backward regexp beg t) | 57 | "\\(" |
| 58 | (setq list | 58 | "@anchor" ; match-string 2 matches @anchor |
| 59 | (cons (list (buffer-substring-no-properties | 59 | "\\)" |
| 60 | (match-beginning 1) | 60 | "\\(-no\\|-yes\\)" ; match-string 3 matches -no or -yes |
| 61 | (match-end 1)) | 61 | "\\(" |
| 62 | beg) | 62 | "-refill" |
| 63 | list))))) | 63 | "\\)" |
| 64 | |||
| 65 | "\\(" | ||
| 66 | "{" | ||
| 67 | "\\)" | ||
| 68 | "\\(" | ||
| 69 | "[^}]+" ; match-string 6 matches arg to anchor | ||
| 70 | "\\)" | ||
| 71 | "\\(" | ||
| 72 | "}" | ||
| 73 | "\\)" | ||
| 74 | |||
| 75 | "\\|" | ||
| 76 | |||
| 77 | "\\(" | ||
| 78 | "\n\^_" | ||
| 79 | "\\)" | ||
| 80 | |||
| 81 | "\\(" | ||
| 82 | "\nFile:[ \t]*\\([^,\n\t]*\\)[,\t\n]+[ \t\n]*" | ||
| 83 | "Node:[ \t]*" | ||
| 84 | "\\(" | ||
| 85 | "[^,\n\t]*" ; match-string 11 matches arg to node name | ||
| 86 | "\\)" | ||
| 87 | "[,\t\n]" | ||
| 88 | "\\)" | ||
| 89 | |||
| 90 | "\\)" | ||
| 91 | ))) | ||
| 92 | (while (re-search-forward regexp nil t) | ||
| 93 | (if (string-equal "@anchor" (match-string 2)) | ||
| 94 | (progn | ||
| 95 | ;; kludge lest lose match-data | ||
| 96 | (if (string-equal "-yes" (match-string 3)) | ||
| 97 | (setq refillp t)) | ||
| 98 | (setq tag-list | ||
| 99 | (cons (list | ||
| 100 | (concat "Ref: " (match-string 6)) | ||
| 101 | (match-beginning 0)) | ||
| 102 | tag-list)) | ||
| 103 | (if (eq refillp t) | ||
| 104 | ;; set start and end so texinfo-format-refill works | ||
| 105 | (let ((texinfo-command-start (match-beginning 0)) | ||
| 106 | (texinfo-command-end (match-end 0))) | ||
| 107 | (texinfo-format-refill)) | ||
| 108 | (delete-region (match-beginning 0) (match-end 0)))) | ||
| 109 | ;; else this is a Node | ||
| 110 | (setq tag-list | ||
| 111 | (cons (list | ||
| 112 | (concat "Node: " (match-string 11)) | ||
| 113 | (match-beginning 0)) | ||
| 114 | tag-list)))) | ||
| 115 | |||
| 64 | (goto-char (point-max)) | 116 | (goto-char (point-max)) |
| 65 | (forward-line -8) | 117 | (forward-line -8) |
| 66 | (let ((buffer-read-only nil)) | 118 | (let ((buffer-read-only nil)) |
| @@ -73,13 +125,13 @@ | |||
| 73 | (insert "\^_\f\nTag table:\n") | 125 | (insert "\^_\f\nTag table:\n") |
| 74 | (if (eq major-mode 'info-mode) | 126 | (if (eq major-mode 'info-mode) |
| 75 | (move-marker Info-tag-table-marker (point))) | 127 | (move-marker Info-tag-table-marker (point))) |
| 76 | (setq list (nreverse list)) | 128 | (setq tag-list (nreverse tag-list)) |
| 77 | (while list | 129 | (while tag-list |
| 78 | (insert "Node: " (car (car list)) ?\177) | 130 | (insert (car (car tag-list)) ?\177) |
| 79 | (princ (position-bytes (car (cdr (car list)))) | 131 | (princ (position-bytes (car (cdr (car list)))) |
| 80 | (current-buffer)) | 132 | (current-buffer)) |
| 81 | (insert ?\n) | 133 | (insert ?\n) |
| 82 | (setq list (cdr list))) | 134 | (setq tag-list (cdr tag-list))) |
| 83 | (insert "\^_\nEnd tag table\n"))))) | 135 | (insert "\^_\nEnd tag table\n"))))) |
| 84 | (goto-char opoint) | 136 | (goto-char opoint) |
| 85 | (narrow-to-region omin (if nomax (1+ (buffer-size)) | 137 | (narrow-to-region omin (if nomax (1+ (buffer-size)) |