9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] autoroff
@ 2007-03-08 16:49 Russ Cox
  2007-03-08 19:41 ` Anthony Sorace
  2007-03-11  6:58 ` Scott Schwartz
  0 siblings, 2 replies; 7+ messages in thread
From: Russ Cox @ 2007-03-08 16:49 UTC (permalink / raw)
  To: 9fans

One really nice thing about troff is that it is very fast.
It hasn't changed appreciably in decades, so it is riding
out the hardware performance improvements quite nicely.

I was marvelling about how when I middle-click a troff | page
command line in acme it just pops up instantly, and I decided
to write a little shell script to do that for me.

This script watches the acme window it is executed in,
and every time you type a newline or cut/paste with
the mouse, it re-runs troff with the window contents,
updating a postscript file being watched by gv --watch.

There is a slight lag before gv notices the file has
changed, but it's certainly good enough, and even
better than repeatedly clicking Put and then executing
the troff command.

If one were going to write a real command, you'd want
to reroff in the background, waiting for pauses in the
editing.  But for a shell script, this isn't bad.

One unfortunate effect is that because the window is
attached to a program, Undo, Redo, and Put go away
and have to be added on the other side of the tag | .

Enjoy.
Russ


	#!/usr/local/plan9/bin/rc
	
	. $PLAN9/lib/acme.rc
	nl='
	'
	
	tmp=/tmp/autoroff.$pid
	
	fn reroff {
		9p read acme/$winid/body >$tmp.tr
		{ 9 tbl $tmp.tr | 9 troff -ms | tr2post >$tmp.ps_
			&& mv $tmp.ps_ $tmp.ps } >[2]/dev/null
	}
	
	fn event {
		switch($1$2){
		case KI
			if(~ $9 $nl)
				reroff
		case KD MD MI
			reroff
		}
		switch($1$2){
		case Mx MX Ml ML
			winwriteevent $*
		}
	}
	
	if(! winread tag | 9 grep -s Put)
		echo -n ' Put' | winwrite tag
	reroff
	wineventloop &
	psv --watch $tmp.ps
	kill $apid
	killall 9p  # BUG
	rm $tmp.*


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

* Re: [9fans] autoroff
  2007-03-08 16:49 [9fans] autoroff Russ Cox
@ 2007-03-08 19:41 ` Anthony Sorace
  2007-03-08 20:00   ` Russ Cox
  2007-03-11  6:58 ` Scott Schwartz
  1 sibling, 1 reply; 7+ messages in thread
From: Anthony Sorace @ 2007-03-08 19:41 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

very nice indeed.

most of my troff work these days is with man pages. it looks like
replacing the line:
	{ 9 tbl $tmp.tr | 9 troff -ms | tr2post >$tmp.ps_
with
	{ `{doctype $tmp.tr} | tr2post >$tmp.ps_
will get it to use the right macro packages (and other tools as
needed). i also added a ". 9.rc" up front to encourage it to pick up
plan9's troff and friends (since doctype provides command names
without paths).

both the original and my modified version seem to be getting fonts
wrong, with lots of overlap. likely a local issue.


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

* Re: [9fans] autoroff
  2007-03-08 19:41 ` Anthony Sorace
@ 2007-03-08 20:00   ` Russ Cox
  2007-03-08 20:31     ` Anthony Sorace
  0 siblings, 1 reply; 7+ messages in thread
From: Russ Cox @ 2007-03-08 20:00 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Plan9port comes with a different set of Postscript fonts
than Plan 9 does.  If your man page is trying to use the
Plan 9 fonts, it may not be able to find them.

See $PLAN9/man/fonts for incantations (case luxi and
case dejavu) that should be viewable with a stock plan9port.
Since 9 man adds these automatically, you will have to
put them at the top of your file for autoroff to work out.

The corresponding fonts are in subdirectories of
$PLAN9/postscript/font.

Russ


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

* Re: [9fans] autoroff
  2007-03-08 20:00   ` Russ Cox
@ 2007-03-08 20:31     ` Anthony Sorace
  2007-03-08 21:15       ` Russ Cox
  0 siblings, 1 reply; 7+ messages in thread
From: Anthony Sorace @ 2007-03-08 20:31 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

putting psfonts in the pipeline after tr2post causes the correct fonts
to be included. this is also what 9 man does in dopage.
anthony


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

* Re: [9fans] autoroff
  2007-03-08 20:31     ` Anthony Sorace
@ 2007-03-08 21:15       ` Russ Cox
  0 siblings, 0 replies; 7+ messages in thread
From: Russ Cox @ 2007-03-08 21:15 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On 3/8/07, Anthony Sorace <anothy@gmail.com> wrote:
> putting psfonts in the pipeline after tr2post causes the correct fonts
> to be included. this is also what 9 man does in dopage.
> anthony

If you are running psv then they should already
be in the font search path (there is a setting of
GS_FONTPATHS in $PLAN9/bin/psv), but that
may well be wrong for whatever reason.

Russ


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

* Re: [9fans] autoroff
  2007-03-08 16:49 [9fans] autoroff Russ Cox
  2007-03-08 19:41 ` Anthony Sorace
@ 2007-03-11  6:58 ` Scott Schwartz
  2007-03-11  8:08   ` Bakul Shah
  1 sibling, 1 reply; 7+ messages in thread
From: Scott Schwartz @ 2007-03-11  6:58 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

I once read a paper that described how someone repackaged TeX as a
library, so an editor could re-typeset your document on every keystroke
avoiding startup overhead.  On a modern machine it apparently had
very good interactive performance.


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

* Re: [9fans] autoroff
  2007-03-11  6:58 ` Scott Schwartz
@ 2007-03-11  8:08   ` Bakul Shah
  0 siblings, 0 replies; 7+ messages in thread
From: Bakul Shah @ 2007-03-11  8:08 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> I once read a paper that described how someone repackaged TeX as a
> library, so an editor could re-typeset your document on every keystroke
> avoiding startup overhead.  On a modern machine it apparently had
> very good interactive performance.

Perhaps you are thinking of Blue Sky's textures?  That was
quite a few years ago....


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

end of thread, other threads:[~2007-03-11  8:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-08 16:49 [9fans] autoroff Russ Cox
2007-03-08 19:41 ` Anthony Sorace
2007-03-08 20:00   ` Russ Cox
2007-03-08 20:31     ` Anthony Sorace
2007-03-08 21:15       ` Russ Cox
2007-03-11  6:58 ` Scott Schwartz
2007-03-11  8:08   ` Bakul Shah

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).