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>
{ color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
// So far instructions can only contain linear lists of properties. Now we add
// support for more complex trees of properties in dilated reagents. This will
// come in handy later for expressing complex types, like "a dictionary from
// (address to array of charaters) to (list of numbers)".
//
// Type trees aren't as general as s-expressions even if they look like them:
// the first element of a type tree is always an atom, and it can never be
// dotted (right->right->right->...->right is always NULL).
//
// For now you can't use the simpler 'colon-based' representation inside type
// trees. Once you start typing parens, keep on typing parens.

:(scenarios load)
:(scenario dilated_reagent_with_nested_brackets)
def main [
  {1: number, foo: (bar (baz quux))} <- copy 34
]
+parse:   product: {1: "number", "foo": ("bar" ("baz" "quux"))}

:(before "End Parsing Dilated Reagent Property(value)")
value = parse_string_tree(value);
:(before "End Parsing Dilated Reagent Type Property(type_names)")
type_names = parse_string_tree(type_names);

:(code)
string_tree* parse_string_tree(string_tree* s) {
  assert(s->atom);
  if (!starts_with(s->value, "(")) return s;
  string_tree* result = parse_string_tree(s->value);
  delete s;
  return result;
}

string_tree* parse_string_tree(const string& s) {
  istringstream in(s);
  in >> std::noskipws;
  return parse_string_tree(in);
}

string_tree* parse_string_tree(istream& in) {
  skip_whitespace_but_not_newline(in);
  if (!has_data(in)) return NULL;
  if (in.peek() == ')') {
    in.get();
    return NULL;
  }
  if (in.peek() != '(') {
    string s = next_word(in);
    if (s.empty()) {
      assert(!has_data(in));
      raise << "incomplete string tree at end of file (0)\n" << end();
      return NULL;
    }
    string_tree* result = new string_tree(s);
    return result;
  }
  in.get();  // skip '('
  string_tree* result = NULL;
  string_tree** curr = &result;
  while (true) {
    skip_whitespace_but_not_newline(in);
    assert(has_data(in));
    if (in.peek() == ')') break;
    *curr = new string_tree(NULL, NULL);
    if (in.peek() == '(') {
      (*curr)->left = parse_string_tree(in);
    }
    else {
      string s = next_word(in);
      if (s.empty()) {
        assert(!has_data(in));
        raise << "incomplete string tree at end of file (1)\n" << end();
        return NULL;
      }
      (*curr)->left = new string_tree(s);
    }
    curr = &(*curr)->right;
  }
  in.get();  // skip ')'
  assert(*curr == NULL);
  return result;
}

:(scenario dilated_reagent_with_type_tree)
% Hide_errors = true;  // 'map' isn't defined yet
def main [
  {1: (foo (address array character) (bar number))} <- copy 34
]
# just to avoid errors
container foo [
]
container bar [
]
+parse:   product: {1: ("foo" ("address" "array" "character") ("bar" "number"))}

:(scenario dilated_empty_tree)
def main [
  {1: number, foo: ()} <- copy 34
]
+parse:   product: {1: "number", "foo": ()}

:(scenario dilated_singleton_tree)
def main [
  {1: number, foo: (bar)} <- copy 34
]
+parse:   product: {1: "number", "foo": ("bar")}