Karsten Hopp 1144a1
To: vim_dev@googlegroups.com
Karsten Hopp 1144a1
Subject: Patch 7.4.774
Karsten Hopp 1144a1
Fcc: outbox
Karsten Hopp 1144a1
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 1144a1
Mime-Version: 1.0
Karsten Hopp 1144a1
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 1144a1
Content-Transfer-Encoding: 8bit
Karsten Hopp 1144a1
------------
Karsten Hopp 1144a1
Karsten Hopp 1144a1
Patch 7.4.774
Karsten Hopp 1144a1
Problem:    When using the CompleteDone autocommand event it's difficult to
Karsten Hopp 1144a1
            get to the completed items.
Karsten Hopp 1144a1
Solution:   Add the v:completed_items variable. (Shougo Matsu)
Karsten Hopp 1144a1
Files:      runtime/doc/autocmd.txt, runtime/doc/eval.txt, src/edit.c,
Karsten Hopp 1144a1
            src/eval.c, src/macros.h, src/proto/eval.pro, src/vim.h
Karsten Hopp 1144a1
Karsten Hopp 1144a1
Karsten Hopp 1144a1
*** ../vim-7.4.773/runtime/doc/autocmd.txt	2014-08-22 23:05:50.098606614 +0200
Karsten Hopp 1144a1
--- runtime/doc/autocmd.txt	2015-07-10 17:37:59.618121125 +0200
Karsten Hopp 1144a1
***************
Karsten Hopp 1144a1
*** 502,507 ****
Karsten Hopp 1144a1
--- 505,512 ----
Karsten Hopp 1144a1
  CompleteDone			After Insert mode completion is done.  Either
Karsten Hopp 1144a1
  				when something was completed or abandoning
Karsten Hopp 1144a1
  				completion. |ins-completion|
Karsten Hopp 1144a1
+ 				The |v:completed_item| variable contains
Karsten Hopp 1144a1
+ 				information about the completed item.
Karsten Hopp 1144a1
  
Karsten Hopp 1144a1
  							*CursorHold*
Karsten Hopp 1144a1
  CursorHold			When the user doesn't press a key for the time
Karsten Hopp 1144a1
*** ../vim-7.4.773/runtime/doc/eval.txt	2015-06-25 16:09:20.698461237 +0200
Karsten Hopp 1144a1
--- runtime/doc/eval.txt	2015-07-10 17:39:36.641207424 +0200
Karsten Hopp 1144a1
***************
Karsten Hopp 1144a1
*** 1330,1335 ****
Karsten Hopp 1144a1
--- 1330,1341 ----
Karsten Hopp 1144a1
  		can only be used in autocommands.  For user commands |<bang>|
Karsten Hopp 1144a1
  		can be used.
Karsten Hopp 1144a1
  
Karsten Hopp 1144a1
+ 				*v:completed_item* *completed_item-variable*
Karsten Hopp 1144a1
+ v:completed_item
Karsten Hopp 1144a1
+ 		|Dictionary| containing the |complete-items| for the most
Karsten Hopp 1144a1
+ 		recently completed word after |CompleteDone|.  The
Karsten Hopp 1144a1
+ 		|Dictionary| is empty if the completion failed.
Karsten Hopp 1144a1
+ 
Karsten Hopp 1144a1
  					*v:count* *count-variable*
Karsten Hopp 1144a1
  v:count		The count given for the last Normal mode command.  Can be used
Karsten Hopp 1144a1
  		to get the count before a mapping.  Read-only.	Example: >
Karsten Hopp 1144a1
*** ../vim-7.4.773/src/edit.c	2015-03-31 19:17:55.620054448 +0200
Karsten Hopp 1144a1
--- src/edit.c	2015-07-10 17:37:22.574469987 +0200
Karsten Hopp 1144a1
***************
Karsten Hopp 1144a1
*** 3372,3377 ****
Karsten Hopp 1144a1
--- 3372,3379 ----
Karsten Hopp 1144a1
      vim_free(compl_orig_text);
Karsten Hopp 1144a1
      compl_orig_text = NULL;
Karsten Hopp 1144a1
      compl_enter_selects = FALSE;
Karsten Hopp 1144a1
+     /* clear v:completed_item */
Karsten Hopp 1144a1
+     set_vim_var_dict(VV_COMPLETED_ITEM, dict_alloc());
Karsten Hopp 1144a1
  }
