summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-04-27 00:48:09 +0200
committerhut <hut@lavabit.com>2010-04-27 00:48:09 +0200
commit9247ff0133a2624f82fd61609b5aa55c2ea2ffa9 (patch)
treed812f5d2707e111006cb85a6525c7313cca77043
parente209b66101e475a0aa85d5eed3dbe0e8307ffba0 (diff)
downloadranger-9247ff0133a2624f82fd61609b5aa55c2ea2ffa9.tar.gz
defaults.commands: added optional "minus" argument for :mark
-rw-r--r--ranger/defaults/commands.py9
-rw-r--r--ranger/help/console.py3
2 files changed, 8 insertions, 4 deletions
diff --git a/ranger/defaults/commands.py b/ranger/defaults/commands.py
index d4c00f60..53d7a475 100644
--- a/ranger/defaults/commands.py
+++ b/ranger/defaults/commands.py
@@ -280,23 +280,26 @@ class delete(Command):
 
 class mark(Command):
 	"""
-	:mark <regexp>
+	:mark [-] <regexp>
 
 	Mark all files matching a regular expression.
+
+	If the first argument is a "-", unmark them instead.
 	"""
 
 	def execute(self):
 		import re
 		cwd = self.fm.env.cwd
 		line = parse(self.line)
-		input = line.rest(1)
+		mark_them = line.chunk(1) != "-"
+		input = line.rest(mark_them and 1 or 2)
 		searchflags = re.UNICODE
 		if input.lower() == input: # "smartcase"
 			searchflags |= re.IGNORECASE 
 		pattern = re.compile(input, searchflags)
 		for fileobj in cwd.files:
 			if pattern.search(fileobj.basename):
-				cwd.mark_item(fileobj, val=True)
+				cwd.mark_item(fileobj, val=mark_them)
 
 
 class mkdir(Command):
diff --git a/ranger/help/console.py b/ranger/help/console.py
index d88cc267..a85af677 100644
--- a/ranger/help/console.py
+++ b/ranger/help/console.py
@@ -94,8 +94,9 @@ it conflicts with ":cd".
       Looks for a string in all marked files or directory.
       (equivalent to "!grep [some options] -e <string> -r %s | less")
 
-:mark <regexp>
+:mark [-] <regexp>
       Mark all files matching a regular expression.
+      If the first argument is a "-", unmark them instead.
 
 :mkdir <dirname>
       Creates a directory with the name <dirname>