From ffe8143cc7ff9c78054de143b5b52644b29be4a0 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 1 Jul 2014 08:48:52 +0100 Subject: [PATCH] Accept upper case macro names, convert them to lower case --- src/normal.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/normal.cc b/src/normal.cc index 1c3c48b9b..6a5468b42 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -966,26 +966,26 @@ void start_or_end_macro_recording(Context& context, int) context.input_handler().stop_recording(); else on_next_key_with_autoinfo(context, [](Key key, Context& context) { - if (key.modifiers == Key::Modifiers::None and - key.key >= 'a' and key.key <= 'z') - context.input_handler().start_recording(key.key); + if (key.modifiers == Key::Modifiers::None and isalpha(key.key)) + context.input_handler().start_recording(tolower(key.key)); }, "record macro", "enter macro name "); } void replay_macro(Context& context, int count) { on_next_key_with_autoinfo(context, [count](Key key, Context& context) mutable { - if (key.modifiers == Key::Modifiers::None) + if (key.modifiers == Key::Modifiers::None and isalpha(key.key)) { static std::unordered_set running_macros; - if (contains(running_macros, key.key)) + const char name = tolower(key.key); + if (contains(running_macros, name)) throw runtime_error("recursive macros call detected"); - memoryview reg_val = RegisterManager::instance()[key.key].values(context); + memoryview reg_val = RegisterManager::instance()[name].values(context); if (not reg_val.empty()) { - running_macros.insert(key.key); - auto stop = on_scope_end([&]{ running_macros.erase(key.key); }); + running_macros.insert(name); + auto stop = on_scope_end([&]{ running_macros.erase(name); }); auto keys = parse_keys(reg_val[0]); ScopedEdition edition(context);