Sam commands within Acme

157 views
Skip to first unread message

Deepanjan Kesh

unread,
May 19, 2022, 8:58:46 AM5/19/22
to plan9port-dev
Hello all,

Let me preface my query by saying that I am relatively new to Acme and Sam, and hence there might be some trivial oversight on my part.

I use Mail in Acme and I want to insert an extra blank line between messages to make them a little more distinguishable. To achieve that, I am using the following command -

    Edit ,x/^[0-9]+\// .,/^[0-9]+\//- x/$\n/ c/\n\n/

Executing the command affects no change at all. I have tried the command

    Edit ,x/^[0-9]+\// .,/^[0-9]+\//- x/$\n/ p

and it prints the newlines, yet the 'c' command after that does not make the desired change.

Any help in this regard would be most appreciated.

Thank you,
Deepanjan Kesh

Russ Cox

unread,
May 19, 2022, 6:31:20 PM5/19/22
to deep...@gmail.com, plan9port-dev
I am not sure if perhaps acme Mail is eating the Edit commands somehow, but I doubt it.
There may or may not be something wrong with the regexp sequence; at first glance it's hard to tell.
A simpler approach might be:

    Edit ,s!(.\n)([0-9]+/)!\1\n\2!g

Best,
Russ


--

---
You received this message because you are subscribed to the Google Groups "plan9port-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to plan9port-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/plan9port-dev/c5042fc8-1efd-452f-b2b5-112edf95ea9en%40googlegroups.com.

Deepanjan Kesh

unread,
May 20, 2022, 6:28:59 AM5/20/22
to plan9port-dev
Dear Russ,

Thank you for your solution - it works. As I am still learning the tools of Plan9 from User Space, it would be nice if I can recognise the mistakes in my expression.

I had copied the text from the Mail window for experimentation to a normal text window, so, as you guessed, the Mail command is not interfering. The way I formulated the expression is as follows. I had printed what the commands are doing at each step and they seem to be doing exactly what they should.

1) I extract the mail identifiers using

    Edit ,x/^[0-9]+\// p

2) I, then, set dot to be the selection from the current mail identifier to the next identifier, sans the last line - this sets the dot to individual mail messages.

    Edit ,x/^[0-9]+\// .,/^[0-9]+\//- p

3) I, next, search for the newline at the end in the current text.


    Edit ,x/^[0-9]+\// .,/^[0-9]+\//- x/$\n/ p

4) Finally, I replace it by two newlines.


    Edit ,x/^[0-9]+\// .,/^[0-9]+\//- x/$\n/ c/\n\n/

If you can isolate my mistake, I really thank for your patience.

Thank you,
Deepanjan Kesh
Reply all
Reply to author
Forward
0 new messages