GNU bug report logs - #13522
24.2; save-buffer removes edited file under some conditions

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Vincent Lefevre <vincent@HIDDEN>; Keywords: confirmed; dated Tue, 22 Jan 2013 01:49:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
bug Marked as found in versions 25.1. Request was from npostavs@HIDDEN to control <at> debbugs.gnu.org. Full text available.
Severity set to 'normal' from 'important' Request was from npostavs@HIDDEN to control <at> debbugs.gnu.org. Full text available.

Message received at 13522 <at> debbugs.gnu.org:


Received: (at 13522) by debbugs.gnu.org; 11 Aug 2014 01:06:51 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Aug 10 21:06:51 2014
Received: from localhost ([127.0.0.1]:38148 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1XGe4Y-0006r4-Jd
	for submit <at> debbugs.gnu.org; Sun, 10 Aug 2014 21:06:50 -0400
Received: from fencepost.gnu.org ([208.118.235.10]:33447 ident=Debian-exim)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <rgm@HIDDEN>) id 1XGe4V-0006qv-Le
 for 13522 <at> debbugs.gnu.org; Sun, 10 Aug 2014 21:06:48 -0400
Received: from rgm by fencepost.gnu.org with local (Exim 4.71)
 (envelope-from <rgm@HIDDEN>)
 id 1XGe4V-0002fz-2v; Sun, 10 Aug 2014 21:06:47 -0400
From: Glenn Morris <rgm@HIDDEN>
To: 13522 <at> debbugs.gnu.org
Subject: Re: bug#13522: 24.2;
 save-buffer removes edited file under some conditions
References: <87622qaszq.fsf@HIDDEN> <aqtxq6e36c.fsf@HIDDEN>
 <20130125000256.GC3397@HIDDEN>
 <s14ni6axzc.fsf@HIDDEN> <83libhlnpz.fsf@HIDDEN>
 <y5txq5n0rm.fsf@HIDDEN> <3b8v7byrki.fsf@HIDDEN>
 <jwv4nhybh3s.fsf-monnier+emacs@HIDDEN>
 <c6halxg8py.fsf@HIDDEN>
X-Spook: Uzbekistan Indigo Aldergrove subversive CDC Attorney
X-Ran: aFlt%E+?O)@$$H@g,)3\o5<f<P5%LGKm>Psh.^Q56K8c|Q;!7+\oq5t2/U.,CS}7%A5M_J
X-Hue: blue
X-Attribution: GM
Date: Sun, 10 Aug 2014 21:06:47 -0400
In-Reply-To: <c6halxg8py.fsf@HIDDEN> (Glenn Morris's message of
 "Thu, 31 Jan 2013 01:36:09 -0500")
Message-ID: <3v8umvdec8.fsf@HIDDEN>
User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: 13522
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)


Had to revert this fix - see discussion in http://debbugs.gnu.org/18141 .




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#13522; Package emacs. Full text available.
bug Marked as found in versions 24.4; no longer marked as fixed in versions 24.4 and reopened. Request was from Glenn Morris <rgm@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
bug unarchived. Request was from Glenn Morris <rgm@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
bug archived. Request was from Debbugs Internal Request <help-debbugs@HIDDEN> to internal_control <at> debbugs.gnu.org. Full text available.
bug marked as fixed in version 24.4, send any further explanations to 13522 <at> debbugs.gnu.org and Vincent Lefevre <vincent@HIDDEN> Request was from Glenn Morris <rgm@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 13522 <at> debbugs.gnu.org:


Received: (at 13522) by debbugs.gnu.org; 31 Jan 2013 06:36:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 31 01:36:57 2013
Received: from localhost ([127.0.0.1]:56674 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1U0nlY-00040K-NE
	for submit <at> debbugs.gnu.org; Thu, 31 Jan 2013 01:36:56 -0500
Received: from fencepost.gnu.org ([208.118.235.10]:52211)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <rgm@HIDDEN>) id 1U0nlV-00040B-5m
	for 13522 <at> debbugs.gnu.org; Thu, 31 Jan 2013 01:36:54 -0500
Received: from rgm by fencepost.gnu.org with local (Exim 4.71)
	(envelope-from <rgm@HIDDEN>)
	id 1U0nkn-0006Sw-N6; Thu, 31 Jan 2013 01:36:09 -0500
From: Glenn Morris <rgm@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#13522: 24.2;
	save-buffer removes edited file under some conditions
References: <87622qaszq.fsf@HIDDEN> <aqtxq6e36c.fsf@HIDDEN>
	<20130125000256.GC3397@HIDDEN>
	<s14ni6axzc.fsf@HIDDEN> <83libhlnpz.fsf@HIDDEN>
	<y5txq5n0rm.fsf@HIDDEN> <3b8v7byrki.fsf@HIDDEN>
	<jwv4nhybh3s.fsf-monnier+emacs@HIDDEN>
