On Fri, Feb 17, 2012 at 8:47 PM, Anurag Priyam <anurag08pri...@gmail.com> wrote: >>> Finally: What about indentation? >> >> Luadoc ignores it. IIRC, only one code example in the entire doc uses >> indentation: awful.menu.new. It is painfully difficult to add >> indentation; see 514fd796f3272583ee409b784fcd9ee2a6f95875 (one of my >> first patches :-|). > > Even if you use pre tag around it.
Added it nevertheless, so at least reading docu along with the source is easier. -- Anurag Priyam
From 605e3cfe20b27d0a1878fce480c63d346b70874f Mon Sep 17 00:00:00 2001 From: Anurag Priyam <anurag08pri...@gmail.com> Date: Fri, 17 Feb 2012 02:32:28 +0530 Subject: [PATCH 2/2] add awful.client.cycle to iterate through clients that match a given condition A common use case is to cycle through clients that match a given rule and take certain action on them: raise, set or get property, etc.; see usage example in the docs. Signed-off-by: Anurag Priyam <anurag08pri...@gmail.com> --- lib/awful/client.lua.in | 23 +++++++++++++++++++++++ 1 files changed, 23 insertions(+), 0 deletions(-) diff --git a/lib/awful/client.lua.in b/lib/awful/client.lua.in index 2d5ec45..6937c32 100644 --- a/lib/awful/client.lua.in +++ b/lib/awful/client.lua.in @@ -862,6 +862,29 @@ function property.set(c, prop, value) c:emit_signal("property::" .. prop) end +--- +-- Returns an iterator to cycle through, starting from the client in focus or +-- the given index, all clients that match a given criteria. +-- @param filter a function that returns true to indicate a positive match +-- @param start what index to start iterating from. Defaults to using the +-- index of the currently focused client. +-- @usage e.g.: un-minimize all urxvt instances +-- <p><code> +-- local urxvt = function (c) <br/> +-- return awful.rules.match(c, {class = "URxvt"}) <br/> +-- end <br/> +-- </br> +-- for c in awful.client.cycle(urxvt) do <br/> +-- c.minimized = false <br/> +-- end <br/> +-- </code></p> +function cycle(filter, start, s) + local clients = capi.client.get(s) + local focused = capi.client.focus + local start = start or util.table.hasitem(clients, focused) + return util.table.cycle(clients, filter, start) +end + -- Register standards signals capi.client.add_signal("property::floating_geometry") capi.client.add_signal("property::floating") -- 1.7.9