unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* emacs refuses to save file in the same encoding it was read
@ 2003-10-10 20:08 Sam Steingold
  2003-10-14  0:52 ` Kenichi Handa
  2003-10-22  9:14 ` Juri Linkov
  0 siblings, 2 replies; 14+ messages in thread
From: Sam Steingold @ 2003-10-10 20:08 UTC (permalink / raw)


GNU Emacs 21.3.50.1 (i386-msvc-nt5.0.2195)
 of 2003-10-08 on WINSTEINGOLDLAP
--with-msvc (12.00)

I have a file which starts with this line:
;;; -*- coding: utf-8-unix -*-

it is opened and displayed by emacs correctly.
however, when I try to modify and save it, I get the following question:

Selected encoding mule-utf-8-unix disagrees with iso-2022-7bit specified
by file contents.  Really save (else edit coding cookies and try again)?
(y or n)

when I answer affirmatively, the file is saved, but a line
;; -*- coding: iso-2022-7bit; -*-
is added in front of my cookie.

what is going on?

My understanding is that since everything can be encoded with utf-8,
there is no reason for Emacs to suggest a different encoding.
I seem to remember that there are some identical characters - from the
unicode POV - which Emacs represents differently.
First, I thought this bug has been fixed already.
Second, I thought it was irrelevant here anyway: the file is read in
utf-8!

It appears that buffer-file-coding-system is somehow set to
iso-2022-7bit; I sets default value to utf-8.

-- 
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.honestreporting.com>
main(a){printf(a,34,a="main(a){printf(a,34,a=%c%s%c,34);}",34);}

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: emacs refuses to save file in the same encoding it was read
  2003-10-10 20:08 emacs refuses to save file in the same encoding it was read Sam Steingold
@ 2003-10-14  0:52 ` Kenichi Handa
  2003-10-14  3:42   ` Pascal J.Bourguignon
  2003-10-22  9:14 ` Juri Linkov
  1 sibling, 1 reply; 14+ messages in thread
From: Kenichi Handa @ 2003-10-14  0:52 UTC (permalink / raw)
  Cc: emacs-devel

In article <uekxk97pv.fsf@gnu.org>, Sam Steingold <sds@gnu.org> writes:
> I have a file which starts with this line:
> ;;; -*- coding: utf-8-unix -*-

> it is opened and displayed by emacs correctly.
> however, when I try to modify and save it, I get the following question:

> Selected encoding mule-utf-8-unix disagrees with iso-2022-7bit specified
> by file contents.  Really save (else edit coding cookies and try again)?
> (y or n)

> when I answer affirmatively, the file is saved, but a line
> ;; -*- coding: iso-2022-7bit; -*-
> is added in front of my cookie.

> what is going on?

I can't reproduce this bug.  Could you please send me the
file that causes this problem in 8-bit safe way (base64 or
uuencode)?

---
Ken'ichi HANDA
handa@m17n.org

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: emacs refuses to save file in the same encoding it was read
  2003-10-14  0:52 ` Kenichi Handa
@ 2003-10-14  3:42   ` Pascal J.Bourguignon
  0 siblings, 0 replies; 14+ messages in thread
From: Pascal J.Bourguignon @ 2003-10-14  3:42 UTC (permalink / raw)
  Cc: clisp-list, emacs-devel


Kenichi Handa writes:
> In article <uekxk97pv.fsf@gnu.org>, Sam Steingold <sds@gnu.org> writes:
> > I have a file which starts with this line:
> > ;;; -*- coding: utf-8-unix -*-
> 
> > it is opened and displayed by emacs correctly.
> > however, when I try to modify and save it, I get the following question:
> 
> > Selected encoding mule-utf-8-unix disagrees with iso-2022-7bit specified
> > by file contents.  Really save (else edit coding cookies and try again)?
> > (y or n)
> 
> > when I answer affirmatively, the file is saved, but a line
> > ;; -*- coding: iso-2022-7bit; -*-
> > is added in front of my cookie.
> 
> > what is going on?
> 
> I can't reproduce this bug.  Could you please send me the
> file that causes this problem in 8-bit safe way (base64 or
> uuencode)?


I  had  recently  a  similar   problem  (without  a  -*-  coding:  -*-
line). I've got an answer on  usenet saying that emacs did not support
yet fully unicode, so when you have japanese characters, you must save
in iso-2022.

-- 
__Pascal_Bourguignon__
http://www.informatimago.com/
Do not adjust your mind, there is a fault in reality.


-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: emacs refuses to save file in the same encoding it was read
  2003-10-10 20:08 emacs refuses to save file in the same encoding it was read Sam Steingold
  2003-10-14  0:52 ` Kenichi Handa
