Re: [Factor-talk] Factor interface to Spotlight

2013-11-17 Thread CW Alston
Hi all,

The Factor Spotlight interface is definitely getting somewhere. John B.
(mrjbq7) has
significantly streamlined the code, and whipped up a docs file to boot.
Take a look at
the revision on GitHub , and
give it a whirl. Looks like it may get merged.

Thanks & cheers!
~cw


On Sun, Nov 17, 2013 at 7:49 PM, CW Alston  wrote:

> Looks pretty dang good, John -
>
> Thanks for the emendations. Someday I'll get around to using the scaffold
> tool.
> If it's already in the latest build, I'll check out the new format.
>
> Much obliged,
> ~cw
>
>
> On Sun, Nov 17, 2013 at 6:17 PM, John Benediktsson wrote:
>
>> Sweet, I merged it and converted a bunch of your comments into help
>> documents for the various commands.
>>
>>
>> http://gitweb.factorcode.org/gitweb.cgi?p=factor;a=commitdiff;h=803d0d4968733ab17afe0207ee6fed63f91abcfc;hp=c6e217da0600b98e17cb09143c06675c51afddcd
>>
>> Let me know what you think.
>>
>> P.S. if you update from github you'll have to wait a bit for us to get
>> the sync script working as the factorcode server was upgraded and it looks
>> like it isn't working properly yet.
>>
>>
>>
>>
>> On Sat, Nov 16, 2013 at 7:40 PM, CW Alston  wrote:
>>
>>> Hi John,
>>>
>>>  That sounds great. I just now set up the code on 
>>> GitHub,
>>> and added the factorcode BSD license line.
>>> First time for me; hope I got the hairy thing right. Being brand new to
>>> collaborative coding, I don't know
>>> the etiquette on adding contributors names. I got so much help, I reckon
>>> other names should be added.
>>> Let me know what to do about that.
>>>
>>>  The solution to the problem of gathering all kMDItem atributes was
>>> staring me in the face, but I didn't
>>> see it until this evening. It's added in the GiHub code.
>>>
>>>  I hope folks can put spotlight.factor through its paces, & suggest
>>> improvements.
>>> Thanks to all for the patient help.
>>>
>>> Cheers!
>>> ~cw
>>>
>>>
>>> On Sat, Nov 16, 2013 at 4:13 PM, John Benediktsson wrote:
>>>
 Hi,

 I'd like to merge this into the main repository, i see that it is
 copyright you, would you like to make it available to us with BSD license
 like the other factorcode?

 Thanks,
 John.


 On Wed, Nov 13, 2013 at 4:58 PM, CW Alston wrote:

> A good point, Björn -
>
>  Since the number of elements is known beforehand in mdutil & mdls, an
> immutable array
> would suffice (& use less words). I carried the vector format over
> from a previous incarnation
> of , where I didn't know how many elems would be needed in
> the array.
>
> I'm not religious about mutating data structures, but your suggestion
> makes the code more succinct.
>
> Thanks,
> ~cw
>
>
> On Wed, Nov 13, 2013 at 5:04 AM, Björn Lindqvist wrote:
>
>> Here are some random tips from me. I'm also a Factor newbie so take it
>> with a grain of salt:
>>
>>  * Don't use vectors because normal sequences works just as well.
>>  * Be functional! Avoid words that mutate data structures because they
>> make the code harder to reason about.
>>
>> F.e. this piece of code in mdls:
>>
>> "mdls" 1vector swap suffix!
>>
>> can be written as just:
>>
>> "mdls" swap 2array
>>
>> Another example is your mdutil word:
>>
>> :: (mdutil) ( flags on|off volume root/owner -- seq )
>> root/owner 1vector "-" flags append suffix!
>> "-i" suffix! on|off suffix! volume suffix!
>>
>> It's a great showcase for local variables but can be better written
>> without array mutations:
>>
>> :: mdutil ( flags on|off volume root/owner -- seq )
>> root/owner flags "-" prepend "-i" on|off volume 5 narray
>>
>>
>> 2013/11/13 CW Alston :
>> >  I've posted a new gist for spotlight.factor w/ filename & Factor
>> > formatting.
>> > I think I dealt with most of Alex's red-lines, & I shed the string
>> > constants.
>> > The whole thing is much shorter. The included examples work on my
>> machine.
>> >
>> >  The file can be USE:d from the listener if you give it a folder in
>> your
>> > 'work'.
>> >
>> >  After a long divagation, looks like I've wound up back where John
>> & Alex
>> > suggested I start, 3 weeks ago. Well, like I was warned in the Boy
>> Scouts,
>> > when you wander lost in the woods, you tend to go 'round in circles.
>> > Just couldn't see how to get on from there without a compass (or
>> native
>> > guides),
>> > & I did learn a lot along the way. Still needs some improvement
>> (maybe bug
>> > fixes, too).
>> >
>> >  In particular, I'd like to memoize an API call to
>> > MDSchemaCopyAllAttributes(),
>> > but I'm better at Chinese than C. Pointers on alien-invoke, o

