On 17.02.2012 00:39, Anurag Priyam wrote: > On Fri, Feb 17, 2012 at 4:01 AM, Anurag Priyam <anurag08pri...@gmail.com> > wrote: > [...] >> However, most of the times starting to iterate from the currently >> focused client helps, so I can iterate through Chrome instances in >> order starting from the one focused. > > I started off wanting to make this task easy -- iterating through > clients based on certain rules/filter. Maybe all I need is a generic > function that lets me iterate through collections based on the given > criteria. Something like (if it is possible) : > > for c in awful.client.cycle(filter) do > ... > end > > Let me try again :).
http://www.lua.org/pil/7.2.html Dunno about a good implementation. Something like this? function iterate(filter) local clients = client.get() local idx = 0 local iter = function() idx = idx+1 while clients[idx] and not filter(clients[idx]) do idx = idx+1 end return idx, clients[idx] end return iter, null, iter() end for c in iterate(function(c) return c.name ~= "Firefox" end) do print("not Firefox: ", c.name) end (Disclaimer: No idea if this code even works) Uli -- "Why make things difficult, when it is possible to make them cryptic and totally illogical, with just a little bit more effort?" -- A. P. J. -- To unsubscribe, send mail to awesome-devel-unsubscr...@naquadah.org.