From 712ec67e1426fe601e99c63ac078d215378299c7 Mon Sep 17 00:00:00 2001 From: Wojciech Siewierski Date: Sun, 19 Aug 2018 15:48:45 +0200 Subject: Implement the filter stack rotation Tested to work both ways, so one can rotate by negative number to undo the previous positive rotation. --- doc/ranger.1 | 6 +++++- doc/ranger.pod | 7 ++++++- ranger/config/commands.py | 7 +++++++ ranger/config/rc.conf | 1 + 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 -- cgit 1.4.1-2-gfad0