@ 2003-10-22  9:14 ` Juri Linkov
  2003-10-22 12:43   ` Stefan Monnier
  2003-10-23 18:38   ` Richard Stallman
  1 sibling, 2 replies; 14+ messages in thread
From: Juri Linkov @ 2003-10-22  9:14 UTC (permalink / raw)


Sam Steingold <sds@gnu.org> writes:
> when I answer affirmatively, the file is saved, but a line
> ;; -*- coding: iso-2022-7bit; -*-
> is added in front of my cookie.
> 
> what is going on?

This line is added by the function `bbdb-write-file-hook-fn'.
Up to now it was added to `local-write-file-hooks' locally only in
the bbdb buffer.  But now the value of `local-write-file-hooks'
is set by the function `add-hook' globally, so this hook adds
this line in the beginning of every saved buffer.

-- 
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: emacs refuses to save file in the same encoding it was read
  2003-10-22  9:14 ` Juri Linkov
@ 2003-10-22 12:43   ` Stefan Monnier
  2003-10-22 15:17     ` Juri Linkov
  2003-10-23 18:38   ` Richard Stallman
  1 sibling, 1 reply; 14+ messages in thread
From: Stefan Monnier @ 2003-10-22 12:43 UTC (permalink / raw)
  Cc: emacs-devel

>> when I answer affirmatively, the file is saved, but a line
>> ;; -*- coding: iso-2022-7bit; -*-
>> is added in front of my cookie.
>> 
>> what is going on?

> This line is added by the function `bbdb-write-file-hook-fn'.
> Up to now it was added to `local-write-file-hooks' locally only in
> the bbdb buffer.  But now the value of `local-write-file-hooks'
> is set by the function `add-hook' globally, so this hook adds
> this line in the beginning of every saved buffer.

Since when dos it do that and why ?


        Stefan


PS: If the hook should be modified locally, you should set the `local'
    argument to a non-nil value.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: emacs refuses to save file in the same encoding it was read
  2003-10-22 12:43   ` Stefan Monnier
@ 2003-10-22 15:17     ` Juri Linkov
  2003-10-22 17:15       ` Stefan Monnier
  0 siblings, 1 reply; 14+ messages in thread
From: Juri Linkov @ 2003-10-22 15:17 UTC (permalink / raw)
  Cc: emacs-devel

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:
> > This line is added by the function `bbdb-write-file-hook-fn'.
> > Up to now it was added to `local-write-file-hooks' locally only in
> > the bbdb buffer.  But now the value of `local-write-file-hooks'
> > is set by the function `add-hook' globally, so this hook adds
> > this line in the beginning of every saved buffer.
> 
> Since when does it do that and why ?

I encountered this bug yesterday after I updated Emacs from CVS.

> PS: If the hook should be modified locally, you should set the `local'
>     argument to a non-nil value.

It's not easy to fix, because bbdb is not part of Emacs.

-- 
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: emacs refuses to save file in the same encoding it was read
  2003-10-22 15:17     ` Juri Linkov
@ 2003-10-22 17:15       ` Stefan Monnier
  0 siblings, 0 replies; 14+ messages in thread
From: Stefan Monnier @ 2003-10-22 17:15 UTC (permalink / raw)
  Cc: emacs-devel

