9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] Using Guide Files
@ 2009-08-10  8:46 Aaron W. Hsu
  2009-08-10  9:09 ` Noah Evans
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Aaron W. Hsu @ 2009-08-10  8:46 UTC (permalink / raw)
  To: 9fans

Hello,

When using guide files, let's say I have some Edit command or the like
that I run often on certain types of files. So I have the guide file open,
and I can copy the command over to the tag line of the file I want to
edit, but it would be faster if I could just run the command in the
context of some arbitrary window. Is this possible? If not, does one
normally just copy over text to the tag line when it needs to be used?

	Aaron W. Hsu


--
Of all tyrannies, a tyranny sincerely exercised for the good of its
victims may be the most oppressive. -- C. S. Lewis



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

* Re: [9fans] Using Guide Files
  2009-08-10  8:46 [9fans] Using Guide Files Aaron W. Hsu
@ 2009-08-10  9:09 ` Noah Evans
  2009-08-10 12:03 ` Rudolf Sykora
  2009-08-10 13:11 ` Jason Catena
  2 siblings, 0 replies; 13+ messages in thread
From: Noah Evans @ 2009-08-10  9:09 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Do you know the 2-1 chord? Try putting an Edit in the tag, then
leaving the Edit commands in your guide.

On Mon, Aug 10, 2009 at 10:46 AM, Aaron W. Hsu<arcfide@sacrideo.us> wrote:
> Hello,
>
> When using guide files, let's say I have some Edit command or the like that
> I run often on certain types of files. So I have the guide file open, and I
> can copy the command over to the tag line of the file I want to edit, but it
> would be faster if I could just run the command in the context of some
> arbitrary window. Is this possible? If not, does one normally just copy over
> text to the tag line when it needs to be used?
>
>        Aaron W. Hsu
>
>
> --
> Of all tyrannies, a tyranny sincerely exercised for the good of its victims
> may be the most oppressive. -- C. S. Lewis
>
>



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

* Re: [9fans] Using Guide Files
  2009-08-10  8:46 [9fans] Using Guide Files Aaron W. Hsu
  2009-08-10  9:09 ` Noah Evans
@ 2009-08-10 12:03 ` Rudolf Sykora
  2009-08-10 13:11 ` Jason Catena
  2 siblings, 0 replies; 13+ messages in thread
From: Rudolf Sykora @ 2009-08-10 12:03 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Also check the Run script we discussed earlier in this forum. Could be
of help...
Ruda

2009/8/10 Aaron W. Hsu <arcfide@sacrideo.us>:
> Hello,
>
> When using guide files, let's say I have some Edit command or the like that
> I run often on certain types of files. So I have the guide file open, and I
> can copy the command over to the tag line of the file I want to edit, but it
> would be faster if I could just run the command in the context of some
> arbitrary window. Is this possible? If not, does one normally just copy over
> text to the tag line when it needs to be used?
>
>        Aaron W. Hsu



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

* Re: [9fans] Using Guide Files
  2009-08-10  8:46 [9fans] Using Guide Files Aaron W. Hsu
  2009-08-10  9:09 ` Noah Evans
  2009-08-10 12:03 ` Rudolf Sykora
@ 2009-08-10 13:11 ` Jason Catena
  2009-08-10 13:35   ` Rudolf Sykora
  2 siblings, 1 reply; 13+ messages in thread
From: Jason Catena @ 2009-08-10 13:11 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> just run the command in the context of some
> arbitrary window.

Wily does this.  The 2-1 chord uses the context of the object applied
to the command, rather than the command.

This makes commands like New useful from the top of a column.  When
you type in a new file name in its directory, highlight the name,
apply it with 2-1 to New atop the column, then a new file is created
in the directory where you selected the new filename, not the
directory from which you started acme.

This also makes centralized guide files more useful: you can write a
command once for very many directories.  When you select a file in a
directory window, and apply it to the single, centralized guide file
in a different directory, the command runs in the selected file's
window rather than the guide's.

After switching to acme, I've say that if you can write a guide file
into the directory you're working with, you end up with smaller guide
files, which usually works faster.  However, with directories you
can't write to, you have to store the guide somewhere else, which
means you have to copy the command into the context you work with to
apply it to a selection in that directory's window.  With commands
that apply across a directory tree (eg version control), this can
result in some duplication, which means if you change an idiom you
might end up updating all its guides (or inadvertently use the old
idiom).

Edit can apply a sam command (which selects its range) to the entire
file.  Run can apply a shell command to a directory, or directory
context of a file.  But in each case, you can't select a range of text
or a file name within the window to use as the target of the
operation, since you're using the select-appy operation to figure out
which command to do.

For example, I often run "|fmt -w 72" to justify a paragraph in a text
file.  With wily, I can highlight text in any window, and justify the
text from one copy of the command stored in any guide file.  With
acme, I can't apply this command to highlighted text until I copy the
command to the particular window (tag or body) that needs it.  I can't
even use it from a guide file in the current directory: if I sweep
some text in a window, then apply that text to a pipe command in a
guide file in the current directory, the pipe command runs against its
own line in the guide file.

So from the standpoint of having used Wily for years, acme requires
more cutting and pasting, and some commands don't seem directly useful
in place.  For example, to use New without copying it somewhere else
or retyping it, you must know and type (or get on the screen in some
way) the path between the directory where you started acme and the
directory where you want the file.

Jason Catena



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

* Re: [9fans] Using Guide Files
  2009-08-10 13:11 ` Jason Catena
