*** src/quickfix.c.orig	Sat Jun  1 16:10:30 2013
--- src/quickfix.c	Sun Jun  2 10:58:56 2013
*************** get_mef_name()
*** 2939,2944 ****
--- 2939,2983 ----
  }
  
  /*
+  * Returns a list of buffer numbers in the quickfix list.
+  */
+     int
+ qf_get_buffers(garray_T *gap, int qfl)
+ {
+     qf_info_T	*qi = &ql_info;
+     qfline_T	*qfp;
+     int		prev_fnum = 0;
+     int		i;
+ 
+     if (!qfl)
+     {
+ 	/* Location list */
+ 	qi = GET_LOC_LIST(curwin);
+ 	if (qi == NULL)
+ 	    return FAIL;
+     }
+ 
+     if (qi->qf_lists[qi->qf_curlist].qf_count <= 0)
+ 	return FAIL;
+ 
+     ga_init2(gap, sizeof(int), 1);
+ 
+     for (i = 0, qfp = qi->qf_lists[qi->qf_curlist].qf_start;
+ 	 (i < qi->qf_lists[qi->qf_curlist].qf_count) && (qfp != NULL);
+ 	 ++i, qfp = qfp->qf_next)
+     {
+ 	if (qfp->qf_valid && (qfp->qf_fnum > 0) && (qfp->qf_fnum != prev_fnum))
+ 	{
+ 	    if (ga_grow(gap, 1) == OK)
+ 		((int *)(gap->ga_data))[gap->ga_len++] = qfp->qf_fnum;
+ 	    prev_fnum = qfp->qf_fnum;
+ 	}
+     }
+ 
+     return OK;
+ }
+ 
+ /*
   * ":cc", ":crewind", ":cfirst" and ":clast".
   * ":ll", ":lrewind", ":lfirst" and ":llast".
   */
*** src/ex_cmds.h.orig	Sat Jun  1 16:11:04 2013
--- src/ex_cmds.h	Sat Jun  1 21:21:30 2013
*************** EX(CMD_cclose,		"cclose",	ex_cclose,
*** 205,210 ****
--- 205,212 ----
  			RANGE|NOTADR|COUNT|TRLBAR),
  EX(CMD_cd,		"cd",		ex_cd,
  			BANG|FILE1|TRLBAR|CMDWIN),
+ EX(CMD_cdo,		"cdo",	ex_listdo,
+ 			BANG|NEEDARG|EXTRA|NOTRLCOM),
  EX(CMD_center,		"center",	ex_align,
  			TRLBAR|RANGE|WHOLEFOLD|EXTRA|CMDWIN|MODIFY),
  EX(CMD_cexpr,		"cexpr",	ex_cexpr,
*************** EX(CMD_lclose,		"lclose",	ex_cclose,
*** 507,512 ****
--- 509,516 ----
  			RANGE|NOTADR|COUNT|TRLBAR),
  EX(CMD_lcscope,		"lcscope",	do_cscope,
  			EXTRA|NOTRLCOM|XFILE),
+ EX(CMD_ldo,		"ldo",	ex_listdo,
+ 			BANG|NEEDARG|EXTRA|NOTRLCOM),
  EX(CMD_left,		"left",		ex_align,
  			TRLBAR|RANGE|WHOLEFOLD|EXTRA|CMDWIN|MODIFY),
  EX(CMD_leftabove,	"leftabove",	ex_wrongmodifier,
*** src/ex_cmds2.c.orig	Sat Jun  1 16:11:49 2013
--- src/ex_cmds2.c	Sun Jun  2 10:59:38 2013
*************** ex_argdelete(eap)
*** 2392,2398 ****
  }
  
  /*
!  * ":argdo", ":windo", ":bufdo", ":tabdo"
   */
      void
  ex_listdo(eap)
--- 2392,2398 ----
  }
  
  /*
!  * ":argdo", ":windo", ":bufdo", ":tabdo", ":cdo"
   */
      void
  ex_listdo(eap)
*************** ex_listdo(eap)
*** 2409,2414 ****
--- 2409,2417 ----
      char_u	*save_ei = NULL;
  #endif
      char_u	*p_shm_save;
+ #ifdef FEAT_QUICKFIX
+     garray_T	ga;
+ #endif
  
  #ifndef FEAT_WINDOWS
      if (eap->cmdidx == CMD_windo)
*************** ex_listdo(eap)
*** 2439,2444 ****
--- 2442,2455 ----
  	/* set pcmark now */
  	if (eap->cmdidx == CMD_bufdo)
  	    goto_buffer(eap, DOBUF_FIRST, FORWARD, 0);
+ #ifdef FEAT_QUICKFIX
+ 	else if (eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo)
+ 	{
+ 	    if (qf_get_buffers(&ga, (eap->cmdidx == CMD_cdo)) != OK)
+ 		return;
+ 	    goto_buffer(eap, DOBUF_FIRST, FORWARD, ((int *)ga.ga_data)[i]);
+ 	}
+ #endif
  	else
  	    setpcmark();
  	listcmd_busy = TRUE;	    /* avoids setting pcmark below */