>> PS: If the hook should be modified locally, you should set the `local'
>> argument to a non-nil value.
> It's not easy to fix, because bbdb is not part of Emacs.

Emacs should be fixed to maintain the backward compatibility, of course.
But a bug-report to bbdb-list is in order, I think.


        Stefan

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: emacs refuses to save file in the same encoding it was read
  2003-10-22  9:14 ` Juri Linkov
  2003-10-22 12:43   ` Stefan Monnier
@ 2003-10-23 18:38   ` Richard Stallman
  2003-10-23 19:15     ` Stefan Monnier
  2003-10-23 19:27     ` Alan Shutko
  1 sibling, 2 replies; 14+ messages in thread
From: Richard Stallman @ 2003-10-23 18:38 UTC (permalink / raw)
  Cc: emacs-devel

    This line is added by the function `bbdb-write-file-hook-fn'.
    Up to now it was added to `local-write-file-hooks' locally only in
    the bbdb buffer.  But now the value of `local-write-file-hooks'
    is set by the function `add-hook' globally, so this hook adds
    this line in the beginning of every saved buffer.

it looks like my change in add-hook is not right for
variables that become local when set.

dies ths chg work in general?

*** subr.el.~1.365.~	Mon Oct 20 19:26:00 2003
--- subr.el	Thu Oct 23 06:10:42 2003
***************
*** 852,857 ****
--- 852,859 ----
  function, it is changed to a list of functions."
    (or (boundp hook) (set hook nil))
    (or (default-boundp hook) (set-default hook nil))
