summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2011-10-10 23:01:11 +0200
committerhut <hut@lavabit.com>2011-10-10 23:01:11 +0200
commitbf9c5c988aa19e8e9a1cdd3c7b8aef1c8cb74f59 (patch)
tree2fdddf1a4373b1077b9cd3775b3cb4aa3f8e4fe4 /ranger
parent1008f630fbb854849ab8debb128d09b450ba7e16 (diff)
downloadranger-bf9c5c988aa19e8e9a1cdd3c7b8aef1c8cb74f59.tar.gz
core.helper: Cleaned up load_settings
1. put all the common operations before the "if"
2. put the loader of custom commands AFTER loading default commands
3. removed the load_default_rc guessing code, that might lead
   to unexpected behaviour.
Diffstat (limited to 'ranger')
-rw-r--r--ranger/core/helper.py45
-rw-r--r--ranger/defaults/options.py4
2 files changed, 16 insertions, 33 deletions
diff --git a/ranger/core/helper.py b/ranger/core/helper.py
index 45db80e9..eedbbb78 100644
--- a/ranger/core/helper.py
+++ b/ranger/core/helper.py
@@ -73,22 +73,24 @@ def load_settings(fm, clean):
 	from ranger.core.actions import Actions
 	import ranger.core.shared
 	import ranger.api.commands
+	from ranger.defaults import commands
+
+	# Load default commands
+	fm.commands = ranger.api.commands.CommandContainer()
+	exclude = ['settings']
+	include = [name for name in dir(Actions) if name not in exclude]
+	fm.commands.load_commands_from_object(fm, include)
+	fm.commands.load_commands_from_module(commands)
+
 	if not clean:
 		allow_access_to_confdir(ranger.arg.confdir, True)
 
-		# Load commands
-		comcont = ranger.api.commands.CommandContainer()
-		exclude = ['settings']
-		include = [name for name in dir(Actions) if name not in exclude]
-		comcont.load_commands_from_object(fm, include)
+		# Load custom commands
 		try:
 			import commands
-			comcont.load_commands_from_module(commands)
+			fm.commands.load_commands_from_module(commands)
 		except ImportError:
 			pass
-		from ranger.defaults import commands
-		comcont.load_commands_from_module(commands)
-		fm.commands = comcont
 
 		# Load apps
 		try:
@@ -102,24 +104,12 @@ def load_settings(fm, clean):
 		default_conf = fm.relpath('defaults', 'rc.conf')
 		load_default_rc = fm.settings.load_default_rc
 
-		# If load_default_rc is None, think hard:  If the users rc.conf is
-		# about as large as the default rc.conf, he probably copied it as a whole
-		# and doesn't want to load the default rc.conf anymore.
-		if load_default_rc is None:
-			try:
-				custom_conf_size = os.stat(custom_conf).st_size
-			except:
-				load_default_rc = True
-			else:
-				default_conf_size = os.stat(default_conf).st_size
-				load_default_rc = custom_conf_size < default_conf_size - 2048
-
 		if load_default_rc:
 			fm.source(default_conf)
 		if os.access(custom_conf, os.R_OK):
 			fm.source(custom_conf)
 
-		# Load plugins
+		# XXX Load plugins (experimental)
 		try:
 			plugindir = fm.confpath('plugins')
 			plugins = [p[:-3] for p in os.listdir(plugindir) \
@@ -145,16 +135,9 @@ def load_settings(fm, clean):
 
 		allow_access_to_confdir(ranger.arg.confdir, False)
 	else:
-		comcont = ranger.api.commands.CommandContainer()
-		from ranger.defaults import commands, apps
-		comcont = ranger.api.commands.CommandContainer()
-		exclude = ['settings']
-		include = [name for name in dir(Actions) if name not in exclude]
-		comcont.load_commands_from_object(fm, include)
-		comcont.load_commands_from_module(commands)
-		fm.commands = comcont
-		fm.source(fm.relpath('defaults', 'rc.conf'))
+		from ranger.defaults import apps
 		fm.apps = apps.CustomApplications()
+		fm.source(fm.relpath('defaults', 'rc.conf'))
 
 
 def load_apps(fm, clean):
diff --git a/ranger/defaults/options.py b/ranger/defaults/options.py
index d9f6278c..f4025a7c 100644
--- a/ranger/defaults/options.py
+++ b/ranger/defaults/options.py
@@ -34,8 +34,8 @@ of the values stay the same.
 from ranger.api.options import *
 
 # Load the deault rc.conf file?  If you've copied it to your configuration
-# direcory, then you should deactivate this option.  "None" means guess.
-load_default_rc = None
+# direcory, then you should deactivate this option.
+load_default_rc = True
 
 # How many columns are there, and what are their relative widths?
 column_ratios = (1, 3, 4)