*************** ex_listdo(eap)
*** 2528,2533 ****
--- 2539,2565 ----
  		    break;
  	    }
  
+ #ifdef FEAT_QUICKFIX
+ 	    if (eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo)
+ 	    {
+ 		i++;
+ 		if (i >= ga.ga_len)
+ 		    break;
+ 
+ 		/* Go to the next buffer.  Clear 'shm' to avoid that the file
+ 		 * message overwrites any output from the command. */
+ 		p_shm_save = vim_strsave(p_shm);
+ 		set_option_value((char_u *)"shm", 0L, (char_u *)"", 0);
+ 		goto_buffer(eap, DOBUF_FIRST, FORWARD, ((int *)ga.ga_data)[i]);
+ 		set_option_value((char_u *)"shm", 0L, p_shm_save, 0);
+ 		vim_free(p_shm_save);
+ 
+ 		/* If autocommands took us elsewhere, quit here */
+ 		if (curbuf->b_fnum != ((int *)ga.ga_data)[i])
+ 		    break;
+ 	    }
+ #endif
+ 
  	    if (eap->cmdidx == CMD_windo)
  	    {
  		validate_cursor();	/* cursor may have moved */
*************** ex_listdo(eap)
*** 2539,2544 ****
--- 2571,2581 ----
  	    }
  	}
  	listcmd_busy = FALSE;
+ 
+ #ifdef FEAT_QUICKFIX
+ 	if (eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo)
+ 	    ga_clear(&ga);
+ #endif
      }
  
  #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
*** src/ex_docmd.c.orig	Sat Jun  1 16:24:45 2013
--- src/ex_docmd.c	Sun Jun  2 10:55:46 2013
*************** set_one_cmd_context(xp, buff)
*** 3584,3589 ****
--- 3584,3590 ----
  	case CMD_browse:
  	case CMD_bufdo:
  	case CMD_confirm:
+ 	case CMD_cdo:
  	case CMD_debug:
  	case CMD_folddoclosed:
  	case CMD_folddoopen:
