aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1993-07-31 07:33:02 +0000
committerRichard M. Stallman1993-07-31 07:33:02 +0000
commitbbd93e412956015a91a2d3c58ad9629f9915eb22 (patch)
treedde68ec63c2755c5d433d0d932f5a677ebe2b74c
parent2943f983f2f0e1d0320aed2b98ada4517beded24 (diff)
downloademacs-bbd93e412956015a91a2d3c58ad9629f9915eb22.tar.gz
emacs-bbd93e412956015a91a2d3c58ad9629f9915eb22.zip
(validate-tex-buffer): Record mismatches in *Occur*.
-rw-r--r--lisp/textmodes/tex-mode.el60
1 files changed, 48 insertions, 12 deletions
diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el
index e6db1dafcdf..edf48c17d65 100644
--- a/lisp/textmodes/tex-mode.el
+++ b/lisp/textmodes/tex-mode.el
@@ -506,23 +506,59 @@ inserts \" characters."
506 506
507(defun validate-tex-buffer () 507(defun validate-tex-buffer ()
508 "Check current buffer for paragraphs containing mismatched $s. 508 "Check current buffer for paragraphs containing mismatched $s.
509As each such paragraph is found, a mark is pushed at its beginning, 509Their positions are recorded in the buffer `*Occur*'.
510and the location is displayed for a few seconds." 510To find a particular invalidity from `*Occur*',
511switch to to that buffer and type C-c C-c on the line
512for the invalidity you want to see."
511 (interactive) 513 (interactive)
512 (let ((opoint (point))) 514 (let ((buffer (current-buffer))
513 (goto-char (point-max)) 515 (prevpos (point-min))
514 ;; Does not use save-excursion 516 (linenum nil))
515 ;; because we do not want to save the mark. 517 (with-output-to-temp-buffer "*Occur*"
516 (unwind-protect 518 (princ "Mismatches:\n")
519 (save-excursion
520 (set-buffer standard-output)
521 (occur-mode)
522 (setq occur-buffer buffer)
523 (setq occur-nlines 0)
524 (setq occur-pos-list nil))
525 (save-excursion
526 (goto-char (point-max))
517 (while (and (not (input-pending-p)) (not (bobp))) 527 (while (and (not (input-pending-p)) (not (bobp)))
518 (let ((end (point))) 528 (let ((end (point)))
529 ;; Scan the previous paragraph for invalidities.
519 (search-backward "\n\n" nil 'move) 530 (search-backward "\n\n" nil 'move)
520 (or (tex-validate-region (point) end) 531 (or (tex-validate-region (point) end)
521 (progn 532 (let* ((end (save-excursion (forward-line 1) (point)))
522 (push-mark (point)) 533 start tem)
523 (message "Mismatch found in paragraph starting here") 534 (beginning-of-line)
524 (sit-for 4))))) 535 (setq start (point))
525 (goto-char opoint)))) 536 ;; Keep track of line number as we scan,
537 ;; in a cumulative fashion.
538 (if linenum
539 (setq linenum (- linenum (count-lines prevpos (point))))
540 (setq linenum (1+ (count-lines 1 start))))
541 (setq prevpos (point))
542 ;; Mention this mismatch in *Occur*.
543 ;; Since we scan from end of buffer to beginning,
544 ;; add each mismatch at the beginning of *Occur*
545 ;; and at the beginning of occur-pos-list.
546 (save-excursion
547 (setq tem (point-marker))
548 (set-buffer standard-output)
549 (goto-char (point-min))
550 ;; Skip "Mismatches:" header line.
551 (forward-line 1)
552 (setq occur-pos-list (cons tem occur-pos-list))
553 (insert-buffer-substring buffer start end)
554 (forward-char (- start end))
555 (insert (format "%3d: " linenum))))))))
556 (save-excursion
557 (set-buffer standard-output)
558 (if (null occur-pos-list)
559 (insert "None!\n"))
560 (if (interactive-p)
561 (message "%d mismatches found" (length occur-pos-list)))))))
526 562
527(defun tex-validate-region (start end) 563(defun tex-validate-region (start end)
528 "Check for mismatched braces or $'s in region. 564 "Check for mismatched braces or $'s in region.