Re: [Factor-talk] Factor interface to Spotlight

2013-11-16 Thread CW Alston
Hi John,

 That sounds great. I just now set up the code on
GitHub,
and added the factorcode BSD license line.
First time for me; hope I got the hairy thing right. Being brand new to
collaborative coding, I don't know
the etiquette on adding contributors names. I got so much help, I reckon
other names should be added.
Let me know what to do about that.

 The solution to the problem of gathering all kMDItem atributes was staring
me in the face, but I didn't
see it until this evening. It's added in the GiHub code.

 I hope folks can put spotlight.factor through its paces, & suggest
improvements.
Thanks to all for the patient help.

Cheers!
~cw


On Sat, Nov 16, 2013 at 4:13 PM, John Benediktsson  wrote:

> Hi,
>
> I'd like to merge this into the main repository, i see that it is
> copyright you, would you like to make it available to us with BSD license
> like the other factorcode?
>
> Thanks,
> John.
>
>
> On Wed, Nov 13, 2013 at 4:58 PM, CW Alston  wrote:
>
>> A good point, Björn -
>>
>>  Since the number of elements is known beforehand in mdutil & mdls, an
>> immutable array
>> would suffice (& use less words). I carried the vector format over from a
>> previous incarnation
>> of , where I didn't know how many elems would be needed in
>> the array.
>>
>> I'm not religious about mutating data structures, but your suggestion
>> makes the code more succinct.
>>
>> Thanks,
>> ~cw
>>
>>
>> On Wed, Nov 13, 2013 at 5:04 AM, Björn Lindqvist wrote:
>>
>>> Here are some random tips from me. I'm also a Factor newbie so take it
>>> with a grain of salt:
>>>
>>>  * Don't use vectors because normal sequences works just as well.
>>>  * Be functional! Avoid words that mutate data structures because they
>>> make the code harder to reason about.
>>>
>>> F.e. this piece of code in mdls:
>>>
>>> "mdls" 1vector swap suffix!
>>>
>>> can be written as just:
>>>
>>> "mdls" swap 2array
>>>
>>> Another example is your mdutil word:
>>>
>>> :: (mdutil) ( flags on|off volume root/owner -- seq )
>>> root/owner 1vector "-" flags append suffix!
>>> "-i" suffix! on|off suffix! volume suffix!
>>>
>>> It's a great showcase for local variables but can be better written
>>> without array mutations:
>>>
>>> :: mdutil ( flags on|off volume root/owner -- seq )
>>> root/owner flags "-" prepend "-i" on|off volume 5 narray
>>>
>>>
>>> 2013/11/13 CW Alston :
>>> >  I've posted a new gist for spotlight.factor w/ filename & Factor
>>> > formatting.
>>> > I think I dealt with most of Alex's red-lines, & I shed the string
>>> > constants.
>>> > The whole thing is much shorter. The included examples work on my
>>> machine.
>>> >
>>> >  The file can be USE:d from the listener if you give it a folder in
>>> your
>>> > 'work'.
>>> >
>>> >  After a long divagation, looks like I've wound up back where John &
>>> Alex
>>> > suggested I start, 3 weeks ago. Well, like I was warned in the Boy
>>> Scouts,
>>> > when you wander lost in the woods, you tend to go 'round in circles.
>>> > Just couldn't see how to get on from there without a compass (or native
>>> > guides),
>>> > & I did learn a lot along the way. Still needs some improvement (maybe
>>> bug
>>> > fixes, too).
>>> >
>>> >  In particular, I'd like to memoize an API call to
>>> > MDSchemaCopyAllAttributes(),
>>> > but I'm better at Chinese than C. Pointers on alien-invoke, or what
>>> else to
>>> > use?
>>>
>>>
>>>
>>> --
>>> mvh/best regards Björn Lindqvist
>>>
>>
>>
>>
>> --
>> *~ Memento Amori*
>>
>>
>> --
>> DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
>> OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
>> Free app hosting. Or install the open source package on any LAMP server.
>> Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
>>
>> ___
>> Factor-talk mailing list
>> Factor-talk@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/factor-talk
>>
>>
>