*** src/proto/quickfix.pro.orig	Sat Jun  1 16:09:34 2013
--- src/proto/quickfix.pro	Sun Jun  2 10:59:20 2013
*************** int set_errorlist __ARGS((win_T *wp, lis
*** 27,30 ****
--- 27,31 ----
  void ex_cbuffer __ARGS((exarg_T *eap));
  void ex_cexpr __ARGS((exarg_T *eap));
  void ex_helpgrep __ARGS((exarg_T *eap));
+ int qf_get_buffers __ARGS((garray_T *gap, int qfl));
  /* vim: set ft=c : */
*** runtime/doc/cmdline.txt.orig	Sun Jun  2 11:02:32 2013
--- runtime/doc/cmdline.txt	Sun Jun  2 11:02:47 2013
*************** followed by another Vim command:
*** 507,512 ****
--- 507,513 ----
      :argdo
      :autocmd
      :bufdo
+     :cdo
      :command
      :cscope
      :debug
*************** followed by another Vim command:
*** 517,522 ****
--- 518,524 ----
      :help
      :helpfind
      :lcscope
+     :ldo
      :make
      :normal
      :perl
*** runtime/doc/index.txt.orig	Sun Jun  2 11:10:04 2013
--- runtime/doc/index.txt	Sun Jun  2 11:09:24 2013
*************** tag	      command	      action ~
*** 1129,1134 ****
--- 1129,1135 ----
  |:cc|		:cc		go to specific error
  |:cclose|	:ccl[ose]	close quickfix window
  |:cd|		:cd		change directory
+ |:cdo|		:cdo		execute command in each buffer in error list
  |:center|	:ce[nter]	format lines at the center
  |:cexpr|	:cex[pr]	read errors from expr and jump to first
  |:cfile|	:cf[ile]	read file with error messages and jump to first
*************** tag	      command	      action ~
*** 1282,1287 ****
--- 1283,1289 ----
  |:lchdir|	:lch[dir]	change directory locally
  |:lclose|	:lcl[ose]	close location window
  |:lcscope|	:lcs[cope]      like ":cscope" but uses location list
+ |:ldo|		:ld[o]		execute command in each buffer in location list
  |:left|		:le[ft]		left align lines
  |:leftabove|	:lefta[bove]	make split window appear left or above
  |:let|		:let		assign a value to a variable or option
*** runtime/doc/tabpage.txt.orig	Sun Jun  2 11:12:02 2013
--- runtime/doc/tabpage.txt	Sun Jun  2 11:12:43 2013
*************** LOOPING OVER TAB PAGES:
*** 207,213 ****
  		{cmd} must not open or close tab pages or reorder them.
  		{not in Vi} {not available when compiled without the
  		|+listcmds| feature}
! 		Also see |:windo|, |:argdo| and |:bufdo|.
  
  ==============================================================================
  3. Other items						*tab-page-other*
--- 207,213 ----
  		{cmd} must not open or close tab pages or reorder them.
  		{not in Vi} {not available when compiled without the
  		|+listcmds| feature}
! 		Also see |:windo|, |:argdo|, |:bufdo|, |:cdo| and |:ldo|.
  
  ==============================================================================
  3. Other items						*tab-page-other*
*** runtime/doc/editing.txt.orig	Sun Jun  2 11:02:57 2013
--- runtime/doc/editing.txt	Sun Jun  2 11:16:17 2013
*************** USING THE ARGUMENT LIST
*** 839,845 ****
  			each file.
  			{not in Vi} {not available when compiled without the
  			|+listcmds| feature}
! 			Also see |:windo|, |:tabdo| and |:bufdo|.
  
  Example: >
  	:args *.c
--- 839,846 ----
  			each file.
  			{not in Vi} {not available when compiled without the
  			|+listcmds| feature}
! 			Also see |:windo|, |:tabdo|, |:bufdo|, |:cdo| and
! 			|:ldo|
  
  Example: >
  	:args *.c
*** runtime/doc/quickfix.txt.orig	Sat Jun  1 18:32:10 2013
--- runtime/doc/quickfix.txt	Sun Jun  2 11:20:36 2013
*************** use this code: >
*** 298,303 ****
--- 298,352 ----
  
  	au QuickfixCmdPost make call QfMakeConv()
  
+ EXECUTE A COMMAND IN ALL THE BUFFERS IN QUICKFIX OR LOCATION LIST:
+ 							*:cdo*
+ :cdo[!] {cmd}		Execute {cmd} in each buffer in the quickfix list.
+ 			It works like doing this: >
+ 				:cfirst
+ 				:{cmd}
+ 				:cnext
+ 				:{cmd}
+ 				etc.
+ <			When the current file can't be |abandon|ed and the [!]
+ 			is not present, the command fails.
+ 			When an error is detected on one buffer, further
+ 			buffers will not be visited.
+ 			The last buffer (or where an error occurred) becomes
+ 			the current buffer.
+ 			{cmd} can contain '|' to concatenate several commands.
+ 			Note: While this command is executing, the Syntax
+ 			autocommand event is disabled by adding it to
+ 			'eventignore'.  This considerably speeds up editing
+ 			each buffer.
+ 			{not in Vi} {not available when compiled without the
+ 			|+listcmds| feature}
+ 			Also see |:bufdo|, |:tabdo|, |:argdo|, |:windo| and
+ 			|:ldo|.
+ 
+ 							*:ldo*
+ :ld[o][!] {cmd}		Execute {cmd} in each buffer in the location list for
+ 			the current window.
+ 			It works like doing this: >
+ 				:lfirst
+ 				:{cmd}
+ 				:lnext
+ 				:{cmd}
+ 				etc.
+ <			When the current file can't be |abandon|ed and the [!]
+ 			is not present, the command fails.
+ 			When an error is detected on one buffer, further
+ 			buffers will not be visited.
+ 			The last buffer (or where an error occurred) becomes
+ 			the current buffer.
+ 			{cmd} can contain '|' to concatenate several commands.
+ 			Note: While this command is executing, the Syntax
+ 			autocommand event is disabled by adding it to
+ 			'eventignore'.  This considerably speeds up editing
+ 			each buffer.
+ 			{not in Vi} {not available when compiled without the
+ 			|+listcmds| feature}
+ 			Also see |:bufdo|, |:tabdo|, |:argdo|, |:windo| and
+ 			|:cdo|.
  
  =============================================================================
  2. The error window					*quickfix-window*
*** runtime/doc/windows.txt.orig	Sun Jun  2 11:13:20 2013
--- runtime/doc/windows.txt	Sun Jun  2 11:14:27 2013
*************** can also get to them with the buffer lis
*** 669,675 ****
  			{cmd} must not open or close windows or reorder them.
  			{not in Vi} {not available when compiled without the
  			|+listcmds| feature}
! 			Also see |:tabdo|, |:argdo| and |:bufdo|.
  
  							*:bufdo*
  :bufdo[!] {cmd}		Execute {cmd} in each buffer in the buffer list.
--- 669,676 ----
  			{cmd} must not open or close windows or reorder them.
  			{not in Vi} {not available when compiled without the
  			|+listcmds| feature}
! 			Also see |:tabdo|, |:argdo|, |:bufdo|, |:cdo| and
! 			|:ldo|.
  
  							*:bufdo*
  :bufdo[!] {cmd}		Execute {cmd} in each buffer in the buffer list.
*************** can also get to them with the buffer lis
*** 695,701 ****
  			each buffer.
  			{not in Vi} {not available when compiled without the
  			|+listcmds| feature}
! 			Also see |:tabdo|, |:argdo| and |:windo|.
  
  Examples: >
  
--- 696,703 ----
  			each buffer.
  			{not in Vi} {not available when compiled without the
  			|+listcmds| feature}
! 			Also see |:tabdo|, |:argdo|, |:windo|, |:cdo| and
! 			|:ldo|.
  
  Examples: >
  
