9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] use of plumber for new rule
@ 2022-10-19 13:24 Chris Gorman
  2022-10-20  8:56 ` umbraticus
  0 siblings, 1 reply; 7+ messages in thread
From: Chris Gorman @ 2022-10-19 13:24 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 1920 bytes --]

Hello all,

I am trying to implement a rule that will display dvi files in plumber.  There are currently two rules that cover dvi files.  Neither will allow for rendered displaying via a mouse 3 click in acme.  This does work for ps and pdf files, so I would like to change it to allow for dvi's as well.  My thought is to pass this through a pipe from dvips to page.  I have built and installed kertex thanks to Thierry Laronde.  In a terminal all I have to call is kertex/dvips <filename.dvi> | page.  Unfortunately the logic escapes me on how to do this properly with the plumber.  

I have the following blocks that pertain to the implementation of pdf / ps viewing.

type    is      text
data    matches '[a-zA-Z¡-�0-9_\-.,/]+'
data    matches '([a-zA-Z¡-�0-9_\-.,/]+)\.(ps|PS|eps|EPS|pdf|PDF|dvi|DVI|doc|DOC|epub|EPUB|cb[tz]|CB[TZ])'
arg     isfile  $0
plumb   to      postscript
plumb   start   page -w $file

type    is      text
data    matches '[a-zA-Z¡-�0-9_\-.,/]+'
data    matches '([a-zA-Z¡-�0-9_\-.,/]+)\.(ps|PS|eps|EPS|pdf|PDF|dvi|DVI|doc|DOC|epub|EPUB|cb[tz]|CB[TZ])'
arg     isfile  $0
plumb   to      postscript
plumb   start   page -w $file

dst     is      image
plumb   to      image
plumb   client  page -wi

dst     is      postscript
arg     isfile  $data
plumb   start   page -w $data

These were the settings set by the system.  I have hacked around with them, but can't seem to get a solution and I am sadly not versed  enough with plumb(6).   Does anyone have a hint or idea on how I might accomplish my goal?  Reading man plumb pages as I await a reply.

Thanks in advance,

Chris Gorman









------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tce7385fe52c532d6-M5f805c1f59ac39c459fe847d
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

[-- Attachment #2: Type: text/html, Size: 3074 bytes --]

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

* Re: [9fans] use of plumber for new rule
  2022-10-19 13:24 [9fans] use of plumber for new rule Chris Gorman
@ 2022-10-20  8:56 ` umbraticus
  2022-10-20 13:18   ` Chris Gorman
  0 siblings, 1 reply; 7+ messages in thread
From: umbraticus @ 2022-10-20  8:56 UTC (permalink / raw)
  To: 9fans

Here's my rule for manpages:

data matches (.+)\(([0-9])\)
arg isfile /sys/man/$2/$1
plumb start rc -c 'man -t '$2' '$1' | plumb -id image'

which replumbs the cmd output to the image port; then:

dst is image
plumb to image
plumb client rc -c 'window -r 380 0 1600 900 ''echo -n page >/dev/label; bind /dev/mordor /dev/label; page -i -p180 -m64'''

either sends it to any existing page instance
or else starts a new one to send it to.
Worth noting I am using 9front's version of page,
which listens on the image port; can't recall if the original
listens on the postscript port in a similar way: probably.
If you just want to pop open a new window with
your dvi each time you can use a plumb start rule
that does whatever you want; something like:

data matches '([a-zA-Z¡-�0-9_\-.,/]+)\.(dvi|DVI)'
arg isfile $0
plumb start window kertex/dvips $0 '|' page

There are other workflows too, if what you want is a tight
loop for editing a document and seeing the new version.
Some people use a watch(1) program that runs a command
whenever a given file changes. I prefer to tie the file write
and doc gen to a single command using (9front) sam's ^ cmd,
which sends its output to sam's command window:

^echo w; window troff $% '|' page

The last shell command is remembered, so subsequent
write'n'reviews are a simple ^ thereafter.

umbraticus

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tce7385fe52c532d6-Me347adb350456cff65756620
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

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

* Re: [9fans] use of plumber for new rule
  2022-10-20  8:56 ` umbraticus
