@@ -92,7 +92,7 @@ def the_filter(path):
9292 extensions = ['php' , 'phpt' , 'js' , 'css' , 'rb' , 'erb' ]
9393)
9494
95- def run_interactive (query , editor = None , just_count = False ):
95+ def run_interactive (query , editor = None , just_count = False , default_no = False ):
9696 """
9797 Asks the user about each patch suggested by the result of the query.
9898
@@ -128,7 +128,7 @@ def run_interactive(query, editor=None, just_count=False):
128128
129129 for patch in suggestions :
130130 _save_bookmark (patch .start_position )
131- _ask_about_patch (patch , editor )
131+ _ask_about_patch (patch , editor , default_no )
132132 print 'Searching...'
133133 _delete_bookmark ()
134134 if yes_to_all :
@@ -567,8 +567,9 @@ def print_file_line(line_number):
567567 print_file_line (i )
568568
569569yes_to_all = False
570- def _ask_about_patch (patch , editor ):
570+ def _ask_about_patch (patch , editor , default_no ):
571571 global yes_to_all
572+ default_action = 'n' if default_no else 'y'
572573 terminal_clear ()
573574 terminal_print ('%s\n ' % patch .render_range (), color = 'WHITE' )
574575 print
@@ -580,9 +581,13 @@ def _ask_about_patch(patch, editor):
580581
581582 if patch .new_lines is not None :
582583 if not yes_to_all :
583- print 'Accept change (y = yes [default], n = no, e = edit, \
584- A = yes to all, E = yes+edit)? ' ,
585- p = _prompt ('yneEA' , default = 'y' )
584+ if default_no :
585+ print ('Accept change (y = yes, n = no [default], e = edit, ' +
586+ 'A = yes to all, E = yes+edit)? ' ),
587+ else :
588+ print ('Accept change (y = yes [default], n = no, e = edit, ' +
589+ 'A = yes to all, E = yes+edit)? ' ),
590+ p = _prompt ('yneEA' , default = default_action )
586591 else :
587592 p = 'y'
588593 else :
@@ -810,6 +815,9 @@ def _parse_command_line():
810815 parser .add_argument ('--accept-all' , action = 'store_true' ,
811816 help = 'Automatically accept all changes (use with caution).' )
812817
818+ parser .add_argument ('--default-no' , action = 'store_true' ,
819+ help = 'If set, this will make the default option to not accept the change.' )
820+
813821 parser .add_argument ('--editor' , action = 'store' , type = str ,
814822 help = 'Specify an editor, e.g. "vim" or emacs". '
815823 'If omitted, defaults to $EDITOR environment variable.' )
@@ -857,6 +865,7 @@ def _parse_command_line():
857865 if arguments .editor is not None :
858866 options ['editor' ] = arguments .editor
859867 options ['just_count' ] = arguments .count
868+ options ['default_no' ] = arguments .default_no
860869
861870 return options
862871
0 commit comments