@ 2009-08-10 13:35   ` Rudolf Sykora
  2009-08-10 14:05     ` Jason Catena
  2009-08-12  3:08     ` 6o205zd02
  0 siblings, 2 replies; 13+ messages in thread
From: Rudolf Sykora @ 2009-08-10 13:35 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

A few words pertaining one of your points.

2009/8/10 Jason Catena <jason.catena@gmail.com>:

> For example, I often run "|fmt -w 72" to justify a paragraph in a text
> file.  With wily, I can highlight text in any window, and justify the
> text from one copy of the command stored in any guide file.  With
> acme, I can't apply this command to highlighted text until I copy the
> command to the particular window (tag or body) that needs it.  I can't
> even use it from a guide file in the current directory: if I sweep
> some text in a window, then apply that text to a pipe command in a
> guide file in the current directory, the pipe command runs against its
> own line in the guide file.

I can have that '|fmt -w 72' anywhere in any window, but other than
where my text is. I ensure I have 'Edit' in the tag line of the text
window. I highlight the text I want be formatted. I go to the window
with the command, |fmt -w 72. I highlight that. I go back to the Edit
in the text's window. I 2-1 chord on that Edit. And it does do, what
you want. Or not? Where is the trouble?

Ruda



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

* Re: [9fans] Using Guide Files
  2009-08-10 13:35   ` Rudolf Sykora
@ 2009-08-10 14:05     ` Jason Catena
  2009-08-10 14:18       ` erik quanstrom
  2009-08-10 14:22       ` Rudolf Sykora
  2009-08-12  3:08     ` 6o205zd02
  1 sibling, 2 replies; 13+ messages in thread
From: Jason Catena @ 2009-08-10 14:05 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> I can have that '|fmt -w 72' anywhere in any window, but other than
> where my text is. I ensure I have 'Edit' in the tag line of the text
> window. I highlight the text I want be formatted. I go to the window
> with the command, |fmt -w 72. I highlight that. I go back to the Edit
> in the text's window. I 2-1 chord on that Edit. And it does do, what
> you want. Or not? Where is the trouble?

And so it does.  I assumed I could only use Edit in conjunction with
sam commands, but apparently Edit (or at least its author) is smarter
than that.

I assume Run works similarly? That is, I can put Run in a directory's
tag, highlight a filename in that directory, then highlight a command
and apply it to Run with 2-1 to run the command on the file?

> Ruda

Thanks, I'm a happier acme user now.

Jason Catena



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