X-Spook: Bosnia blackjack condor PET analyzer red noise Commecen
X-Ran: fe4w8dnluO4;D~Z:VU8LQKlwc+xg6CZ2\z7CY*'+JaY_3`_}Z0BZCBf4aSA,7A^3:+uWIc
X-Hue: cyan
X-Debbugs-No-Ack: yes
X-Attribution: GM
Date: Thu, 31 Jan 2013 01:36:09 -0500
In-Reply-To: <jwv4nhybh3s.fsf-monnier+emacs@HIDDEN> (Stefan Monnier's message
	of "Wed, 30 Jan 2013 14:34:57 -0500")
Message-ID: <c6halxg8py.fsf@HIDDEN>
User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Spam-Score: -4.7 (----)
X-Debbugs-Envelope-To: 13522
Cc: Eli Zaretskii <eliz@HIDDEN>, vincent@HIDDEN, 13522 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -7.4 (-------)

Stefan Monnier wrote:

> Rather than introduce a new var, we could let bind
> coding-system-for-write (and coding-system-require-warning).

Sold.

Done in trunk.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#13522; Package emacs. Full text available.

Message received at 13522 <at> debbugs.gnu.org:


Received: (at 13522) by debbugs.gnu.org; 30 Jan 2013 19:35:53 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jan 30 14:35:52 2013
Received: from localhost ([127.0.0.1]:56195 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1U0dRo-0000xs-Nn
	for submit <at> debbugs.gnu.org; Wed, 30 Jan 2013 14:35:52 -0500
Received: from ironport2-out.teksavvy.com ([206.248.154.182]:57583)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <monnier@HIDDEN>) id 1U0dRn-0000xk-6G
	for 13522 <at> debbugs.gnu.org; Wed, 30 Jan 2013 14:35:51 -0500
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: Av4EABK/CFG4rw3e/2dsb2JhbABEvw4Xc4IfAQVWIxALDiYSFBgNJIgkwS2RCgOIYZwZgV6DFQ
X-IPAS-Result: Av4EABK/CFG4rw3e/2dsb2JhbABEvw4Xc4IfAQVWIxALDiYSFBgNJIgkwS2RCgOIYZwZgV6DFQ
X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; 
   d="scan'208";a="48456"
Received: from 184-175-13-222.dsl.teksavvy.com (HELO ceviche.home)
	([184.175.13.222])
	by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA;
	30 Jan 2013 14:35:06 -0500
Received: by ceviche.home (Postfix, from userid 20848)
	id 8201166130; Wed, 30 Jan 2013 14:34:57 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Glenn Morris <rgm@HIDDEN>
Subject: Re: bug#13522: 24.2;
	save-buffer removes edited file under some conditions
Message-ID: <jwv4nhybh3s.fsf-monnier+emacs@HIDDEN>
References: <87622qaszq.fsf@HIDDEN> <aqtxq6e36c.fsf@HIDDEN>
	<20130125000256.GC3397@HIDDEN>
	<s14ni6axzc.fsf@HIDDEN> <83libhlnpz.fsf@HIDDEN>
	<y5txq5n0rm.fsf@HIDDEN> <3b8v7byrki.fsf@HIDDEN>
Date: Wed, 30 Jan 2013 14:34:57 -0500
In-Reply-To: <3b8v7byrki.fsf@HIDDEN> (Glenn Morris's message of
	"Wed, 30 Jan 2013 03:59:25 -0500")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 13522
Cc: Eli Zaretskii <eliz@HIDDEN>, vincent@HIDDEN, 13522 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -1.9 (-)

