On Friday, November 23, 2001, at 01:33 pm, Ondra Cada wrote:
>
> % alias rewrap sed -f ~/Script/rewrap.sed
Oh, I see what you mean. I didn't get it at first. No, I don't really
like that. It creates two entities, the script and the shell alias. As
sed is ubiquitous, I just wanted one self-contained entity that declared
its origins and function (in the comments) and functioned. Just one thing
to move around among my various systems. You can do this with awk, why
not with sed (haven't seen any sed script examples beginning #!...)
> Or do you need a real script to be able to run it throught NSTask and
> alike?
In the current context I run it through TextExtras, which doesn't care if
it's a script or a command line.
> Strangely, I need this seldom enough to be quite satisfied with the
> quick-and-dirty TextEdit solution (find-and-replace \n\n by blahblah, f&r
> \n
> by space, f&r blahblah by \n\n, manually).
Does TextEdit recognise \n in Find? I've never been able to do this.
>
> OTOH, should I need it as often as you, I would probably write a "smart"
> tool, which would support different ways of re-wrapping, it would also
> clean
> out those CR's from windoze or Classic, etc.
I've found it easier just to clean out Classic and Windows... :-) Just
don't touch 'em, mate. And I'm not sure why you would want different ways
of re-wrapping. This is a tool that simply shifts text out of an
Emacs-like environment, where visible line endings are delineated by \n,
into any of these new-fangled GUI text environments where you-
don't-care-what delineates the visible line endings, as long as you can
trust it to break at a convenient space (so all you need supply is the
space.) (BTW, has anyone noticed the very peculiar ideas that Mail.app
seems to have about breaking lines?)
> And, when run without any switch
> to select a particular behaviour, it would analyze the source file and try
> to guess what the proper operation should be (and then either ask me to
> confirm, or, with a proper switch, use the best guess unattended).
I don't want any interactivity, thanks very much. Quite enough of that
nonsense everywhere else in these so-called modern GUI operating systems.
And if the original text is delineated by anything other than \n, as God
intended, then to hell with it. Or, if you must, normalise the line
endings to \n with a separate tool, and then pipe the output to our baby.
> Of course, such thing would have to be written in ObjC/OpenStep, not to be
> too complicated.
The sed thing is fine -- perfect, in fact. It creates a lightweight,
cross-platform tool that does the job unobtrusively.
--
el bid
|