Mercurial > emacs
comparison lisp/textmodes/texinfmt.el @ 48697:880db53196d5
(texinfo-format-scan) Handle new functions for copyright
notice and copying permissions.
(texinfo-copying, texinfo-insertcopying): New functions.
Installed for TAKAHASHI Kaoru <kaoru@kaisei.org>
(texinfo-format-xml): New function.
(ifxml, ifnotxml): New aliases.
author | Robert J. Chassell <bob@rattlesnake.com> |
---|---|
date | Fri, 06 Dec 2002 19:43:49 +0000 |
parents | 8a7dcd7fcbf7 |
children | a4aa559a2dec |
comparison
equal
deleted
inserted
replaced
48696:85612d482136 | 48697:880db53196d5 |
---|---|
35 | 35 |
36 (or (fboundp 'defcustom) | 36 (or (fboundp 'defcustom) |
37 (defmacro defcustom (var value doc &rest ignore) | 37 (defmacro defcustom (var value doc &rest ignore) |
38 `(defvar ,var ,value ,doc))) | 38 `(defvar ,var ,value ,doc))) |
39 | 39 |
40 (defvar texinfmt-version "2.39 of 24 Nov 2002") | 40 (defvar texinfmt-version "2.40 of 6 Dec 2002") |
41 | 41 |
42 (defun texinfmt-version (&optional here) | 42 (defun texinfmt-version (&optional here) |
43 "Show the version of texinfmt.el in the minibuffer. | 43 "Show the version of texinfmt.el in the minibuffer. |
44 If optional argument HERE is non-nil, insert info at point." | 44 If optional argument HERE is non-nil, insert info at point." |
45 (interactive "P") | 45 (interactive "P") |
823 ;;; Perform those texinfo-to-info conversions that apply to the whole input | 823 ;;; Perform those texinfo-to-info conversions that apply to the whole input |
824 ;;; uniformly. | 824 ;;; uniformly. |
825 | 825 |
826 (defun texinfo-format-scan () | 826 (defun texinfo-format-scan () |
827 (texinfo-format-convert (point-min) (point-max)) | 827 (texinfo-format-convert (point-min) (point-max)) |
828 ;; Scan for @-commands. | 828 ;; Search for @copying, which has to be first since the |
829 ;; @insertcopying command then inserts the text elsewhere. | |
830 (goto-char (point-min)) | |
831 (when (search-forward "@copying" nil t) | |
832 (texinfo-copying)) | |
833 (while (search-forward "@insertcopying" nil t) | |
834 (delete-region (match-beginning 0) (match-end 0)) | |
835 | |
836 (texinfo-insertcopying)) | |
837 ;; Scan for other @-commands. | |
829 (goto-char (point-min)) | 838 (goto-char (point-min)) |
830 (while (search-forward "@" nil t) | 839 (while (search-forward "@" nil t) |
831 ;; | 840 ;; |
832 ;; These are the single-character accent commands: @^ @` @' @" @= @~ | 841 ;; These are the single-character accent commands: @^ @` @' @" @= @~ |
833 ;; In Info, they are simply quoted and the @ deleted. | 842 ;; In Info, they are simply quoted and the @ deleted. |
929 (let ((cmd (get texinfo-command-name 'texinfo-format))) | 938 (let ((cmd (get texinfo-command-name 'texinfo-format))) |
930 (if cmd (funcall cmd) (texinfo-unsupported))))))) | 939 (if cmd (funcall cmd) (texinfo-unsupported))))))) |
931 | 940 |
932 (cond (texinfo-stack | 941 (cond (texinfo-stack |
933 (goto-char (nth 2 (car texinfo-stack))) | 942 (goto-char (nth 2 (car texinfo-stack))) |
934 (error "Unterminated @%s" (car (car texinfo-stack)))))) | 943 (error "Unterminated @%s" (car (car texinfo-stack))))) |
944 | |
945 ;; Remove excess whitespace | |
946 (whitespace-cleanup)) | |
947 | |
948 (defvar texinfo-copying-text "" | |
949 "Text of the copyright notice and copying permissions.") | |
950 | |
951 (defun texinfo-copying () | |
952 "Copy the copyright notice and copying permissions from the Texinfo file, | |
953 as indicated by the @copying ... @end copying command; | |
954 insert the text with the @insertcopying command." | |
955 (let ((beg (progn (beginning-of-line) (point))) | |
956 (end (progn (re-search-forward "^@end copying[ \t]*\n") (point)))) | |
957 (setq texinfo-copying-text | |
958 (buffer-substring-no-properties | |
959 (save-excursion (goto-char beg) (forward-line 1) (point)) | |
960 (save-excursion (goto-char end) (forward-line -1) (point)))) | |
961 (delete-region beg end))) | |
962 | |
963 (defun texinfo-insertcopying () | |
964 "Insert the copyright notice and copying permissions from the Texinfo file, | |
965 which are indicated by the @copying ... @end copying command." | |
966 (insert (concat "\n" texinfo-copying-text))) | |
935 | 967 |
936 (put 'begin 'texinfo-format 'texinfo-format-begin) | 968 (put 'begin 'texinfo-format 'texinfo-format-begin) |
937 (defun texinfo-format-begin () | 969 (defun texinfo-format-begin () |
938 (texinfo-format-begin-end 'texinfo-format)) | 970 (texinfo-format-begin-end 'texinfo-format)) |
939 | 971 |
2133 (setq column-number (1+ column-number)))) | 2165 (setq column-number (1+ column-number)))) |
2134 (kill-buffer texinfo-multitable-buffer-name) | 2166 (kill-buffer texinfo-multitable-buffer-name) |
2135 (setq fill-column existing-fill-column))) | 2167 (setq fill-column existing-fill-column))) |
2136 | 2168 |
2137 | 2169 |
2138 ;;; @ifinfo, @iftex, @tex, @ifhtml, @html, @ifplaintext | 2170 ;;; @ifinfo, @iftex, @tex, @ifhtml, @html, @ifplaintext, @ifxml, @xml |
2139 ;; @ifnottex, @ifnotinfo, @ifnothtml, @ifnotplaintext | 2171 ;; @ifnottex, @ifnotinfo, @ifnothtml, @ifnotplaintext, @ifnotxml |
2140 | 2172 |
2141 (put 'ifinfo 'texinfo-format 'texinfo-discard-line) | 2173 (put 'ifinfo 'texinfo-format 'texinfo-discard-line) |
2142 (put 'ifinfo 'texinfo-end 'texinfo-discard-command) | 2174 (put 'ifinfo 'texinfo-end 'texinfo-discard-command) |
2143 | 2175 |
2144 (put 'iftex 'texinfo-format 'texinfo-format-iftex) | 2176 (put 'iftex 'texinfo-format 'texinfo-format-iftex) |
2157 (defun texinfo-format-ifplaintext () | 2189 (defun texinfo-format-ifplaintext () |
2158 (delete-region texinfo-command-start | 2190 (delete-region texinfo-command-start |
2159 (progn (re-search-forward "@end ifplaintext[ \t]*\n") | 2191 (progn (re-search-forward "@end ifplaintext[ \t]*\n") |
2160 (point)))) | 2192 (point)))) |
2161 | 2193 |
2194 (put 'ifxml 'texinfo-format 'texinfo-format-ifxml) | |
2195 (defun texinfo-format-ifxml () | |
2196 (delete-region texinfo-command-start | |
2197 (progn (re-search-forward "^@end ifxml[ \t]*\n") | |
2198 (point)))) | |
2199 | |
2162 (put 'tex 'texinfo-format 'texinfo-format-tex) | 2200 (put 'tex 'texinfo-format 'texinfo-format-tex) |
2163 (defun texinfo-format-tex () | 2201 (defun texinfo-format-tex () |
2164 (delete-region texinfo-command-start | 2202 (delete-region texinfo-command-start |
2165 (progn (re-search-forward "@end tex[ \t]*\n") | 2203 (progn (re-search-forward "@end tex[ \t]*\n") |
2166 (point)))) | 2204 (point)))) |
2169 (defun texinfo-format-html () | 2207 (defun texinfo-format-html () |
2170 (delete-region texinfo-command-start | 2208 (delete-region texinfo-command-start |
2171 (progn (re-search-forward "@end html[ \t]*\n") | 2209 (progn (re-search-forward "@end html[ \t]*\n") |
2172 (point)))) | 2210 (point)))) |
2173 | 2211 |
2212 (put 'xml 'texinfo-format 'texinfo-format-xml) | |
2213 (defun texinfo-format-xml () | |
2214 (delete-region texinfo-command-start | |
2215 (progn (re-search-forward "^@end xml[ \t]*\n") | |
2216 (point)))) | |
2217 | |
2174 (put 'ifnotinfo 'texinfo-format 'texinfo-format-ifnotinfo) | 2218 (put 'ifnotinfo 'texinfo-format 'texinfo-format-ifnotinfo) |
2175 (defun texinfo-format-ifnotinfo () | 2219 (defun texinfo-format-ifnotinfo () |
2176 (delete-region texinfo-command-start | 2220 (delete-region texinfo-command-start |
2177 (progn (re-search-forward "@end ifnotinfo[ \t]*\n") | 2221 (progn (re-search-forward "@end ifnotinfo[ \t]*\n") |
2178 (point)))) | 2222 (point)))) |
2183 (put 'ifnottex 'texinfo-format 'texinfo-discard-line) | 2227 (put 'ifnottex 'texinfo-format 'texinfo-discard-line) |
2184 (put 'ifnottex 'texinfo-end 'texinfo-discard-command) | 2228 (put 'ifnottex 'texinfo-end 'texinfo-discard-command) |
2185 | 2229 |
2186 (put 'ifnothtml 'texinfo-format 'texinfo-discard-line) | 2230 (put 'ifnothtml 'texinfo-format 'texinfo-discard-line) |
2187 (put 'ifnothtml 'texinfo-end 'texinfo-discard-command) | 2231 (put 'ifnothtml 'texinfo-end 'texinfo-discard-command) |
2232 | |
2233 (put 'ifnotxml 'texinfo-format 'texinfo-discard-line) | |
2234 (put 'ifnotxml 'texinfo-end 'texinfo-discard-command) | |
2188 | 2235 |
2189 | 2236 |
2190 ;;; @titlepage | 2237 ;;; @titlepage |
2191 | 2238 |
2192 (put 'titlepage 'texinfo-format 'texinfo-format-titlepage) | 2239 (put 'titlepage 'texinfo-format 'texinfo-format-titlepage) |