From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 18141@debbugs.gnu.org, vincent@vinc17.net, yamaoka@jpl.org
Subject: bug#18141: 24.4.50; saving .gz file breaks file coding
Date: Wed, 06 Aug 2014 20:45:59 -0400 [thread overview]
Message-ID: <jwv61i5xhi4.fsf-monnier+emacsbugs@gnu.org> (raw)
In-Reply-To: <83tx5po5eo.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 06 Aug 2014 21:10:39 +0300")
>> > - (let ((coding-system-for-write writecoding)
>> > - (coding-system-require-warning nil))
>> > + (let ((coding-system-for-write
>> > + (if filename-is-magic coding-system-for-write writecoding))
>> > + (coding-system-require-warning
>> > + (if filename-is-magic coding-system-require-warning)))
>> > (write-region nil nil
>> > buffer-file-name nil t buffer-file-truename)
>> > (setq success t))
>> I can vaguely guess why that avoids the problem
> The problem is the binding of coding-system-for-write based on
> incorrect interpretation of buffer-file-name. Why that causes the bug
> was explained in the text you elided. The code avoids the binding,
> and thus fixes its adverse effects.
Actually, the code doesn't really avoid the binding: there's still
a let-binding. So the variable's value is still restored when we finish.
Also, while I understand that the binding is wrong, I don't understand
why the "non-binding" is right.
>> but I'm having a hard time seeing why the above is "right".
> Do you see why the binding is "wrong"?
The other problem I see is with the filename-is-magic condition which
seems overly general.
> I agree that reverting the original change, which introduced this
> binding, is a better solution. Again, the text you elided said
> precisely that. I wonder why you didn't comment on that at all.
Because you said it very well, so I had nothing further to add.
> As for unintended consequences, I don't see how can any come out of
> that, since this just restores the code that was working for years.
Hmm... so you're saying this reverts part of the change?
[ I'm not very familiar with this code, in case you haven't noticed yet. ]
> Of course, if you have a better suggestion that would be safe enough
> for the release branch, I'm all ears.
Don't know yet what to do for the release branch, but I suspect reverting
is the better option since this problem has been with us for many many
years already.
As for the right fix: move the backup-generation to a later point.
This means either to split write-region into several sub-elements that
basic-save-buffer-2 can call separately. Or to add some kind of hook to
write-region so basic-save-buffer-2 can use it to create the backup at
the right time.
I'd prefer the "split" direction since write-region is much too large
for my taste.
Stefan
next prev parent reply other threads:[~2014-08-07 0:45 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-29 6:59 bug#18141: 24.4.50; saving .gz file breaks file coding Katsumi Yamaoka
2014-07-30 0:10 ` Glenn Morris
2014-07-30 2:36 ` Katsumi Yamaoka
2014-07-30 13:15 ` Katsumi Yamaoka
2014-08-05 8:34 ` Glenn Morris
2014-08-06 14:36 ` Eli Zaretskii
2014-08-06 16:43 ` Vincent Lefevre
2014-08-06 17:32 ` Eli Zaretskii
2014-08-06 19:08 ` Vincent Lefevre
2014-08-06 19:45 ` Eli Zaretskii
2014-08-07 0:31 ` Vincent Lefevre
2014-08-07 12:20 ` Stefan Monnier
2014-08-07 14:23 ` Vincent Lefevre
2014-08-11 1:06 ` Glenn Morris
2014-08-06 17:48 ` Stefan Monnier
2014-08-06 18:10 ` Eli Zaretskii
2014-08-07 0:45 ` Stefan Monnier [this message]
2014-08-07 15:14 ` Eli Zaretskii
2014-08-07 19:08 ` Stefan Monnier
2014-08-07 19:37 ` Eli Zaretskii
2014-08-07 20:43 ` Stefan Monnier
2014-08-08 5:51 ` Eli Zaretskii
2014-08-06 23:45 ` Glenn Morris
2014-08-07 0:03 ` Glenn Morris
2014-08-07 12:14 ` Stefan Monnier
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwv61i5xhi4.fsf-monnier+emacsbugs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=18141@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=vincent@vinc17.net \
--cc=yamaoka@jpl.org \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.