summary refs log tree commit diff stats
diff options
context:
space:
mode:
-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>
='#n150'>150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175