acme: Getting the address of dot

51 views
Skip to first unread message

Jamie Hall

unread,
May 25, 2025, 9:39:22 AMMay 25
to plan9port-dev
Hi all,

I'm trying to work out the best way to get the address (ideally as character offsets into the window) of the current selection. Using 9fans.net/go/acme, I would have thought the following code would return the address of the selection:

err := win.Ctl("addr=dot")
// handle error
start, end, err := win.ReadAddr()
// handle err

However, this always returns 0, 0, nil. I've tried taking the same actions manually by reading the filesystem, but get the same results. The manual page for the acme filesystem (https://man.cat-v.org/plan_9/4/acme) suggests this is the right approach. Am I missing something?

Jacob Vosmaer

unread,
May 25, 2025, 11:19:17 AMMay 25
to the.sl...@gmail.com, plan9port-dev
I've run into the same problem. It seems that 'addr=dot' correctly updates w->addr.q0 and q1, but then something somewhere resets them to 0, 0.


Op zo 25 mei 2025 om 15:39 schreef Jamie Hall <the.sl...@gmail.com>:
--

---
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 visit https://groups.google.com/d/msgid/plan9port-dev/e41c18ab-c5ba-4fd0-b584-743c9289acf5n%40googlegroups.com.

Mathieu Bivert

unread,
May 25, 2025, 11:36:00 AMMay 25
to con...@jacobvosmaer.nl, the.sl...@gmail.com, plan9port-dev
I've ran into this as well a while ago. a (the?) trick is to have
both files opened at once:

    → echo -n 'addr=dot' | 9p write acme/686/ctl
    → 9p read acme/686/addr
              0           0

fails, but not:

    → set $(echo -n 'addr=dot' | 9p write acme/686/ctl & 9p read acme/686/addr)
    → echo $1:$2
    134:140



Jamie Hall

unread,
May 25, 2025, 9:19:45 PMMay 25
to plan9port-dev
Ah, fantastic. I've managed to achieve the same thing using 9fans.net/go/acme by reading the address (and discarding the result) before setting addr=dot. Thanks!

Connor Taffe

unread,
May 25, 2025, 9:19:48 PMMay 25
to mathieu...@gmail.com, con...@jacobvosmaer.nl, the.sl...@gmail.com, plan9port-dev
Hi folks,

Apparently ctl acts similarly to Plan 9’s /net/tcp/clone; there’s a pattern in rc shell that works with files, the <>[fd]/path/to/file { … }


However if using plan9port without FUSE, there is not an equivalent <>[fd]{9p rw path/to/file}, that syntax simply returns two named pipes and silently ignores the fd number.

My reading of the acme library code is that the new/ctl file is opened on acme.New() and not closed until win.CloseFiles(); so win.ReadAddr() should act accordingly?


Best,
Connor Taffe

On May 25, 2025, at 10:36, Mathieu Bivert <mathieu...@gmail.com> wrote:



Jacob Vosmaer

unread,
May 26, 2025, 3:13:35 AMMay 26
to the.sl...@gmail.com, plan9port-dev
Is this because the 9P protocol uses some sort of "session" concept (the fid?) and the effect of "dot=addr" is local to the session?

Op ma 26 mei 2025 om 03:19 schreef Jamie Hall <the.sl...@gmail.com>:

Anthony Sorace

unread,
May 26, 2025, 1:25:00 PMMay 26
to plan9port-dev
The “session” is the file being held open. This is trivial to do in C (or go, or most non-script programming languages), but is tricky from the shell (and many other scripting languages). Hence the clone dance to hold the file open.

(Note: http, hot https, on that clonedance link.)

On May 26, 2025, at 00:13, Jacob Vosmaer <con...@jacobvosmaer.nl> wrote:



Jacob Vosmaer

unread,
May 26, 2025, 1:52:50 PMMay 26
to plan9port-dev
Right, but there are two files here: acme/$winid/addr and acme/$winid/ctl. What binds them together?

I don't mean to be pedantic; I'm a regular user of plan9port but I have no experiene with actual plan9. I'm curious about the original concepts that plan9port is emulating.

Op ma 26 mei 2025 om 19:25 schreef Anthony Sorace <a...@9srv.net>:
Reply all
Reply to author
Forward
0 new messages