From 3d2b31bbb99282a12bd79e97b434bcf35a316bdd Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Fri, 15 Jan 2016 22:05:24 -0500 Subject: [PATCH] util: Add awful.util.table.crush Allow to replace copy pasted code used to apply class heritage in much of wibox.widget --- lib/awful/util.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/awful/util.lua b/lib/awful/util.lua index 1caf9cd4..327c5f15 100644 --- a/lib/awful/util.lua +++ b/lib/awful/util.lua @@ -399,6 +399,18 @@ function util.table.join(...) return ret end +--- Override elements in the first table by the one in the second +-- @tparam table t the table to be overriden +-- @tparam table set the table used to override members of `t` +-- @treturn table t (for convenience) +function util.table.crush(t, set) + for k, v in pairs(set) do + t[k] = v + end + + return t +end + --- Check if a table has an item and return its key. -- @param t The table. -- @param item The item to look for in values of the table.