Re: [9fans] Script to apply Edit commands in acme

2023-01-20 Thread Ben Hancock
i...@9lab.org wrote:

> Quoth Ben Hancock :
> […]
> > By the way, […] cleaning whitespace at the end of a newline
> > (Edit ,x/ +$/d), acme does this by default on Put.  
> […]
> 
> Minor correction: There exist ACME patches accomplishing the above.
> Howbeit, ACME does not strip trailing whitespace on Put by default.
> 

Thanks Igor. I'm using the plan9port version of acme, and I typically
run in autoindent mode, which seems to trigger this behavior.

>From the man page:

> When a window is in autoindent mode [...] and a newline character is
> typed, acme copies leading white space on the current line to the new
> line, and when a window is Put, acme removes all trailing end-of-line
> white space before writing the file.  The option -a causes each
> window to start in autoindent mode.

You are indeed correct that when starting without the '-a' flag, this
is not the behavior.

Cheers.

  - Ben


--
9fans: 9fans
Permalink: 
https://9fans.topicbox.com/groups/9fans/Taf408751bc6fb344-Md0954cf3a725613753213c68
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription


Re: [9fans] Script to apply Edit commands in acme

2023-01-19 Thread igor
Quoth Ben Hancock :
[…]
> By the way, […] cleaning whitespace at the end of a newline
> (Edit ,x/ +$/d), acme does this by default on Put.
[…]

Minor correction: There exist ACME patches accomplishing the above.
Howbeit, ACME does not strip trailing whitespace on Put by default.


--
9fans: 9fans
Permalink: 
https://9fans.topicbox.com/groups/9fans/Taf408751bc6fb344-M7878a439846f17b1a1d8594b
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription


Re: [9fans] Script to apply Edit commands in acme

2023-01-19 Thread Ben Hancock
(Re-posting this message as earlier send appeared to fail; apologies for
any duplication.)

revr...@mweb.co.za writes:
> In sam I can create a script file consisting of a list of edit
> commands to apply to the document. [...] I would like to know if such
> a script would require the regular #!/bin/rc heading, and how it
> would be invoked from within acme.

The paradigm is much the same in acme. As noted earlier, the shebang
just determines which shell the script will run in; you can choose
any shell, or use any executable. You'll just want to make sure that
the script is in your $PATH.

For example, you could create this as $HOME/bin/lstrip:

#! /bin/sh
ssam 'x/^ +?/d'

Make it executable, then write some text in acme:

This is
  some text
that will be cleaned

If you select this text, type "|lstrip" in the tag (without the quotes),
and Button-2 (middle click) it, you will get the desired effect:

This is
some text
that will be cleaned

To operate on the entire window, type "Edit ,|lstrip" and execute that
with B2. By the way, as for your other example of cleaning whitespace at
the end of a newline (Edit ,x/ +$/d), acme does this by default on Put.

The other way you might approach this is just to keep a text file of
commonly used commands around. Then you can select the command you want,
and mouse-chord B2-B1 on "Edit" in the tag of the desired window to
execute that command.

  - Ben

--
9fans: 9fans
Permalink: 
https://9fans.topicbox.com/groups/9fans/Taf408751bc6fb344-Mab8c70f37dc76a709197b202
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription


Re: [9fans] Script to apply Edit commands in acme

2023-01-19 Thread revrari
Great tips. Thank you. 
--
9fans: 9fans
Permalink: 
https://9fans.topicbox.com/groups/9fans/Taf408751bc6fb344-M6ae700b031c62aa50ebf7c05
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription


Re: [9fans] Script to apply Edit commands in acme

2023-01-18 Thread Paul Lalonde
You can, of course, execute multiple commands in one Edit, either lineline
or chroding the "{}" block:
Edit {
,x/a/c/b/
,x/d/c/e/
}


On Wed, Jan 18, 2023 at 8:46 AM Henri Ducrocq 
wrote:

> Here is a script I wrote to run any arbitrary command (Edit, Look, etc)
> in a window (current one by default):
>   https://gist.github.com/perpen/9902359ddf09b24129277ce121e3e86d
>
> E.g.: Aexe 'Edit ,blah'
>
> It's quite horrible, as it appends the command to the body to run it
> using an event (would have been simpler running the command from the
> tag, but there is race making that impossible iirc).
>
> I ended up not using it, so it is not much tested. And I wrote it for
> plan 9, not
> sure how that would work with plan9port.
>
> On Mon, Jan 16, 2023 at 9:06 AM  wrote:
> >
> > Great tips. Thank you. I had no idea I could run ed commands that way.
> > 9fans / 9fans / see discussions + participants + delivery options
> Permalink

--
9fans: 9fans
Permalink: 
https://9fans.topicbox.com/groups/9fans/Taf408751bc6fb344-Mfc6d82c231782e86759f2c05
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription


Re: [9fans] Script to apply Edit commands in acme

2023-01-18 Thread Henri Ducrocq
Here is a script I wrote to run any arbitrary command (Edit, Look, etc)
in a window (current one by default):
  https://gist.github.com/perpen/9902359ddf09b24129277ce121e3e86d

E.g.: Aexe 'Edit ,blah'

It's quite horrible, as it appends the command to the body to run it
using an event (would have been simpler running the command from the
tag, but there is race making that impossible iirc).

I ended up not using it, so it is not much tested. And I wrote it for
plan 9, not
sure how that would work with plan9port.

On Mon, Jan 16, 2023 at 9:06 AM  wrote:
>
> Great tips. Thank you. I had no idea I could run ed commands that way.
> 9fans / 9fans / see discussions + participants + delivery options Permalink

--
9fans: 9fans
Permalink: 
https://9fans.topicbox.com/groups/9fans/Taf408751bc6fb344-M11c0f3c688a704b33e48632a
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription


Re: [9fans] Script to apply Edit commands in acme

2023-01-16 Thread revrari
Great tips. Thank you. I had no idea I could run ed commands that way. 
--
9fans: 9fans
Permalink: 
https://9fans.topicbox.com/groups/9fans/Taf408751bc6fb344-M2ed9c18cedf4f94ca36b7c63
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription


Re: [9fans] Script to apply Edit commands in acme

2023-01-16 Thread sirjofri
Hello,

the shebang (#!/bin/rc) just says which shell you want to run it. You could 
also use /bin/ed, if you want to run ed commands, for example.

Acme can do pretty crazy stuff to extend it. For example, you can write your 
own scripts (or programs) in any language you like. Middle-click can execute 
simple programs with no magic. See also /acme/ folder for examples.

There can be simple programs like spell checkers that are just scripts using 
the file path as parameters, and there are more complex programs that actually 
use the acme filesystem to do crazy stuff. For example, you can adjust the 
buffer as you like, write into the tag line whatever you like, capture mouse 
input in the tag line and do whatever you like, oben new acme windows, 

For your specific question about Edit commands, I don't know of a way. However, 
if there is a way I'm sure you can find it in the man pages.

What could work though, is running ssam (or sam) on the data file in your acme 
filesystem. It just exposes an interface for each of your acme windows with a 
few files to control it.

sirjofri

--
9fans: 9fans
Permalink: 
https://9fans.topicbox.com/groups/9fans/Taf408751bc6fb344-M75bfff0a46aceb39fb2713c0
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription