From e239492696334775a6917cf11e3c6f5315d79dc8 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sun, 11 Dec 2016 14:51:33 -0500 Subject: [PATCH 1/2] utils: Add optional awful.util.deprecate options. For now, only a `raw` option is implemented. --- lib/awful/util.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/awful/util.lua b/lib/awful/util.lua index 899d6294..8653163d 100644 --- a/lib/awful/util.lua +++ b/lib/awful/util.lua @@ -37,7 +37,10 @@ util.shell = os.getenv("SHELL") or "/bin/sh" local displayed_deprecations = {} --- Display a deprecation notice, but only once per traceback. -- @param[opt] see The message to a new method / function to use. -function util.deprecate(see) +-- @tparam table args Extra arguments +-- @tparam boolean args.raw Print the message as-is without the automatic context +function util.deprecate(see, args) + args = args or {} local tb = debug.traceback() if displayed_deprecations[tb] then return @@ -49,7 +52,9 @@ function util.deprecate(see) local funcname = info.name or "?" local msg = "awful: function " .. funcname .. " is deprecated" if see then - if string.sub(see, 1, 3) == 'Use' then + if args.raw then + msg = see + elseif string.sub(see, 1, 3) == 'Use' then msg = msg .. ". " .. see else msg = msg .. ", see " .. see From 828d6f2cd9843e8d18868f8f605afcb4e4402dd8 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sun, 11 Dec 2016 14:53:44 -0500 Subject: [PATCH 2/2] utils: Better class deprecation warnings Fix #1228 --- lib/awful/util.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/awful/util.lua b/lib/awful/util.lua index 8653163d..f30ffc45 100644 --- a/lib/awful/util.lua +++ b/lib/awful/util.lua @@ -85,7 +85,7 @@ function util.deprecate_class(fallback, old_name, new_name) end local function newindex(_, k, v) - util.deprecate(message) + util.deprecate(message, {raw = true}) fallback[k] = v end