summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--TODO4
-rw-r--r--ranger/defaults/commands.py35
-rw-r--r--ranger/defaults/options.py8
-rw-r--r--ranger/help/console.py6
4 files changed, 47 insertions, 6 deletions
diff --git a/TODO b/TODO
index e91a1598..169fa6d6 100644
--- a/TODO
+++ b/TODO
@@ -52,7 +52,7 @@ General
    (X) #79  10/04/08  tab number zero
    ( ) #80  10/04/08  when closing tabs, avoid gaps?
    ( ) #81  10/04/15  system crash when previewing /proc/kcore with root permissions
-   ( ) #83  10/04/19  better ways to mark files. eg by regexp, filetype,..
+   (X) #83  10/04/19  better ways to mark files. eg by regexp, filetype,..
    ( ) #86  10/04/21  narg for move_parent
    ( ) #60  10/02/05  utf support improvable
 
@@ -80,7 +80,7 @@ Bugs
    (X) #73  10/03/21  when clicking on the first column, it goes 1x down
    (X) #74  10/03/21  console doesn't scroll
    (X) #78  10/03/31  broken preview when deleting all files in a directory
-   ( ) #85  10/04/26  no automatic reload of directory after using :filter
+   (X) #85  10/04/26  no automatic reload of directory after using :filter
 
 
 Ideas
diff --git a/ranger/defaults/commands.py b/ranger/defaults/commands.py
index e33cc2f1..bfe038c5 100644
--- a/ranger/defaults/commands.py
+++ b/ranger/defaults/commands.py
@@ -277,6 +277,40 @@ class delete(Command):
 		# no need for a confirmation, just delete
 		self.fm.delete()
 
+
+class mark(Command):
+	"""
+	:mark <regexp>
+
+	Mark all files matching a regular expression.
+	"""
+	do_mark = True
+
+	def execute(self):
+		import re
+		cwd = self.fm.env.cwd
+		line = parse(self.line)
+		input = line.rest(1)
+		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=self.do_mark)
+		self.fm.ui.status.need_redraw = True
+		self.fm.ui.need_redraw = True
+
+
+class unmark(mark):
+	"""
+	:unmark <regexp>
+
+	Unmark all files matching a regular expression.
+	"""
+	do_mark = False
+
+
 class mkdir(Command):
 	"""
 	:mkdir <dirname>
@@ -431,6 +465,7 @@ class filter(Command):
 	def execute(self):
 		line = parse(self.line)
 		self.fm.set_filter(line.rest(1))
+		self.fm.reload_cwd()
 
 
 class grep(Command):
diff --git a/ranger/defaults/options.py b/ranger/defaults/options.py
index 9fb9d728..ac074e1c 100644
--- a/ranger/defaults/options.py
+++ b/ranger/defaults/options.py
@@ -108,6 +108,10 @@ sort_reverse = False
 sort_case_insensitive = False
 sort_directories_first = True
 
+# Enable this if key combinations with the Alt Key don't work for you.
+# (Especially on xterm)
+xterm_alt_key = False
+
 
 # Apply an overlay function to the colorscheme.  It will be called with
 # 4 arguments: the context and the 3 values (fg, bg, attr) returned by
@@ -127,7 +131,3 @@ def colorscheme_overlay(context, fg, bg, attr):
 
 # The above function was just an example, let's set it back to None
 colorscheme_overlay = None
-
-# Enable this if key combinations with the Alt Key don't work for you.
-# (Especially on xterm)
-xterm_alt_key = False
diff --git a/ranger/help/console.py b/ranger/help/console.py
index c62d0244..04372f38 100644
--- a/ranger/help/console.py
+++ b/ranger/help/console.py
@@ -94,6 +94,12 @@ 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 all files matching a regular expression.
+
+:unmark <regexp>
+      Unmark all files matching a regular expression.
+
 :mkdir <dirname>
       Creates a directory with the name <dirname>