I have too much formatting (and email always has a way of wrecking
that), so I put a comment on the gist:
https://gist.github.com/cwalston/7368493#comment-948159

Have a good one,
--Alex Vondrak


On Mon, Nov 11, 2013 at 1:28 AM, CW Alston <cwalsto...@gmail.com> wrote:
> Hi all-
>
>  Re-factoring 'spotlight.factor' worked better than SlimFast. "Look Ma, no
> files"!
> Much obliged for the pointers on how to set up commands for
> "with-process-reader".
>
>  I've replaced the code in the Gist previously posted with a revised,
> self-contained
> version. Please do take a look & beat on the code. It should compile fine
> simply
> pasted whole in the listener. I'm sure many query formatting cases aren't
> covered yet.
>
>  There are a passel of terminal examples to try to emulate at the end of the
> file.
> As there are myriad variations in formatting terminal commands, it would be
> good to
> have as general an interface from Factor as possible. I'd like to develop
> 'spotlight'
> into a practical utility. Suggestions? Feedback appreciated.
>
> Thanks kindly,
> ~ CW Alston
>
>
>
> On Sat, Nov 9, 2013 at 7:43 PM, CW Alston <cwalsto...@gmail.com> wrote:
>>
>> Great help, folks!
>>
>> I think I can figure this out now. With a l'il more elbow-grease & your
>> pointers,
>> I'd like to make the 2 crutch files disappear, & access the MetaData index
>> in all its glory directly. That certainly would make this a much more
>> independent,
>> self-contained utility. Useful breakdown, Alex. Back to the drawing board.
>>
>> Thanks, all -
>> ~cw
>>
>>
>>
>> On Sat, Nov 9, 2013 at 8:36 AM, John Benediktsson <mrj...@gmail.com>
>> wrote:
>>>
>>> This works for me, it has to be a string or sequence of strings:
>>>
>>> IN: scratchpad { "mdfind" "kMDItemComposer == 'Andrea Bocelli'" } utf8 [
>>> lines ] with-process-reader
>>>
>>> Anyway, I love this vocab and getting it to work is like 95% of the
>>> challenge, I think it would be fun to modify it to not require the
>>> indirection and contribute it to the main repository if you're interested!
>>>
>>> Best,
>>> John.
>>>
>>>
>>>
>>> On Fri, Nov 8, 2013 at 10:11 PM, CW Alston <cwalsto...@gmail.com> wrote:
>>>>
>>>> Hi John,
>>>>
>>>> I can't get your suggestion to work with mdfind:
>>>>
>>>> > Why go through the indirection of a shell script and a query results
>>>> > rather than just preparing
>>>> > a sequence of args and then grabbing all the results, e.g.
>>>> > { mdfind "kMDItemAuthor == '*MyFavoriteAuthor*'" } utf8 [ lines ]
>>>> > with-process-reader
>>>>
>>>> - Trying this command format (with a different MD Attribute) works fine
>>>> in the terminal:
>>>>
>>>> ➜  ~ git:(master) ✗ mdfind "kMDItemComposer == 'Dylan'"
>>>> /Applications/Music/iTunes/iTunes Music/Bob Dylan/Planet Waves/11
>>>> Wedding Song.m4a
>>>> /Applications/Music/iTunes/iTunes Music/Bob Dylan/Planet Waves/10 Never
>>>> Say Goodbye.m4a
>>>> /Applications/Music/iTunes/iTunes Music/Bob Dylan/Planet Waves/09 You
>>>> Angel You.m4a
>>>> /Applications/Music/iTunes/iTunes Music/Bob Dylan/Planet Waves/08
>>>> Dirge.m4a
>>>> ...
>>>> ➜  ~ git:(master) ✗
>>>>
>>>> - But trying the same command in the with-process-reader format fails in
>>>> the listener:
>>>>
>>>> IN: scratchpad { mdfind "kMDItemComposer == 'Dylan'" } utf8 [ lines ]
>>>> with-process-reader
>>>>
>>>> Process exited with error code 254
>>>>
>>>> Launch descriptor:
>>>>
>>>> T{ process
>>>>     { command { mdfind "kMDItemComposer == 'Dylan'" } }
>>>>     { environment H{ } }
>>>>     { environment-mode +append-environment+ }
>>>>     { stdout T{ fd { disposed t } { fd 23 } } }
>>>>     { group +same-group+ }
>>>>     { status 254 }
>>>>     { pipe
>>>>         T{ pipe
>>>>             { in T{ fd { disposed t } { fd 19 } } }
>>>>             { out T{ fd { disposed t } { fd 23 } } }
>>>>         }
>>>>     }
>>>> }
>>>> ---------------
>>>> -Switching single & double quotes around doesn't help:
>>>> IN: scratchpad { mdfind 'kMDItemComposer == "Dylan"' } utf8 [ lines ]
>>>> with-process-reader
>>>>
>>>> Error
>>>> No word named “'kMDItemComposer” found in current vocabulary search path
>>>> (however, mdfind 'kMDItemComposer == "Dylan"' works in terminal)
>>>>
>>>> ---------------
>>>> -Ok, so trying various permutations of single, double, triple quotes in
>>>> the command:
>>>> IN: scratchpad { """mdfind "kMDItemComposer == 'Dylan'"""" } utf8 [
>>>> lines ] with-process-reader
>>>>
>>>> Process exited with error code 255
>>>> (however, mdfind "kMDItemComposer == 'Dylan'" works in terminal)
>>>>
>>>> ---------------
>>>> IN: scratchpad { """mdfind 'kMDItemComposer == "Dylan"'""" } utf8 [
>>>> lines ] with-process-reader
>>>>
>>>> Process exited with error code 255
>>>> (however, mdfind 'kMDItemComposer == "Dylan"' works in terminal)
>>>>
>>>> ---------------
>>>> IN: scratchpad { "mdfind" """'kMDItemComposer == "Dylan"'""" } utf8 [
>>>> lines ] with-process-reader
>>>>
>>>> Process exited with error code 1
>>>> (again, mdfind 'kMDItemComposer == "Dylan"' works in terminal)
>>>>
>>>> ---------------
>>>> -Using the code from the spotlight.factor vocab works like the terminal
>>>> example above:
>>>> IN: scratchpad "Dylan" by-Composer mdfind .
>>>>
>>>> {
>>>>     "/Applications/Music/iTunes/iTunes Music/Bob Dylan/Planet Waves/11
>>>> Wedding Song.m4a"
>>>>     "/Applications/Music/iTunes/iTunes Music/Bob Dylan/Planet Waves/10
>>>> Never Say Goodbye.m4a"
>>>>     "/Applications/Music/iTunes/iTunes Music/Bob Dylan/Planet Waves/09
>>>> You Angel You.m4a"
>>>>     "/Applications/Music/iTunes/iTunes Music/Bob Dylan/Planet Waves/08
>>>> Dirge.m4a"
>>>>     "/Applications/Music/iTunes/iTunes Music/Bob Dylan/Planet Waves/07
>>>> Forever Young (Continued).m4a"
>>>>     "/Applications/Music/iTunes/iTunes Music/Bob Dylan/Planet Waves/06
>>>> Forever Young.m4a"
>>>>     ...
>>>> }
>>>>
>>>> I'm probably missing something simple, but I haven't found a way to get
>>>> mdfind to work in
>>>> a process command, and reading the output stream-lines.
>>>> Hence, my relief at getting "a shell script and a query results"
>>>> approach to work without blowing up.
>>>>
>>>> I agree, it would be much more elegant to craft a solution in the form
>>>> of your suggestion.
>>>> If anyone can cook one up, that would really be sweet! I just want to
>>>> access the Spotlight
>>>> MetaData Index from Factor in the simplest possible way. Meanwhile, I'll
>>>> exercise spotlight;
>>>> baroque as it is, it gets me to the MetaData, and does find things.
>>>>
>>>> Thanks,
>>>> Charles
>>>>
>>>>
>>>>
>>>> On Fri, Nov 8, 2013 at 8:37 AM, John Benediktsson <mrj...@gmail.com>
>>>> wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> Why go through the indirection of a shell script and a query results
>>>>> rather than just preparing a sequence of args and then grabbing all the
>>>>> results, e.g.
>>>>>
>>>>> { mdfind "kMDItemAuthor == '*MyFavoriteAuthor*'" } utf8 [ lines ]
>>>>> with-process-reader
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Fri, Nov 8, 2013 at 1:55 AM, CW Alston <cwalsto...@gmail.com> wrote:
>>>>>>
>>>>>> (Oops- forgot to sign in)
>>>>>> Thanks for the heads-up, Björn - try this link, folks.
>>>>>> ~cw
>>>>>>
>>>>>>
>>>>>> On Fri, Nov 8, 2013 at 1:14 AM, CW Alston <cwalsto...@gmail.com>
>>>>>> wrote:
>>>>>>>
>>>>>>> Thanks for the heads-up, Björn - try this link.
>>>>>>>
>>>>>>> ~cw
>>>>>>>
>>>>>>>
>>>>>>> On Fri, Nov 8, 2013 at 12:49 AM, Björn Lindqvist <bjou...@gmail.com>
>>>>>>> wrote:
>>>>>>>>
>>>>>>>> 2013/11/8 CW Alston <cwalsto...@gmail.com>:
>>>>>>>> > Greetings, Factorials -
>>>>>>>> >
>>>>>>>> > I've posted a vocab to the pastebin, a Factor interface to OS X
>>>>>>>> > Spotlight.
>>>>>>>> > Pardon the length; this should be split into at least 2 code files
>>>>>>>> > &
>>>>>>>> > a docs file. Just seems best to show everything together for the
>>>>>>>> > post.
>>>>>>>>
>>>>>>>> Check your link, it doesn't go anywhere. :) Perhaps try
>>>>>>>> https://gist.github.com/ for long-lived pastes because they dont
>>>>>>>> delete them after a few days.
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> mvh/best regards Björn Lindqvist
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> ~ Memento Amori
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> ~ Memento Amori
>>>>>>
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>> November Webinars for C, C++, Fortran Developers
>>>>>> Accelerate application performance with scalable programming models.
>>>>>> Explore
>>>>>> techniques for threading, error checking, porting, and tuning. Get the
>>>>>> most
>>>>>> from the latest Intel processors and coprocessors. See abstracts and
>>>>>> register
>>>>>>
>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
>>>>>> _______________________________________________
>>>>>> Factor-talk mailing list
>>>>>> Factor-talk@lists.sourceforge.net
>>>>>> https://lists.sourceforge.net/lists/listinfo/factor-talk
>>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> ~ Memento Amori
>>>
>>>
>>
>>
>>
>> --
>> ~ Memento Amori
>
>
>
>
> --
> ~ Memento Amori
>
> ------------------------------------------------------------------------------
> November Webinars for C, C++, Fortran Developers
> Accelerate application performance with scalable programming models. Explore
> techniques for threading, error checking, porting, and tuning. Get the most
> from the latest Intel processors and coprocessors. See abstracts and
> register
> http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>

------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to