From: ori@eigenstate.org
To: kvik@a-b.xyz
To: 9front@9front.org
Subject: Re: [9front] [PATCH] ptrap: implement attribute filters
Date: Sat, 05 Dec 2020 09:32:56 -0800 [thread overview]
Message-ID: <0236D9AD4D5FBA15B144E815E3EBCC47@eigenstate.org> (raw)
In-Reply-To: <7FEC8FB4A961AC2CBF0FB20FA1FBCDDB@hog>
Quoth kvik@a-b.xyz:
>
> This adds support for filtering plumbs based on message
> attributes. An example use case is to make a specific
> acme instance display the manual pages produced by
> man -b or plumbing the manual reference words:
>
> ptrap edit '.*' +action '^showdata' +filename '^/man/'
>
> ---
> +
> +next:
> + p = argv[i++];
> + if(p == nil || p[0] != '+'){
> + i--;
> + continue;
> + }
> + p++;
> + fa = emalloc9p(sizeof(FAttr));
> + fa->name = estrdup9p(p);
> + p = argv[i++];
> + if(p[0] == '!'){
> + p++;
> + fa->invert = 1;
> + }
> + if((fa->filt = regcomp(p)) == nil)
> + sysfatal("regcomp: %r");
> + fa->next = f->attr;
> + f->attr = fa;
> +
> + goto next;
> }
> threadpostmountsrv(&ptrapsrv, nil, "/mnt/plumb", MREPL | MCREATE);
>
>
Testing now, though I don't use the filtering *that* heavily,
I mainly use it to prevent acme from becoming an editor.
Looking over the code, only thought is that this bit may read
better as a nested loop, like:
for(; i < argc; i++){
...
}
Other than that, I think this looks good.
next prev parent reply other threads:[~2020-12-05 17:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-05 16:52 kvik
2020-12-05 17:32 ` ori [this message]
2020-12-05 19:07 ` kvik
2020-12-06 0:49 ` ori
2020-12-06 20:55 ` kvik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0236D9AD4D5FBA15B144E815E3EBCC47@eigenstate.org \
--to=ori@eigenstate.org \
--cc=9front@9front.org \
--cc=kvik@a-b.xyz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).