summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--doc/ranger.pod2
-rw-r--r--ranger/config/rifle.conf1
-rw-r--r--ranger/container/fsobject.py6
-rw-r--r--ranger/core/actions.py10
-rw-r--r--tests/ranger/container/test_fsobject.py34
5 files changed, 48 insertions, 5 deletions
diff --git a/doc/ranger.pod b/doc/ranger.pod
index 91ba904a..91629a86 100644
--- a/doc/ranger.pod
+++ b/doc/ranger.pod
@@ -228,6 +228,8 @@ The macro %rangerdir expands to the directory of ranger's python library, you
 can use it for something like this command:
   alias show_commands shell less %rangerdir/config/commands.py
 
+%confdir expands to the directory given by B<--confdir>.
+
 The macro %space expands to a space character. You can use it to add spaces to
 the end of a command when needed, while preventing editors to strip spaces off
 the end of the line automatically.
diff --git a/ranger/config/rifle.conf b/ranger/config/rifle.conf
index 31db35a4..f95c94ff 100644
--- a/ranger/config/rifle.conf
+++ b/ranger/config/rifle.conf
@@ -168,6 +168,7 @@ ext djvu, has atril,  X, flag f = atril -- "$@"
 mime ^image/svg, has inkscape, X, flag f = inkscape -- "$@"
 mime ^image/svg, has display,  X, flag f = display -- "$@"
 
+mime ^image, has pqiv,      X, flag f = pqiv -- "$@"
 mime ^image, has sxiv,      X, flag f = sxiv -- "$@"
 mime ^image, has feh,       X, flag f = feh -- "$@"
 mime ^image, has mirage,    X, flag f = mirage -- "$@"
diff --git a/ranger/container/fsobject.py b/ranger/container/fsobject.py
index 1daf6d70..db6772ac 100644
--- a/ranger/container/fsobject.py
+++ b/ranger/container/fsobject.py
@@ -30,7 +30,7 @@ else:
     from string import maketrans
 _unsafe_chars = '\n' + ''.join(map(chr, range(32))) + ''.join(map(chr, range(128, 256)))
 _safe_string_table = maketrans(_unsafe_chars, '?' * len(_unsafe_chars))
-_extract_number_re = re.compile(r'(\d+)')
+_extract_number_re = re.compile(r'(\d+|\D)')
 
 def safe_path(path):
     return path.translate(_safe_string_table)
@@ -134,12 +134,12 @@ class FileSystemObject(FileManagerAware, SettingsAware):
 
     @lazy_property
     def basename_natural(self):
-        return [int(s) if s.isdigit() else s \
+        return [('0', int(s)) if s.isdigit() else (s, 0) \
                 for s in _extract_number_re.split(self.relative_path)]
 
     @lazy_property
     def basename_natural_lower(self):
-        return [int(s) if s.isdigit() else s \
+        return [('0', int(s)) if s.isdigit() else (s, 0) \
                 for s in _extract_number_re.split(self.relative_path_lower)]
 
     @lazy_property
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index 89924dc0..a168a095 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -23,6 +23,7 @@ from ranger.ext.next_available_filename import next_available_filename
 from ranger.ext.rifle import squash_flags, ASK_COMMAND
 from ranger.core.shared import FileManagerAware, SettingsAware
 from ranger.core.tab import Tab
+from ranger.container.directory import Directory
 from ranger.container.file import File
 from ranger.core.loader import CommandLoader, CopyLoader
 from ranger.container.settings import ALLOWED_SETTINGS
@@ -245,6 +246,7 @@ class Actions(FileManagerAware, SettingsAware):
         macros = {}
 
         macros['rangerdir'] = ranger.RANGERDIR
+        macros['confdir'] = self.fm.confpath()
         macros['space'] = ' '
 
         if self.fm.thisfile:
@@ -782,10 +784,14 @@ class Actions(FileManagerAware, SettingsAware):
         except KeyError:
             pass
 
-    def set_bookmark(self, key):
+    def set_bookmark(self, key, val=None):
         """Set the bookmark with the name <key> to the current directory"""
+        if val is None:
+            val = self.thisdir
+        else:
+            val = Directory(val)
         self.bookmarks.update_if_outdated()
-        self.bookmarks[str(key)] = self.thisdir
+        self.bookmarks[str(key)] = val
 
     def unset_bookmark(self, key):
         """Delete the bookmark with the name <key>"""
diff --git a/tests/ranger/container/test_fsobject.py b/tests/ranger/container/test_fsobject.py
new file mode 100644
index 00000000..3ea52d6f
--- /dev/null
+++ b/tests/ranger/container/test_fsobject.py
@@ -0,0 +1,34 @@
+import pytest
+import operator
+
+from ranger.container.fsobject import FileSystemObject
+
+
+class MockFM(object):
+    """Used to fullfill the dependency by FileSystemObject."""
+
+    default_linemodes = []
+
+
+def create_filesystem_object(path):
+    """Create a FileSystemObject without an fm object."""
+    fso = FileSystemObject.__new__(FileSystemObject)
+    fso.fm = MockFM()
+    fso.__init__(path)
+    return fso
+
+
+def test_basename_natural1():
+    """Test filenames without extensions."""
+    fsos = [create_filesystem_object(path)
+            for path in ("hello", "hello1", "hello2")]
+    assert(fsos == sorted(fsos[::-1], key=operator.attrgetter("basename_natural")))
+    assert(fsos == sorted(fsos[::-1], key=operator.attrgetter("basename_natural_lower")))
+
+
+def test_basename_natural2():
+    """Test filenames with extensions."""
+    fsos = [create_filesystem_object(path)
+            for path in ("hello", "hello.txt", "hello1.txt", "hello2.txt")]
+    assert(fsos == sorted(fsos[::-1], key=operator.attrgetter("basename_natural")))
+    assert(fsos == sorted(fsos[::-1], key=operator.attrgetter("basename_natural_lower")))