On Tue, 5 Jan 2010, Max Kellermann wrote:

> On 2010/01/05 17:46, Jeff Frasca <phaed...@u.washington.edu> wrote:
>> When done in the completer code, it requires two extra fork()/exec()s of
>> the sed and sort code.  The sed and sort code are more general than we
>> would write, but they are also already debugged, and not that much more
>> overhead for something that runs no more than once or twice in a second,
>> and then only occasionally.
>
> mpc used to have (or still has?  I'm not sure) special commands for

Still has.  'mpc tab' is the interesting one here (used to complete
'mpc add').

> the bash completion.  That should be avoided if possible, because mpc
> shouldn't be bloated with interactive features.  mpc isn't supposed to
> be an interactive client, and I think bash+sed (as you said) might be
> well enough for implementing the completion.

mpc is my main client.  However, I agree on the minimalist approach
to the code (that's why I like it).

So, right now, cmd_tab() sends the listall command like this:

     if (!mpd_send_list_all(conn, ""))
                printErrorAndExit(conn);

The "" is the directory to list, so this could be made significantly
smarter by supplying the directory.  It took me 11 LoC (counting blank
lines and closing brackets).  It doesn't change the behavior with
the current completer code--the items that get culled by the server
would have been culled by the client.

However, that change merely cuts down the traffic over the socket for
subsequent tab mashes.  Any tab mash in the top-level directory is just
as expensive as before.

It also doesn't get me what I want (list only the entries in the current
directory level).  That would require significantly more C code or the
extra bash+sed that I'm already using.

> If something is really missing in mpc, and you come to the conclusion
> that the completion can be optimized with a new mpc command, then this
> command should be designed in a generic way (if possible), to make it
> reusable for other mpc users.

Right.  OTOH, my other feature idea--globbing or regex in 'mpc add'
makes the command significantly more complex.  I ended up writing a
mockup of the functionality by adding an 'mpc radd' code (so mpc add
continues to work exactly as before--thus not breaking any scripts).
'mpc radd' is more of an interactive type feature, but I know at least
one other person on the list wants it.

(All the code is still sitting on my harddrive, I haven't pushed any of
it yet.)

Jeff

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Musicpd-dev-team mailing list
Musicpd-dev-team@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team

Reply via email to