@@ -89,7 +89,7 @@ def the_filter(path):
8989 extensions = ['php' , 'phpt' , 'js' , 'css' , 'rb' , 'erb' ]
9090)
9191
92- def run_interactive (query , editor = None , just_count = False ):
92+ def run_interactive (query , editor = None , just_count = False , default_no = False ):
9393 """
9494 Asks the user about each patch suggested by the result of the query.
9595
@@ -125,7 +125,7 @@ def run_interactive(query, editor=None, just_count=False):
125125
126126 for patch in suggestions :
127127 _save_bookmark (patch .start_position )
128- _ask_about_patch (patch , editor )
128+ _ask_about_patch (patch , editor , default_no )
129129 print 'Searching...'
130130 _delete_bookmark ()
131131 if yes_to_all :
@@ -564,8 +564,9 @@ def print_file_line(line_number):
564564 print_file_line (i )
565565
566566yes_to_all = False
567- def _ask_about_patch (patch , editor ):
567+ def _ask_about_patch (patch , editor , default_no ):
568568 global yes_to_all
569+ default_action = 'n' if default_no else 'y'
569570 terminal_clear ()
570571 terminal_print ('%s\n ' % patch .render_range (), color = 'WHITE' )
571572 print
@@ -577,9 +578,13 @@ def _ask_about_patch(patch, editor):
577578
578579 if patch .new_lines is not None :
579580 if not yes_to_all :
580- print 'Accept change (y = yes [default], n = no, e = edit, \
581- A = yes to all, E = yes+edit)? ' ,
582- p = _prompt ('yneEA' , default = 'y' )
581+ if default_no :
582+ print ('Accept change (y = yes, n = no [default], e = edit, ' +
583+ 'A = yes to all, E = yes+edit)? ' ),
584+ else :
585+ print ('Accept change (y = yes [default], n = no, e = edit, ' +
586+ 'A = yes to all, E = yes+edit)? ' ),
587+ p = _prompt ('yneEA' , default = default_action )
583588 else :
584589 p = 'y'
585590 else :
@@ -807,6 +812,9 @@ def _parse_command_line():
807812 parser .add_argument ('--accept-all' , action = 'store_true' ,
808813 help = 'Automatically accept all changes (use with caution).' )
809814
815+ parser .add_argument ('--default-no' , action = 'store_true' ,
816+ help = 'If set, this will make the default option to not accept the change.' )
817+
810818 parser .add_argument ('--editor' , action = 'store' , type = str ,
811819 help = 'Specify an editor, e.g. "vim" or emacs". '
812820 'If omitted, defaults to $EDITOR environment variable.' )
@@ -854,6 +862,7 @@ def _parse_command_line():
854862 if arguments .editor is not None :
855863 options ['editor' ] = arguments .editor
856864 options ['just_count' ] = arguments .count
865+ options ['default_no' ] = arguments .default_no
857866
858867 return options
859868
0 commit comments