summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--doc/ranger.16
-rw-r--r--doc/ranger.pod6
-rw-r--r--ranger/core/linemode.py7
-rw-r--r--ranger/core/main.py4
-rw-r--r--ranger/ext/img_display.py9
5 files changed, 26 insertions, 6 deletions
diff --git a/doc/ranger.1 b/doc/ranger.1
index 98c7a0d0..ecc4f7f1 100644
--- a/doc/ranger.1
+++ b/doc/ranger.1
@@ -406,6 +406,9 @@ a function that ranger uses.  This allows you to change pretty much every part
 of ranger, but there is no guarantee that things will continue to work in
 future versions as the source code evolves.
 .PP
+Adding new commands via a plugin as simple as specifying them like you would do
+in the \fIcommands.py\fR.
+.PP
 There are some hooks that are specifically made for the use in plugins.  They
 are functions that start with hook_ and can be found throughout the code.
 .PP
@@ -1294,7 +1297,8 @@ and settings are defined here.
 .IP "commands.py" 10
 .IX Item "commands.py"
 A python module that defines commands which can be used in ranger's console by
-typing \*(L":\*(R" or in the rc.conf file.
+typing \*(L":\*(R" or in the rc.conf file.  Note that you can define commands in the
+same manner within plugins.
 .IP "commands_full.py" 10
 .IX Item "commands_full.py"
 This file is copied by \-\-copy\-config=commands_full and serves as a reference
diff --git a/doc/ranger.pod b/doc/ranger.pod
index 2a4a1674..00c26f12 100644
--- a/doc/ranger.pod
+++ b/doc/ranger.pod
@@ -302,6 +302,9 @@ a function that ranger uses.  This allows you to change pretty much every part
 of ranger, but there is no guarantee that things will continue to work in
 future versions as the source code evolves.
 
+Adding new commands via a plugin as simple as specifying them like you would do
+in the I<commands.py>.
+
 There are some hooks that are specifically made for the use in plugins.  They
 are functions that start with hook_ and can be found throughout the code.
 
@@ -1367,7 +1370,8 @@ and settings are defined here.
 =item commands.py
 
 A python module that defines commands which can be used in ranger's console by
-typing ":" or in the rc.conf file.
+typing ":" or in the rc.conf file.  Note that you can define commands in the
+same manner within plugins.
 
 =item commands_full.py
 
diff --git a/ranger/core/linemode.py b/ranger/core/linemode.py
index b7aef23f..be559578 100644
--- a/ranger/core/linemode.py
+++ b/ranger/core/linemode.py
@@ -97,8 +97,11 @@ class FileInfoLinemode(LinemodeBase):
 
     def infostring(self, file, metadata):
         if not file.is_directory:
-            from subprocess import check_output
-            fileinfo = check_output(["file", "-bL", file.path]).strip()
+            from subprocess import check_output, CalledProcessError
+            try:
+                fileinfo = check_output(["file", "-bL", file.path]).strip()
+            except CalledProcessError:
+                return "unknown"
             if sys.version_info[0] >= 3:
                 fileinfo = fileinfo.decode("utf-8")
             return fileinfo
diff --git a/ranger/core/main.py b/ranger/core/main.py
index 39d682f7..2972a1eb 100644
--- a/ranger/core/main.py
+++ b/ranger/core/main.py
@@ -6,6 +6,7 @@
 import os.path
 import sys
 import tempfile
+import importlib
 
 def main():
     """initialize objects and run the filemanager"""
@@ -301,7 +302,8 @@ def load_settings(fm, clean):
             ranger.fm = fm
             for plugin in sorted(plugins):
                 try:
-                    module = __import__('plugins', fromlist=[plugin])
+                    module = importlib.import_module('plugins.' + plugin)
+                    fm.commands.load_commands_from_module(module)
                     fm.log.append("Loaded plugin '%s'." % plugin)
                 except Exception as e:
                     fm.log.append("Error in plugin '%s'" % plugin)
diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py
index 9df64316..0c6a11d4 100644
--- a/ranger/ext/img_display.py
+++ b/ranger/ext/img_display.py
@@ -11,6 +11,7 @@ implementations, which are currently w3m and iTerm2.
 
 import base64
 import curses
+import errno
 import fcntl
 import imghdr
 import os
@@ -117,7 +118,13 @@ class W3MImageDisplayer(ImageDisplayer):
                 h = height * fonth + 1)
                 # h = (height - 1) * fonth + 1) # (for tmux top status bar)
 
-        self.process.stdin.write(cmd)
+        try:
+            self.process.stdin.write(cmd)
+        except IOError as e:
+            if e.errno == errno.EPIPE:
+                return
+            else:
+                raise e
         self.process.stdin.flush()
         self.process.stdout.readline()