Browse files

core.actions: More reliable mimetype checking @ execute_file

This is a result of #43 :

  Hmm... I found this behavior is different between running in Debian Sid
  and Fedora 17.

  Their python version are both 2.7.3, but when you touch a file named, and press "r", ranger in Fedora 17 displays bash as the first
  opener, then editor and pager, but ranger in Debian Sid displays editor
  first, then pager and bash.


  Ok, with your help I found it. Actions.execute_file and
  Actions.draw_possible_programs optimize the process by skipping the call
  to file --mimetype -Lb and using the mime type that the python mimetypes
  library found. The two methods return different mimetypes sometimes.
  Since file is more reliable than the python mimetypes library, I'll
  change it to use file always.
  • Loading branch information...
1 parent b0314dd commit a1be5fc881e1378d5133fa6244e9f72a3dfc5508 @hut hut committed Aug 5, 2012
Showing with 2 additions and 3 deletions.
  1. +2 −3 ranger/core/
@@ -292,10 +292,9 @@ def execute_file(self, files, **kw):
self.signal_emit('execute.before', keywords=kw)
filenames = [f.path for f in files]
- mimetype = files[0].mimetype if files else None
label = kw.get('label', kw.get('app', None))
- return self.rifle.execute(filenames, mode, label, flags, mimetype)
+ return self.rifle.execute(filenames, mode, label, flags, None)
@@ -684,7 +683,7 @@ def draw_possible_programs(self):
self.ui.browser.draw_info = []
- programs = self.rifle.list_commands([target.path], target.mimetype)
+ programs = self.rifle.list_commands([target.path], None)
programs = ['%s | %s' % program[0:2] for program in programs]
self.ui.browser.draw_info = programs

0 comments on commit a1be5fc

Please sign in to comment.