> + 	      (let ((write-region-coding-system writecoding))
>   		(write-region nil nil
>   			      buffer-file-name nil t buffer-file-truename)

Rather than introduce a new var, we could let bind
coding-system-for-write (and coding-system-require-warning).


        Stefan




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#13522; Package emacs. Full text available.

Message received at 13522 <at> debbugs.gnu.org:


Received: (at 13522) by debbugs.gnu.org; 30 Jan 2013 09:00:05 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jan 30 04:00:05 2013
Received: from localhost ([127.0.0.1]:55213 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1U0TWX-0006L0-0Q
	for submit <at> debbugs.gnu.org; Wed, 30 Jan 2013 04:00:05 -0500
Received: from fencepost.gnu.org ([208.118.235.10]:37160)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <rgm@HIDDEN>) id 1U0TWU-0006KN-KR
	for 13522 <at> debbugs.gnu.org; Wed, 30 Jan 2013 04:00:04 -0500
Received: from rgm by fencepost.gnu.org with local (Exim 4.71)
	(envelope-from <rgm@HIDDEN>)
	id 1U0TVu-0003CS-40; Wed, 30 Jan 2013 03:59:26 -0500
From: Glenn Morris <rgm@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#13522: 24.2;
	save-buffer removes edited file under some conditions
References: <87622qaszq.fsf@HIDDEN> <aqtxq6e36c.fsf@HIDDEN>
	<20130125000256.GC3397@HIDDEN>
	<s14ni6axzc.fsf@HIDDEN> <83libhlnpz.fsf@HIDDEN>
	<y5txq5n0rm.fsf@HIDDEN>
X-Spook: Downing Street World Trade Center Blowpipe Plame class
X-Ran: /-Hg7m,\{zoejgS-m`{Jzz0=R9F7GOq\uud'XfZt=O-teO"8HjNmsoY[rZqSs0/mUdK+)m
X-Hue: black
X-Debbugs-No-Ack: yes
X-Attribution: GM
Date: Wed, 30 Jan 2013 03:59:25 -0500
In-Reply-To: <y5txq5n0rm.fsf@HIDDEN> (Glenn Morris's message of
	"Fri, 25 Jan 2013 03:07:57 -0500")
Message-ID: <3b8v7byrki.fsf@HIDDEN>
User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Spam-Score: -7.4 (-------)
X-Debbugs-Envelope-To: 13522
Cc: 13522 <at> debbugs.gnu.org, vincent@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -7.4 (-------)

Glenn Morris wrote:

> Maybe the right solution is to have the select-safe-coding-system check
> in basic-save-buffer-2 before backup-buffer, then pass the resulting
> coding system to write-region somehow so it does not need to query
> again.

Very lightly tested patch:

*** lisp/files.el	2013-01-10 15:50:04 +0000
--- lisp/files.el	2013-01-30 08:53:30 +0000
***************
*** 4656,4662 ****
  ;; This returns a value (MODES EXTENDED-ATTRIBUTES BACKUPNAME), like
  ;; backup-buffer.
  (defun basic-save-buffer-2 ()
!   (let (tempsetmodes setmodes)
      (if (not (file-writable-p buffer-file-name))
  	(let ((dir (file-name-directory buffer-file-name)))
  	  (if (not (file-directory-p dir))
--- 4656,4662 ----
  ;; This returns a value (MODES EXTENDED-ATTRIBUTES BACKUPNAME), like
  ;; backup-buffer.
  (defun basic-save-buffer-2 ()
!   (let (tempsetmodes setmodes writecoding)
      (if (not (file-writable-p buffer-file-name))
  	(let ((dir (file-name-directory buffer-file-name)))
  	  (if (not (file-directory-p dir))
***************
*** 4672,4677 ****
--- 4672,4680 ----
  		     buffer-file-name)))
  		  (setq tempsetmodes t)
  		(error "Attempt to save to a file which you aren't allowed to write"))))))
+     (setq writecoding
+ 	  (choose-write-coding-system nil nil buffer-file-name nil t
+ 				      buffer-file-truename))
      (or buffer-backed-up
  	(setq setmodes (backup-buffer)))
      (let* ((dir (file-name-directory buffer-file-name))
***************
*** 4753,4762 ****
  				 (logior (car setmodes) 128))))))
  	(let (success)
  	  (unwind-protect
- 	      (progn
                  ;; Pass in nil&nil rather than point-min&max to indicate
                  ;; we're saving the buffer rather than just a region.
                  ;; write-region-annotate-functions may make us of it.
  		(write-region nil nil
  			      buffer-file-name nil t buffer-file-truename)
  		(setq success t))
--- 4756,4765 ----
  				 (logior (car setmodes) 128))))))
  	(let (success)
  	  (unwind-protect
  	      ;; Pass in nil&nil rather than point-min&max to indicate
  	      ;; we're saving the buffer rather than just a region.
  	      ;; write-region-annotate-functions may make us of it.
+ 	      (let ((write-region-coding-system writecoding))
  		(write-region nil nil
  			      buffer-file-name nil t buffer-file-truename)
  		(setq success t))

=== modified file 'src/fileio.c'
*** src/fileio.c	2013-01-23 20:07:28 +0000
--- src/fileio.c	2013-01-30 08:55:45 +0000
***************
*** 249,254 ****
--- 249,255 ----
  static Lisp_Object Qset_file_acl;
  static Lisp_Object Qfile_newer_than_file_p;
  Lisp_Object Qinsert_file_contents;
+ Lisp_Object Qchoose_write_coding_system;
  Lisp_Object Qwrite_region;
  static Lisp_Object Qverify_visited_file_modtime;
  static Lisp_Object Qset_visited_file_modtime;
***************
*** 4615,4628 ****
  
  /* Decide the coding-system to encode the data with.  */
  
! static Lisp_Object
! choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object filename,
! 			    Lisp_Object append, Lisp_Object visit, Lisp_Object lockname,
! 			    struct coding_system *coding)
  {
    Lisp_Object val;
    Lisp_Object eol_parent = Qnil;
  
    if (auto_saving
        && NILP (Fstring_equal (BVAR (current_buffer, filename),
  			      BVAR (current_buffer, auto_save_file_name))))
--- 4616,4637 ----
  
  /* Decide the coding-system to encode the data with.  */
  
! DEFUN ("choose-write-coding-system", Fchoose_write_coding_system,
!        Schoose_write_coding_system, 3, 6, 0,
!        doc: /* Choose coding system for write.
! Arguments as for `write-region'.  */ )
!   (Lisp_Object start, Lisp_Object end, Lisp_Object filename,
!    Lisp_Object append, Lisp_Object visit, Lisp_Object lockname)
  {
    Lisp_Object val;
    Lisp_Object eol_parent = Qnil;
  
+   if (NILP (start))
+     {
+       XSETFASTINT (start, BEGV);
+       XSETFASTINT (end, ZV);
+     }
+ 
    if (auto_saving
        && NILP (Fstring_equal (BVAR (current_buffer, filename),
  			      BVAR (current_buffer, auto_save_file_name))))
***************
*** 4715,4724 ****
      }
  
    val = coding_inherit_eol_type (val, eol_parent);
-   setup_coding_system (val, coding);
- 
-   if (!STRINGP (start) && !NILP (BVAR (current_buffer, selective_display)))
-     coding->mode |= CODING_MODE_SELECTIVE_DISPLAY;
    return val;
  }
  
--- 4724,4729 ----
***************
*** 4874,4882 ****
       We used to make this choice before calling build_annotations, but that
       leads to problems when a write-annotate-function takes care of
       unsavable chars (as was the case with X-Symbol).  */
!   Vlast_coding_system_used
!     = choose_write_coding_system (start, end, filename,
! 				  append, visit, lockname, &coding);
  
  #ifdef CLASH_DETECTION
    if (!auto_saving)
--- 4879,4893 ----
       We used to make this choice before calling build_annotations, but that
       leads to problems when a write-annotate-function takes care of
       unsavable chars (as was the case with X-Symbol).  */
!   Vlast_coding_system_used = NILP (Vwrite_region_coding_system) ?
!     Fchoose_write_coding_system (start, end, filename,
!                                 append, visit, lockname) :
!     Vwrite_region_coding_system;
! 
!   setup_coding_system (Vlast_coding_system_used, &coding);
! 
!   if (!STRINGP (start) && !NILP (BVAR (current_buffer, selective_display)))
!     coding.mode |= CODING_MODE_SELECTIVE_DISPLAY;
  
  #ifdef CLASH_DETECTION
    if (!auto_saving)
***************
*** 5861,5866 ****
--- 5872,5878 ----
    DEFSYM (Qset_file_acl, "set-file-acl");
    DEFSYM (Qfile_newer_than_file_p, "file-newer-than-file-p");
    DEFSYM (Qinsert_file_contents, "insert-file-contents");
+   DEFSYM (Qchoose_write_coding_system, "choose-write-coding-system");
    DEFSYM (Qwrite_region, "write-region");
    DEFSYM (Qverify_visited_file_modtime, "verify-visited-file-modtime");
    DEFSYM (Qset_visited_file_modtime, "set-visited-file-modtime");
***************
*** 5890,5895 ****
--- 5902,5912 ----
  of file names regardless of the current language environment.  */);
    Vdefault_file_name_coding_system = Qnil;
  
