9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] Minor change to pr(1)
@ 2003-04-18 18:07 David Swasey
  2003-04-18 18:15 ` rsc
  2003-04-22  6:53 ` Lucio De Re
  0 siblings, 2 replies; 3+ messages in thread
From: David Swasey @ 2003-04-18 18:07 UTC (permalink / raw)
  To: 9fans

Please consider changing pr -i to use a single space, rather than a
tab, in the case where one space is needed just before a tab stop.
For example, I would prefer that the output of

	echo 'donttab here' | pr -ti

contains no tabs.  One way to accomplish this is

diff /n/dump/2003/0418/sys/src/cmd/pr.c /sys/src/cmd/pr.c
27c27
< #define ITABS		(Itabn > 0 && Nspace >= (nc = Itabn - Outpos % Itabn))
---
> #define ITABS		(Itabn > 0 && Nspace > 1 && Nspace >= (nc = Itabn - Outpos % Itabn))

In case you are curious, I will explain why I want this.  I must often
edit SML code that uses four space indents and eight space tabs.  (I am
forced to use this horrible indentation scheme.)  My scripts to indent
and unindent blocks of code use pr.  For example, my ind4 is

#!/bin/rc

cat $* |
pr -te |
sed 's/^/    /' |
pr -ti

The problem with using this script on SML code is that SML does not
allow tabs in string literals.  The change to pr avoids this problem
for strings that do not contain a run of spaces and makes the code
look a little better with a proportional font.  For example, if I pipe
the code

val x = "no tabs allowed"

through ind4 I get

    val	x = "no	tabs allowed"

with the stock pr and

    val x = "no tabs allowed"

with a modified pr.  The former is malformed SML.

-dave



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

end of thread, other threads:[~2003-04-22  6:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-18 18:07 [9fans] Minor change to pr(1) David Swasey
2003-04-18 18:15 ` rsc
2003-04-22  6:53 ` Lucio De Re

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 NNTP newsgroup(s).