Function: sgml-pretty-print

sgml-pretty-print is an interactive and byte-compiled function defined in sgml-mode.el.gz.

Signature

(sgml-pretty-print BEG END)

Documentation

Simple-minded pretty printer for SGML.

Re-indents the code and inserts newlines between BEG and END. You might want to turn on auto-fill-mode to get better results.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/sgml-mode.el.gz
(defun sgml-pretty-print (beg end)
  "Simple-minded pretty printer for SGML.
Re-indents the code and inserts newlines between BEG and END.
You might want to turn on `auto-fill-mode' to get better results."
  ;; TODO:
  ;; - insert newline between some start-tag and text.
  ;; - don't insert newline in front of some end-tags.
  (interactive "r")
  (save-excursion
    (if (< beg end)
	(goto-char beg)
      (goto-char end)
      (setq end beg)
      (setq beg (point)))
    ;; Don't use narrowing because it screws up auto-indent.
    (setq end (copy-marker end t))
    (with-syntax-table sgml-tag-syntax-table
      (while (re-search-forward "<" end t)
	(goto-char (match-beginning 0))
	(unless (or ;;(looking-at "</")
		    (progn (skip-chars-backward " \t") (bolp)))
	  (reindent-then-newline-and-indent))
	(sgml-forward-sexp 1)))
    ;; (indent-region beg end)
    ))