From 11644f4582e1e120ba06cce6defdb77af0063eef Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Thu, 29 Sep 2016 02:41:01 -0400 Subject: [PATCH] prompt: Deprecate 8 parameters. --- awesomerc.lua | 10 +++++---- lib/awful/prompt.lua | 53 +++++++++++++++++++++++++++++++++++++++----- 2 files changed, 54 insertions(+), 9 deletions(-) diff --git a/awesomerc.lua b/awesomerc.lua index b26f0a04..87d9da74 100755 --- a/awesomerc.lua +++ b/awesomerc.lua @@ -332,10 +332,12 @@ globalkeys = awful.util.table.join( awful.key({ modkey }, "x", function () - awful.prompt.run({ prompt = "Run Lua code: " }, - awful.screen.focused().mypromptbox.widget, - awful.util.eval, nil, - awful.util.get_cache_dir() .. "/history_eval") + awful.prompt.run { + prompt = "Run Lua code: ", + textbox = awful.screen.focused().mypromptbox.widget, + exe_callback = awful.util.eval, + history_path = awful.util.get_cache_dir() .. "/history_eval" + } end, {description = "lua execute prompt", group = "awesome"}), -- Menubar diff --git a/lib/awful/prompt.lua b/lib/awful/prompt.lua index 6772b670..3c49a56f 100644 --- a/lib/awful/prompt.lua +++ b/lib/awful/prompt.lua @@ -269,20 +269,23 @@ end -- return command -- end} -- } --- @param textbox The textbox to use for the prompt. +-- @param textbox The textbox to use for the prompt. [**DEPRECATED**] -- @param exe_callback The callback function to call with command as argument --- when finished. +-- when finished. [**DEPRECATED**] -- @param completion_callback The callback function to call to get completion. +-- [**DEPRECATED**] -- @param[opt] history_path File path where the history should be --- saved, set nil to disable history +-- saved, set nil to disable history [**DEPRECATED**] -- @param[opt] history_max Set the maximum entries in history --- file, 50 by default +-- file, 50 by default [**DEPRECATED**] -- @param[opt] done_callback The callback function to always call -- without arguments, regardless of whether the prompt was cancelled. +-- [**DEPRECATED**] -- @param[opt] changed_callback The callback function to call --- with command as argument when a command was changed. +-- with command as argument when a command was changed. [**DEPRECATED**] -- @param[opt] keypressed_callback The callback function to call -- with mod table, key and command as arguments when a key was pressed. +-- [**DEPRECATED**] function prompt.run(args, textbox, exe_callback, completion_callback, history_path, history_max, done_callback, changed_callback, keypressed_callback) @@ -301,6 +304,46 @@ function prompt.run(args, textbox, exe_callback, completion_callback, local selectall = args.selectall local hooks = {} + -- A function with 9 parameters deserve to die + if textbox then + util.deprecate("Use args.textbox instead of the textbox parameter") + end + if exe_callback then + util.deprecate( + "Use args.exe_callback instead of the exe_callback parameter" + ) + end + if completion_callback then + util.deprecate( + "Use args.completion_callback instead of the completion_callback parameter" + ) + end + if history_path then + util.deprecate( + "Use args.history_path instead of the history_path parameter" + ) + end + if history_max then + util.deprecate( + "Use args.history_max instead of the history_max parameter" + ) + end + if done_callback then + util.deprecate( + "Use args.done_callback instead of the done_callback parameter" + ) + end + if changed_callback then + util.deprecate( + "Use args.changed_callback instead of the changed_callback parameter" + ) + end + if keypressed_callback then + util.deprecate( + "Use args.keypressed_callback instead of the keypressed_callback parameter" + ) + end + -- This function has already an absurd number of parameters, allow them -- to be set using the args to avoid a "nil, nil, nil, nil, foo" scenario keypressed_callback = keypressed_callback or args.keypressed_callback