Karsten Hopp 1144a1
  
Karsten Hopp 1144a1
  /*
Karsten Hopp 1144a1
***************
Karsten Hopp 1144a1
*** 4606,4622 ****
Karsten Hopp 1144a1
--- 4608,4646 ----
Karsten Hopp 1144a1
      /* TODO: is this sufficient for redrawing?  Redrawing everything causes
Karsten Hopp 1144a1
       * flicker, thus we can't do that. */
Karsten Hopp 1144a1
      changed_cline_bef_curs();
Karsten Hopp 1144a1
+     /* clear v:completed_item */
Karsten Hopp 1144a1
+     set_vim_var_dict(VV_COMPLETED_ITEM, dict_alloc());
Karsten Hopp 1144a1
  }
Karsten Hopp 1144a1
  
Karsten Hopp 1144a1
  /* Insert the new text being completed. */
Karsten Hopp 1144a1
      static void
Karsten Hopp 1144a1
  ins_compl_insert()
Karsten Hopp 1144a1
  {
Karsten Hopp 1144a1
+     dict_T	*dict;
Karsten Hopp 1144a1
+ 
Karsten Hopp 1144a1
      ins_bytes(compl_shown_match->cp_str + ins_compl_len());
Karsten Hopp 1144a1
      if (compl_shown_match->cp_flags & ORIGINAL_TEXT)
Karsten Hopp 1144a1
  	compl_used_match = FALSE;
Karsten Hopp 1144a1
      else
Karsten Hopp 1144a1
  	compl_used_match = TRUE;
Karsten Hopp 1144a1
+ 
Karsten Hopp 1144a1
+     /* Set completed item. */
Karsten Hopp 1144a1
+     /* { word, abbr, menu, kind, info } */
Karsten Hopp 1144a1
+     dict = dict_alloc();
Karsten Hopp 1144a1
+     if (dict != NULL)
Karsten Hopp 1144a1
+     {
Karsten Hopp 1144a1
+ 	dict_add_nr_str(dict, "word", 0L,
Karsten Hopp 1144a1
+ 		    EMPTY_IF_NULL(compl_shown_match->cp_str));
Karsten Hopp 1144a1
+ 	dict_add_nr_str(dict, "abbr", 0L,
Karsten Hopp 1144a1
+ 		    EMPTY_IF_NULL(compl_shown_match->cp_text[CPT_ABBR]));
Karsten Hopp 1144a1
+ 	dict_add_nr_str(dict, "menu", 0L,
Karsten Hopp 1144a1
+ 		    EMPTY_IF_NULL(compl_shown_match->cp_text[CPT_MENU]));
Karsten Hopp 1144a1
+ 	dict_add_nr_str(dict, "kind", 0L,
Karsten Hopp 1144a1
+ 		    EMPTY_IF_NULL(compl_shown_match->cp_text[CPT_KIND]));
Karsten Hopp 1144a1
+ 	dict_add_nr_str(dict, "info", 0L,
Karsten Hopp 1144a1
+ 		    EMPTY_IF_NULL(compl_shown_match->cp_text[CPT_INFO]));
Karsten Hopp 1144a1
+     }
Karsten Hopp 1144a1
+     set_vim_var_dict(VV_COMPLETED_ITEM, dict);
Karsten Hopp 1144a1
  }
Karsten Hopp 1144a1
  
Karsten Hopp 1144a1
  /*
Karsten Hopp 1144a1
*** ../vim-7.4.773/src/eval.c	2015-06-25 16:09:20.702461194 +0200
Karsten Hopp 1144a1
--- src/eval.c	2015-07-10 17:42:52.831359939 +0200
Karsten Hopp 1144a1
***************
Karsten Hopp 1144a1
*** 364,369 ****
Karsten Hopp 1144a1
--- 364,370 ----
Karsten Hopp 1144a1
      {VV_NAME("oldfiles",	 VAR_LIST), 0},
Karsten Hopp 1144a1
      {VV_NAME("windowid",	 VAR_NUMBER), VV_RO},
Karsten Hopp 1144a1
      {VV_NAME("progpath",	 VAR_STRING), VV_RO},
Karsten Hopp 1144a1
+     {VV_NAME("completed_item",	 VAR_DICT), VV_RO},
Karsten Hopp 1144a1
  };
Karsten Hopp 1144a1
  
Karsten Hopp 1144a1
  /* shorthand */
