Merge pull request #685 from actionless/hotkeys_extended_mathes

feat(awful: hotkeys): extended matching rules
This commit is contained in:
Daniel Hahler 2016-02-11 21:52:22 +01:00
commit bb85e10042
2 changed files with 14 additions and 7 deletions

View File

@ -9,12 +9,12 @@
local hotkeys_popup = require("awful.hotkeys_popup.widget") 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({ for group_name, group_data in pairs({
vim_motion= { color="#009F00", rule=vim_rule }, vim_motion= { color="#009F00", rule_any=vim_rule_any },
vim_command= { color="#aFaF00", rule=vim_rule }, vim_command= { color="#aFaF00", rule_any=vim_rule_any },
vim_command_insert= { color="#cF4F40", rule=vim_rule }, vim_command_insert= { color="#cF4F40", rule_any=vim_rule_any },
vim_operator= { color="#aF6F00", rule=vim_rule }, vim_operator= { color="#aF6F00", rule_any=vim_rule_any },
}) do }) do
hotkeys_popup.group_rules[group_name] = group_data hotkeys_popup.group_rules[group_name] = group_data
end end

View File

@ -376,8 +376,15 @@ function widget.show_help(c, s)
for group, _ in pairs(group_list) do for group, _ in pairs(group_list) do
local need_match local need_match
for group_name, data in pairs(widget.group_rules) do for group_name, data in pairs(widget.group_rules) do
if group_name==group and data.rule then if group_name==group and (
if not c or not awful.rules.match(c, data.rule) then 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 need_match = true
break break
end end