bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#24978: 25.1; Bad interaction between nxml-auto-insert-xml-declaratio


From: Lars Ingebrigtsen
Subject: bug#24978: 25.1; Bad interaction between nxml-auto-insert-xml-declaration-flag and archive-extract
Date: Sat, 27 Jul 2019 14:02:48 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Heinz Rommerskirchen <heinz@h-rommerskirchen.de> writes:

> If the variable nxml-auto-insert-xml-declaration-flag is set, an XML
> declaration is inserted into non-empty XML files inside a zip archive.
>
> To reproduce this bug create the valid XML file foo.xml containing
> === start foo.xml ===
> <?xml version="1.0" encoding="utf-8"?>
> <content>y</content>
> === end foo.xml ===
> and pack it into a zip-archive:
> $ zip -m bar.zip foo.xml
> Now start "emacs -Q", evaluate
> "(setq nxml-auto-insert-xml-declaration-flag 't)" in the *scratch*
> buffer, visit bar.zip with C-x C-f, and press Enter on the entry
> "foo.xml". foo.xml will be opened and an additional XML declaration is
> inserted into the buffer rendering the file invalid and marking the
> buffer as modified.

(I'm going through older Emacs bug reports that have received no
response.)

I was able to reproduce the bug in Emacs 27, too.

> The following simple patch solved the problem for me.

[...]

> -  (when (not (and (buffer-file-name) (file-exists-p (buffer-file-name))))
> +  (when (and (not (and (buffer-file-name) (file-exists-p 
> (buffer-file-name))))
> +             (not archive-superior-buffer))

Thanks for the patch, but I think the problem is a bit more general.
The intention seems to be to insert the declaration whenever you're
starting a new file, so I think a more general solution is to just check
whether the buffer is empty before inserting the declaration.  I've now
done this change on the Emacs trunk.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





reply via email to

[Prev in Thread] Current Thread [Next in Thread]