Karsten Hopp 1144a1
***************
Karsten Hopp 1144a1
*** 372,377 ****
Karsten Hopp 1144a1
--- 373,379 ----
Karsten Hopp 1144a1
  #define vv_float	vv_di.di_tv.vval.v_float
Karsten Hopp 1144a1
  #define vv_str		vv_di.di_tv.vval.v_string
Karsten Hopp 1144a1
  #define vv_list		vv_di.di_tv.vval.v_list
Karsten Hopp 1144a1
+ #define vv_dict		vv_di.di_tv.vval.v_dict
Karsten Hopp 1144a1
  #define vv_tv		vv_di.di_tv
Karsten Hopp 1144a1
  
Karsten Hopp 1144a1
  static dictitem_T	vimvars_var;		/* variable used for v: */
Karsten Hopp 1144a1
***************
Karsten Hopp 1144a1
*** 888,893 ****
Karsten Hopp 1144a1
--- 890,896 ----
Karsten Hopp 1144a1
      }
Karsten Hopp 1144a1
      set_vim_var_nr(VV_SEARCHFORWARD, 1L);
Karsten Hopp 1144a1
      set_vim_var_nr(VV_HLSEARCH, 1L);
Karsten Hopp 1144a1
+     set_vim_var_dict(VV_COMPLETED_ITEM, dict_alloc());
Karsten Hopp 1144a1
      set_reg_var(0);  /* default for v:register is not 0 but '"' */
Karsten Hopp 1144a1
  
Karsten Hopp 1144a1
  #ifdef EBCDIC
Karsten Hopp 1144a1
***************
Karsten Hopp 1144a1
*** 20577,20582 ****
Karsten Hopp 1144a1
--- 20580,20614 ----
Karsten Hopp 1144a1
  }
Karsten Hopp 1144a1
  
Karsten Hopp 1144a1
  /*
Karsten Hopp 1144a1
+  * Set Dictionary v: variable to "val".
Karsten Hopp 1144a1
+  */
Karsten Hopp 1144a1
+     void
Karsten Hopp 1144a1
+ set_vim_var_dict(idx, val)
Karsten Hopp 1144a1
+     int		idx;
Karsten Hopp 1144a1
+     dict_T	*val;
Karsten Hopp 1144a1
+ {
Karsten Hopp 1144a1
+     int		todo;
Karsten Hopp 1144a1
+     hashitem_T	*hi;
Karsten Hopp 1144a1
+ 
Karsten Hopp 1144a1
+     dict_unref(vimvars[idx].vv_dict);
Karsten Hopp 1144a1
+     vimvars[idx].vv_dict = val;
Karsten Hopp 1144a1
+     if (val != NULL)
Karsten Hopp 1144a1
+     {
Karsten Hopp 1144a1
+ 	++val->dv_refcount;
Karsten Hopp 1144a1
+ 
Karsten Hopp 1144a1
+ 	/* Set readonly */
Karsten Hopp 1144a1
+ 	todo = (int)val->dv_hashtab.ht_used;
Karsten Hopp 1144a1
+ 	for (hi = val->dv_hashtab.ht_array; todo > 0 ; ++hi)
Karsten Hopp 1144a1
+ 	{
Karsten Hopp 1144a1
+ 	    if (HASHITEM_EMPTY(hi))
Karsten Hopp 1144a1
+ 		continue;
Karsten Hopp 1144a1
+ 	    --todo;
Karsten Hopp 1144a1
+ 	    HI2DI(hi)->di_flags = DI_FLAGS_RO | DI_FLAGS_FIX;
Karsten Hopp 1144a1
+ 	}
Karsten Hopp 1144a1
+     }
Karsten Hopp 1144a1
+ }
Karsten Hopp 1144a1
+ 
Karsten Hopp 1144a1
+ /*
Karsten Hopp 1144a1
   * Set v:register if needed.
Karsten Hopp 1144a1
   */
Karsten Hopp 1144a1
      void
Karsten Hopp 1144a1
*** ../vim-7.4.773/src/macros.h	2014-11-05 17:44:47.676471691 +0100
Karsten Hopp 1144a1
--- src/macros.h	2015-07-10 17:25:46.129029911 +0200
Karsten Hopp 1144a1
***************
Karsten Hopp 1144a1
*** 118,123 ****
Karsten Hopp 1144a1
--- 118,126 ----
Karsten Hopp 1144a1
  # define ASCII_ISALNUM(c) (ASCII_ISALPHA(c) || VIM_ISDIGIT(c))
