Re: [9fans] A few more questions about sam

2021-08-06 Thread Stuart Morrow
On 06/08/2021, o...@eigenstate.org  wrote:
> man 6 regexp: http://man.9front.org/6/regexp

I wonder if it would be good if libregexp itself could look for a
fixed string the way Plan 9 grep does: '*foo' is foo.

I've found myself wanting this in Mothra. Can't remember the
circumstance. It might be even more useful in other programs.

Sam and Acme implement regex by themselves so it still wouldn't be
universal in the system.

Might create problems in mk (if anywhere),

but if it works everywhere I don't see what there is to lose.

Nothing that runs, say, sed from within APE is going to be attempting
to start a regex with * in the first place, so that's something that
need not be worried about.

--
9fans: 9fans
Permalink: 
https://9fans.topicbox.com/groups/9fans/T3107cd3bc536dc63-M4b28d60fa00554b77085a929
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription


Re: [9fans] A few more questions about sam

2021-08-06 Thread revcomninos
On Friday, 6 August 2021, at 5:04 PM, ori wrote:
> It will not run in your setup. The version of sam you
decided to use does not support the operators in that
script.
Many thanks for your response. You have answered my questions. 
--
9fans: 9fans
Permalink: 
https://9fans.topicbox.com/groups/9fans/T3107cd3bc536dc63-M141558c47ff1a58c9940c7d9
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription


Re: [9fans] A few more questions about sam

2021-08-06 Thread ori
Quoth revcomni...@gmail.com:
> I am running sam as a standalone on Debian 10:
> https://9fans.github.io/plan9port/
> I have found this version to be stable and would not like to change it.
> I also like the visual display. 
> I start up sam from the terminal with a single option:
> font=/mnt/font/GoMono/14/font sam
> In this scenario, i.e. not running sam on plan9 itself, does
> 
> - (plumb) perform any useful action?

It sends data to the plumber. Plan9port comes
with a plumber, though it doesn't run by default.

> - Is there a way to customise the starting layout of sam? Someone recommended 
> this link:
> http://runjimmyrunrunyoufuckerrun.com/rc/s
> However, I have had difficulty running this script in my setup.

It will not run in your setup. The version of sam you
decided to use does not support the operators in that
script.

> - Does sam have any such a thing as a customisation file, such as .emacs or 
> .vimrc? If so, where can I find any documentation on it? 

No.

> - sam's regex seem to lie somewhere between ed and more recent structural 
> regular expressions, yet is not synonymous with either. Can someone point me 
> to a specific resource that explains these expressions in more detail than 
> does the sam man and sam tut?

man 6 regexp: http://man.9front.org/6/regexp


--
9fans: 9fans
Permalink: 
https://9fans.topicbox.com/groups/9fans/T3107cd3bc536dc63-Mf6311b911b1e626e0cd740dd
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription


Re: [9fans] A few more questions about sam

2021-08-06 Thread revcomninos
On Friday, 6 August 2021, at 2:22 AM, fwrm wrote:
> The command ,x/".+"/ would select every string that begins with a double 
> quote, has one character or more after that, and ends with a double quote. If 
> we wanted to select only the characters inside double quotes, we could reject 
> the double quote character by adding the command y/"/ to the previous one. Or 
> we can also only select the quotes by adding x/"/ instead, if we wanted to 
> change double quotes (that surround one or more characters) to single quotes 
> we could do: ,x/".+"/ x/"/ c/'/ or to capitalize all letters inside quotes 
> (with the unix tool tr(1)) we could do: ,x/".+"/ y/"/ | tr [:lower:] [:upper:]
Excellent examples. Thanks. 
--
9fans: 9fans
Permalink: 
https://9fans.topicbox.com/groups/9fans/T3107cd3bc536dc63-M202c739cc540c35cc01f7c22
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription


Re: [9fans] A few more questions about sam

2021-08-06 Thread revcomninos
Thank you very much for your replies which are extremely helpful. I am going to 
test these solutions and revert back. 
--
9fans: 9fans
Permalink: 
https://9fans.topicbox.com/groups/9fans/T3107cd3bc536dc63-Ma1895276c47f740f67f4c1e2
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription


Re: [9fans] A few more questions about sam

