summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2011-09-29 00:05:06 +0200
committerhut <hut@lavabit.com>2011-09-29 00:14:35 +0200
commitaffbad6ce1e2c8783b0002b617fe0a229546a069 (patch)
tree38bb46d7b90a04cdc81891bdfd8d51730727c1f1 /ranger
parentbdc872b0178be74059f49d8878b5c05f2d7ed8ce (diff)
downloadranger-affbad6ce1e2c8783b0002b617fe0a229546a069.tar.gz
core.main: added --list-unused-keys option
Diffstat (limited to 'ranger')
-rw-r--r--ranger/container/keymap.py4
-rw-r--r--ranger/core/helper.py2
-rw-r--r--ranger/core/main.py14
3 files changed, 18 insertions, 2 deletions
diff --git a/ranger/container/keymap.py b/ranger/container/keymap.py
index d52a5215..8739d22a 100644
--- a/ranger/container/keymap.py
+++ b/ranger/container/keymap.py
@@ -95,9 +95,9 @@ class KeyMapWithDirections(KeyMap):
 		self.directions = KeyMap()
 
 	def merge(self, other):
-		assert hasattr(other, 'directions'), 'Merging with wrong type?'
 		Tree.merge(self, other)
-		Tree.merge(self.directions, other.directions)
+		if hasattr(other, 'directions'):
+			Tree.merge(self.directions, other.directions)
 
 	def dir(self, *args, **keywords):
 		if ALIASARG in keywords:
diff --git a/ranger/core/helper.py b/ranger/core/helper.py
index d1ef3ed0..910c0241 100644
--- a/ranger/core/helper.py
+++ b/ranger/core/helper.py
@@ -73,6 +73,8 @@ def parse_arguments():
 	parser.add_option('--choosedir', type='string', metavar='TARGET',
 			help="Makes ranger act like a directory chooser. When ranger quits"
 			", it will write the name of the last visited directory to TARGET")
+	parser.add_option('--list-unused-keys', action='store_true',
+			help="List common keys which are not bound to any action.")
 
 	options, positional = parser.parse_args()
 	arg = OpenStruct(options.__dict__, targets=positional)
diff --git a/ranger/core/main.py b/ranger/core/main.py
index e6392387..5a7b32af 100644
--- a/ranger/core/main.py
+++ b/ranger/core/main.py
@@ -77,6 +77,20 @@ def main():
 		fm.tabs = dict((n+1, os.path.abspath(path)) for n, path \
 				in enumerate(targets[:9]))
 		load_settings(fm, arg.clean)
+
+		if arg.list_unused_keys:
+			from ranger.ext.keybinding_parser import special_keys
+			tree = EnvironmentAware.env.keymanager.get_context('browser')
+			tree.merge(tree.directions)
+			reversed_special_keys = dict((v,k) for k,v in special_keys.items())
+			for key in sorted(special_keys.values()):
+				if key not in tree._tree:
+					print("<%s>" % reversed_special_keys[key])
+			for key in range(33, 128):
+				if key not in tree._tree:
+					print(chr(key))
+			return 1 if arg.fail_unless_cd else 0
+
 		if fm.env.username == 'root':
 			fm.settings.preview_files = False
 			fm.settings.use_preview_script = False