[PATCH 0/5] lib: make folder: prefix literal

Austin Clements amdragon at MIT.EDU
Tue Feb 4 12:02:50 PST 2014


Quoth Jani Nikula on Feb 01 at  4:54 pm:
> On Fri, 31 Jan 2014, Austin Clements <amdragon at MIT.EDU> wrote:
> > What if we introduce two prefixes, say folder: and path: (maybe dir:?)
> > to address both use cases, each as naturally as possible?  Both would
> > be boolean prefixes because of the limitations of probabilistic
> > prefixes, but we could take advantage of Jani's idea of generating
> > several boolean terms.
> 
> Agreed. On to details:
> 
> > folder: could work the way I suggested (simply the path to the file,
> > with {cur,new} stripped off).
> 
> What if the file is not in a folder named cur/new? I suggest indexing
> the folder as-is, if only for some backwards compatibility.

Agreed.  I believe this will also support MH, if I understand MH
correctly (does anyone actually use MH?)

> What if there is not all of cur/new/tmp folders? I suggest ignoring
> that, and only look at the path to the file being indexed. This is
> simplest to implement, and it does not matter if the sibling directories
> come and go, and for this reason also unsurprising.

That sounds good to me.

> For top level cur/new, index the empty string "".

Yes.

> > path: would support file system search
> > uses.  These seem more varied, but I think fall into exact match and
> > recursive match.  Since I don't have this use case, I can't have any
> > strong opinions about syntax, but I'll throw out an idea: many shells
> > support "**" for recursive path matching and people are already quite
> > familiar with glob patterns for paths, so why not simply adopt this?
> > In other words, when adding the path "a/b/cur/x:2," add path: terms
> > "a/b/cur" and "a/b/**" and "a/**" and "**".
> 
> Since folder: would cover the cur/new cases, I suggest the non-recursive
> variant of path: prefix is the exact filesystem folder name as-is (with
> the top level being the empty string ""). I presume this is what you
> meant too.

Yes.  I suppose I didn't actually say it, but that's what I was
thinking.

> I kind of like the "/**" suffix for recursive, but there's two small
> wrinkles: 1) it needs quoting on the command line (unlike my original
> suggestion of just "/" suffix), and 2) what should the top level
> recursive search be? path:"**" or path:"/**" or path:"./**"? I guess the
> first one is most obvious?

The shell quoting is annoying, but depending on the shell, it should
at least give an error (zsh) or Just Work (apparently bash and sh pass
the unexpanded glob through if it doesn't match anything?).

> So here's what my original suggestions would become:
> 
> >> Here's a thought. With boolean prefix folder:, we can devise a scheme
> >> where the folder: query defines what is to be matched.
> >> 
> >> For example:
> >> 
> >> folder:foo	match files in foo, foo/new, and foo/cur.
> 
> -> folder:foo
> 
> >> folder:foo/	match all files in all subdirectories under foo (this
> >> 		would handle Tomi's use case), including foo/new and foo/cur.
> 
> -> path:"foo/**"
> 
> >> folder:foo/.	match in foo only, and specifically not in foo/cur or foo/new.
> 
> -> path:foo
> 
> >> folder:foo/new  match in foo/new, and specifically not in foo/cur (this
> >> 		allows distinguishing between messages in cur and new).
> 
> -> path:foo/new
> 
> >> folder:/	match everything.
> 
> -> path:"**"
> 
> >> folder:/.	match in top level maildir only.
> 
> -> path:""
> 
> >> folder:""	match in top level maildir, including cur/new.
> 
> -> folder:""
> 
> 
> I'd like these details to be ironed out and agreed on before I send the
> next version.

This all looks good to me.

> BR,
> Jani.


More information about the notmuch mailing list