Handling CRLF line endings

72 views
Skip to first unread message

John Barham

unread,
Jun 18, 2007, 6:00:20 PM6/18/07
to acme-sac
Hi all,

I'm developing Python code in a mostly Windows environment and would
like to try using Acme(-sac) on a day-to-day basis. However, our
codebase has CRLF line endings but Acme seems to assume Unix-style LF-
only line endings inasmuch as it displays the CR character as a
visible glyph. Can I get Acme to automatically convert CRLF line
endings on read and write?

John

Caerwyn Jones

unread,
Jun 18, 2007, 8:45:34 PM6/18/07
to acme...@googlegroups.com
> Can I get Acme to automatically convert CRLF line
> endings on read and write?

See pipefs(4)

Here's an example that worked for me on a directory of RFCs. Where \r
is actually the CR glyph. (The backslash r (\r) doesn't work in the
substitution position of sed, it seems).

Local pipefs -c -r 'sed ''s/\r//''' -w 'sed ''s/$/\r/''' /n/d/library/rfc /n/rfc

Arvindh Rajesh Tamilmani

unread,
Jun 26, 2007, 1:21:12 PM6/26/07
to acme...@googlegroups.com
> I'm developing Python code in a mostly Windows environment and would
> like to try using Acme(-sac) on a day-to-day basis. However, our
> codebase has CRLF line endings but Acme seems to assume Unix-style LF-
> only line endings inasmuch as it displays the CR character as a
> visible glyph.

The following scripts (from /n/sources/rsc/contrib/scripts, slightly
modified for
use with acme-sac) are useful when dealing with Windows files. (\r to be
replaced with the CR glyph.)

Arvindh

% cat /dis/fromdos
#!/dis/sh

for i in $* {
echo ',s/\r//g
w
q' | ed $i >/dev/null
}
% cat /dis/todos
#!/dis/sh

for i in $* {
echo ',s/(^|[^\r])$/&\r/g
w
q' | ed $i >/dev/null
}
% cat /dis/dcr
#!/dis/sh

load std

if{no $acmewin}{
echo dcr: no acmewin >[1=2]
raise 'fail:no acmewin'
}
echo -n ',s/\r//g' >/mnt/acme/$acmewin/edit
% cat /dis/icr
#!/dis/sh

load std

if{no $acmewin}{
echo icr: no acmewin >[1=2]
raise 'fail:no acmewin'
}
echo -n ',s/(^|[^\r])$/&\r/g' >/mnt/acme/$acmewin/edit
%

Reply all
Reply to author
Forward
0 new messages