diff options
| author | Stefan Monnier | 2003-02-11 00:37:28 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2003-02-11 00:37:28 +0000 |
| commit | 6147e7255377bda1ed8fac5ccb0f6cf929eee3b6 (patch) | |
| tree | c09449607ea420a3f5eb5fa307aaa117a4a87760 | |
| parent | dac15a1e71e1b4ea13415e5f9ec9da514e2f7d7e (diff) | |
| download | emacs-6147e7255377bda1ed8fac5ccb0f6cf929eee3b6.tar.gz emacs-6147e7255377bda1ed8fac5ccb0f6cf929eee3b6.zip | |
(texinfo-format-iftex, texinfo-format-ifhtml)
(texinfo-format-ifplaintext, texinfo-format-tex, texinfo-format-html)
(texinfo-format-ifnotinfo, texinfo-format-titlepage)
(texinfo-format-titlespec, texinfo-format-ignore, texinfo-if-set)
(texinfo-if-clear): Use re-search-forward's return value.
(texinfo-sort-startkeyfun, texinfo-format-buffer-1)
(texinfo-format-region): Use line-{end,beginning}-position.
(texinfo-append-refill, texinfo-alias): Use match-string-no-properties.
| -rw-r--r-- | lisp/textmodes/texinfmt.el | 88 |
1 files changed, 32 insertions, 56 deletions
diff --git a/lisp/textmodes/texinfmt.el b/lisp/textmodes/texinfmt.el index 35d40a1efda..d9ec000f7d0 100644 --- a/lisp/textmodes/texinfmt.el +++ b/lisp/textmodes/texinfmt.el | |||
| @@ -244,12 +244,9 @@ converted to Info is stored in a temporary buffer." | |||
| 244 | (goto-char (point-min)) | 244 | (goto-char (point-min)) |
| 245 | ;; Remove `@setfilename' line from included file, if any, | 245 | ;; Remove `@setfilename' line from included file, if any, |
| 246 | ;; so @setfilename command not duplicated. | 246 | ;; so @setfilename command not duplicated. |
| 247 | (if (re-search-forward | 247 | (if (re-search-forward "^@setfilename" (line-end-position 100) t) |
| 248 | "^@setfilename" (save-excursion (forward-line 100) (point)) t) | 248 | (delete-region (line-beginning-position 1) |
| 249 | (progn | 249 | (line-beginning-position 2))))))) |
| 250 | (beginning-of-line) | ||
| 251 | (delete-region | ||
| 252 | (point) (save-excursion (forward-line 1) (point))))))))) | ||
| 253 | 250 | ||
| 254 | ;; Raise or lower level of each section, if necessary. | 251 | ;; Raise or lower level of each section, if necessary. |
| 255 | (goto-char (point-min)) | 252 | (goto-char (point-min)) |
| @@ -271,7 +268,7 @@ converted to Info is stored in a temporary buffer." | |||
| 271 | 268 | ||
| 272 | (goto-char (point-min)) | 269 | (goto-char (point-min)) |
| 273 | (if (looking-at "\\\\input[ \t]+texinfo") | 270 | (if (looking-at "\\\\input[ \t]+texinfo") |
| 274 | (delete-region (point) (save-excursion (forward-line 1) (point)))) | 271 | (delete-region (point) (line-beginning-position 2))) |
| 275 | 272 | ||
| 276 | ;; Insert Info region title text. | 273 | ;; Insert Info region title text. |
| 277 | (goto-char (point-min)) | 274 | (goto-char (point-min)) |
| @@ -395,7 +392,7 @@ if large. You can use Info-split to do this manually." | |||
| 395 | (let ((filename (concat input-directory | 392 | (let ((filename (concat input-directory |
| 396 | (texinfo-parse-line-arg)))) | 393 | (texinfo-parse-line-arg)))) |
| 397 | (re-search-backward "^@include") | 394 | (re-search-backward "^@include") |
| 398 | (delete-region (point) (save-excursion (forward-line 1) (point))) | 395 | (delete-region (point) (line-beginning-position 2)) |
| 399 | (message "Reading included file: %s" filename) | 396 | (message "Reading included file: %s" filename) |
| 400 | (save-excursion | 397 | (save-excursion |
| 401 | (save-restriction | 398 | (save-restriction |
| @@ -405,13 +402,9 @@ if large. You can use Info-split to do this manually." | |||
| 405 | (goto-char (point-min)) | 402 | (goto-char (point-min)) |
| 406 | ;; Remove `@setfilename' line from included file, if any, | 403 | ;; Remove `@setfilename' line from included file, if any, |
| 407 | ;; so @setfilename command not duplicated. | 404 | ;; so @setfilename command not duplicated. |
| 408 | (if (re-search-forward | 405 | (if (re-search-forward "^@setfilename" (line-end-position 100) t) |
| 409 | "^@setfilename" | 406 | (delete-region (line-beginning-position 1) |
| 410 | (save-excursion (forward-line 100) (point)) t) | 407 | (line-beginning-position 2))))))) |
| 411 | (progn | ||
| 412 | (beginning-of-line) | ||
| 413 | (delete-region | ||
| 414 | (point) (save-excursion (forward-line 1) (point))))))))) | ||
| 415 | ;; Raise or lower level of each section, if necessary. | 408 | ;; Raise or lower level of each section, if necessary. |
| 416 | (goto-char (point-min)) | 409 | (goto-char (point-min)) |
| 417 | (texinfo-raise-lower-sections) | 410 | (texinfo-raise-lower-sections) |
| @@ -469,8 +462,7 @@ if large. You can use Info-split to do this manually." | |||
| 469 | ;; Convert three hyphens in a row to two. | 462 | ;; Convert three hyphens in a row to two. |
| 470 | (goto-char min) | 463 | (goto-char min) |
| 471 | (while (re-search-forward "\\( \\|\\w\\)\\(---\\)\\( \\|\\w\\)" max t) | 464 | (while (re-search-forward "\\( \\|\\w\\)\\(---\\)\\( \\|\\w\\)" max t) |
| 472 | (delete-region (1+ (match-beginning 2)) (+ 2 (match-beginning | 465 | (delete-region (1+ (match-beginning 2)) (+ 2 (match-beginning 2))))) |
| 473 | 2))))) | ||
| 474 | 466 | ||
| 475 | 467 | ||
| 476 | ;;; Handle paragraph filling | 468 | ;;; Handle paragraph filling |
| @@ -612,21 +604,17 @@ Do not append @refill to paragraphs containing @w{TEXT} or @*." | |||
| 612 | (forward-line 1)) | 604 | (forward-line 1)) |
| 613 | ;; 2. Skip over @example and similar no-refill environments. | 605 | ;; 2. Skip over @example and similar no-refill environments. |
| 614 | (if (looking-at texinfo-no-refill-regexp) | 606 | (if (looking-at texinfo-no-refill-regexp) |
| 615 | (let ((environment | 607 | (let ((environment (match-string-no-properties 1))) |
| 616 | (buffer-substring-no-properties (match-beginning 1) (match-end 1)))) | ||
| 617 | (progn (re-search-forward (concat "^@end " environment) nil t) | 608 | (progn (re-search-forward (concat "^@end " environment) nil t) |
| 618 | (forward-line 1))) | 609 | (forward-line 1))) |
| 619 | ;; Else | 610 | ;; Else |
| 620 | ;; 3. Do not refill a paragraph containing @w or @*, or ending | 611 | ;; 3. Do not refill a paragraph containing @w or @*, or ending |
| 621 | ;; with @<newline> followed by a newline. | 612 | ;; with @<newline> followed by a newline. |
| 622 | (if (or | 613 | (if (or (>= (point) (point-max)) |
| 623 | (>= (point) (point-max)) | 614 | (re-search-forward |
| 624 | (re-search-forward | 615 | "@w{\\|@\\*\\|@\n\n" |
| 625 | "@w{\\|@\\*\\|@\n\n" | 616 | (save-excursion (forward-paragraph) (forward-line 1) (point)) |
| 626 | (save-excursion | 617 | t)) |
| 627 | (forward-paragraph) | ||
| 628 | (forward-line 1) | ||
| 629 | (point)) t)) | ||
| 630 | ;; Go to end of paragraph and do nothing. | 618 | ;; Go to end of paragraph and do nothing. |
| 631 | (forward-paragraph) | 619 | (forward-paragraph) |
| 632 | ;; 4. Else go to end of paragraph and insert @refill | 620 | ;; 4. Else go to end of paragraph and insert @refill |
| @@ -2234,20 +2222,17 @@ Use only the FILENAME arg; for Info, ignore the other arguments to @image." | |||
| 2234 | (put 'iftex 'texinfo-format 'texinfo-format-iftex) | 2222 | (put 'iftex 'texinfo-format 'texinfo-format-iftex) |
| 2235 | (defun texinfo-format-iftex () | 2223 | (defun texinfo-format-iftex () |
| 2236 | (delete-region texinfo-command-start | 2224 | (delete-region texinfo-command-start |
| 2237 | (progn (re-search-forward "@end iftex[ \t]*\n") | 2225 | (re-search-forward "@end iftex[ \t]*\n"))) |
| 2238 | (point)))) | ||
| 2239 | 2226 | ||
| 2240 | (put 'ifhtml 'texinfo-format 'texinfo-format-ifhtml) | 2227 | (put 'ifhtml 'texinfo-format 'texinfo-format-ifhtml) |
| 2241 | (defun texinfo-format-ifhtml () | 2228 | (defun texinfo-format-ifhtml () |
| 2242 | (delete-region texinfo-command-start | 2229 | (delete-region texinfo-command-start |
| 2243 | (progn (re-search-forward "@end ifhtml[ \t]*\n") | 2230 | (re-search-forward "@end ifhtml[ \t]*\n"))) |
| 2244 | (point)))) | ||
| 2245 | 2231 | ||
| 2246 | (put 'ifplaintext 'texinfo-format 'texinfo-format-ifplaintext) | 2232 | (put 'ifplaintext 'texinfo-format 'texinfo-format-ifplaintext) |
| 2247 | (defun texinfo-format-ifplaintext () | 2233 | (defun texinfo-format-ifplaintext () |
| 2248 | (delete-region texinfo-command-start | 2234 | (delete-region texinfo-command-start |
| 2249 | (progn (re-search-forward "@end ifplaintext[ \t]*\n") | 2235 | (re-search-forward "@end ifplaintext[ \t]*\n"))) |
| 2250 | (point)))) | ||
| 2251 | 2236 | ||
| 2252 | (put 'ifxml 'texinfo-format 'texinfo-format-ifxml) | 2237 | (put 'ifxml 'texinfo-format 'texinfo-format-ifxml) |
| 2253 | (defun texinfo-format-ifxml () | 2238 | (defun texinfo-format-ifxml () |
| @@ -2258,14 +2243,12 @@ Use only the FILENAME arg; for Info, ignore the other arguments to @image." | |||
| 2258 | (put 'tex 'texinfo-format 'texinfo-format-tex) | 2243 | (put 'tex 'texinfo-format 'texinfo-format-tex) |
| 2259 | (defun texinfo-format-tex () | 2244 | (defun texinfo-format-tex () |
| 2260 | (delete-region texinfo-command-start | 2245 | (delete-region texinfo-command-start |
| 2261 | (progn (re-search-forward "@end tex[ \t]*\n") | 2246 | (re-search-forward "@end tex[ \t]*\n"))) |
| 2262 | (point)))) | ||
| 2263 | 2247 | ||
| 2264 | (put 'html 'texinfo-format 'texinfo-format-html) | 2248 | (put 'html 'texinfo-format 'texinfo-format-html) |
| 2265 | (defun texinfo-format-html () | 2249 | (defun texinfo-format-html () |
| 2266 | (delete-region texinfo-command-start | 2250 | (delete-region texinfo-command-start |
| 2267 | (progn (re-search-forward "@end html[ \t]*\n") | 2251 | (re-search-forward "@end html[ \t]*\n"))) |
| 2268 | (point)))) | ||
| 2269 | 2252 | ||
| 2270 | (put 'xml 'texinfo-format 'texinfo-format-xml) | 2253 | (put 'xml 'texinfo-format 'texinfo-format-xml) |
| 2271 | (defun texinfo-format-xml () | 2254 | (defun texinfo-format-xml () |
| @@ -2276,8 +2259,7 @@ Use only the FILENAME arg; for Info, ignore the other arguments to @image." | |||
| 2276 | (put 'ifnotinfo 'texinfo-format 'texinfo-format-ifnotinfo) | 2259 | (put 'ifnotinfo 'texinfo-format 'texinfo-format-ifnotinfo) |
| 2277 | (defun texinfo-format-ifnotinfo () | 2260 | (defun texinfo-format-ifnotinfo () |
| 2278 | (delete-region texinfo-command-start | 2261 | (delete-region texinfo-command-start |
| 2279 | (progn (re-search-forward "@end ifnotinfo[ \t]*\n") | 2262 | (re-search-forward "@end ifnotinfo[ \t]*\n"))) |
| 2280 | (point)))) | ||
| 2281 | 2263 | ||
| 2282 | (put 'ifnotplaintext 'texinfo-format 'texinfo-discard-line) | 2264 | (put 'ifnotplaintext 'texinfo-format 'texinfo-discard-line) |
| 2283 | (put 'ifnotplaintext 'texinfo-end 'texinfo-discard-command) | 2265 | (put 'ifnotplaintext 'texinfo-end 'texinfo-discard-command) |
| @@ -2297,8 +2279,7 @@ Use only the FILENAME arg; for Info, ignore the other arguments to @image." | |||
| 2297 | (put 'titlepage 'texinfo-format 'texinfo-format-titlepage) | 2279 | (put 'titlepage 'texinfo-format 'texinfo-format-titlepage) |
| 2298 | (defun texinfo-format-titlepage () | 2280 | (defun texinfo-format-titlepage () |
| 2299 | (delete-region texinfo-command-start | 2281 | (delete-region texinfo-command-start |
| 2300 | (progn (re-search-forward "@end titlepage[ \t]*\n") | 2282 | (re-search-forward "@end titlepage[ \t]*\n"))) |
| 2301 | (point)))) | ||
| 2302 | 2283 | ||
| 2303 | (put 'endtitlepage 'texinfo-format 'texinfo-discard-line) | 2284 | (put 'endtitlepage 'texinfo-format 'texinfo-discard-line) |
| 2304 | 2285 | ||
| @@ -2307,8 +2288,7 @@ Use only the FILENAME arg; for Info, ignore the other arguments to @image." | |||
| 2307 | (put 'titlespec 'texinfo-format 'texinfo-format-titlespec) | 2288 | (put 'titlespec 'texinfo-format 'texinfo-format-titlespec) |
| 2308 | (defun texinfo-format-titlespec () | 2289 | (defun texinfo-format-titlespec () |
| 2309 | (delete-region texinfo-command-start | 2290 | (delete-region texinfo-command-start |
| 2310 | (progn (re-search-forward "@end titlespec[ \t]*\n") | 2291 | (re-search-forward "@end titlespec[ \t]*\n"))) |
| 2311 | (point)))) | ||
| 2312 | 2292 | ||
| 2313 | (put 'endtitlespec 'texinfo-format 'texinfo-discard-line) | 2293 | (put 'endtitlespec 'texinfo-format 'texinfo-discard-line) |
| 2314 | 2294 | ||
| @@ -2343,8 +2323,7 @@ Use only the FILENAME arg; for Info, ignore the other arguments to @image." | |||
| 2343 | (put 'ignore 'texinfo-format 'texinfo-format-ignore) | 2323 | (put 'ignore 'texinfo-format 'texinfo-format-ignore) |
| 2344 | (defun texinfo-format-ignore () | 2324 | (defun texinfo-format-ignore () |
| 2345 | (delete-region texinfo-command-start | 2325 | (delete-region texinfo-command-start |
| 2346 | (progn (re-search-forward "@end ignore[ \t]*\n") | 2326 | (re-search-forward "@end ignore[ \t]*\n"))) |
| 2347 | (point)))) | ||
| 2348 | 2327 | ||
| 2349 | (put 'endignore 'texinfo-format 'texinfo-discard-line) | 2328 | (put 'endignore 'texinfo-format 'texinfo-discard-line) |
| 2350 | 2329 | ||
| @@ -2439,8 +2418,8 @@ Use only the FILENAME arg; for Info, ignore the other arguments to @image." | |||
| 2439 | (setq texinfo-alias-list | 2418 | (setq texinfo-alias-list |
| 2440 | (cons | 2419 | (cons |
| 2441 | (cons | 2420 | (cons |
| 2442 | (buffer-substring-no-properties (match-beginning 1) (match-end 1)) | 2421 | (match-string-no-properties 1) |
| 2443 | (buffer-substring-no-properties (match-beginning 2) (match-end 2))) | 2422 | (match-string-no-properties 2)) |
| 2444 | texinfo-alias-list)) | 2423 | texinfo-alias-list)) |
| 2445 | (texinfo-discard-command)) | 2424 | (texinfo-discard-command)) |
| 2446 | ) | 2425 | ) |
| @@ -3007,13 +2986,12 @@ Default is to leave paragraph indentation as is." | |||
| 3007 | ;; Subroutine for sorting an index. | 2986 | ;; Subroutine for sorting an index. |
| 3008 | ;; At start of a line, return a string to sort the line under. | 2987 | ;; At start of a line, return a string to sort the line under. |
| 3009 | (defun texinfo-sort-startkeyfun () | 2988 | (defun texinfo-sort-startkeyfun () |
| 3010 | (let ((line | 2989 | (let ((line (buffer-substring-no-properties (point) (line-end-position)))) |
| 3011 | (buffer-substring-no-properties (point) (save-excursion (end-of-line) (point))))) | ||
| 3012 | ;; Canonicalize whitespace and eliminate funny chars. | 2990 | ;; Canonicalize whitespace and eliminate funny chars. |
| 3013 | (while (string-match "[ \t][ \t]+\\|[^a-z0-9 ]+" line) | 2991 | (while (string-match "[ \t][ \t]+\\|[^a-z0-9 ]+" line) |
| 3014 | (setq line (concat (substring line 0 (match-beginning 0)) | 2992 | (setq line (concat (substring line 0 (match-beginning 0)) |
| 3015 | " " | 2993 | " " |
| 3016 | (substring line (match-end 0) (length line))))) | 2994 | (substring line (match-end 0))))) |
| 3017 | line)) | 2995 | line)) |
| 3018 | 2996 | ||
| 3019 | 2997 | ||
| @@ -4036,8 +4014,7 @@ The command `@value{foo}' expands to the value." | |||
| 4036 | 'flag-cleared) | 4014 | 'flag-cleared) |
| 4037 | ;; Clear region (i.e., cause the text to be ignored). | 4015 | ;; Clear region (i.e., cause the text to be ignored). |
| 4038 | (delete-region texinfo-command-start | 4016 | (delete-region texinfo-command-start |
| 4039 | (progn (re-search-forward "@end ifset[ \t]*\n") | 4017 | (re-search-forward "@end ifset[ \t]*\n"))) |
| 4040 | (point)))) | ||
| 4041 | ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp) | 4018 | ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp) |
| 4042 | nil) | 4019 | nil) |
| 4043 | ;; In this case flag is neither set nor cleared. | 4020 | ;; In this case flag is neither set nor cleared. |
| @@ -4054,8 +4031,7 @@ The command `@value{foo}' expands to the value." | |||
| 4054 | 'flag-set) | 4031 | 'flag-set) |
| 4055 | ;; Clear region (i.e., cause the text to be ignored). | 4032 | ;; Clear region (i.e., cause the text to be ignored). |
| 4056 | (delete-region texinfo-command-start | 4033 | (delete-region texinfo-command-start |
| 4057 | (progn (re-search-forward "@end ifclear[ \t]*\n") | 4034 | (re-search-forward "@end ifclear[ \t]*\n"))) |
| 4058 | (point)))) | ||
| 4059 | ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp) | 4035 | ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp) |
| 4060 | 'flag-cleared) | 4036 | 'flag-cleared) |
| 4061 | ;; Format the text (i.e., do not remove it); do nothing here. | 4037 | ;; Format the text (i.e., do not remove it); do nothing here. |
| @@ -4341,8 +4317,8 @@ For example, invoke | |||
| 4341 | (message ">> Error: %s" (prin1-to-string err)) | 4317 | (message ">> Error: %s" (prin1-to-string err)) |
| 4342 | (message ">> point at") | 4318 | (message ">> point at") |
| 4343 | (let ((s (buffer-substring-no-properties (point) | 4319 | (let ((s (buffer-substring-no-properties (point) |
| 4344 | (min (+ (point) 100) | 4320 | (min (+ (point) 100) |
| 4345 | (point-max)))) | 4321 | (point-max)))) |
| 4346 | (tem 0)) | 4322 | (tem 0)) |
| 4347 | (while (setq tem (string-match "\n+" s tem)) | 4323 | (while (setq tem (string-match "\n+" s tem)) |
| 4348 | (setq s (concat (substring s 0 (match-beginning 0)) | 4324 | (setq s (concat (substring s 0 (match-beginning 0)) |