9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Ben Hancock <ben@benghancock.com>
To: 9fans@9fans.net
Subject: Re: [9fans] Script to apply Edit commands in acme
Date: Thu, 19 Jan 2023 21:25:57 -0800	[thread overview]
Message-ID: <20230119212557.6642fc99@shasta> (raw)
In-Reply-To: <16741207890.71a19d.319186@composer.9fans.topicbox.com>

(Re-posting this message as earlier send appeared to fail; apologies for
any duplication.)

revrari@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

  reply	other threads:[~2023-01-20  5:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-16  3:49 revrari
2023-01-16  8:17 ` sirjofri
2023-01-16  9:06   ` revrari
2023-01-18 16:44     ` Henri Ducrocq
2023-01-18 16:54       ` Paul Lalonde
2023-01-19  9:33         ` revrari
2023-01-20  5:25           ` Ben Hancock [this message]
2023-01-20  7:23             ` igor
2023-01-20 14:24               ` Ben Hancock

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=20230119212557.6642fc99@shasta \
    --to=ben@benghancock.com \
    --cc=9fans@9fans.net \
    /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).