9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] [Patch] acme open filenames with at
@ 2021-02-22 19:37 Philip Silva
  2021-03-02 21:09 ` [9front] " Philip Silva
  0 siblings, 1 reply; 2+ messages in thread
From: Philip Silva @ 2021-02-22 19:37 UTC (permalink / raw)
  To: 9front

Hi!

I've seen in plan9port there's a commit allowing @s in filenames:

commit ac487c754e009b0f3c01c2a8ad5bda2143da4a6b
Author: Russ Cox <rsc@swtch.com>
Date:   Wed Dec 30 14:42:47 2020 -0500

    acme: allow @ in file names

    For upspin and other tools that put email addresses in names.

diff --git a/src/cmd/acme/look.c b/src/cmd/acme/look.c
index 35667c6c..a7172b50 100644
--- a/src/cmd/acme/look.c
+++ b/src/cmd/acme/look.c
@@ -378,7 +378,7 @@ search(Text *ct, Rune *r, uint n)
 int
 isfilec(Rune r)
 {
-       static Rune Lx[] = { '.', '-', '+', '/', ':', 0 };
+       static Rune Lx[] = { '.', '-', '+', '/', ':', '@', 0 };
        if(isalnum(r))
                return TRUE;
        if(runestrchr(Lx, r))

In the Go module paths this is used in path names actually to delimit the version. Here's a patch for this, would be great if it could get merged!

diff -r 318117d314ad sys/src/cmd/acme/look.c
--- a/sys/src/cmd/acme/look.c   Mon Feb 22 19:27:49 2021 +0100
+++ b/sys/src/cmd/acme/look.c   Mon Feb 22 20:23:07 2021 +0100
@@ -314,7 +314,7 @@ isfilec(Rune r)
 {
        if(isalnum(r))
                return TRUE;
-       if(runestrchr(L".-+/:", r))
+       if(runestrchr(L".-+/:@", r))
                return TRUE;
        return FALSE;
 }


Greetings, Philip

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

* [9front] Re: [Patch] acme open filenames with at
  2021-02-22 19:37 [9front] [Patch] acme open filenames with at Philip Silva
@ 2021-03-02 21:09 ` Philip Silva
  0 siblings, 0 replies; 2+ messages in thread
From: Philip Silva @ 2021-03-02 21:09 UTC (permalink / raw)
  To: 9front

Sorry, I forgot to actually test this! Like this it doesn't do much because it interferes with the plumber rule for mails, so here would be an updated patch.

Generally I would find it very really useful because it allows to quickly right-click through references in Go stack traces with modules. (And Go modules seem to replace GOPATH from Go 1.17 on. [1])

E.g.:

github.com/mjl-/duit.(*DUI).Key(0x28220000, 0xa)
        /usr/glenda/go/pkg/mod/github.com/mjl-/duit@v0.0.0-20200330125617-580cb0b2843f/duit.go:578 +0x108
github.com/mjl-/duit.(*DUI).Input(0x28220000, 0x1, 0x0, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0)
        /usr/glenda/go/pkg/mod/github.com/mjl-/duit@v0.0.0-20200330125617-580cb0b2843f/duit.go:684 +0x169

Without the patch I find it really hard to navigate to the referenced code. (Cloning github.com/mjl-/duit.git and navigating there seems simpler to me) The other use case would be browsing through the Go modules directory with acme. E.g. when in directory /usr/glenda/go/pkg/mod/github.com/mjl-/, then there is:

duit@v0.0.0-20200330125617-580cb0b2843f/

And I can just right-click it instead of trying to cd into it. Since it ends with '/' I thought it might make sense to just add a '$' to the end of the email address matcher. The downside is that right-clicking just duit@v0.0.0-20200330125617-580cb0b2843f without trailing slash still applies the mail plumber rule. (Same goes for normal files containing @s but no slash)

So here would be an updated patch that allows to navigate paths containing @s (and /s :-)):

diff -r 100ce3da6613 sys/lib/plumb/basic
--- a/sys/lib/plumb/basic       Tue Mar 02 10:03:25 2021 +0100
+++ b/sys/lib/plumb/basic       Tue Mar 02 21:39:50 2021 +0100
@@ -29,7 +29,7 @@

 # email addresses get a new mail window
 type is text
-data matches '[a-zA-Z0-9_+.\-]+@[a-zA-Z0-9_+.\-]*'
+data matches '[a-zA-Z0-9_+.\-]+@[a-zA-Z0-9_+.\-]*$'
 plumb to sendmail
 plumb start window rc -c '''echo % mail '''$0'; mail '$0

diff -r 100ce3da6613 sys/src/cmd/acme/look.c
--- a/sys/src/cmd/acme/look.c   Tue Mar 02 10:03:25 2021 +0100
+++ b/sys/src/cmd/acme/look.c   Tue Mar 02 21:39:50 2021 +0100
@@ -314,7 +314,7 @@
 {
        if(isalnum(r))
                return TRUE;
-       if(runestrchr(L".-+/:", r))
+       if(runestrchr(L".-+/:@", r))
                return TRUE;
        return FALSE;
 }

In any case I'll try this out for a while, maybe there's a better solution that also works without trailing slashes.

Greetings, Philip


[1] https://blog.golang.org/go116-module-changes


‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
Am Montag, 22. Februar 2021 20:37 schrieb Philip Silva <philip.silva@protonmail.com>:

> Hi!
>
> I've seen in plan9port there's a commit allowing @s in filenames:
>
> commit ac487c754e009b0f3c01c2a8ad5bda2143da4a6b
> Author: Russ Cox rsc@swtch.com
> Date: Wed Dec 30 14:42:47 2020 -0500
>
> acme: allow @ in file names
>
> For upspin and other tools that put email addresses in names.
>
> diff --git a/src/cmd/acme/look.c b/src/cmd/acme/look.c
> index 35667c6c..a7172b50 100644
> --- a/src/cmd/acme/look.c
> +++ b/src/cmd/acme/look.c
> @@ -378,7 +378,7 @@ search(Text *ct, Rune *r, uint n)
> int
> isfilec(Rune r)
> {
>
> -         static Rune Lx[] = { '.', '-', '+', '/', ':', 0 };
>
>
>
> -         static Rune Lx[] = { '.', '-', '+', '/', ':', '@', 0 };
>           if(isalnum(r))
>                   return TRUE;
>           if(runestrchr(Lx, r))
>
>
>
> In the Go module paths this is used in path names actually to delimit the version. Here's a patch for this, would be great if it could get merged!
>
> diff -r 318117d314ad sys/src/cmd/acme/look.c
> --- a/sys/src/cmd/acme/look.c Mon Feb 22 19:27:49 2021 +0100
> +++ b/sys/src/cmd/acme/look.c Mon Feb 22 20:23:07 2021 +0100
> @@ -314,7 +314,7 @@ isfilec(Rune r)
> {
> if(isalnum(r))
> return TRUE;
>
> -         if(runestrchr(L".-+/:", r))
>
>
>
> -         if(runestrchr(L".-+/:@", r))
>                   return TRUE;
>           return FALSE;
>
>
>
> }
>
> Greetings, Philip



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

end of thread, other threads:[~2021-03-02 21:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-22 19:37 [9front] [Patch] acme open filenames with at Philip Silva
2021-03-02 21:09 ` [9front] " Philip Silva

9front - general discussion about 9front

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/9front

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

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


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