+   DEFVAR_LISP ("write-region-coding-system", Vwrite_region_coding_system,
+ 	       doc: /* If non-nil, coding system for `write-region'.
+ You should only ever `let'-bind this around a `write-region' call.  */);
+   Vwrite_region_coding_system = Qnil;
+ 
    DEFSYM (Qformat_decode, "format-decode");
    DEFSYM (Qformat_annotate_function, "format-annotate-function");
    DEFSYM (Qafter_insert_file_set_coding, "after-insert-file-set-coding");
***************
*** 6085,6090 ****
--- 6102,6108 ----
    defsubr (&Sdefault_file_modes);
    defsubr (&Sfile_newer_than_file_p);
    defsubr (&Sinsert_file_contents);
+   defsubr (&Schoose_write_coding_system);
    defsubr (&Swrite_region);
    defsubr (&Scar_less_than_car);
    defsubr (&Sverify_visited_file_modtime);





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#13522; Package emacs. Full text available.

Message received at 13522 <at> debbugs.gnu.org:


Received: (at 13522) by debbugs.gnu.org; 25 Jan 2013 08:08:09 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jan 25 03:08:09 2013
Received: from localhost ([127.0.0.1]:48522 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1TyeKX-00083l-2a
	for submit <at> debbugs.gnu.org; Fri, 25 Jan 2013 03:08:09 -0500
Received: from fencepost.gnu.org ([208.118.235.10]:44084)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <rgm@HIDDEN>) id 1TyeKV-00083e-A3
	for 13522 <at> debbugs.gnu.org; Fri, 25 Jan 2013 03:08:08 -0500
Received: from rgm by fencepost.gnu.org with local (Exim 4.71)
	(envelope-from <rgm@HIDDEN>)
	id 1TyeKL-0000Pl-TS; Fri, 25 Jan 2013 03:07:57 -0500
From: Glenn Morris <rgm@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#13522: 24.2;
	save-buffer removes edited file under some conditions
References: <87622qaszq.fsf@HIDDEN> <aqtxq6e36c.fsf@HIDDEN>
	<20130125000256.GC3397@HIDDEN>
	<s14ni6axzc.fsf@HIDDEN> <83libhlnpz.fsf@HIDDEN>
