Subject: bug#16449: 24.3.50; emacs hangs while deleting comment in xml file with flyspell-mode on

From: Dmitry Antipov <[email-masked]>
Date: Wed, 15 Jan 2014 18:58:47 +0400

On 01/15/2014 07:16 AM, Levin Du wrote:

> 1. Starting from `emacs -Q'
[...skip...]

Reproduced. Consider simpler example with the following XML:

<?xml version="1.0" encoding="UTF-8"?>
<tag0>
   <!--<tag1>Text</tag1>-->
</tag0>

Visit this file in nxml-mode and try to eval:

(goto-char (nxml-token-after))

from the beginning - you should advance token by token after
each evaluation, up to the end of buffer.

Next, remove comment, i.e. change the XML above to:

<?xml version="1.0" encoding="UTF-8"?>
<tag0>
   <tag1>Text</tag1>
</tag0>

Then try to advance from the beginning again. In my test, nxml-token-after
stops at '<' of '<tag1>' and never continues. Due to this, there is an
endless loop in  nxml-forward-single-balanced-item (lisp/nxml/nxml-mode.el):

  1627  (defun nxml-forward-single-balanced-item ()
  1628    (condition-case err
  1629        (goto-char (let ((end (nxml-token-after)))
  1630                     (save-excursion
  1631                       (while (eq xmltok-type 'space)   ; this is an
  1632                         (goto-char end)                ; endless
  1633                         (setq end (nxml-token-after))) ; loop

BTW, I have no ideas why C-g doesn't help.

Dmitry