summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorWojciech Siewierski <wojciech.siewierski@onet.pl>2018-08-19 15:48:45 +0200
committerWojciech Siewierski <wojciech.siewierski@onet.pl>2018-08-19 15:50:15 +0200
commit712ec67e1426fe601e99c63ac078d215378299c7 (patch)
tree72ac72d4aa246de4ffd49d42195a5e8908b37c66
parentf4d3edae2572a1a96670dd8a9c6710f2d5d22e0c (diff)
downloadranger-712ec67e1426fe601e99c63ac078d215378299c7.tar.gz
Implement the filter stack rotation
Tested to work both ways, so one can rotate by negative number to undo
the previous positive rotation.
-rw-r--r--doc/ranger.16
-rw-r--r--doc/ranger.pod7
-rwxr-xr-xranger/config/commands.py7
-rw-r--r--ranger/config/rc.conf1
4 files changed, 19 insertions, 2 deletions
diff --git a/doc/ranger.1 b/doc/ranger.1
index 4ed1e584..8423d068 100644
--- a/doc/ranger.1
+++ b/doc/ranger.1
@@ -670,10 +670,14 @@ Apply the typefilter \*(L"file\*(R".
 .IX Item ".l"
 Apply the typefilter \*(L"symlink\*(R".
 .IP ".|" 14
-Combine te two topmost filters from the filter stack in the \*(L"\s-1OR\*(R"\s0
+Combine the two topmost filters from the filter stack in the \*(L"\s-1OR\*(R"\s0
 relationship, instead of the \*(L"\s-1AND\*(R"\s0 used implicitly.
 .IP ".!" 14
 Negate the topmost filter.
+.IP ".r" 14
+.IX Item ".r"
+Rotate the filter stack by N elements. Just confirm with enter to
+rotate by 1, i.e. move the topmost element to the bottom of the stack.
 .IP ".c" 14
 .IX Item ".c"
 Clear the filter stack.
diff --git a/doc/ranger.pod b/doc/ranger.pod
index 849acbb2..6e7075a7 100644
--- a/doc/ranger.pod
+++ b/doc/ranger.pod
@@ -638,13 +638,18 @@ Apply the typefilter "symlink".
 
 =item .|
 
-Combine te two topmost filters from the filter stack in the "OR"
+Combine the two topmost filters from the filter stack in the "OR"
 relationship, instead of the "AND" used implicitly.
 
 =item .!
 
 Negate the topmost filter.
 
+=item .r
+
+Rotate the filter stack by N elements. Just confirm with enter to
+rotate by 1, i.e. move the topmost element to the bottom of the stack.
+
 =item .c
 
 Clear the filter stack.
diff --git a/ranger/config/commands.py b/ranger/config/commands.py
index 35aa3ffb..c136db56 100755
--- a/ranger/config/commands.py
+++ b/ranger/config/commands.py
@@ -1554,6 +1554,7 @@ class filter_stack(Command):
         filter_stack add FILTER_TYPE ARGS...
         filter_stack pop
         filter_stack decompose
+        filter_stack rotate [N=1]
         filter_stack clear
         filter_stack show
     """
@@ -1577,6 +1578,12 @@ class filter_stack(Command):
                 self.fm.thisdir.filter_stack.extend(inner_filters)
         elif subcommand == "clear":
             self.fm.thisdir.filter_stack = []
+        elif subcommand == "rotate":
+            rotate_by = int(self.arg(2) or 1)
+            self.fm.thisdir.filter_stack = (
+                self.fm.thisdir.filter_stack[-rotate_by:]
+                + self.fm.thisdir.filter_stack[:-rotate_by]
+            )
         elif subcommand == "show":
             stack = map(str, self.fm.thisdir.filter_stack)
             pager = self.fm.ui.open_pager()
diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf
index 4d8f1f54..14706dce 100644
--- a/ranger/config/rc.conf
+++ b/ranger/config/rc.conf
@@ -564,6 +564,7 @@ map .f filter_stack add type f
 map .l filter_stack add type l
 map .| filter_stack add or
 map .! filter_stack add not
+map .r console filter_stack rotate
 map .c filter_stack clear
 map .* filter_stack decompose
 map .p filter_stack pop