@ 2022-10-20 13:18   ` Chris Gorman
  2022-10-20 16:52     ` Chris Gorman
  0 siblings, 1 reply; 7+ messages in thread
From: Chris Gorman @ 2022-10-20 13:18 UTC (permalink / raw)
  To: 9fans

Thank you Umbraticus!

On Thu, Oct 20, 2022 at 4:56 AM <umbraticus@prosimetrum.com> wrote:
>
> Here's my rule for manpages:
>
> data matches (.+)\(([0-9])\)
> arg isfile /sys/man/$2/$1
> plumb start rc -c 'man -t '$2' '$1' | plumb -id image'
>
> which replumbs the cmd output to the image port; then:
>
> dst is image
> plumb to image
> plumb client rc -c 'window -r 380 0 1600 900 ''echo -n page >/dev/label; bind /dev/mordor /dev/label; page -i -p180 -m64'''
>
> either sends it to any existing page instance
> or else starts a new one to send it to.
> Worth noting I am using 9front's version of page,
> which listens on the image port; can't recall if the original
> listens on the postscript port in a similar way: probably.
> If you just want to pop open a new window with
> your dvi each time you can use a plumb start rule
> that does whatever you want; something like:
>
> data matches '([a-zA-Z¡-�0-9_\-.,/]+)\.(dvi|DVI)'
> arg isfile $0
> plumb start window kertex/dvips $0 '|' page
>

This solution works near perfectly for me.  I needed to add a $wdir
before the filename, but otherwise it works!  To be clear, my rule is
now...

data matches '([a-zA-Z¡-�0-9_\-.,/]+)\.(dvi|DVI)'
arg isfile $0
plumb start window kertex/dvips $wdir/$0 '|' page

> There are other workflows too, if what you want is a tight
> loop for editing a document and seeing the new version.
> Some people use a watch(1) program that runs a command
> whenever a given file changes. I prefer to tie the file write
> and doc gen to a single command using (9front) sam's ^ cmd,
> which sends its output to sam's command window:
>
> ^echo w; window troff $% '|' page
>
> The last shell command is remembered, so subsequent
> write'n'reviews are a simple ^ thereafter.

Very nice suggestion.  I will try to put this one in my bag of tricks.

>
> umbraticus

Thank you again.

Take care,

Chris


------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tce7385fe52c532d6-M62d39a71195ef5c3462e8b42
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

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

* Re: [9fans] use of plumber for new rule
  2022-10-20 13:18   ` Chris Gorman
@ 2022-10-20 16:52     ` Chris Gorman
  2022-10-20 17:00       ` umbraticus
  0 siblings, 1 reply; 7+ messages in thread
From: Chris Gorman @ 2022-10-20 16:52 UTC (permalink / raw)
  To: 9fans

A small improvement on the last solution to my problem.

> data matches '([a-zA-Z¡-�0-9_\-.,/]+)\.(dvi|DVI)'
> arg isfile $0
> plumb start window kertex/dvips $wdir/$0 '|' page
>
This solution opens a default sized window and I need to resize it to
see the .dvi.  Instead of a pipe to page, I now use a pipe to plumb
-id image.  This makes a full sized window.  The last line becomes

plumb start window kertex/dvips $wdir/$0 '|' plumb -id image

Chris

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tce7385fe52c532d6-Mc29d1e5d7b39cd973f7d33eb
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

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

* Re: [9fans] use of plumber for new rule
  2022-10-20 16:52     ` Chris Gorman
@ 2022-10-20 17:00       ` umbraticus
  2022-10-20 17:52         ` Chris Gorman
  0 siblings, 1 reply; 7+ messages in thread
From: umbraticus @ 2022-10-20 17:00 UTC (permalink / raw)
  To: 9fans

I think you probably want:

plumb start rc -c 'kertex/divps '$wdir'/'$0' | page -w'

umbraticus

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tce7385fe52c532d6-M95c2618ac3b3dd2f17c75c24
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

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

