Commits

Steve Losh  committed 48b02f4

Add the --angle-brackets option to keep zsh users sane.

  • Participants
  • Parent commits 187b25f

Comments (0)

Files changed (1)

     if any(out_groups) and not all(out_groups):
         print 'Error parsing prompt string.  Mismatched braces?'
     
+    out = out.replace('%', '%%')
     return ("%s" + out + "%s") % (out_groups[0][:-1] if out_groups[0] else '',
                                   out_groups[1][1:] if out_groups[1] else '')    
 
                 return ''
         return _r
     
-    tag_start = r'\{([^{}]*?\{)?'
-    tag_end = r'(\}[^{}]*?)?\}'
+    
+    if opts.get("angle_brackets"):
+        tag_start = r'\<([^><]*?\<)?'
+        tag_end = r'(\>[^><]*?)?>'
+        brackets = '<>'
+    else:
+        tag_start = r'\{([^{}]*?\{)?'
+        tag_end = r'(\}[^{}]*?)?\}'
+        brackets = '{}'
+    
     patterns = {
         'bookmark': _bookmark,
         'branch(\|quiet)?': _branch,
             '|(\|count)'
             '|(\|quiet)'
             ')*': _patch,
-        'patches(?:'
-            '(\|join\(.*?\))'
-            '|(\|reverse)'
-            '|(\|hide_applied)'
-            '|(\|hide_unapplied)'
-            '|(\|pre_applied\(.*?\))'
-            '|(\|post_applied\(.*?\))'
-            '|(\|pre_unapplied\(.*?\))'
-            '|(\|post_unapplied\(.*?\))'
+        'patches(?:' +
+            '(\|join\([^%s]*?\))' % brackets[-1] +
+            '|(\|reverse)' +
+            '|(\|hide_applied)' +
+            '|(\|hide_unapplied)' +
+            '|(\|pre_applied\([^%s]*?\))' % brackets[-1] +
+            '|(\|post_applied\([^%s]*?\))' % brackets[-1] +
+            '|(\|pre_unapplied\([^%s]*?\))' % brackets[-1] +
+            '|(\|post_unapplied\([^%s]*?\))' % brackets[-1] +
             ')*': _patches,
         'rev(\|merge)?': _rev,
         'root': _root,
             '(\|modified)'
             '|(\|unknown)'
             ')*': _status,
-        'tags(\|[^}]*)?': _tags,
+        'tags(\|[^%s]*?)?' % brackets[-1]: _tags,
         'task': _task,
         'tip(?:'
             '(\|node)'
 cmdtable = {
     "prompt": 
     (prompt, [
+        ('', 'angle-brackets', None, 'use angle brackets (<>) for keywords'),
         ('', 'cache-incoming', None, 'used internally by hg-prompt'),
         ('', 'cache-outgoing', None, 'used internally by hg-prompt'),
     ],