about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorWojciech Siewierski <wojciech.siewierski@onet.pl>2018-01-03 23:47:54 +0100
committerWojciech Siewierski <wojciech.siewierski@onet.pl>2018-01-03 23:49:07 +0100
commit82cc5eaefcfded380254382ac2193b6fd76deb68 (patch)
treecca3d8ee98f696f72f18cddde468540816bbe7a9
parent62e8308fbef35ef76fbe3679fb08aa9734fbb313 (diff)
downloadranger-82cc5eaefcfded380254382ac2193b6fd76deb68.tar.gz
config.commands: :set tab completion refactoring
-rwxr-xr-xranger/config/commands.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/ranger/config/commands.py b/ranger/config/commands.py
index 6fd34ee1..841ac6f4 100755
--- a/ranger/config/commands.py
+++ b/ranger/config/commands.py
@@ -445,13 +445,18 @@ class set_(Command):
             return sorted(self.firstpart + setting for setting in settings
                           if setting.startswith(name))
         if not value:
-            # Cycle through colorschemes when name, but no value is specified
-            if name == "colorscheme":
-                return sorted(self.firstpart + colorscheme for colorscheme
-                              in get_all_colorschemes(self.fm))
-            if name == "column_ratios":
-                return self.firstpart + ",".join(map(str, settings[name]))
-            return self.firstpart + str(settings[name])
+            value_completers = {
+                "colorscheme": lambda:
+                # Cycle through colorschemes when name, but no value is specified
+                sorted(self.firstpart + colorscheme for colorscheme
+                       in get_all_colorschemes(self.fm)),
+
+                "column_ratios": lambda:
+                self.firstpart + ",".join(map(str, settings[name])),
+            }
+            def default_value_completer():
+                return self.firstpart + str(settings[name])
+            return value_completers.get(name, default_value_completer)()
         if bool in settings.types_of(name):
             if 'true'.startswith(value.lower()):
                 return self.firstpart + 'True'