diff options
author | hut <hut@lavabit.com> | 2013-01-01 18:49:17 +0100 |
---|---|---|
committer | hut <hut@lavabit.com> | 2013-01-01 18:49:17 +0100 |
commit | cfc8a68eed60d6f898130a1203c07949c6f82de5 (patch) | |
tree | 09354af032eeb6e9b9fc07faccaf04d9e1de6662 | |
parent | 07b79215a381757cd1fe93ff365add8db696b65e (diff) | |
download | ranger-cfc8a68eed60d6f898130a1203c07949c6f82de5.tar.gz |
config/commands: Added commands 'mark_tag' and 'unmark_tag'
-rw-r--r-- | doc/ranger.1 | 12 | ||||
-rw-r--r-- | doc/ranger.pod | 12 | ||||
-rw-r--r-- | ranger/config/commands.py | 35 |
3 files changed, 58 insertions, 1 deletions
diff --git a/doc/ranger.1 b/doc/ranger.1 index 301653db..0deac56e 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -124,7 +124,7 @@ .\" ======================================================================== .\" .IX Title "RANGER 1" -.TH RANGER 1 "ranger-1.5.5" "12/10/2012" "ranger manual" +.TH RANGER 1 "ranger-1.5.5" "01/01/2013" "ranger manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -717,6 +717,7 @@ ranger. For your convenience, this is a list of the \*(L"public\*(R" commands i \& load_copy_buffer \& map key command \& mark pattern +\& mark_tag [tags] \& mkdir dirname \& open_with [application] [flags] [mode] \& pmap key command @@ -737,6 +738,7 @@ ranger. For your convenience, this is a list of the \*(L"public\*(R" commands i \& tunmap keys... \& unmap keys... \& unmark pattern +\& unmark_tag [tags] .Ve .PP There are additional commands which are directly translated to python @@ -854,6 +856,10 @@ not in the console, task view or pager. To bind keys there, use the commands .IP "mark \fIpattern\fR" 2 .IX Item "mark pattern" Mark all files matching the regular expression pattern. +.IP "mark_tag [\fItags\fR]" 2 +.IX Item "mark_tag [tags]" +Mark all tags that are tagged with either of the given tags. When leaving out +the tag argument, all tagged files are marked. .IP "mkdir \fIdirname\fR" 2 .IX Item "mkdir dirname" Creates a directory with the name \fIdirname\fR. @@ -939,6 +945,10 @@ in the console, taskview, or pager use \*(L"cunmap\*(R", \*(L"tunmap\*(R" or \*( .IP "unmark \fIpattern\fR" 2 .IX Item "unmark pattern" Unmark all files matching a regular expression pattern. +.IP "unmark_tag [\fItags\fR]" 2 +.IX Item "unmark_tag [tags]" +Unmark all tags that are tagged with either of the given tags. When leaving +out the tag argument, all tagged files are unmarked. .SH "FILES" .IX Header "FILES" ranger reads several configuration files which are located in diff --git a/doc/ranger.pod b/doc/ranger.pod index 8ac18911..7ab59460 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -726,6 +726,7 @@ ranger. For your convenience, this is a list of the "public" commands including load_copy_buffer map key command mark pattern + mark_tag [tags] mkdir dirname open_with [application] [flags] [mode] pmap key command @@ -746,6 +747,7 @@ ranger. For your convenience, this is a list of the "public" commands including tunmap keys... unmap keys... unmark pattern + unmark_tag [tags] There are additional commands which are directly translated to python functions, one for every method in the ranger.core.actions.Actions class. @@ -886,6 +888,11 @@ not in the console, task view or pager. To bind keys there, use the commands Mark all files matching the regular expression pattern. +=item mark_tag [I<tags>] + +Mark all tags that are tagged with either of the given tags. When leaving out +the tag argument, all tagged files are marked. + =item mkdir I<dirname> Creates a directory with the name I<dirname>. @@ -989,6 +996,11 @@ in the console, taskview, or pager use "cunmap", "tunmap" or "punmap". Unmark all files matching a regular expression pattern. +=item unmark_tag [I<tags>] + +Unmark all tags that are tagged with either of the given tags. When leaving +out the tag argument, all tagged files are unmarked. + =back diff --git a/ranger/config/commands.py b/ranger/config/commands.py index 3a3b84c4..07c595e0 100644 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -548,6 +548,31 @@ class mark(Command): self.fm.ui.need_redraw = True +class mark_tag(Command): + """ + :mark_tag [<tags>] + + Mark all tags that are tagged with either of the given tags. + When leaving out the tag argument, all tagged files are marked. + """ + do_mark = True + + def execute(self): + cwd = self.fm.thisdir + tags = self.rest(1).replace(" ","") + if not self.fm.tags: + return + for fileobj in cwd.files: + try: + tag = self.fm.tags.tags[fileobj.realpath] + except KeyError: + continue + if not tags or tag in tags: + cwd.mark_item(fileobj, val=self.do_mark) + self.fm.ui.status.need_redraw = True + self.fm.ui.need_redraw = True + + class console(Command): """ :console <command> @@ -615,6 +640,16 @@ class unmark(mark): do_mark = False +class unmark_tag(mark_tag): + """ + :unmark_tag [<tags>] + + Unmark all tags that are tagged with either of the given tags. + When leaving out the tag argument, all tagged files are unmarked. + """ + do_mark = False + + class mkdir(Command): """ :mkdir <dirname> |