From 901771e51b3d607b8e77f6eac6129f0736fa959b Mon Sep 17 00:00:00 2001 From: actionless Date: Thu, 11 Feb 2016 12:33:02 +0100 Subject: [PATCH] feat(awful: hotkeys): extended matching rules --- lib/awful/hotkeys_popup/keys/vim.lua | 10 +++++----- lib/awful/hotkeys_popup/widget.lua | 11 +++++++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/awful/hotkeys_popup/keys/vim.lua b/lib/awful/hotkeys_popup/keys/vim.lua index 43860a35..2c03360c 100644 --- a/lib/awful/hotkeys_popup/keys/vim.lua +++ b/lib/awful/hotkeys_popup/keys/vim.lua @@ -9,12 +9,12 @@ local hotkeys_popup = require("awful.hotkeys_popup.widget") -local vim_rule = {name="vim"} +local vim_rule_any = {name={"vim", "VIM"}} for group_name, group_data in pairs({ - vim_motion= { color="#009F00", rule=vim_rule }, - vim_command= { color="#aFaF00", rule=vim_rule }, - vim_command_insert= { color="#cF4F40", rule=vim_rule }, - vim_operator= { color="#aF6F00", rule=vim_rule }, + vim_motion= { color="#009F00", rule_any=vim_rule_any }, + vim_command= { color="#aFaF00", rule_any=vim_rule_any }, + vim_command_insert= { color="#cF4F40", rule_any=vim_rule_any }, + vim_operator= { color="#aF6F00", rule_any=vim_rule_any }, }) do hotkeys_popup.group_rules[group_name] = group_data end diff --git a/lib/awful/hotkeys_popup/widget.lua b/lib/awful/hotkeys_popup/widget.lua index b027d316..3e137def 100644 --- a/lib/awful/hotkeys_popup/widget.lua +++ b/lib/awful/hotkeys_popup/widget.lua @@ -376,8 +376,15 @@ function widget.show_help(c, s) for group, _ in pairs(group_list) do local need_match for group_name, data in pairs(widget.group_rules) do - if group_name==group and data.rule then - if not c or not awful.rules.match(c, data.rule) then + if group_name==group and ( + data.rule or data.rule_any or data.except or data.except_any + ) then + if not c or not awful.rules.matches(c, { + rule=data.rule, + rule_any=data.rule_any, + except=data.except, + except_any=data.except_any + }) then need_match = true break end