9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: David Swasey <swasey@cs.cmu.edu>
To: 9fans@cse.psu.edu
Subject: [9fans] Minor change to pr(1)
Date: Fri, 18 Apr 2003 14:07:13 -0400	[thread overview]
Message-ID: <29d74e36513be89fc1fdef0aa4c96dfb@cs.cmu.edu> (raw)

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



             reply	other threads:[~2003-04-18 18:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-18 18:07 David Swasey [this message]
2003-04-18 18:15 ` rsc
2003-04-22  6:53 ` Lucio De Re

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=29d74e36513be89fc1fdef0aa4c96dfb@cs.cmu.edu \
    --to=swasey@cs.cmu.edu \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).