X-Spook: RSA Bellcore afsatcom security CIA Downing Street kibo
X-Ran: vG\h/{o2]QyCu7k2'ED.rzAV?8JP_S'0>pb6*;=Hxt<d/H|C.~3HEeT?nq[(n~)*V(=%2E
X-Hue: black
X-Debbugs-No-Ack: yes
X-Attribution: GM
Date: Fri, 25 Jan 2013 03:07:57 -0500
In-Reply-To: <83libhlnpz.fsf@HIDDEN> (Eli Zaretskii's message of "Fri, 25 Jan
	2013 09:35:04 +0200")
Message-ID: <y5txq5n0rm.fsf@HIDDEN>
User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Spam-Score: -4.2 (----)
X-Debbugs-Envelope-To: 13522
Cc: 13522 <at> debbugs.gnu.org, vincent@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -5.5 (-----)

Eli Zaretskii wrote:

> I can't.  Moreover, the recipe says "Type C-c in the terminal to kill
> Emacs", but C-c does not kill Emacs, only C-x C-c does. 

C-c *in the shell* from which Emacs was started in the foreground, not
from in Emacs; ie interrupt it from outside.

Or even: do C-x C-s, and leave the coding prompt unanswered. You will
find the original file missing until you answer, or quit, the coding
question!

Looks like it has been this way since the unicode merge.
basic-save-buffer-2 calls backup-buffer, which may rename the original
file. It then calls write-region. This may call
select-safe-coding-system, so there can be an arbitrarily long interval
between the original file being renamed to the backup, and the new file
being written.

If you interrupt the coding prompt with C-g, the unwind-protect in
basic-save-buffer-2 puts back the original file. I suppose the problem
could maybe be papered over by adding something equivalent to
kill-emacs-hook, but it's still very far from ideal.

Maybe the right solution is to have the select-safe-coding-system check
in basic-save-buffer-2 before backup-buffer, then pass the resulting
coding system to write-region somehow so it does not need to query
again.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#13522; Package emacs. Full text available.

Message received at 13522 <at> debbugs.gnu.org:


Received: (at 13522) by debbugs.gnu.org; 25 Jan 2013 07:35:11 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jan 25 02:35:11 2013
Received: from localhost ([127.0.0.1]:48464 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Tydoc-0007FJ-N2
	for submit <at> debbugs.gnu.org; Fri, 25 Jan 2013 02:35:11 -0500
Received: from mtaout21.012.net.il ([80.179.55.169]:34336)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <eliz@HIDDEN>) id 1TydoY-0007F7-JH
	for 13522 <at> debbugs.gnu.org; Fri, 25 Jan 2013 02:35:08 -0500
Received: from conversion-daemon.a-mtaout21.012.net.il by
	a-mtaout21.012.net.il (HyperSendmail v2007.08) id
	<0MH600L007OGFW00@HIDDEN> for
	13522 <at> debbugs.gnu.org; Fri, 25 Jan 2013 09:34:57 +0200 (IST)
Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout21.012.net.il
	(HyperSendmail v2007.08) with ESMTPA id
	<0MH600LLV7Q9AF70@HIDDEN>;
	Fri, 25 Jan 2013 09:34:57 +0200 (IST)
Date: Fri, 25 Jan 2013 09:35:04 +0200
From: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#13522: 24.2;
	save-buffer removes edited file under some conditions
In-reply-to: <s14ni6axzc.fsf@HIDDEN>
X-012-Sender: halo1@HIDDEN
To: Glenn Morris <rgm@HIDDEN>
Message-id: <83libhlnpz.fsf@HIDDEN>
References: <87622qaszq.fsf@HIDDEN> <aqtxq6e36c.fsf@HIDDEN>
	<20130125000256.GC3397@HIDDEN>
	<s14ni6axzc.fsf@HIDDEN>
X-Spam-Score: 0.7 (/)
X-Debbugs-Envelope-To: 13522
Cc: 13522 <at> debbugs.gnu.org, vincent@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
Reply-To: Eli Zaretskii <eliz@HIDDEN>
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -1.2 (-)

> From: Glenn Morris <rgm@HIDDEN>
> Date: Thu, 24 Jan 2013 19:48:55 -0500
> Cc: 13522 <at> debbugs.gnu.org
> 
> Vincent Lefevre wrote:
> 
> >> I can't reproduce this with 24.2.
> 
> I was using a file in /tmp

I wasn't.

> Using a file in $HOME I can reproduce it.

I can't.  Moreover, the recipe says "Type C-c in the terminal to kill
Emacs", but C-c does not kill Emacs, only C-x C-c does.  And if I type
C-x C-c, I am asked whether to exit without saving etc.  This doesn't
seem to be the described scenario at all.  What am I missing?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#13522; Package emacs. Full text available.
bug Marked as found in versions 24.1. Request was from Glenn Morris <rgm@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
bug Marked as found in versions 23.4. Request was from Glenn Morris <rgm@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
bug Marked as found in versions 23.3. Request was from Glenn Morris <rgm@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
bug Marked as found in versions 23.2. Request was from Glenn Morris <rgm@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
bug Marked as found in versions 23.1. Request was from Glenn Morris <rgm@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 13522 <at> debbugs.gnu.org:


Received: (at 13522) by debbugs.gnu.org; 25 Jan 2013 00:49:04 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 24 19:49:04 2013
Received: from localhost ([127.0.0.1]:48296 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1TyXTc-0004Sx-1T
	for submit <at> debbugs.gnu.org; Thu, 24 Jan 2013 19:49:04 -0500
Received: from fencepost.gnu.org ([208.118.235.10]:32896)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <rgm@HIDDEN>) id 1TyXTa-0004Sq-2c
	for 13522 <at> debbugs.gnu.org; Thu, 24 Jan 2013 19:49:02 -0500
Received: from rgm by fencepost.gnu.org with local (Exim 4.71)
	(envelope-from <rgm@HIDDEN>)
	id 1TyXTT-00016E-NU; Thu, 24 Jan 2013 19:48:55 -0500
From: Glenn Morris <rgm@HIDDEN>
To: Vincent Lefevre <vincent@HIDDEN>
Subject: Re: bug#13522: 24.2;
	save-buffer removes edited file under some conditions
References: <87622qaszq.fsf@HIDDEN> <aqtxq6e36c.fsf@HIDDEN>
	<20130125000256.GC3397@HIDDEN>
X-Spook: weapons of mass destruction Putin Aladdin South Africa
X-Ran: zUE^-y55/ZS8P1|mdxis.wDiF9m6irN^%=1d!biwp*b|e4QFKDs{f9,`CZ*RI$XO.a{v=4
X-Hue: white
X-Debbugs-No-Ack: yes
X-Attribution: GM
Date: Thu, 24 Jan 2013 19:48:55 -0500
In-Reply-To: <20130125000256.GC3397@HIDDEN> (Vincent Lefevre's
	message of "Fri, 25 Jan 2013 01:02:56 +0100")
Message-ID: <s14ni6axzc.fsf@HIDDEN>
User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Spam-Score: -4.2 (----)
X-Debbugs-Envelope-To: 13522
Cc: 13522 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -5.0 (-----)

Vincent Lefevre wrote:

>> I can't reproduce this with 24.2.

I was using a file in /tmp, and apparently Emacs does not make backups
of files in /tmp (normal-backup-enable-predicate; not sure that seems
useful behaviour to me). Using a file in $HOME I can reproduce it.

>> Here I have both "file" and "#file", no "file~".
>
> I have "file~" and "#file#" (with 2 # characters).

(The "#" was just a typo on my part.)




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#13522; Package emacs. Full text available.

Message received at 13522 <at> debbugs.gnu.org:


Received: (at 13522) by debbugs.gnu.org; 25 Jan 2013 00:03:06 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 24 19:03:06 2013
Received: from localhost ([127.0.0.1]:48286 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1TyWl8-0003Ph-E3
	for submit <at> debbugs.gnu.org; Thu, 24 Jan 2013 19:03:06 -0500
Received: from vinc17.pck.nerim.net ([213.41.242.187]:56091
	helo=smtp-xvii.vinc17.net) by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <vincent@HIDDEN>) id 1TyWl5-0003PY-3u
	for 13522 <at> debbugs.gnu.org; Thu, 24 Jan 2013 19:03:04 -0500
Received: by xvii.vinc17.org (Postfix, from userid 1000)
	id 66445314021; Fri, 25 Jan 2013 01:02:56 +0100 (CET)
Date: Fri, 25 Jan 2013 01:02:56 +0100
From: Vincent Lefevre <vincent@HIDDEN>
To: Glenn Morris <rgm@HIDDEN>
Subject: Re: bug#13522: 24.2; save-buffer removes edited file under some
	conditions
Message-ID: <20130125000256.GC3397@HIDDEN>
References: <87622qaszq.fsf@HIDDEN> <aqtxq6e36c.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
In-Reply-To: <aqtxq6e36c.fsf@HIDDEN>
X-Mailer-Info: http://www.vinc17.net/mutt/
User-Agent: Mutt/1.5.21-6294-vl-r57845 (2013-01-23)
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.8 (/)
X-Debbugs-Envelope-To: 13522
Cc: 13522 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -0.0 (/)

On 2013-01-24 15:28:27 -0500, Glenn Morris wrote:
> Vincent Lefevre wrote:
> > 1. Create a file with: printf "\x80" > file
> > 2. Open the file under X Window with: emacs -Q file
> > 3. Modify the file e.g. by adding a space.
> > 4. Type C-x C-s
> >    At this point, Emacs asks the user to select a coding system.
> > 5. Type C-c in the terminal to kill Emacs.
> >
> > The result is that the file "file" is no longer there!

Same problem with the official GNU Emacs 24.2.1 (not Debian's).

> I can't reproduce this with 24.2.
> Here I have both "file" and "#file", no "file~".

I have "file~" and "#file#" (with 2 # characters).

--=20
Vincent Lef=E8vre <vincent@HIDDEN> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#13522; Package emacs. Full text available.

Message received at 13522 <at> debbugs.gnu.org:


Received: (at 13522) by debbugs.gnu.org; 24 Jan 2013 20:28:45 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 24 15:28:44 2013
Received: from localhost ([127.0.0.1]:48181 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1TyTPb-0004zn-Pz
	for submit <at> debbugs.gnu.org; Thu, 24 Jan 2013 15:28:44 -0500
Received: from fencepost.gnu.org ([208.118.235.10]:57321)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <rgm@HIDDEN>) id 1TyTPV-0004zZ-4i
	for 13522 <at> debbugs.gnu.org; Thu, 24 Jan 2013 15:28:38 -0500
Received: from rgm by fencepost.gnu.org with local (Exim 4.71)
	(envelope-from <rgm@HIDDEN>)
	id 1TyTPP-0006VX-8E; Thu, 24 Jan 2013 15:28:27 -0500
From: Glenn Morris <rgm@HIDDEN>
To: Vincent Lefevre <vincent@HIDDEN>
Subject: Re: bug#13522: 24.2;
	save-buffer removes edited file under some conditions
References: <87622qaszq.fsf@HIDDEN>
X-Spook: investigation analyzer cybercash asset mindwar Europol
X-Ran: sdX?s_wKZ]@'^pgWoP)m&umipi-Laqa&ezGj8K%O\'*Tp7p&rEjgq)HkpmEfhh:1pHf^DP
X-Hue: blue
X-Attribution: GM
Date: Thu, 24 Jan 2013 15:28:27 -0500
In-Reply-To: <87622qaszq.fsf@HIDDEN> (Vincent Lefevre's message of
	"Tue, 22 Jan 2013 02:47:37 +0100")
Message-ID: <aqtxq6e36c.fsf@HIDDEN>
User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Spam-Score: -4.2 (----)
X-Debbugs-Envelope-To: 13522
Cc: 13522 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -6.9 (------)

Vincent Lefevre wrote:

> 1. Create a file with: printf "\x80" > file
> 2. Open the file under X Window with: emacs -Q file
> 3. Modify the file e.g. by adding a space.
> 4. Type C-x C-s
>    At this point, Emacs asks the user to select a coding system.
> 5. Type C-c in the terminal to kill Emacs.
>
> The result is that the file "file" is no longer there!

I can't reproduce this with 24.2.
Here I have both "file" and "#file", no "file~".

> Actually there is a backup. Here it is easy to see (file~), but




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#13522; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 22 Jan 2013 01:48:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 21 20:48:57 2013
Received: from localhost ([127.0.0.1]:43798 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1TxSyu-0005q5-Qq
	for submit <at> debbugs.gnu.org; Mon, 21 Jan 2013 20:48:57 -0500
Received: from eggs.gnu.org ([208.118.235.92]:59390)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <vincent@HIDDEN>) id 1TxSys-0005px-Cu
	for submit <at> debbugs.gnu.org; Mon, 21 Jan 2013 20:48:55 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <vincent@HIDDEN>) id 1TxSxm-0000bV-A4
	for submit <at> debbugs.gnu.org; Mon, 21 Jan 2013 20:47:47 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-101.9 required=5.0 tests=BAYES_00, USER_IN_WHITELIST
	autolearn=unavailable version=3.3.2
Received: from lists.gnu.org ([208.118.235.17]:36604)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <vincent@HIDDEN>) id 1TxSxm-0000bP-6l
	for submit <at> debbugs.gnu.org; Mon, 21 Jan 2013 20:47:46 -0500
Received: from eggs.gnu.org ([208.118.235.92]:42513)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <vincent@HIDDEN>) id 1TxSxk-0001oM-JR
	for bug-gnu-emacs@HIDDEN; Mon, 21 Jan 2013 20:47:46 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <vincent@HIDDEN>) id 1TxSxi-0000a6-O5
	for bug-gnu-emacs@HIDDEN; Mon, 21 Jan 2013 20:47:44 -0500
Received: from vinc17.pck.nerim.net ([213.41.242.187]:56968
	helo=smtp-xvii.vinc17.net) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <vincent@HIDDEN>) id 1TxSxi-0000Zj-5h
	for bug-gnu-emacs@HIDDEN; Mon, 21 Jan 2013 20:47:42 -0500
Received: by xvii.vinc17.org (Postfix, from userid 1000)
	id B41F231001E; Tue, 22 Jan 2013 02:47:37 +0100 (CET)
From: Vincent Lefevre <vincent@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 24.2; save-buffer removes edited file under some conditions
Date: Tue, 22 Jan 2013 02:47:37 +0100
Message-ID: <87622qaszq.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 208.118.235.17
X-Spam-Score: -6.9 (------)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -6.9 (------)

1. Create a file with: printf "\x80" > file
2. Open the file under X Window with: emacs -Q file
3. Modify the file e.g. by adding a space.
4. Type C-x C-s
   At this point, Emacs asks the user to select a coding system.
5. Type C-c in the terminal to kill Emacs.

The result is that the file "file" is no longer there!

Actually there is a backup. Here it is easy to see (file~), but
if the user has defined find-backup-file-name, he may not be
aware that there is a backup (as this is not the normal use of
backups since the file hasn't been saved) and may think that the
file has been lost (it took me some time to find out...).

I think that Emacs makes the backup too soon. It should do it only
just before saving.

This might be a variant of the old bug:

  http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=194171


In GNU Emacs 24.2.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.10)
 of 2012-09-11 on xvii, modified by Debian
Windowing system distributor `The X.Org Foundation', version 11.0.11204000
Configured using:
 `configure '--build' 'x86_64-linux-gnu' '--build' 'x86_64-linux-gnu'
 '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib'
 '--localstatedir=/var/lib' '--infodir=/usr/share/info'
 '--mandir=/usr/share/man' '--with-pop=yes'
 '--enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.2/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.2/site-lisp:/usr/share/emacs/site-lisp'
 '--with-crt-dir=/usr/lib/x86_64-linux-gnu' '--with-x=yes'
 '--with-x-toolkit=gtk' '--with-toolkit-scroll-bars'
 'build_alias=x86_64-linux-gnu' 'CFLAGS=-g -O2 -fstack-protector
 --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall'
 'CPPFLAGS=-D_FORTIFY_SOURCE=2''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: POSIX
  value of $LC_CTYPE: en_US.UTF-8
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: en_DK
  value of $LANG: POSIX
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Fundamental

Minor modes in effect:
  tooltip-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
<help-echo> <escape> x r e p o r t - b u <tab> <re
turn>

Recent messages:
Loading /etc/emacs/site-start.d/50html-helper-mode.el (source)...done
Loading /etc/emacs/site-start.d/50latex-cjk-common.el (source)...
Loading cjk-enc...done
Loading /etc/emacs/site-start.d/50latex-cjk-common.el (source)...done
Loading /etc/emacs/site-start.d/50latex-cjk-thai.el (source)...done
Loading /etc/emacs/site-start.d/50psvn.el (source)...done
Loading /etc/emacs/site-start.d/50rnc-mode.el (source)...done
Loading /etc/emacs/site-start.d/50thailatex.el (source)...done
Loading /etc/emacs/site-start.d/50w3m-el.el (source)...done
For information about GNU Emacs and the GNU system, type C-h C-a.

Load-path shadows:
/usr/share/emacs24/site-lisp/css-mode/css-mode hides /usr/share/emacs/site-lisp/css-mode/css-mode
/usr/share/emacs/24.2/site-lisp/debian-startup hides /usr/share/emacs/site-lisp/debian-startup
/usr/share/emacs/site-lisp/autoconf/autotest-mode hides /usr/share/emacs/site-lisp/autotest-mode
/usr/share/emacs/24.2/site-lisp/cmake-data/cmake-mode hides /usr/share/emacs/site-lisp/cmake-mode
/usr/share/emacs24/site-lisp/html-helper-mode/tempo hides /usr/share/emacs/24.2/lisp/tempo
/usr/share/emacs24/site-lisp/flim/hex-util hides /usr/share/emacs/24.2/lisp/hex-util
/usr/share/emacs24/site-lisp/flim/md4 hides /usr/share/emacs/24.2/lisp/md4
/usr/share/emacs24/site-lisp/dictionaries-common/flyspell hides /usr/share/emacs/24.2/lisp/textmodes/flyspell
/usr/share/emacs24/site-lisp/dictionaries-common/ispell hides /usr/share/emacs/24.2/lisp/textmodes/ispell
/usr/share/emacs24/site-lisp/css-mode/css-mode hides /usr/share/emacs/24.2/lisp/textmodes/css-mode
/usr/share/emacs24/site-lisp/flim/hmac-md5 hides /usr/share/emacs/24.2/lisp/net/hmac-md5
/usr/share/emacs24/site-lisp/flim/sasl-ntlm hides /usr/share/emacs/24.2/lisp/net/sasl-ntlm
/usr/share/emacs24/site-lisp/flim/sasl-cram hides /usr/share/emacs/24.2/lisp/net/sasl-cram
/usr/share/emacs24/site-lisp/flim/ntlm hides /usr/share/emacs/24.2/lisp/net/ntlm
/usr/share/emacs24/site-lisp/flim/sasl hides /usr/share/emacs/24.2/lisp/net/sasl
/usr/share/emacs24/site-lisp/flim/hmac-def hides /usr/share/emacs/24.2/lisp/net/hmac-def
/usr/share/emacs24/site-lisp/flim/sasl-digest hides /usr/share/emacs/24.2/lisp/net/sasl-digest
/usr/share/emacs24/site-lisp/latex-cjk-thai/thai-word hides /usr/share/emacs/24.2/lisp/language/thai-word
/usr/share/emacs24/site-lisp/html-helper-mode/html-helper-mode hides /usr/share/emacs/site-lisp/html-helper-mode/html-helper-mode
/usr/share/emacs24/site-lisp/html-helper-mode/hhm-config hides /usr/share/emacs/site-lisp/html-helper-mode/hhm-config
/usr/share/emacs24/site-lisp/html-helper-mode/tempo hides /usr/share/emacs/site-lisp/html-helper-mode/tempo
/usr/share/emacs24/site-lisp/html-helper-mode/visual-basic-mode hides /usr/share/emacs/site-lisp/html-helper-mode/visual-basic-mode

Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
easymenu mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail regexp-opt rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mail-utils w3m-load jabber-autoloads
time-date tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd
tool-bar dnd fontset image fringe lisp-mode register page menu-bar
rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax
facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak
czech european ethiopic indian cyrillic chinese case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer loaddefs button faces
cus-face files text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget hashtable-print-readable backquote
make-network-process dbusbind dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs)




Acknowledgement sent to Vincent Lefevre <vincent@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#13522; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sat, 4 Feb 2017 06:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.