* Re: [9fans] Using Guide Files
  2009-08-10 14:05     ` Jason Catena
@ 2009-08-10 14:18       ` erik quanstrom
  2009-08-10 14:22       ` Rudolf Sykora
  1 sibling, 0 replies; 13+ messages in thread
From: erik quanstrom @ 2009-08-10 14:18 UTC (permalink / raw)
  To: 9fans

> I assume Run works similarly? That is, I can put Run in a directory's
> tag, highlight a filename in that directory, then highlight a command
> and apply it to Run with 2-1 to run the command on the file?

posting to 9fans is now easier than typing 3 characters and three
mouse actions.  wow!

- erik



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

* Re: [9fans] Using Guide Files
  2009-08-10 14:05     ` Jason Catena
  2009-08-10 14:18       ` erik quanstrom
@ 2009-08-10 14:22       ` Rudolf Sykora
  2009-08-10 18:37         ` Jason Catena
  1 sibling, 1 reply; 13+ messages in thread
From: Rudolf Sykora @ 2009-08-10 14:22 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

2009/8/10 Jason Catena <jason.catena@gmail.com>:
> And so it does.  I assumed I could only use Edit in conjunction with
> sam commands, but apparently Edit (or at least its author) is smarter
> than that.

Well, I'd say, that |... thing still _is_ a sam command..., only
delivered to the Edit command via the chord now.
(Although, in acme this one (like >, <) can be used without the Edit command)

> I assume Run works similarly? That is, I can put Run in a directory's
> tag, highlight a filename in that directory, then highlight a command
> and apply it to Run with 2-1 to run the command on the file?

I don't know how well the Run script (note that it is _not_ a part of
acme; it was designed by Russ Cox just a couple of months ago, thus
you must really get it first in order to use it) can be used in
directory listing windows.

Otherwise I use it in the much same way as the Edit command. While
Edit understands sam commands, Run can run any series of commands,
like multiline awk script, for example. Find it in the forum.

Ruda



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

* Re: [9fans] Using Guide Files
  2009-08-10 14:22       ` Rudolf Sykora
@ 2009-08-10 18:37         ` Jason Catena
  0 siblings, 0 replies; 13+ messages in thread
From: Jason Catena @ 2009-08-10 18:37 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> Find it in the forum.

A search for "Run title" uniquely found Russ' post.
http://9fans.net/archive/2009/06/138 (Well, it did until this post.)
Once I installed Run and studied Russ' illustration, I can set up my
own commands, thanks.

In acme I highlight some text to process (filenames, data, whatever);
highlight (if not already) in the guide file a command that (with
xargs' help) takes stdin, and its carriage return; highlight the name
of the guide file and 2-1 it to |Run or >Run in the tag of the first
window.

wily simplifies this particular operation a bit, by bringing it inside
the program: the name of the guide file (or scratch buffer containing
commands) is not highlighted by the user.  In wily, I'd highlight the
text to process, 2-highlight the command (with | or >) to run on it
(with or without a carriage return) if not already highlighted, then
chord-1-and-release to execute the command.

Jason Catena



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

* Re: [9fans] Using Guide Files
  2009-08-10 13:35   ` Rudolf Sykora
  2009-08-10 14:05     ` Jason Catena
@ 2009-08-12  3:08     ` 6o205zd02
  2009-08-12  3:16       ` Jason Catena
  2009-08-14 17:57       ` yy
  1 sibling, 2 replies; 13+ messages in thread
From: 6o205zd02 @ 2009-08-12  3:08 UTC (permalink / raw)
  To: 9fans

On Mon, 2009-08-10 at 15:35 +0200, Rudolf Sykora
rudolf.sykora-at-gmail.com |9fans| wrote:
> I can have that '|fmt -w 72' anywhere in any window, but other than
> where my text is. I ensure I have 'Edit' in the tag line of the text
> window. I highlight the text I want be formatted. I go to the window
> with the command, |fmt -w 72. I highlight that. I go back to the Edit
> in the text's window. I 2-1 chord on that Edit. And it does do, what
> you want. Or not? Where is the trouble?
>
> Ruda
>

