unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Heinz Rommerskirchen <heinz@h-rommerskirchen.de>
Cc: 24978@debbugs.gnu.org
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	[thread overview]
Message-ID: <87mugzit1z.fsf@mouse.gnus.org> (raw)
In-Reply-To: <790b5bcd-716f-b4b2-31e8-2fe0c512405c@h-rommerskirchen.de> (Heinz Rommerskirchen's message of "Mon, 21 Nov 2016 14:41:24 +0100")

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	other threads:[~2019-07-27 12:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-21 13:41 bug#24978: 25.1; Bad interaction between nxml-auto-insert-xml-declaration-flag and archive-extract Heinz Rommerskirchen
2019-07-27 12:02 ` Lars Ingebrigtsen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mugzit1z.fsf@mouse.gnus.org \
    --to=larsi@gnus.org \
    --cc=24978@debbugs.gnu.org \
    --cc=heinz@h-rommerskirchen.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).