@@ -2041,7 +2041,7 @@ autowrite(buf_T *buf, int forceit)
20412041}
20422042
20432043/*
2044- * flush all buffers, except the ones that are readonly
2044+ * Flush all buffers, except the ones that are readonly or are never written.
20452045 */
20462046 void
20472047autowrite_all (void )
@@ -2051,7 +2051,7 @@ autowrite_all(void)
20512051 if (!(p_aw || p_awa ) || !p_write )
20522052 return ;
20532053 FOR_ALL_BUFFERS (buf )
2054- if (bufIsChanged (buf ) && !buf -> b_p_ro )
2054+ if (bufIsChanged (buf ) && !buf -> b_p_ro && ! bt_dontwrite ( buf ) )
20552055 {
20562056 bufref_T bufref ;
20572057
@@ -2518,10 +2518,10 @@ buf_write_all(buf_T *buf, int forceit)
25182518 */
25192519
25202520static char_u * do_one_arg (char_u * str );
2521- static int do_arglist (char_u * str , int what , int after );
2521+ static int do_arglist (char_u * str , int what , int after , int will_edit );
25222522static void alist_check_arg_idx (void );
25232523static int editing_arg_idx (win_T * win );
2524- static int alist_add_list (int count , char_u * * files , int after );
2524+ static void alist_add_list (int count , char_u * * files , int after , int will_edit );
25252525#define AL_SET 1
25262526#define AL_ADD 2
25272527#define AL_DEL 3
@@ -2626,7 +2626,7 @@ get_arglist_exp(
26262626 void
26272627set_arglist (char_u * str )
26282628{
2629- do_arglist (str , AL_SET , 0 );
2629+ do_arglist (str , AL_SET , 0 , FALSE );
26302630}
26312631
26322632/*
@@ -2640,7 +2640,8 @@ set_arglist(char_u *str)
26402640do_arglist (
26412641 char_u * str ,
26422642 int what ,
2643- int after UNUSED ) /* 0 means before first one */
2643+ int after UNUSED , // 0 means before first one
2644+ int will_edit ) // will edit added argument
26442645{
26452646 garray_T new_ga ;
26462647 int exp_count ;
@@ -2725,11 +2726,11 @@ do_arglist(
27252726
27262727 if (what == AL_ADD )
27272728 {
2728- ( void ) alist_add_list (exp_count , exp_files , after );
2729+ alist_add_list (exp_count , exp_files , after , will_edit );
27292730 vim_free (exp_files );
27302731 }
27312732 else /* what == AL_SET */
2732- alist_set (ALIST (curwin ), exp_count , exp_files , FALSE , NULL , 0 );
2733+ alist_set (ALIST (curwin ), exp_count , exp_files , will_edit , NULL , 0 );
27332734 }
27342735
27352736 alist_check_arg_idx ();
@@ -3005,7 +3006,7 @@ ex_next(exarg_T *eap)
30053006 {
30063007 if (* eap -> arg != NUL ) /* redefine file list */
30073008 {
3008- if (do_arglist (eap -> arg , AL_SET , 0 ) == FAIL )
3009+ if (do_arglist (eap -> arg , AL_SET , 0 , TRUE ) == FAIL )
30093010 return ;
30103011 i = 0 ;
30113012 }
@@ -3025,7 +3026,7 @@ ex_argedit(exarg_T *eap)
30253026 // Whether curbuf will be reused, curbuf->b_ffname will be set.
30263027 int curbuf_is_reusable = curbuf_reusable ();
30273028
3028- if (do_arglist (eap -> arg , AL_ADD , i ) == FAIL )
3029+ if (do_arglist (eap -> arg , AL_ADD , i , TRUE ) == FAIL )
30293030 return ;
30303031#ifdef FEAT_TITLE
30313032 maketitle ();
@@ -3047,7 +3048,8 @@ ex_argedit(exarg_T *eap)
30473048ex_argadd (exarg_T * eap )
30483049{
30493050 do_arglist (eap -> arg , AL_ADD ,
3050- eap -> addr_count > 0 ? (int )eap -> line2 : curwin -> w_arg_idx + 1 );
3051+ eap -> addr_count > 0 ? (int )eap -> line2 : curwin -> w_arg_idx + 1 ,
3052+ FALSE);
30513053#ifdef FEAT_TITLE
30523054 maketitle ();
30533055#endif
@@ -3097,7 +3099,7 @@ ex_argdelete(exarg_T *eap)
30973099 else if (* eap -> arg == NUL )
30983100 EMSG (_ (e_argreq ));
30993101 else
3100- do_arglist (eap -> arg , AL_DEL , 0 );
3102+ do_arglist (eap -> arg , AL_DEL , 0 , FALSE );
31013103#ifdef FEAT_TITLE
31023104 maketitle ();
31033105#endif
@@ -3342,13 +3344,13 @@ ex_listdo(exarg_T *eap)
33423344 * Add files[count] to the arglist of the current window after arg "after".
33433345 * The file names in files[count] must have been allocated and are taken over.
33443346 * Files[] itself is not taken over.
3345- * Returns index of first added argument. Returns -1 when failed (out of mem).
33463347 */
3347- static int
3348+ static void
33483349alist_add_list (
33493350 int count ,
33503351 char_u * * files ,
3351- int after ) /* where to add: 0 = before first one */
3352+ int after , // where to add: 0 = before first one
3353+ int will_edit ) // will edit adding argument
33523354{
33533355 int i ;
33543356 int old_argcount = ARGCOUNT ;
@@ -3364,19 +3366,19 @@ alist_add_list(
33643366 (ARGCOUNT - after ) * sizeof (aentry_T ));
33653367 for (i = 0 ; i < count ; ++ i )
33663368 {
3369+ int flags = BLN_LISTED | (will_edit ? BLN_CURBUF : 0 );
3370+
33673371 ARGLIST [after + i ].ae_fname = files [i ];
3368- ARGLIST [after + i ].ae_fnum =
3369- buflist_add (files [i ], BLN_LISTED | BLN_CURBUF );
3372+ ARGLIST [after + i ].ae_fnum = buflist_add (files [i ], flags );
33703373 }
33713374 ALIST (curwin )-> al_ga .ga_len += count ;
33723375 if (old_argcount > 0 && curwin -> w_arg_idx >= after )
33733376 curwin -> w_arg_idx += count ;
3374- return after ;
3377+ return ;
33753378 }
33763379
33773380 for (i = 0 ; i < count ; ++ i )
33783381 vim_free (files [i ]);
3379- return -1 ;
33803382}
33813383
33823384#if defined(FEAT_CMDL_COMPL ) || defined(PROTO )
0 commit comments