Karsten Hopp 1144a1
  #endif
Karsten Hopp 1144a1
  
Karsten Hopp 1144a1
+ /* Returns empty string if it is NULL. */
Karsten Hopp 1144a1
+ #define EMPTY_IF_NULL(x) ((x) ? (x) : (u_char *)"")
Karsten Hopp 1144a1
+ 
Karsten Hopp 1144a1
  /* macro version of chartab().
Karsten Hopp 1144a1
   * Only works with values 0-255!
Karsten Hopp 1144a1
   * Doesn't work for UTF-8 mode with chars >= 0x80. */
Karsten Hopp 1144a1
*** ../vim-7.4.773/src/proto/eval.pro	2015-02-03 12:55:11.140179551 +0100
Karsten Hopp 1144a1
--- src/proto/eval.pro	2015-07-10 17:25:46.129029911 +0200
Karsten Hopp 1144a1
***************
Karsten Hopp 1144a1
*** 91,96 ****
Karsten Hopp 1144a1
--- 91,97 ----
Karsten Hopp 1144a1
  void set_vcount __ARGS((long count, long count1, int set_prevcount));
Karsten Hopp 1144a1
  void set_vim_var_string __ARGS((int idx, char_u *val, int len));
Karsten Hopp 1144a1
  void set_vim_var_list __ARGS((int idx, list_T *val));
Karsten Hopp 1144a1
+ void set_vim_var_dict __ARGS((int idx, dict_T *val));
Karsten Hopp 1144a1
  void set_reg_var __ARGS((int c));
Karsten Hopp 1144a1
  char_u *v_exception __ARGS((char_u *oldval));
Karsten Hopp 1144a1
  char_u *v_throwpoint __ARGS((char_u *oldval));
Karsten Hopp 1144a1
*** ../vim-7.4.773/src/vim.h	2015-03-21 17:32:14.058780006 +0100
Karsten Hopp 1144a1
--- src/vim.h	2015-07-10 17:37:04.970635775 +0200
Karsten Hopp 1144a1
***************
Karsten Hopp 1144a1
*** 1897,1903 ****
Karsten Hopp 1144a1
  #define VV_OLDFILES	55
Karsten Hopp 1144a1
  #define VV_WINDOWID	56
Karsten Hopp 1144a1
  #define VV_PROGPATH	57
Karsten Hopp 1144a1
! #define VV_LEN		58	/* number of v: vars */
Karsten Hopp 1144a1
  
Karsten Hopp 1144a1
  #ifdef FEAT_CLIPBOARD
Karsten Hopp 1144a1
  
Karsten Hopp 1144a1
--- 1897,1904 ----
Karsten Hopp 1144a1
  #define VV_OLDFILES	55
Karsten Hopp 1144a1
  #define VV_WINDOWID	56
Karsten Hopp 1144a1
  #define VV_PROGPATH	57
Karsten Hopp 1144a1
! #define VV_COMPLETED_ITEM 58
Karsten Hopp 1144a1
! #define VV_LEN		59	/* number of v: vars */
Karsten Hopp 1144a1
  
Karsten Hopp 1144a1
  #ifdef FEAT_CLIPBOARD
Karsten Hopp 1144a1
  
Karsten Hopp 1144a1
*** ../vim-7.4.773/src/version.c	2015-07-10 17:19:25.024620239 +0200
Karsten Hopp 1144a1
--- src/version.c	2015-07-10 17:27:37.643979391 +0200
Karsten Hopp 1144a1
***************
Karsten Hopp 1144a1
*** 743,744 ****
Karsten Hopp 1144a1
--- 743,746 ----
Karsten Hopp 1144a1
  {   /* Add new patch number below this line */
Karsten Hopp 1144a1
+ /**/
Karsten Hopp 1144a1
+     774,
Karsten Hopp 1144a1
  /**/
Karsten Hopp 1144a1
Karsten Hopp 1144a1
-- 
Karsten Hopp 1144a1
hundred-and-one symptoms of being an internet addict:
Karsten Hopp 1144a1
201. When somebody asks you where you are, you tell them in which chat room.
Karsten Hopp 1144a1
Karsten Hopp 1144a1
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 1144a1
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 1144a1
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 1144a1
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///