Function: nxml-insert-xml-declaration

nxml-insert-xml-declaration is an interactive and byte-compiled function defined in nxml-mode.el.gz.

Signature

(nxml-insert-xml-declaration)

Documentation

Insert an XML declaration at the beginning of buffer.

The XML declaration will declare an encoding depending on the buffer's buffer-file-coding-system.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/nxml/nxml-mode.el.gz
;;; Encodings

(defun nxml-insert-xml-declaration ()
  "Insert an XML declaration at the beginning of buffer.
The XML declaration will declare an encoding depending on the buffer's
`buffer-file-coding-system'."
  (interactive "*")
  (let ((coding-system
	 (if (and buffer-file-coding-system
		  (coding-system-p buffer-file-coding-system)
		  (coding-system-get buffer-file-coding-system
				     'mime-charset))
	     buffer-file-coding-system
	   (nxml-choose-utf-coding-system))))
    (goto-char (point-min))
    (insert (format "<?xml version=\"1.0\" encoding=\"%s\"?>\n"
		    (nxml-coding-system-name coding-system)))))