Code

Allow built-in run requests to be unbound
authorJonas Fonseca <fonseca@diku.dk>
Thu, 22 Apr 2010 02:15:08 +0000 (22:15 -0400)
committerJonas Fonseca <fonseca@diku.dk>
Thu, 22 Apr 2010 02:33:56 +0000 (22:33 -0400)
By adding built-in run requests after loading config files and checking
if each of them conflicts with an existing keybinding.

Reported by Simon Ruderich.

NEWS
tig.c

diff --git a/NEWS b/NEWS
index 59d748947cdea0b7b5936c85c50ac04f4c5a19bb..d03fea86c5ababa7dfee109efe617bebde19f6ad 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -30,6 +30,7 @@ Bug fixes:
  - Fix parsing of boolean show-date values.
  - Fix relative date.
  - Fix unbind to behave as if the keybinding was never defined.
+ - Fix unbind to also cover built-in run requests.
  - Fix parsing of unknown keymap names.
 
 tig-0.15
diff --git a/tig.c b/tig.c
index 49ef43727a3925d409276907fe0241ecb7023261..7eb9f71b6827036fea61d811fedd0296d0a7dc28 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -1762,8 +1762,10 @@ add_builtin_run_requests(void)
        int i;
 
        for (i = 0; i < ARRAY_SIZE(reqs); i++) {
-               enum request req;
+               enum request req = get_keybinding(reqs[i].keymap, reqs[i].key);
 
+               if (req != reqs[i].key)
+                       continue;
                req = add_run_request(reqs[i].keymap, reqs[i].key, reqs[i].argc, reqs[i].argv);
                if (req != REQ_NONE)
                        add_keybinding(reqs[i].keymap, req, reqs[i].key);
@@ -2137,8 +2139,6 @@ load_options(void)
        const char *tigrc_system = getenv("TIGRC_SYSTEM");
        char buf[SIZEOF_STR];
 
-       add_builtin_run_requests();
-
        if (!tigrc_system)
                tigrc_system = SYSCONFDIR "/tigrc";
        load_option_file(tigrc_system);
@@ -2150,6 +2150,10 @@ load_options(void)
        }
        load_option_file(tigrc_user);
 
+       /* Add _after_ loading config files to avoid adding run requests
+        * that conflict with keybindings. */
+       add_builtin_run_requests();
+
        return OK;
 }