Subject: bug#23668: 25.0.94; nxml mode doesn't indent correctly if prolog gets deleted

From: Ivan Andrus <[email-masked]>
Date: Tue, 31 May 2016 23:18:19 -0600

From emacs -Q evaluate the following and notice that they are different.

(with-temp-buffer
  (insert "\n <test>\n <bob/>\n</test>")
  (xml-mode)
  (indent-region (point-min) (point-max))
  (buffer-substring-no-properties (point-min) (point-max)))

(with-temp-buffer
  (insert "\n<test>\n <bob/>\n</test>")
  (xml-mode)
  (indent-region (point-min) (point-max))
  (buffer-substring-no-properties (point-min) (point-max)))

As best as I could determine it has to do with the prolog being parsed,
then deleted, but not being reparsed.  Thus it thinks <test> is
part of the prolog.  Unfortunately, the code is rather more than I have
time to understand at the moment.

-Ivan

In GNU Emacs 25.0.94.4 (x86_64-apple-darwin15.4.0, NS appkit-1404.46 Version 10.11.4 (Build 15E65))
of 2016-05-30 built on iandrus-osx
Repository revision: 6bdfb36bbff6dbe3ee2c3a15df9051c6656996ad
Windowing system distributor 'Apple', version 10.3.1404
Configured using:
'configure --with-ns --with-modules
PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig'

Configured features:
JPEG RSVG IMAGEMAGICK DBUS NOTIFY ACL GNUTLS LIBXML2 ZLIB
TOOLKIT_SCROLL_BARS NS MODULES

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
<test>
<bob/>
</test>"
Using vacuous schema
Indenting region...done
"
<test>
  <bob/>
</test>"
C-c C-c is undefined

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message dired format-spec rfc822 mml
mml-sec password-cache epg epg-config gnus-util mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
rfc2047 rfc2045 ietf-drums mm-util help-fns help-mode cl-loaddefs pcase
cl-lib mail-prsvr mail-utils nxml-uchnm rng-xsd xsd-regexp rng-cmpct
rng-nxml rng-valid rng-loc rng-uri rng-parse nxml-parse rng-match rng-dt
rng-util rng-pttrn nxml-ns easymenu nxml-mode nxml-outln nxml-rap
nxml-util nxml-glyph nxml-enc xmltok time-date mule-util tooltip eldoc
electric uniquify ediff-hook vc-hooks lisp-float-type mwheel ns-win
ucs-normalize term/common-win tool-bar dnd fontset image regexp-opt
fringe tabulated-list newcomment elisp-mode lisp-mode prog-mode register
page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock
font-lock syntax facemenu font-core frame cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese charscript case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer cl-preloaded nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote dbusbind kqueue cocoa ns multi-tty
make-network-process emacs)

Memory information:
((conses 16 209690 10284)
(symbols 48 21797 0)
(miscs 40 45 201)
(strings 32 19574 5815)
(string-bytes 1 563342)
(vectors 16 34982)
(vector-slots 8 677819 3811)
(floats 8 178 121)
(intervals 56 230 6)
(buffers 976 12))