-- 
*~ Memento Amori*
--
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Factor interface to Spotlight

2013-11-16 Thread John Benediktsson
Hi,

I'd like to merge this into the main repository, i see that it is copyright
you, would you like to make it available to us with BSD license like the
other factorcode?

Thanks,
John.


On Wed, Nov 13, 2013 at 4:58 PM, CW Alston  wrote:

> A good point, Björn -
>
>  Since the number of elements is known beforehand in mdutil & mdls, an
> immutable array
> would suffice (& use less words). I carried the vector format over from a
> previous incarnation
> of , where I didn't know how many elems would be needed in the
> array.
>
> I'm not religious about mutating data structures, but your suggestion
> makes the code more succinct.
>
> Thanks,
> ~cw
>
>
> On Wed, Nov 13, 2013 at 5:04 AM, Björn Lindqvist wrote:
>
>> Here are some random tips from me. I'm also a Factor newbie so take it
>> with a grain of salt:
>>
>>  * Don't use vectors because normal sequences works just as well.
>>  * Be functional! Avoid words that mutate data structures because they
>> make the code harder to reason about.
>>
>> F.e. this piece of code in mdls:
>>
>> "mdls" 1vector swap suffix!
>>
>> can be written as just:
>>
>> "mdls" swap 2array
>>
>> Another example is your mdutil word:
>>
>> :: (mdutil) ( flags on|off volume root/owner -- seq )
>> root/owner 1vector "-" flags append suffix!
>> "-i" suffix! on|off suffix! volume suffix!
>>
>> It's a great showcase for local variables but can be better written
>> without array mutations:
>>
>> :: mdutil ( flags on|off volume root/owner -- seq )
>> root/owner flags "-" prepend "-i" on|off volume 5 narray
>>
>>
>> 2013/11/13 CW Alston :
>> >  I've posted a new gist for spotlight.factor w/ filename & Factor
>> > formatting.
>> > I think I dealt with most of Alex's red-lines, & I shed the string
>> > constants.
>> > The whole thing is much shorter. The included examples work on my
>> machine.
>> >
>> >  The file can be USE:d from the listener if you give it a folder in your
>> > 'work'.
>> >
>> >  After a long divagation, looks like I've wound up back where John &
>> Alex
>> > suggested I start, 3 weeks ago. Well, like I was warned in the Boy
>> Scouts,
>> > when you wander lost in the woods, you tend to go 'round in circles.
>> > Just couldn't see how to get on from there without a compass (or native
>> > guides),
>> > & I did learn a lot along the way. Still needs some improvement (maybe
>> bug
>> > fixes, too).
>> >
>> >  In particular, I'd like to memoize an API call to
>> > MDSchemaCopyAllAttributes(),
>> > but I'm better at Chinese than C. Pointers on alien-invoke, or what
>> else to
>> > use?
>>
>>
>>
>> --
>> mvh/best regards Björn Lindqvist
>>
>
>
>
> --
> *~ Memento Amori*
>
>
> --
> DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
> OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
> Free app hosting. Or install the open source package on any LAMP server.
> Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
> http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
>
--
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Factor interface to Spotlight

2013-11-13 Thread CW Alston
A good point, Björn -

 Since the number of elements is known beforehand in mdutil & mdls, an
immutable array
would suffice (& use less words). I carried the vector format over from a
previous incarnation
of , where I didn't know how many elems would be needed in the
array.

