build 1573 - lightweight Spotlight integration

Alpha/Beta versions for early access to new half-cooked features
User avatar
mike
Posts: 1060
Joined: Thu Jul 16, 2015 5:35 am
Location: Exeter, UK

build 1573 - lightweight Spotlight integration

Post by mike » Mon Apr 18, 2016 4:44 am

Hi everybody!

Here's the next preview build with some Spotlight integration (http://filesmanager.info/forum/viewtopic.php?f=6&t=87):
http://filesmanager.info/downloads/prev ... (1573).zip

Spotlight search popup is set on ALT+CMD+F hotkey by default.
Search itself is based on kMDItemFSName, not on item's content.
Spotlight query format can be changed via config at "filePanel.spotlight.format" (no UI currently), by default this value is
"kMDItemFSName == '*#{query}*'cd" - simply searches for items with filenames containing entered search criteria (ignorant to case and diacritical marks).

Mike.

sasha
Posts: 168
Joined: Wed Feb 17, 2016 4:59 pm

Re: build 1573 - lightweight Spotlight integration

Post by sasha » Mon Apr 18, 2016 9:12 pm

Hi Mike,

I've been looking forward to this, thanks for adding it so quickly. Here are some thoughts about it. The default setting

"kMDItemFSName == '*#{query}*'cd"

works fine. Same goes for other "kMDItem*" attributes I've tried (a good overview is given in http://osxnotes.net/spotlight.html). What I'm looking for is getting results from terminal command "mdfind -name ...". So I changed filePanel.spotlight.format to

"-name #{query}"

but this crashes NC instantly. Am I missing something? As you indicated, GUI-based settings would be nice.

Also, a really useful addition to this feature would be live results as-you-type. What do you think?

Best,
Sasha

User avatar
mike
Posts: 1060
Joined: Thu Jul 16, 2015 5:35 am
Location: Exeter, UK

Re: build 1573 - lightweight Spotlight integration

Post by mike » Tue Apr 19, 2016 6:54 am

Hi Sasha,

Oh, my bad, there was no check on query making failure :(

This format uses search query expressions, there's nothing here to do with command-line parameters of mdfind.
Some more info is available in Apple's docs:
https://developer.apple.com/library/mac ... ormat.html
https://developer.apple.com/library/mac ... 001694-SW1

As for fetching results as-you-type - I have serious doubts about it.
First of all - time to process the search query itself is not that small: on my QC machine w/ SSD it takes about 0.5sec (plus time to read information from filesystem). And secondly - currently I haven't figured out how integrate it into existing architecture and UI control flow without any dirty hacks and/or making some decisions I would regret later :)

Mike.

sasha
Posts: 168
Joined: Wed Feb 17, 2016 4:59 pm

Re: build 1573 - lightweight Spotlight integration

Post by sasha » Tue Apr 19, 2016 8:04 am

Ok, I got it, thanks for clarifying.

I would like to enter multiple items into "Find with Spotlight" like "author1 author2 pdf" (w/out the quotation marks) and find filenames that contain all of the items, order irrelevant. The query would look like this:

"format": "(kMDItemFSName == '*author1*'cd) && (kMDItemFSName == '*author2*'cd) && (kMDItemFSName == '*pdf*'cd)"

That works fine with static strings. Is there a way to access space-separated substrings of #{query} in NC's config file? (Just entering "author1*author2*pdf" in NC doesn't work because the items must be in that order.) Thanks!

User avatar
mike
Posts: 1060
Joined: Thu Jul 16, 2015 5:35 am
Location: Exeter, UK

Re: build 1573 - lightweight Spotlight integration

Post by mike » Thu Apr 21, 2016 7:19 am

Well, I think it's possible to implement the following scheme:

- if only #{query} is used in format string - proceed as now
- if there're #{query1}, #{query2}... in format string - split entered text with spaces and use that words as query1, query2 etc

What do you think on this variant?
Anyway, IMHO such usage looks like a very specialized task, not sure if this feature would be used at all.

User avatar
darek
Posts: 179
Joined: Thu Jul 16, 2015 4:50 pm
Location: Warsaw, Poland
Contact:

Re: build 1573 - lightweight Spotlight integration

Post by darek » Thu Apr 21, 2016 9:13 am

Just to chip in my 2 cents: I don't see much use for spotlight integration right now. Personally I'd rather see some workflow improvements and polish in the current find in files feature :)

sasha
Posts: 168
Joined: Wed Feb 17, 2016 4:59 pm

Re: build 1573 - lightweight Spotlight integration

Post by sasha » Thu Apr 21, 2016 2:26 pm

Mike,

that scheme would be very helpful to me. It would be certainly used by me a lot :)

- Sasha

User avatar
mike
Posts: 1060
Joined: Thu Jul 16, 2015 5:35 am
Location: Exeter, UK

Re: build 1573 - lightweight Spotlight integration

Post by mike » Thu Apr 21, 2016 3:24 pm

Alright, this seems to be fairly easy, I've played a bit with this approach, and get working stuff like below:
"format": "(kMDItemFSName == '*#{query1}*'cd) && (kMDItemFSName == '*#{query2}*'cd) && (kMDItemFSName == '*#{query3}*'cd)",

However, there's a major flaw with amount of parameters.
Currently it appears that format string can work with fixed amount of parameters only - there're is no intelligent way to "scale" such format string.
If one wants to filter filenames by, say, 5 parts - then go ahead and change the format string!
That's quite ridiculous, but any dumb scaling, like multiplying strings and concatenate them with fixed logical AND (&&), is ridiculous too - what if someone needs something different?

sasha
Posts: 168
Joined: Wed Feb 17, 2016 4:59 pm

Re: build 1573 - lightweight Spotlight integration

Post by sasha » Thu Apr 21, 2016 4:18 pm

You're right, the current default

"kMDItemFSName == '*#{query}*'cd"

should stay as it is. If the user can access the substrings using something like "#{query2}", that's already incredibly helpful for a lot of Spotlight magic. A more professional solution would probably involve using regular expressions, but your proposed solution is perfectly fine for me.

User avatar
mike
Posts: 1060
Joined: Thu Jul 16, 2015 5:35 am
Location: Exeter, UK

Re: build 1573 - lightweight Spotlight integration

Post by mike » Fri Apr 22, 2016 2:29 am

Ok, great, so I think this is it for Spotlight now, maybe I'll return to this feature at some point later.
However, frankly I didn't quite understand your use case - you want to stick to fixed amount of parameters (say, 3) and use only that type of queries?
Some explanation would help me a lot.

Post Reply