[Idle-dev] [ idlefork-Bugs-661759 ] IDLE should preserve source files' newline conventions

SourceForge.net noreply@sourceforge.net
Mon, 26 May 2003 14:33:24 -0700


Bugs item #661759, was opened at 2003-01-03 13:11
Message generated for change (Comment added) made by kbk
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=109579&aid=661759&group_id=9579

Category: None
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Andrew Koenig (arkoenig)
Assigned to: Nobody/Anonymous (nobody)
Summary: IDLE should preserve source files' newline conventions

Initial Comment:
If I move a Unix source file to a Windows system (or
vice versa) and use IDLE to edit the file, the changed
file acquires the newline convention of its new host. 
This behavior, though logical, is inconvenient in
heterogeneous environments.

I would like to suggest that when IDLE opens a source
file, it should determine what newline convention the
file uses and preserve that convention when it updates
the file.


----------------------------------------------------------------------

>Comment By: Kurt B. Kaiser (kbk)
Date: 2003-05-26 16:33

Message:
Logged In: YES 
user_id=149084

GvR checked in IOBinding.py 1.14 25Apr

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2003-02-21 12:50

Message:
Logged In: YES 
user_id=6380

Here's a patch for IOBinding.py that does what you want. It
assumes the first line of the file is typical, and on output
converts all line endings to whatever the first line ending
was on input (there's no way to save individual line endings
without displaying them, which would be too ugly).

Please test this on Windows; I've only tested it on Unix.

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2003-02-21 12:34

Message:
Logged In: YES 
user_id=6380

Never mind, Kurt meant 538584.

I looked at the code, and it's a little trickier. It already
understands all types of line endings, but always saves in
native mode.

I'll see how easy it is to save in the original mode (if
unambiguous).

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2003-02-21 12:31

Message:
Logged In: YES 
user_id=6380

I'm with Andrew.

Kurt mentioned this is a duplicate of 838584, but I can't
find an IDLEfork bug, patch or feature request by that number.

We can do this once IDLEfork is integrated into Python 2.3
(which I expect to happen by 2.3b1), or we can do it in
IDLEfork right now and code it in such a way that universal
newlines will only be used in Python >= 2.3.

----------------------------------------------------------------------

Comment By: Andrew Koenig (arkoenig)
Date: 2003-02-21 12:18

Message:
Logged In: YES 
user_id=418174

I think that what you're describing is Idle's current
behavior, and it doesn't work for me.  Two use cases:

1) I use rcp to copy a file from my Unix machine to my
Windows machine, change it there using Idle, and then rcp it
back.  The file is now a Windows file on my Unix machine.

2) I use Idle on my Unix machine to edit a file that is
actually on a Windows machine, mounted via Samba.  The file
is now a Windows file on my Unix machine.

In both of these cases, it would be more useful if Idle were
to remember the file's newline convention and preserve it
when writing back changes. 

----------------------------------------------------------------------

Comment By: Bruce Sherwood (bsherwood)
Date: 2003-01-06 13:18

Message:
Logged In: YES 
user_id=34881

Here's another possibility, one which worked well in the cross-
platform cT programming language environment. Have IDLE 
read any format, but always write in the format of the platform 
on which you're currently running. This has various nice 
properties. In addition to allowing seamless editing on all 
platforms, FTP of a saved file will be done intelligently to a 
different platform, because the local FTP expects the local file 
to be in local format.

----------------------------------------------------------------------

Comment By: Andrew Koenig (arkoenig)
Date: 2003-01-06 12:49

Message:
Logged In: YES 
user_id=418174

The other--and perhaps more useful--alternative would be to
have it check for the presence of universal newline support
and fall back to present behavior if the support is absent.

----------------------------------------------------------------------

Comment By: Kurt B. Kaiser (kbk)
Date: 2003-01-05 17:03

Message:
Logged In: YES 
user_id=149084

Duplicate of 838584

----------------------------------------------------------------------

Comment By: Kurt B. Kaiser (kbk)
Date: 2003-01-03 14:59

Message:
Logged In: YES 
user_id=149084

** GvR Idle-dev:
Until recently this would have been a pain.  As of Python 2.3, it can be done quite conveniently using universal newlines, open(filename,"U"), and the new 'newlines' attribute of resulting file objects.
==========

I suppose that since IDLEfork supports 2.2 that this would be 
deferred until after the merge?
KBK

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=109579&aid=661759&group_id=9579