2021-08-05 Thread fwrm via 9fans
4) In ed/awk/grep/etc... regexp is used to "select" *the lines containing it* 
and do stuff, in sam however it's used to describe the shape of string(s) 
themselves you want to "select" (with x and y commands). It doesn't have the 
concept of a line. Your selection can be less than a line, or you can select 
multiple strings that happen to be in different lines. Or multiple lines.

For example, consider this string:
hello "test" bye
"hello" again

The command ,x/".+"/ would select every string that begins with a double quote, 
has one character or more after that, and ends with a double quote. If we 
wanted to select only the characters inside double quotes, we could reject the 
double quote character by adding the command y/"/ to the previous one. Or we 
can also only select the quotes by adding x/"/ instead, if we wanted to change 
double quotes (that surround one or more characters) to single quotes we could 
do: ,x/".+"/ x/"/ c/'/ or to capitalize all letters inside quotes (with the 
unix tool tr(1)) we could do: ,x/".+"/ y/"/ | tr [:lower:] [:upper:]

You can do interesting things with x and y when you combine them with the 
conditionals: g and v.
--
9fans: 9fans
Permalink: 
https://9fans.topicbox.com/groups/9fans/T3107cd3bc536dc63-M6657add7fd6d31ba8f447d79
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription


Re: [9fans] A few more questions about sam

2021-08-05 Thread umbraticus
> Is there a way to customise the starting layout of sam?

I have this patch, which changes the starting geometry of
cmd window and opens files fullscreen immediately instead of
having to sweep a rect:

diff -u /sys/src/cmd/samterm/main.c ./main.c
--- /sys/src/cmd/samterm/main.c Thu Apr 30 10:24:09 2020
+++ ./main.cSat Jan 16 16:08:33 2021
@@ -43,7 +43,7 @@
scratch = alloc(100*RUNESIZE);
nscralloc = 100;
r = screen->r;
-   r.max.y = r.min.y+Dy(r)/5;
+   r.min.x = r.max.x-Dx(r)/4;
flstart(screen->clipr);
rinit();
flnew([0], gettext, 1, );
diff -u /sys/src/cmd/samterm/menu.c ./menu.c
--- /sys/src/cmd/samterm/menu.c Wed Jan 18 13:12:54 2012
+++ ./menu.cMon Jun 21 21:53:12 2021
@@ -205,7 +205,8 @@
Rectangle r;
Text *t;
 
-   if(getr() && (t = malloc(sizeof(Text{
+   r = screen->r;
+   if(t = malloc(sizeof(Text))){
memset((void*)t, 0, sizeof(Text));
current((Flayer *)0);
flnew(>l[0], gettext, 0, (char *)t);

kvik also has some window placement hacks:

https://git.sr.ht/~kvik/ham

There was a video demo somewhere.

To understand sam's automatic window placement around the
cmd window, resize cmd to a square in the centre and
experiment with creating new windows by clicking in various
regions around the square.  There is afaik no way to save &
reproduce window geometry; as mentioned above, I just open
everything fullscreen.

> http://runjimmyrunrunyoufuckerrun.com/rc/s

I wrote this (improvements welcomed) but it relies on the ^
command and $% and $%dot variables which may not exist in
your version of sam.  I believe it was brought to your attention
for these functions, which load a previous editing session:

# ^d [file] # save unwritten changes and dump sam state to file
fn d{
rfork e
switch($#*){
case 0
dump = /tmp/sam.dump
case 1
dump = $1
case *
echo !u d
exit
}
d = `{pwd}
echo 'X/^''/w'
echo !rm -f $dump
echo 'Y/^..\./!echo `{cleanname -d' $d 
'$%}^'':#''^$%dot(2)^'',#''^$%dot(3) >>' $dump
echo 'X/^..\./!echo `{cleanname -d' $d 
'$%}^'':#''^$%dot(2)^'',#''^$%dot(3) >>' $dump
}

# !l [file] # load dump file
fn l{
switch($#*){
case 0
xargs -n1 plumb  Can someone point me to a specific resource that explains
> these expressions in more detail than does the sam man and
> sam tut?

http://sam.cat-v.org/ has a cheat sheet & some other
resources.  What is sam_tut.pdf missing that you would like
to understand?

umbraticus

--
9fans: 9fans
Permalink: 
https://9fans.topicbox.com/groups/9fans/T3107cd3bc536dc63-M51c4690187627a0d4fc416e0
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription