9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] A few more questions about sam 
@ 2021-08-05 16:12 revcomninos
  2021-08-05 19:42 ` umbraticus
  2021-08-06 15:04 ` ori
  0 siblings, 2 replies; 8+ messages in thread
From: revcomninos @ 2021-08-05 16:12 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 1204 bytes --]

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?
- 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.
- 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? 
- 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?

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

[-- Attachment #2: Type: text/html, Size: 2016 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [9fans] A few more questions about sam
  2021-08-05 16:12 [9fans] A few more questions about sam revcomninos
@ 2021-08-05 19:42 ` umbraticus
  2021-08-06  0:22   ` fwrm via 9fans
  2021-08-06 15:04 ` ori
  1 sibling, 1 reply; 8+ messages in thread
From: umbraticus @ 2021-08-05 19:42 UTC (permalink / raw)
  To: 9fans

> 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.c    Sat 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(&cmd.rasp);
        flnew(&cmd.l[0], gettext, 1, &cmd);
diff -u /sys/src/cmd/samterm/menu.c ./menu.c
--- /sys/src/cmd/samterm/menu.c Wed Jan 18 13:12:54 2012
+++ ./menu.c    Mon Jun 21 21:53:12 2021
@@ -205,7 +205,8 @@
        Rectangle r;
        Text *t;
 
-       if(getr(&r) && (t = malloc(sizeof(Text)))){
+       r = screen->r;
+       if(t = malloc(sizeof(Text))){
                memset((void*)t, 0, sizeof(Text));
                current((Flayer *)0);
                flnew(&t->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 </tmp/sam.dump
        case 1
                xargs -n1 plumb <$1
        case *
                u l
        }
}

> 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [9fans] A few more questions about sam
  2021-08-05 19:42 ` umbraticus
@ 2021-08-06  0:22   ` fwrm via 9fans
  2021-08-06  7:45     ` revcomninos
  2021-08-06  9:20     ` revcomninos
  0 siblings, 2 replies; 8+ messages in thread
From: fwrm via 9fans @ 2021-08-06  0:22 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 1394 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 2110 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [9fans] A few more questions about sam
  2021-08-06  0:22   ` fwrm via 9fans
@ 2021-08-06  7:45     ` revcomninos
  2021-08-06  9:20     ` revcomninos
  1 sibling, 0 replies; 8+ messages in thread
From: revcomninos @ 2021-08-06  7:45 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 347 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 845 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [9fans] A few more questions about sam
  2021-08-06  0:22   ` fwrm via 9fans
  2021-08-06  7:45     ` revcomninos
@ 2021-08-06  9:20     ` revcomninos
  1 sibling, 0 replies; 8+ messages in thread
From: revcomninos @ 2021-08-06  9:20 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 924 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 1535 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [9fans] A few more questions about sam
  2021-08-05 16:12 [9fans] A few more questions about sam revcomninos
  2021-08-05 19:42 ` umbraticus
@ 2021-08-06 15:04 ` ori
  2021-08-06 17:22   ` revcomninos
  2021-08-06 19:20   ` Stuart Morrow
  1 sibling, 2 replies; 8+ messages in thread
From: ori @ 2021-08-06 15:04 UTC (permalink / raw)
  To: 9fans

Quoth revcomninos@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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [9fans] A few more questions about sam
  2021-08-06 15:04 ` ori
@ 2021-08-06 17:22   ` revcomninos
  2021-08-06 19:20   ` Stuart Morrow
  1 sibling, 0 replies; 8+ messages in thread
From: revcomninos @ 2021-08-06 17:22 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 463 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 1009 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [9fans] A few more questions about sam
  2021-08-06 15:04 ` ori
  2021-08-06 17:22   ` revcomninos
@ 2021-08-06 19:20   ` Stuart Morrow
  1 sibling, 0 replies; 8+ messages in thread
From: Stuart Morrow @ 2021-08-06 19:20 UTC (permalink / raw)
  To: 9fans

On 06/08/2021, ori@eigenstate.org <ori@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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-08-06 19:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-05 16:12 [9fans] A few more questions about sam revcomninos
2021-08-05 19:42 ` umbraticus
2021-08-06  0:22   ` fwrm via 9fans
2021-08-06  7:45     ` revcomninos
2021-08-06  9:20     ` revcomninos
2021-08-06 15:04 ` ori
2021-08-06 17:22   ` revcomninos
2021-08-06 19:20   ` Stuart Morrow

9fans - fans of the OS Plan 9 from Bell Labs

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.vuxu.org/9fans

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 9fans 9fans/ https://inbox.vuxu.org/9fans \
		9fans@9fans.net
	public-inbox-index 9fans

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.9fans


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git