* Re: [9fans] use of plumber for new rule
  2022-10-20 17:00       ` umbraticus
@ 2022-10-20 17:52         ` Chris Gorman
  2022-10-21  1:10           ` Chris Gorman
  0 siblings, 1 reply; 7+ messages in thread
From: Chris Gorman @ 2022-10-20 17:52 UTC (permalink / raw)
  To: 9fans

Hello again Umbraticus,

Thanks for your email.

On Thu, Oct 20, 2022 at 1:01 PM <umbraticus@prosimetrum.com> wrote:
>
> I think you probably want:
>
> plumb start rc -c 'kertex/divps '$wdir'/'$0' | page -w'

This solution has acme load up the dvi file to edit.  I want to
display the image rendered by page, but after it has been passed
through dvips.  So either

plumb start window kertex/dvips $wdir/$0 '|' page

or

plumb start window kertex/dvips $wdir/$0 '|' page -w

or

plumb start window kertex/dvips $wdir/$0 '|' plumb -id image

have this work for me.  The first one opens a small window, rather
than the full page that is loaded once I have converted the file to a
postscript file.  This can be adjusted to the full window rendering
with the use of page -w, but I can see the initial window that dvips
loaded in the background.  The plumb -id image solution loads up the
initial window, runs dvips and then resizes the window with the output
from the repiping.  Not too sure which solution is the ideal one, but
it's currently working with the pipe to plumb -id.  I'm probably not
explaining myself well enough.  I ideally want the result from
running.

kertex/dvips <filename.dvi> | page -w

which I think I should get running 'plumb start rc -c 'kertex/dvips
'$wdir'/'$0' | page -w', but for some reason it doesn't work. :(

Best,

Chris

> 
> umbraticus

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tce7385fe52c532d6-Mcd186ac9d272297cc3db913f
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

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

* Re: [9fans] use of plumber for new rule
  2022-10-20 17:52         ` Chris Gorman
@ 2022-10-21  1:10           ` Chris Gorman
  0 siblings, 0 replies; 7+ messages in thread
From: Chris Gorman @ 2022-10-21  1:10 UTC (permalink / raw)
  To: 9fans

Hi again Umbraticus,

Sorry for spamming you today.  But I wanted to let you know your
command works and I had made a typo implementing it.
>
> This solution has acme load up the dvi file to edit.  I want to
> display the image rendered by page, but after it has been passed
> through dvips.  So either
>
> plumb start window kertex/dvips $wdir/$0 '|' page
>
> or
>
> plumb start window kertex/dvips $wdir/$0 '|' page -w
>
> or
>
> plumb start window kertex/dvips $wdir/$0 '|' plumb -id image
>
> have this work for me.  The first one opens a small window, rather
> than the full page that is loaded once I have converted the file to a
> postscript file.  This can be adjusted to the full window rendering
> with the use of page -w, but I can see the initial window that dvips
> loaded in the background.  The plumb -id image solution loads up the
> initial window, runs dvips and then resizes the window with the output
> from the repiping.  Not too sure which solution is the ideal one, but
> it's currently working with the pipe to plumb -id.  I'm probably not
> explaining myself well enough.  I ideally want the result from
> running.
>
> kertex/dvips <filename.dvi> | page -w
>
> which I think I should get running 'plumb start rc -c 'kertex/dvips
> '$wdir'/'$0' | page -w', but for some reason it doesn't work. :(

The final plumb command became,

data     matches '([a-zA-Z¡-�0-9_\-.,/]+)\.(dvi|DVI)'
arg isfile $0
plumb start rc -c 'kertex/dvips -q '$wdir'/'$0' | page -w'

My only addition to what you suggested was to run dvips with -q to
suppress the stdout output.  Thanks for the help today.

Take care,

Chris

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tce7385fe52c532d6-M89d36b357efea549a8b62c02
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

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

end of thread, other threads:[~2022-10-21  1:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-19 13:24 [9fans] use of plumber for new rule Chris Gorman
2022-10-20  8:56 ` umbraticus
2022-10-20 13:18   ` Chris Gorman
2022-10-20 16:52     ` Chris Gorman
2022-10-20 17:00       ` umbraticus
2022-10-20 17:52         ` Chris Gorman
2022-10-21  1:10           ` Chris Gorman

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