A single-word command to clear a window in Acme.

222 views
Skip to first unread message

Shoce

unread,
Mar 7, 2021, 8:43:42 AM3/7/21
to plan9port-dev
Running commands that produce any output in Acme, a new +Errors window is created with the output. I always add "Edit ,d" to the tag of that window and iterate running the command, inspecting the output and clearing the window with "Edit ,d". I wonder if there is any single-word command that empties a window like "Edit ,d" so i would not need to select that two words but just B2-click. 

Is there a single-word command that clears a window? Can i create that command by my own?

Is there a reason that the command is not available by default in every new +Errors window? May be the way i do it is not the best and better techniques are possible?

Thank you so much! ✊🏽

Jacob Vosmaer

unread,
Mar 7, 2021, 9:36:02 AM3/7/21
to rs...@icloud.com, plan9port-dev
I more or less use https://pkg.go.dev/9fans.net/g...@v0.0.1/acme/Watch for this. 

Had to fix this issue because I did not install p9p in the default directory 



Jacob Vosmaer

On 7 Mar 2021, at 14:43, 'Shoce' via plan9port-dev <plan9p...@googlegroups.com> wrote:

Running commands that produce any output in Acme, a new +Errors window is created with the output. I always add "Edit ,d" to the tag of that window and iterate running the command, inspecting the output and clearing the window with "Edit ,d". I wonder if there is any single-word command that empties a window like "Edit ,d" so i would not need to select that two words but just B2-click. 

Is there a single-word command that clears a window? Can i create that command by my own?

Is there a reason that the command is not available by default in every new +Errors window? May be the way i do it is not the best and better techniques are possible?

Thank you so much! ✊🏽

--

---
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/98f55941-3ccf-4064-bef1-bae0ce4188b0n%40googlegroups.com.

sqweek

unread,
Mar 11, 2021, 9:19:30 AM3/11/21
to rs...@icloud.com, plan9port-dev
On Sun, 7 Mar 2021 at 21:43, 'Shoce' via plan9port-dev <plan9p...@googlegroups.com> wrote:
Running commands that produce any output in Acme, a new +Errors window is created with the output. I always add "Edit ,d" to the tag of that window and iterate running the command, inspecting the output and clearing the window with "Edit ,d". I wonder if there is any single-word command that empties a window like "Edit ,d" so i would not need to select that two words but just B2-click. 

Is there a single-word command that clears a window? Can i create that command by my own?

Note you can leave "Edit ,d" highlighted (by selecting it with B1) and then just B2-click anywhere on the highlighted text. Of course that approach doesn't scale if you want more than one multi-word command easily accessible. You can certainly create your own commands to use with acme - if the word you B2-click on isn't recognised as an internal command then acme will search $PATH for a matching command and run that. So you could create a script called $HOME/bin/Clear for example (assuming $HOME/bin is in your path) which interacts with acme using its filesystem API to erase the text in a window:

#!/usr/local/plan9/bin/rc
# You could also write a bash script, the shell isn't important

# acme sets "winid" in the environment to identify the window a command was run in, this just aborts if running in a different context
[ -n $winid ] || exit 1

# The "," addresses all text in the window, as normal
echo -n , | 9p write acme/$winid/addr

# Replace the addressed text with nothing
echo -n | 9p write acme/$winid/data

See the acme(4) man page for more detail about acme's filesystem interface.
 

Is there a reason that the command is not available by default in every new +Errors window? May be the way i do it is not the best and better techniques are possible?

Jacob already mentioned Watch which is great for eg. recompiling code whenever you make an edit. For me in other scenarios I notice I delete error output interactively as I go once it has served its purpose/been dealt with - in this usage it also becomes a sort of checklist and en-mass deletion is not something I often reach for.

-sqweek

Shoce

unread,
Mar 25, 2021, 1:46:09 PM3/25/21
to plan9port-dev
On Thursday, March 11, 2021 at 7:49:30 PM UTC+5:30 sqweek wrote:

Note you can leave "Edit ,d" highlighted (by selecting it with B1) and then just B2-click anywhere on the highlighted text. Of course that approach doesn't scale if you want more than one multi-word command easily accessible.

Exactly, keeping it always highlighted does not work for me as i edit address line often for adding/removing other commands. So having one-word command that does not need highlighting is desired.
 
You can certainly create your own commands to use with acme - if the word you B2-click on isn't recognised as an internal command then acme will search $PATH for a matching command and run that. So you could create a script called $HOME/bin/Clear for example (assuming $HOME/bin is in your path) which interacts with acme using its filesystem API to erase the text in a window:

#!/usr/local/plan9/bin/rc
# You could also write a bash script, the shell isn't important

# acme sets "winid" in the environment to identify the window a command was run in, this just aborts if running in a different context
[ -n $winid ] || exit 1

# The "," addresses all text in the window, as normal
echo -n , | 9p write acme/$winid/addr

# Replace the addressed text with nothing
echo -n | 9p write acme/$winid/data

See the acme(4) man page for more detail about acme's filesystem interface.

Huge thanks, i had a feeling that a solution like this should be the best available way but did not look into acme(4) man page (facepalm). Now i have exactly this script placed in $home/bin/Clear and use Clear command in every +Errors window. Now i am thinking of how to make this command available in every +Errors window automatically, hehe.
 
Jacob already mentioned Watch which is great for eg. recompiling code whenever you make an edit. For me in other scenarios I notice I delete error output interactively as I go once it has served its purpose/been dealt with - in this usage it also becomes a sort of checklist and en-mass deletion is not something I often reach for.

Well, for me those +Errors windows hold not only compiler output, but also sometimes output from git, grep, bc and others so i want to have more manual control over the +Errors window contents.

🙏🏽
Reply all
Reply to author
Forward
0 new messages