+   (if (local-variable-if-set-p hook)
+       (setq local t))
    (if local (unless (local-variable-if-set-p hook)
  	      (set (make-local-variable hook) (list t)))
      ;; Detect the case where make-local-variable was used on a hook

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: emacs refuses to save file in the same encoding it was read
  2003-10-23 18:38   ` Richard Stallman
@ 2003-10-23 19:15     ` Stefan Monnier
  2003-10-24 10:42       ` Richard Stallman
  2003-10-23 19:27     ` Alan Shutko
  1 sibling, 1 reply; 14+ messages in thread
From: Stefan Monnier @ 2003-10-23 19:15 UTC (permalink / raw)
  Cc: Juri Linkov, emacs-devel

>     This line is added by the function `bbdb-write-file-hook-fn'.
>     Up to now it was added to `local-write-file-hooks' locally only in
>     the bbdb buffer.  But now the value of `local-write-file-hooks'
>     is set by the function `add-hook' globally, so this hook adds
>     this line in the beginning of every saved buffer.

> it looks like my change in add-hook is not right for
> variables that become local when set.

> dies ths chg work in general?

I think the code is already pretty messy, so I'd rather avoid adding
yet-another-test.  Could you explain the reason for the recent change
that introduced the new problem?  Maybe we can fix it in some other way?


        Stefan

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: emacs refuses to save file in the same encoding it was read
  2003-10-23 18:38   ` Richard Stallman
  2003-10-23 19:15     ` Stefan Monnier
@ 2003-10-23 19:27     ` Alan Shutko
  1 sibling, 0 replies; 14+ messages in thread
From: Alan Shutko @ 2003-10-23 19:27 UTC (permalink / raw)
  Cc: Juri Linkov, emacs-devel

Richard Stallman <rms@gnu.org> writes:

> it looks like my change in add-hook is not right for
> variables that become local when set.
>
> dies ths chg work in general?

It fixes the problems I was seeing.

-- 
Alan Shutko <ats@acm.org> - I am the rocks.
3 days, 20 hours, 33 minutes, 22 seconds till closing!
The only substitute for good manners is *faster* reflexes. ;^)

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: emacs refuses to save file in the same encoding it was read
  2003-10-23 19:15     ` Stefan Monnier
@ 2003-10-24 10:42       ` Richard Stallman
  2003-10-24 14:14         ` Stefan Monnier
  0 siblings, 1 reply; 14+ messages in thread
From: Richard Stallman @ 2003-10-24 10:42 UTC (permalink / raw)
  Cc: juri, emacs-devel

    I think the code is already pretty messy, so I'd rather avoid adding
    yet-another-test.  Could you explain the reason for the recent change
    that introduced the new problem?  Maybe we can fix it in some other way?

sorry, i don't remember, but i think i saw a bug in some case.

does my fix work?

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: emacs refuses to save file in the same encoding it was read
  2003-10-24 10:42       ` Richard Stallman
@ 2003-10-24 14:14         ` Stefan Monnier
  2003-10-25 22:26           ` Richard Stallman
  0 siblings, 1 reply; 14+ messages in thread
From: Stefan Monnier @ 2003-10-24 14:14 UTC (permalink / raw)
  Cc: juri, emacs-devel

>     I think the code is already pretty messy, so I'd rather avoid adding
>     yet-another-test.  Could you explain the reason for the recent change
>     that introduced the new problem?  Maybe we can fix it in some other way?
> sorry, i don't remember, but i think i saw a bug in some case.

It would be helpful if you could remember.  I can't think of any case where
the old code could be wrong.  The logic is as follows:

    If t is not a member of (symbol-value hook), then use
    `setq' rather than `setq-default' to modify the value.

There's no need to distinguish between the case where the variable is
buffer-local or not: if it is local-variable-if-set-p then the code
does the same as the new code and if it is not, `setq' and `setq-default'
do the same anyway.

> does my fix work?

It does, but I'd rather remove the recent patch which does not fix anthing
as far as I can tell.  Or at least I'd rather fix it by replacing
`local-variable-p' by `local-variable-if-set-p' in your recent patch.

The fact that you did not notice the bug even after I pointed out the
faulty code shows that the logic of the code is already complex enough
and should not be made worse as your two patches do.


        Stefan

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: emacs refuses to save file in the same encoding it was read
  2003-10-24 14:14         ` Stefan Monnier
@ 2003-10-25 22:26           ` Richard Stallman
  2003-10-26 18:52             ` Stefan Monnier
  0 siblings, 1 reply; 14+ messages in thread
From: Richard Stallman @ 2003-10-25 22:26 UTC (permalink / raw)
  Cc: juri, emacs-devel

i found it easier to rewrite the code than to understand the old code.

due to the broken arm, i can't discuss it further.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: emacs refuses to save file in the same encoding it was read
  2003-10-25 22:26           ` Richard Stallman
@ 2003-10-26 18:52             ` Stefan Monnier
  0 siblings, 0 replies; 14+ messages in thread
From: Stefan Monnier @ 2003-10-26 18:52 UTC (permalink / raw)
  Cc: juri, emacs-devel

> i found it easier to rewrite the code than to understand the old code.

You didn't need to understand the old code: I wrote it, I understand it,
I would have explained it and/or fixed it.

Also, I'm afraid there is a misunderstanding:
I was talking about the change to add-hook (not to remove-hook), but
this change is a two-line patch: very much unlike a rewrite.


        Stefan

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2003-10-26 18:52 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-10 20:08 emacs refuses to save file in the same encoding it was read Sam Steingold
2003-10-14  0:52 ` Kenichi Handa
2003-10-14  3:42   ` Pascal J.Bourguignon
2003-10-22  9:14 ` Juri Linkov
2003-10-22 12:43   ` Stefan Monnier
2003-10-22 15:17     ` Juri Linkov
2003-10-22 17:15       ` Stefan Monnier
2003-10-23 18:38   ` Richard Stallman
2003-10-23 19:15     ` Stefan Monnier
2003-10-24 10:42       ` Richard Stallman
2003-10-24 14:14         ` Stefan Monnier
2003-10-25 22:26           ` Richard Stallman
2003-10-26 18:52             ` Stefan Monnier
2003-10-23 19:27     ` Alan Shutko

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).