fb5c426
To: vim-dev@vim.org
fb5c426
Subject: patch 7.1.006
fb5c426
Fcc: outbox
fb5c426
From: Bram Moolenaar <Bram@moolenaar.net>
fb5c426
Mime-Version: 1.0
fb5c426
Content-Type: text/plain; charset=ISO-8859-1
fb5c426
Content-Transfer-Encoding: 8bit
fb5c426
------------
fb5c426
fb5c426
Patch 7.1.006
fb5c426
Problem:    Resetting 'modified' in a StdinReadPost autocommand doesn't work.
fb5c426
Solution:   Set 'modified' before the autocommands instead of after it.
fb5c426
Files:	    src/buffer.c
fb5c426
fb5c426
fb5c426
*** ../vim-7.1.005/src/buffer.c	Thu May 10 18:43:46 2007
fb5c426
--- src/buffer.c	Fri Jun  8 20:59:04 2007
fb5c426
***************
fb5c426
*** 171,176 ****
fb5c426
--- 171,183 ----
fb5c426
  	    /* Put the cursor on the first line. */
fb5c426
  	    curwin->w_cursor.lnum = 1;
fb5c426
  	    curwin->w_cursor.col = 0;
fb5c426
+ 
fb5c426
+ 	    /* Set or reset 'modified' before executing autocommands, so that
fb5c426
+ 	     * it can be changed there. */
fb5c426
+ 	    if (!readonlymode && !bufempty())
fb5c426
+ 		changed();
fb5c426
+ 	    else if (retval != FAIL)
fb5c426
+ 		unchanged(curbuf, FALSE);
fb5c426
  #ifdef FEAT_AUTOCMD
fb5c426
  # ifdef FEAT_EVAL
fb5c426
  	    apply_autocmds_retval(EVENT_STDINREADPOST, NULL, NULL, FALSE,
fb5c426
***************
fb5c426
*** 194,209 ****
fb5c426
      /* When reading stdin, the buffer contents always needs writing, so set
fb5c426
       * the changed flag.  Unless in readonly mode: "ls | gview -".
fb5c426
       * When interrupted and 'cpoptions' contains 'i' set changed flag. */
fb5c426
!     if ((read_stdin && !readonlymode && !bufempty())
fb5c426
  #ifdef FEAT_AUTOCMD
fb5c426
  		|| modified_was_set	/* ":set modified" used in autocmd */
fb5c426
  # ifdef FEAT_EVAL
fb5c426
  		|| (aborting() && vim_strchr(p_cpo, CPO_INTMOD) != NULL)
fb5c426
  # endif
fb5c426
  #endif
fb5c426
! 		|| (got_int && vim_strchr(p_cpo, CPO_INTMOD) != NULL))
fb5c426
  	changed();
fb5c426
!     else if (retval != FAIL)
fb5c426
  	unchanged(curbuf, FALSE);
fb5c426
      save_file_ff(curbuf);		/* keep this fileformat */
fb5c426
  
fb5c426
--- 201,216 ----
fb5c426
      /* When reading stdin, the buffer contents always needs writing, so set
fb5c426
       * the changed flag.  Unless in readonly mode: "ls | gview -".
fb5c426
       * When interrupted and 'cpoptions' contains 'i' set changed flag. */
fb5c426
!     if ((got_int && vim_strchr(p_cpo, CPO_INTMOD) != NULL)
fb5c426
  #ifdef FEAT_AUTOCMD
fb5c426
  		|| modified_was_set	/* ":set modified" used in autocmd */
fb5c426
  # ifdef FEAT_EVAL
fb5c426
  		|| (aborting() && vim_strchr(p_cpo, CPO_INTMOD) != NULL)
fb5c426
  # endif
fb5c426
  #endif
fb5c426
!        )
fb5c426
  	changed();
fb5c426
!     else if (retval != FAIL && !read_stdin)
fb5c426
  	unchanged(curbuf, FALSE);
fb5c426
      save_file_ff(curbuf);		/* keep this fileformat */
fb5c426
  
fb5c426
*** ../vim-7.1.005/src/version.c	Tue Jun 19 12:58:55 2007
fb5c426
--- src/version.c	Tue Jun 19 15:37:53 2007
fb5c426
***************
fb5c426
*** 668,669 ****
fb5c426
--- 668,671 ----
fb5c426
  {   /* Add new patch number below this line */
fb5c426
+ /**/
fb5c426
+     6,
fb5c426
  /**/
fb5c426
fb5c426
-- 
fb5c426
If I tell you "you have a beautiful body", would you hold it against me?
fb5c426
fb5c426
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
fb5c426
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
fb5c426
\\\        download, build and distribute -- http://www.A-A-P.org        ///
fb5c426
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///