I'm not religious about mutating data structures, but your suggestion makes
the code more succinct.

Thanks,
~cw


On Wed, Nov 13, 2013 at 5:04 AM, Björn Lindqvist  wrote:

> Here are some random tips from me. I'm also a Factor newbie so take it
> with a grain of salt:
>
>  * Don't use vectors because normal sequences works just as well.
>  * Be functional! Avoid words that mutate data structures because they
> make the code harder to reason about.
>
> F.e. this piece of code in mdls:
>
> "mdls" 1vector swap suffix!
>
> can be written as just:
>
> "mdls" swap 2array
>
> Another example is your mdutil word:
>
> :: (mdutil) ( flags on|off volume root/owner -- seq )
> root/owner 1vector "-" flags append suffix!
> "-i" suffix! on|off suffix! volume suffix!
>
> It's a great showcase for local variables but can be better written
> without array mutations:
>
> :: mdutil ( flags on|off volume root/owner -- seq )
> root/owner flags "-" prepend "-i" on|off volume 5 narray
>
>
> 2013/11/13 CW Alston :
> >  I've posted a new gist for spotlight.factor w/ filename & Factor
> > formatting.
> > I think I dealt with most of Alex's red-lines, & I shed the string
> > constants.
> > The whole thing is much shorter. The included examples work on my
> machine.
> >
> >  The file can be USE:d from the listener if you give it a folder in your
> > 'work'.
> >
> >  After a long divagation, looks like I've wound up back where John & Alex
> > suggested I start, 3 weeks ago. Well, like I was warned in the Boy
> Scouts,
> > when you wander lost in the woods, you tend to go 'round in circles.
> > Just couldn't see how to get on from there without a compass (or native
> > guides),
> > & I did learn a lot along the way. Still needs some improvement (maybe
> bug
> > fixes, too).
> >
> >  In particular, I'd like to memoize an API call to
> > MDSchemaCopyAllAttributes(),
> > but I'm better at Chinese than C. Pointers on alien-invoke, or what else
> to
> > use?
>
>
>
> --
> mvh/best regards Björn Lindqvist
>



-- 
*~ Memento Amori*
--
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Factor interface to Spotlight

2013-11-13 Thread Björn Lindqvist
Here are some random tips from me. I'm also a Factor newbie so take it
with a grain of salt:

 * Don't use vectors because normal sequences works just as well.
 * Be functional! Avoid words that mutate data structures because they
make the code harder to reason about.

F.e. this piece of code in mdls:

"mdls" 1vector swap suffix!

can be written as just:

"mdls" swap 2array

Another example is your mdutil word:

:: (mdutil) ( flags on|off volume root/owner -- seq )
root/owner 1vector "-" flags append suffix!
"-i" suffix! on|off suffix! volume suffix!

It's a great showcase for local variables but can be better written
without array mutations:

:: mdutil ( flags on|off volume root/owner -- seq )
root/owner flags "-" prepend "-i" on|off volume 5 narray


2013/11/13 CW Alston :
>  I've posted a new gist for spotlight.factor w/ filename & Factor
> formatting.
> I think I dealt with most of Alex's red-lines, & I shed the string
> constants.
> The whole thing is much shorter. The included examples work on my machine.
>
>  The file can be USE:d from the listener if you give it a folder in your
> 'work'.
>
>  After a long divagation, looks like I've wound up back where John & Alex
> suggested I start, 3 weeks ago. Well, like I was warned in the Boy Scouts,
> when you wander lost in the woods, you tend to go 'round in circles.
> Just couldn't see how to get on from there without a compass (or native
> guides),
> & I did learn a lot along the way. Still needs some improvement (maybe bug
> fixes, too).
>
>  In particular, I'd like to memoize an API call to
> MDSchemaCopyAllAttributes(),
> but I'm better at Chinese than C. Pointers on alien-invoke, or what else to
> use?



-- 
mvh/best regards Björn Lindqvist

--
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Factor interface to Spotlight

2013-11-12 Thread CW Alston
Hi folks,

 I've posted a new gist for
