Karsten Hopp 424e24
To: vim-dev@vim.org
Karsten Hopp 424e24
Subject: Patch 7.0.038
Karsten Hopp 424e24
Fcc: outbox
Karsten Hopp 424e24
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 424e24
Mime-Version: 1.0
Karsten Hopp 424e24
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp 424e24
Content-Transfer-Encoding: 8bit
Karsten Hopp 424e24
------------
Karsten Hopp 424e24
Karsten Hopp 424e24
Patch 7.0.038
Karsten Hopp 424e24
Problem:    When calling complete() from an Insert mode expression mapping
Karsten Hopp 424e24
	    text could be inserted in an improper way.
Karsten Hopp 424e24
Solution:   Make undo_allowed() global and use it in complete().
Karsten Hopp 424e24
Files:	    src/undo.c, src/proto/undo.pro, src/eval.c
Karsten Hopp 424e24
Karsten Hopp 424e24
Karsten Hopp 424e24
*** ../vim-7.0.037/src/undo.c	Sat Apr 22 00:01:05 2006
Karsten Hopp 424e24
--- src/undo.c	Mon Jul  3 22:23:22 2006
Karsten Hopp 424e24
***************
Karsten Hopp 424e24
*** 84,90 ****
Karsten Hopp 424e24
  static void u_unch_branch __ARGS((u_header_T *uhp));
Karsten Hopp 424e24
  static u_entry_T *u_get_headentry __ARGS((void));
Karsten Hopp 424e24
  static void u_getbot __ARGS((void));
Karsten Hopp 424e24
- static int undo_allowed __ARGS((void));
Karsten Hopp 424e24
  static int u_savecommon __ARGS((linenr_T, linenr_T, linenr_T));
Karsten Hopp 424e24
  static void u_doit __ARGS((int count));
Karsten Hopp 424e24
  static void u_undoredo __ARGS((int undo));
Karsten Hopp 424e24
--- 84,89 ----
Karsten Hopp 424e24
***************
Karsten Hopp 424e24
*** 196,202 ****
Karsten Hopp 424e24
   * Return TRUE when undo is allowed.  Otherwise give an error message and
Karsten Hopp 424e24
   * return FALSE.
Karsten Hopp 424e24
   */
Karsten Hopp 424e24
!     static int
Karsten Hopp 424e24
  undo_allowed()
Karsten Hopp 424e24
  {
Karsten Hopp 424e24
      /* Don't allow changes when 'modifiable' is off.  */
Karsten Hopp 424e24
--- 195,201 ----
Karsten Hopp 424e24
   * Return TRUE when undo is allowed.  Otherwise give an error message and
Karsten Hopp 424e24
   * return FALSE.
Karsten Hopp 424e24
   */
Karsten Hopp 424e24
!     int
Karsten Hopp 424e24
  undo_allowed()
Karsten Hopp 424e24
  {
Karsten Hopp 424e24
      /* Don't allow changes when 'modifiable' is off.  */
Karsten Hopp 424e24
*** ../vim-7.0.037/src/proto/undo.pro	Mon Apr 10 16:38:50 2006
Karsten Hopp 424e24
--- src/proto/undo.pro	Mon Jul  3 22:25:07 2006
Karsten Hopp 424e24
***************
Karsten Hopp 424e24
*** 4,9 ****
Karsten Hopp 424e24
--- 4,10 ----
Karsten Hopp 424e24
  extern int u_savesub __ARGS((linenr_T lnum));
Karsten Hopp 424e24
  extern int u_inssub __ARGS((linenr_T lnum));
Karsten Hopp 424e24
  extern int u_savedel __ARGS((linenr_T lnum, long nlines));
Karsten Hopp 424e24
+ extern int undo_allowed __ARGS((void));
Karsten Hopp 424e24
  extern void u_undo __ARGS((int count));
Karsten Hopp 424e24
  extern void u_redo __ARGS((int count));
Karsten Hopp 424e24
  extern void undo_time __ARGS((long step, int sec, int absolute));
Karsten Hopp 424e24
*** ../vim-7.0.037/src/eval.c	Thu Jun 22 21:01:19 2006
Karsten Hopp 424e24
--- src/eval.c	Mon Jul 10 23:03:13 2006
Karsten Hopp 424e24
***************
Karsten Hopp 424e24
*** 8252,8257 ****
Karsten Hopp 424e24
--- 8252,8263 ----
Karsten Hopp 424e24
  	EMSG(_("E785: complete() can only be used in Insert mode"));
Karsten Hopp 424e24
  	return;
Karsten Hopp 424e24
      }
Karsten Hopp 424e24
+ 
Karsten Hopp 424e24
+     /* Check for undo allowed here, because if something was already inserted
Karsten Hopp 424e24
+      * the line was already saved for undo and this check isn't done. */
Karsten Hopp 424e24
+     if (!undo_allowed())
Karsten Hopp 424e24
+ 	return;
Karsten Hopp 424e24
+ 
Karsten Hopp 424e24
      if (argvars[1].v_type != VAR_LIST || argvars[1].vval.v_list == NULL)
Karsten Hopp 424e24
      {
Karsten Hopp 424e24
  	EMSG(_(e_invarg));
Karsten Hopp 424e24
*** ../vim-7.0.037/src/version.c	Tue Jul 11 22:59:04 2006
Karsten Hopp 424e24
--- src/version.c	Wed Jul 12 20:31:49 2006
Karsten Hopp 424e24
***************
Karsten Hopp 424e24
*** 668,669 ****
Karsten Hopp 424e24
--- 668,671 ----
Karsten Hopp 424e24
  {   /* Add new patch number below this line */
Karsten Hopp 424e24
+ /**/
Karsten Hopp 424e24
+     38,
Karsten Hopp 424e24
  /**/
Karsten Hopp 424e24
Karsten Hopp 424e24
-- 
Karsten Hopp 424e24
If someone questions your market projections, simply point out that your
Karsten Hopp 424e24
target market is "People who are nuts" and "People who will buy any damn
Karsten Hopp 424e24
thing".  Nobody is going to tell you there aren't enough of those people
Karsten Hopp 424e24
to go around.
Karsten Hopp 424e24
				(Scott Adams - The Dilbert principle)
Karsten Hopp 424e24
Karsten Hopp 424e24
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 424e24
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 424e24
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 424e24
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///