Function: TeX-format-filter

TeX-format-filter is a byte-compiled function defined in tex.el.

Signature

(TeX-format-filter PROCESS STRING)

Documentation

Filter to process TeX output.

Source Code

;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/tex.el
(defun TeX-format-filter (process string)
  "Filter to process TeX output."
  (with-current-buffer (process-buffer process)
    (let (str pos end (pt (marker-position (process-mark process))))
      (save-excursion
        (goto-char pt)
        (insert-before-markers string)
        (set-marker (process-mark process) (point))
        ;; Remove line breaks at columns 79 and 80
        (while (> (point) pt)
          (end-of-line 0)
          (when (and (memq (- (point) (line-beginning-position)) '(79 80))
                     ;; Heuristic: Don't delete the linebreak if the next line
                     ;; is empty or starts with an opening parenthesis, or if
                     ;; point is located after a period and in the next line no
                     ;; word char follows.
                     (not (memq (char-after (1+ (point))) '(?\n ?\()))
                     (not (and (eq (char-before) ?.)
                               (char-after (1+ (point)))
                               (not (eq ?w (char-syntax (char-after (1+ (point)))))))))
            (delete-char 1)))
        (goto-char (marker-position (process-mark process)))
        ;; Determine current page
        (while (and pt
                    (skip-chars-backward "^]" pt)
                    (> (point) pt))
          (setq end (point))
          (backward-char)
          (skip-chars-backward "-0-9\n." (max (point-min) (- pt 128)))
          (when (and (eq ?\[ (char-before))
                     (not (eq ?\] (char-after)))
                     (progn
                       (setq str (buffer-substring (1- (point)) end)
                             pos nil)
                       (while (setq pos (string-match "\n" str pos))
                         (setq str (replace-match "" t t str)))
                       (string-match
                        "\\`\\[-?[0-9]+\\(\\.-?[0-9]+\\)\\{0,9\\}\\]\\'"
                        str)))
            (setq TeX-current-page str
                  pt nil)
            (TeX-format-mode-line process)))))))