spotlight.factorw/ filename
& Factor formatting.
I think I dealt with most of Alex's red-lines, & I shed the string
constants.
The whole thing is much shorter. The included examples work on my machine.

 The file can be USE:d from the listener if you give it a folder in your
'work'.

 After a long divagation, looks like I've wound up back where John & Alex
suggested I start, 3 weeks ago. Well, like I was warned in the Boy Scouts,
when you wander lost in the woods, you tend to go 'round in circles.
Just couldn't see how to get on from there without a compass (or native
guides),
& I did learn a lot along the way. Still needs some improvement (maybe bug
fixes, too).

 In particular, I'd like to memoize an API call to
MDSchemaCopyAllAttributes(),
but I'm better at Chinese than C. Pointers on alien-invoke, or what else to
use?

Thanks,
CW Alston



On Mon, Nov 11, 2013 at 4:29 PM, John Benediktsson  wrote:

> I agree with Alex's comments and would add one thing, which is if you like
> all your constants (so you don't have to remember them), instead of
> creating all the specialized words like by-Author, maybe just have the
> constants and then a generic by-attribute so using Alex's "mdfind":
>
> CONSTANT: Author "kMDItemAuthor"
>
> : mdfind-by ( value name -- results )
> swap "%s = '%s'" sprintf mdfind ;
>
> So you could do:
>
> IN: scratchpad "Stephen King" Author mdfind-by
>
>
>
>
>
>
>
>
>
> On Mon, Nov 11, 2013 at 3:39 PM, CW Alston  wrote:
>
>> Phew! - let me co-sign you on that, with a hearty Thanks, Alex!
>>
>>  I really appreciate the time you took to run a fine-toothed comb through
>> through
>> such a heap of code. Lots to chew on, and learn from. All your points
>> make sense.
>> (Sorry about all the SHOUTING, lol - just a visual crutch for me, but I
>> can wean
>> myself away from stylistic improprieties).
>>
>>  Edified, encouraged, let me see what improvements I can come up with.
>>
>> Thanks again. Back to the future (though that may take a while...),
>> ~cw
>>
>>
>> On Mon, Nov 11, 2013 at 10:57 AM, Alex Vondrak wrote:
>>
>>> 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  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 
>>> 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 
>>> >> 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 
>>> 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
>>> 
>>

Re: [Factor-talk] Factor interface to Spotlight

2013-11-11 Thread John Benediktsson
I agree with Alex's comments and would add one thing, which is if you like
all your constants (so you don't have to remember them), instead of
creating all the specialized words like by-Author, maybe just have the
constants and then a generic by-attribute so using Alex's "mdfind":

CONSTANT: Author "kMDItemAuthor"

: mdfind-by ( value name -- results )
swap "%s = '%s'" sprintf mdfind ;

So you could do:

IN: scratchpad "Stephen King" Author mdfind-by









On Mon, Nov 11, 2013 at 3:39 PM, CW Alston  wrote:

> Phew! - let me co-sign you on that, with a hearty Thanks, Alex!
>
>  I really appreciate the time you took to run a fine-toothed comb through
> through
> such a heap of code. Lots to chew on, and learn from. All your points make
> sense.
> (Sorry about all the SHOUTING, lol - just a visual crutch for me, but I
> can wean
> myself away from stylistic improprieties).
>
>  Edified, encouraged, let me see what improvements I can come up with.
>
> Thanks again. Back to the future (though that may take a while...),
> ~cw
>
>
> On Mon, Nov 11, 2013 at 10:57 AM, Alex Vondrak wrote:
>
>> 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  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  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 
>> >> 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 
>> 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 } 

Re: [Factor-talk] Factor interface to Spotlight

2013-11-11 Thread CW Alston
Phew! - let me co-sign you on that, with a hearty Thanks, Alex!

 I really appreciate the time you took to run a fine-toothed comb through
through
such a heap of code. Lots to chew on, and learn from. All your points make
sense.
(Sorry about all the SHOUTING, lol - just a visual crutch for me, but I can
wean
myself away from stylistic improprieties).

 Edified, encouraged, let me see what improvements I can come up with.

Thanks again. Back to the future (though that may take a while...),
~cw


On Mon, Nov 11, 2013 at 10:57 AM, Alex Vondrak  wrote:

> 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  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  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 
> >> 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 
> 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 per

Re: [Factor-talk] Factor interface to Spotlight

2013-11-11 Thread Alex Vondrak
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  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  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 
>> 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  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 spotli

Re: [Factor-talk] Factor interface to Spotlight

2013-11-11 Thread CW Alston
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  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 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  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"
>>> "/Applicati

Re: [Factor-talk] Factor interface to Spotlight

2013-11-09 Thread CW Alston
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  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  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
>>

Re: [Factor-talk] Factor interface to Spotlight

2013-11-08 Thread Alex Vondrak
I guess io.launcher needs better examples...  They show how launch
descriptors are either strings or arrays, but they don't explain what
each means.  The details change by OS backend, but for Unix it works
like this:

- Given a sequence launch descriptor, { "a" "b" "c" }, io.launcher
uses exec-with-path
(http://docs.factorcode.org/content/word-exec-with-path,unix.process.html)
supplying "a" as the filename (the command to execute) and { "a" "b"
"c" } as ARGV: http://notabug.com/2002/coherent/man/argv.html  Thus,
each element of the array (past the first) should be a *single* token,
as provided to ARGV.

So instead of

  { "find -maxdepth 1 -type d" } utf8 [ lines ] with-process-reader .

or

  { "find" "-maxdepth 1 -type d" } utf8 [ lines ] with-process-reader .

or

  { "find" "-maxdepth 1" "-type d" } utf8 [ lines ] with-process-reader .

all of which break, you'd have to run

  { "find" "-maxdepth" "1" "-type" "d" } utf8 [ lines ] with-process-reader .

- Given a string launch descriptor, "a b c", the string gets
*tokenized* into such an array:
http://docs.factorcode.org/content/word-tokenize%2Csimple-tokenizer.html

Thus

  "find -maxdepth 1 -type d" utf8 [ lines ] with-process-reader .

works, because

  "find -maxdepth 1 -type d" tokenize

gives

  V{ "find" "-maxdepth" "1" "-type" "d" }

which is used as the launch descriptor.

Therefore, much like the examples I sent a few weeks back, I suspect
the following will work:

  "mdfind \"kMDItemComposer == 'Dylan'\"" utf8 [ lines ] with-process-reader .

My point in the examples I gave you a few weeks ago was that the
*real* thing to watch out for here is unexpected input or results that
may give non-zero exit statuses.  E.g., on my Linux box,

  "find /proc -name blah" utf8 [ lines ] with-process-reader

throws an error Factor-side because find's exit status is 1, since
find didn't have permission to read /proc.

Hope that helps,
--Alex Vondrak

On Fri, Nov 8, 2013 at 10:11 PM, CW Alston  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

Re: [Factor-talk] Factor interface to Spotlight

2013-11-08 Thread CW Alston
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  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  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  wrote:
>>
>>> Thanks for the heads-up, Björn - try this 
>>> link
>>> .
>>>
>>> ~cw
>>>
>>>
>>> On Fri, Nov 8, 2013 at 12:49 AM, Björn Lindqvist wrote:
>>>
 2013/11/8 CW Alston :
 > 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.


>>>

Re: [Factor-talk] Factor interface to Spotlight

2013-11-08 Thread John Benediktsson
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  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  wrote:
>
>> Thanks for the heads-up, Björn - try this 
>> link
>> .
>>
>> ~cw
>>
>>
>> On Fri, Nov 8, 2013 at 12:49 AM, Björn Lindqvist wrote:
>>
>>> 2013/11/8 CW Alston :
>>> > 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
>
>
--
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


Re: [Factor-talk] Factor interface to Spotlight

2013-11-08 Thread CW Alston
(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  wrote:

> Thanks for the heads-up, Björn - try this 
> link
> .
>
> ~cw
>
>
> On Fri, Nov 8, 2013 at 12:49 AM, Björn Lindqvist wrote:
>
>> 2013/11/8 CW Alston :
>> > 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


Re: [Factor-talk] Factor interface to Spotlight

2013-11-08 Thread CW Alston
P.S. - I should note that, in the posted example for mdutil -

! BUILD THIS SCRIPT:
! sudo mdutil -E-s /Volumes/Jurassic\ Grad\ -\ Spare\ Change/ >
/Users/cwalston/factor/mdquery-results.txt

! EXAMPLE:
! "/Volumes/Jurassic Grad - Spare Change" md-re-index

- there is an issue intercepting the authentication prompt required by
sudo. I actually got
a response after running the command-line directly in my shell, to see what
was going on...
Any suggestions as to how intercept this authentication prompt?
~cw


On Thu, Nov 7, 2013 at 11:25 PM, CW Alston  wrote:

> 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.
>
> The general strategy is to compose a Spotlight query as a command-line
> one-liner
> and write that to an executable shell script file; then, launch a Factor
> process
> that calls that executable. The script directs the shell output to a named
> text file, whose contents are returned to Factor as a sequence of
> file-lines.
>
> OS X exposes 4 commands that deal with Spotlight via its MetaData index:
> mdfind, mdls, mdutil, mdimport (see their man pages for details).
> Implementing
> mdfind was my main aim, but getting at all 4 from Factor seemed worth the
> effort.
> What a rabbit hole! I had to console myself with frequent laughter breaks
> reading
> *The Unix-Hater's Handbook* (*q.v.*). Oy!!
>
> To try out the code, you'll need to put a plain-text file in some
> convenient path,
> to receive query results. Also, set up an executable file somewhere; your
> command-
> line scripts will be written there. You can modify the paths to these 2
> files,
> & the form of the hashbang, to suit convenience & your shell. Just be
> consistent
> with what the code expects. (Dont forget to put the pastebin code in a
> folder named
> "spotlight", within your "work" folder, to exercise it in the listener.)
>
> I'd appreciate it if folks would try the examples (modifying paths &
> filenames),
> compose arbitrary queries; see what breaks, is cumbersome, impossible, or
> goofy;
> and suggest improvements or alternative approaches for working with
> Spotlight.
> Alex's suggestion of using streams seems more intuitive & direct to me,
> but I
> foundered wading those waters.
>
> And, yeah, I'm hip - a ridiculous plethora of string CONSTANT:s. A few are
> just composition crutches, and overkill. The majority seem to suit this
> approach.
> See what you think.
>
> Do take a look at the code, if you have an interest, and opine away.
> Cheers,
> CW Alston
>
> --
> *~ 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


Re: [Factor-talk] Factor interface to Spotlight

2013-11-08 Thread Björn Lindqvist
2013/11/8 CW Alston :
> 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

--
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


[Factor-talk] Factor interface to Spotlight

2013-11-07 Thread CW Alston
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.

The general strategy is to compose a Spotlight query as a command-line
one-liner
and write that to an executable shell script file; then, launch a Factor
process
that calls that executable. The script directs the shell output to a named
text file, whose contents are returned to Factor as a sequence of
file-lines.

OS X exposes 4 commands that deal with Spotlight via its MetaData index:
mdfind, mdls, mdutil, mdimport (see their man pages for details).
Implementing
mdfind was my main aim, but getting at all 4 from Factor seemed worth the
effort.
What a rabbit hole! I had to console myself with frequent laughter breaks
reading
*The Unix-Hater's Handbook* (*q.v.*). Oy!!

To try out the code, you'll need to put a plain-text file in some
convenient path,
to receive query results. Also, set up an executable file somewhere; your
command-
line scripts will be written there. You can modify the paths to these 2
files,
& the form of the hashbang, to suit convenience & your shell. Just be
consistent
with what the code expects. (Dont forget to put the pastebin code in a
folder named
"spotlight", within your "work" folder, to exercise it in the listener.)

I'd appreciate it if folks would try the examples (modifying paths &
filenames),
compose arbitrary queries; see what breaks, is cumbersome, impossible, or
goofy;
and suggest improvements or alternative approaches for working with
Spotlight.
Alex's suggestion of using streams seems more intuitive & direct to me, but
I
foundered wading those waters.

And, yeah, I'm hip - a ridiculous plethora of string CONSTANT:s. A few are
just composition crutches, and overkill. The majority seem to suit this
approach.
See what you think.

Do take a look at the code, if you have an interest, and opine away.
Cheers,
CW Alston

-- 
*~ 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