Blob Blame History Raw
To: vim-dev@vim.org
Subject: Patch 7.1.276
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
------------

Patch 7.1.276
Problem:    "gw" uses 'formatexpr', even though the docs say it doesn't.
Solution:   Don't use 'formatexpr' for "gw".
Files:	    src/vim.h, src/edit.c, src/ops.c, src/proto/ops.pro


*** ../vim-7.1.275/src/vim.h	Wed Mar 12 14:38:51 2008
--- src/vim.h	Wed Mar 12 16:31:44 2008
***************
*** 949,954 ****
--- 952,958 ----
  #define INSCHAR_FORMAT	1	/* force formatting */
  #define INSCHAR_DO_COM	2	/* format comments */
  #define INSCHAR_CTRLV	4	/* char typed just after CTRL-V */
+ #define INSCHAR_NO_FEX	8	/* don't use 'formatexpr' */
  
  /* flags for open_line() */
  #define OPENLINE_DELSPACES  1	/* delete spaces after cursor */
*** ../vim-7.1.275/src/edit.c	Tue Jan 22 17:49:17 2008
--- src/edit.c	Wed Mar 12 16:35:44 2008
***************
*** 5491,5497 ****
  #if defined(FEAT_EVAL)
  	int do_internal = TRUE;
  
! 	if (*curbuf->b_p_fex != NUL)
  	{
  	    do_internal = (fex_format(curwin->w_cursor.lnum, 1L, c) != 0);
  	    /* It may be required to save for undo again, e.g. when setline()
--- 5491,5497 ----
  #if defined(FEAT_EVAL)
  	int do_internal = TRUE;
  
! 	if (*curbuf->b_p_fex != NUL && (flags & INSCHAR_NO_FEX) == 0)
  	{
  	    do_internal = (fex_format(curwin->w_cursor.lnum, 1L, c) != 0);
  	    /* It may be required to save for undo again, e.g. when setline()
***************
*** 6057,6063 ****
       * be adjusted for the text formatting.
       */
      saved_cursor = pos;
!     format_lines((linenr_T)-1);
      curwin->w_cursor = saved_cursor;
      saved_cursor.lnum = 0;
  
--- 6057,6063 ----
       * be adjusted for the text formatting.
       */
      saved_cursor = pos;
!     format_lines((linenr_T)-1, FALSE);
      curwin->w_cursor = saved_cursor;
      saved_cursor.lnum = 0;
  
*** ../vim-7.1.275/src/ops.c	Mon Feb 25 21:54:23 2008
--- src/ops.c	Wed Mar 12 16:37:29 2008
***************
*** 4380,4386 ****
      if (keep_cursor)
  	saved_cursor = oap->cursor_start;
  
!     format_lines(oap->line_count);
  
      /*
       * Leave the cursor at the first non-blank of the last formatted line.
--- 4380,4386 ----
      if (keep_cursor)
  	saved_cursor = oap->cursor_start;
  
!     format_lines(oap->line_count, keep_cursor);
  
      /*
       * Leave the cursor at the first non-blank of the last formatted line.
***************
*** 4495,4502 ****
   * first line.
   */
      void
! format_lines(line_count)
      linenr_T	line_count;
  {
      int		max_len;
      int		is_not_par;		/* current line not part of parag. */
--- 4495,4503 ----
   * first line.
   */
      void
! format_lines(line_count, avoid_fex)
      linenr_T	line_count;
+     int		avoid_fex;		/* don't use 'formatexpr' */
  {
      int		max_len;
      int		is_not_par;		/* current line not part of parag. */
***************
*** 4666,4672 ****
  #ifdef FEAT_COMMENTS
  			+ (do_comments ? INSCHAR_DO_COM : 0)
  #endif
! 			, second_indent);
  		State = old_State;
  		p_smd = smd_save;
  		second_indent = -1;
--- 4667,4673 ----
  #ifdef FEAT_COMMENTS
  			+ (do_comments ? INSCHAR_DO_COM : 0)
  #endif
! 			+ (avoid_fex ? INSCHAR_NO_FEX : 0), second_indent);
  		State = old_State;
  		p_smd = smd_save;
  		second_indent = -1;
*** ../vim-7.1.275/src/proto/ops.pro	Wed Jan 16 20:01:14 2008
--- src/proto/ops.pro	Wed Mar 12 16:38:39 2008
***************
*** 41,47 ****
  void op_format __ARGS((oparg_T *oap, int keep_cursor));
  void op_formatexpr __ARGS((oparg_T *oap));
  int fex_format __ARGS((linenr_T lnum, long count, int c));
! void format_lines __ARGS((linenr_T line_count));
  int paragraph_start __ARGS((linenr_T lnum));
  int do_addsub __ARGS((int command, linenr_T Prenum1));
  int read_viminfo_register __ARGS((vir_T *virp, int force));
--- 41,47 ----
  void op_format __ARGS((oparg_T *oap, int keep_cursor));
  void op_formatexpr __ARGS((oparg_T *oap));
  int fex_format __ARGS((linenr_T lnum, long count, int c));
! void format_lines __ARGS((linenr_T line_count, int avoid_fex));
  int paragraph_start __ARGS((linenr_T lnum));
  int do_addsub __ARGS((int command, linenr_T Prenum1));
  int read_viminfo_register __ARGS((vir_T *virp, int force));
*** ../vim-7.1.275/src/version.c	Wed Mar 12 14:38:51 2008
--- src/version.c	Wed Mar 12 17:23:43 2008
***************
*** 668,669 ****
--- 668,671 ----
  {   /* Add new patch number below this line */
+ /**/
+     276,
  /**/

-- 
An actual excerpt from a classified section of a city newspaper:
"Illiterate?  Write today for free help!"

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///