Closed sminez closed 1 week ago
Hey, I saw you just replaced sh with rc in 0b0aa175bfe9ec30b277f3b3caa2acfc334a196b and I wonder if you want to leave it like that for after ? I do believe it's a better shell than sh, but making it a hard dependency might be a hard point
@rakoo getting it to work nicely with sh
(including the prompts) is surprisingly difficult in a terminal application. For now I'm hard coding rc
and the readme includes instructions on how to install it but I may revisit it in the future. The entire program is 150 lines so its not particularly challenging to hack on or write your own alternatives for :slightly_smiling_face:
Wow this is great! Is there a way of sending "Enter" or Execute via 9p? If "+win" is buffer 1 say I can 9p to the body i.e. echo ls | 9p write ad/buffers/1/body This appends "ls" to the end of the repl window i.e. $ ls but doesn't execute it.
Text appended via the filesystem interface is explicitly not executed as I need to avoid trying to execute output as it gets appended to the buffer. If I added Load
and Execute
commands that would work I think but you'd need to select the text you are wanting to work with (similar to how the handler for newline at the end of the file in ad_repl
is working). So something like this:
echo 'ls' | 9p write ad/buffers/1/body
echo '$-' | 9p write ad/buffers/1/addr
echo 'Execute' | 9p write ad/ctl
edit
The addr being set actually needs to be
$-1
not$-
for this to work
@davcam that should work now :+1:
@sminez many thanks for this it is close.
When I execute the three lines
echo 'ls' | 9p write ad/buffers/1/body
echo '$-' | 9p write ad/buffers/1/addr
echo 'Execute' | 9p write ad/ctl
I get the below in the +win window with no errors rather than an ls listing
% ls
%
%
Huh...I ran exactly that and it worked for me. Did you have anything else in the buffer at the point you ran this? I ran things immediately after starting ad_repl
whenever I run
echo 'Execute' | 9p write ad/ctl
it outputs
%
%
irrespective of the previous lines so perhaps my issue is with "Execute" - could this be due to a difference in interaction with p9p? My version of plan9port is 20240617-1 I installed ad and ad_repl by
git clone https://github.com/sminez/ad
cd ad
git checkout repl
cargo install --path ./
cd crates/ad_repl
cargo install --path ./
cargo 1.82.0 (8f40fc59f 2024-08-21) rustc 1.82.0 (f6e511eec 2024-10-15) (Arch Linux rust 1:1.82.0-2)
Ok I think I understand I was missing a step. You need to select 'ls' in the +win window to add it to dot right? Then
echo 'Execute' | 9p write ad/ctl
works for me. Wait no
echo '$-' | 9p write ad/buffers/1/addr
should do that.
Ok I think the issue is that it is skipping to the next line after
echo 'ls' | 9p write ad/buffers/1/body
9p read ad/buffers/1/addr
2:1 This should be line 1 not line 2 So when I set dot
echo '$-' | 9p write ad/buffers/1/addr
9p read ad/buffers/1/addr
I get 2:1,2:1 which is the line below the 'ls'
Oh! Sorry :facepalm: This is what I'm doing:
https://github.com/user-attachments/assets/364900d9-7010-4ac8-a47d-356633d8720b
I messed up the command I gave you: the addr you want to set is $-1
not $-
Thanks yes or
echo -n 'ls' | 9p write ad/buffers/1/body
echo '$-' | 9p write ad/buffers/1/addr
echo 'Execute' | 9p write ad/ctl
also works
Is there any way to change the "current" buffer externally?
I tried writing to it
echo 2 | 9p write ad/buffers/current
but got a permission problem
The idea is to have two ad windows open: the LH one is my code where I select lines to change dot
I then run the mysend script below to send to the RH +win for execution
#!/bin/sh
source "$HOME/.ad/lib/ad.sh"
requireAd
varin=$(bufRead 1 dot)
nlines=$(echo "$varin" | wc -l)
echo "$varin" | bufWrite "$bufid" body
echo '$-'"$nlines" | bufWrite "$bufid" addr
echo '$-'"$nlines"',+'$((nlines-1)) | bufWrite "$bufid" addr
echo 'Execute' | 9p write ad/ctl
At the moment I'm having to click in the RH window so that Execute sends to +win It would be great to be able to modify the current window in the script to save me from moving away from the LH code window.
@davcam you can use the buffer
command along with the id (See Running Built In Commands
in :help
for details of the available builtins)
For other questions like this would you mind raising an issue rather than asking on this PR? I'd prefer to keep the discussion here related to the PR itself :slightly_smiling_face:
This is aiming to be an equivalent to the
win
command that comes with acme.https://github.com/user-attachments/assets/e0fdc7c5-d95b-4e33-ae79-377571e070bb