Function: preview-canonical-spaces

preview-canonical-spaces is a byte-compiled function defined in preview.el.

Signature

(preview-canonical-spaces ARG)

Documentation

Convert ARG into canonical form.

Removes comments and collapses white space, except for multiple newlines.

Source Code

;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/preview.el
(defun preview-canonical-spaces (arg)
  "Convert ARG into canonical form.
Removes comments and collapses white space, except for multiple newlines."
  (let (pos)
    (while (setq pos (string-match "\\s<.*[\n\r][ \t]*" arg pos))
      (setq arg (replace-match "" t t arg 0)))
    (while (setq pos (string-match "[ \t]*\\(\\([ \t]\\)\\|[\n\r][ \t]*\\)"
                                   arg pos))
      (setq arg (replace-match (if (match-beginning 2) " " "\n") t t arg 0)
            pos (1+ pos)))
    (while (setq pos (string-match "\n+" arg pos))
      (if (string= "\n" (match-string 0 arg))
          (setq arg (replace-match " " t t arg 0)
                pos (1+ pos))
        (setq pos (match-end 0)))))
  arg)