Wow, this is great.  I've been using acme (from P9P( for a while, and
wily before that, but I never knew that would work.  I type all my |
commands in the main tag so that I can use them in any window, but this
will be easier.

Given how useful and important it is to have Edit in the tag of text
windows, is there some reason that it isn't there automatically?

	thanks,
	Peter Canning





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

* Re: [9fans] Using Guide Files
  2009-08-12  3:08     ` 6o205zd02
@ 2009-08-12  3:16       ` Jason Catena
  2009-08-12  3:22         ` erik quanstrom
  2009-08-14 17:57       ` yy
  1 sibling, 1 reply; 13+ messages in thread
From: Jason Catena @ 2009-08-12  3:16 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> Given how useful and important it is to have Edit in the tag of text
> windows, is there some reason that it isn't there automatically?

Probably to avoid temptation for files you shouldn't, and see at a
glance which files you edited and saved (since the dirty bit will be
clear).

>        thanks,
>        Peter Canning

Jason Catena



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

* Re: [9fans] Using Guide Files
  2009-08-12  3:16       ` Jason Catena
@ 2009-08-12  3:22         ` erik quanstrom
  0 siblings, 0 replies; 13+ messages in thread
From: erik quanstrom @ 2009-08-12  3:22 UTC (permalink / raw)
  To: 9fans

On Tue Aug 11 23:18:02 EDT 2009, jason.catena@gmail.com wrote:
> > Given how useful and important it is to have Edit in the tag of text
> > windows, is there some reason that it isn't there automatically?
>
> Probably to avoid temptation for files you shouldn't, and see at a
> glance which files you edited and saved (since the dirty bit will be
> clear).

all this time i thought r got together with p&t to see how many times
he could get us to type "Edit".  it's one of those elaborate p&t practical
jokes.  it's all an elaborate play on the term "practical joke," being so
impractical.

- erik



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

* Re: [9fans] Using Guide Files
  2009-08-12  3:08     ` 6o205zd02
  2009-08-12  3:16       ` Jason Catena
@ 2009-08-14 17:57       ` yy
  1 sibling, 0 replies; 13+ messages in thread
From: yy @ 2009-08-14 17:57 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

2009/8/12  <6o205zd02@sneakemail.com>:
> Given how useful and important it is to have Edit in the tag of text
> windows, is there some reason that it isn't there automatically?

After this discussion, I wrote a little patch, which somebody else
might find useful:

; diff /sys/src/cmd/acme/exec.c src/acme/exec.c
70a71
> 	{ L"|",		edit,		FALSE,	XXX,		XXX		},
149c150,152
< 	e = lookup(r, q1-q0);
---
> 	e = nil;
> 	if(runestrncmp(r, L"|", 1) != 0 || q1-q0 == 1)
> 		e = lookup(r, q1-q0);

What it does is to interpret the pipe symbol '|' like the Edit command
when that is the only selection. That way, you can make the 2-1 chord
with Edit commands in every text window. I know it is a bit too
obscure, but very convenient, since the symbol is *always* in the
window - around the middle of the tag bar surrounded by spaces - and
it does not have any other use (you won't be using it to name
executable files). Maybe somebody else wants to give it a try.

--
- yiyus || JGL . 4l77.com



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

end of thread, other threads:[~2009-08-14 17:57 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-10  8:46 [9fans] Using Guide Files Aaron W. Hsu
2009-08-10  9:09 ` Noah Evans
2009-08-10 12:03 ` Rudolf Sykora
2009-08-10 13:11 ` Jason Catena
2009-08-10 13:35   ` Rudolf Sykora
2009-08-10 14:05     ` Jason Catena
2009-08-10 14:18       ` erik quanstrom
2009-08-10 14:22       ` Rudolf Sykora
2009-08-10 18:37         ` Jason Catena
2009-08-12  3:08     ` 6o205zd02
2009-08-12  3:16       ` Jason Catena
2009-08-12  3:22         ` erik quanstrom
2009-08-14 17:57       ` yy

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