Patch 8.0.0499
Problem:    taglist() does not prioritize tags for a buffer.
Solution:   Add an optional buffer argument. (Duncan McDougall, closes #1194) 
Files:      runtime/doc/eval.txt, src/evalfunc.c, src/proto/tag.pro,
            src/Makefile, src/tag.c, src/testdir/test_alot.vim,
            src/testdir/test_taglist.vim


*** ../vim-8.0.0498/runtime/doc/eval.txt        2017-03-19 21:20:45.893034321 
+0100
--- runtime/doc/eval.txt        2017-03-21 16:57:32.247841355 +0100
***************
*** 2360,2366 ****
  tabpagebuflist([{arg}])               List    list of buffer numbers in tab 
page
  tabpagenr([{arg}])            Number  number of current or last tab page
  tabpagewinnr({tabarg}[, {arg}]) Number        number of current window in tab 
page
! taglist({expr})                       List    list of tags matching {expr}
  tagfiles()                    List    tags files used
  tan({expr})                   Float   tangent of {expr}
  tanh({expr})                  Float   hyperbolic tangent of {expr}
--- 2364,2370 ----
  tabpagebuflist([{arg}])               List    list of buffer numbers in tab 
page
  tabpagenr([{arg}])            Number  number of current or last tab page
  tabpagewinnr({tabarg}[, {arg}]) Number        number of current window in tab 
page
! taglist({expr}[, {filename}]) List    list of tags matching {expr}
  tagfiles()                    List    tags files used
  tan({expr})                   Float   tangent of {expr}
  tanh({expr})                  Float   hyperbolic tangent of {expr}
***************
*** 7722,7729 ****
                for the current buffer.  This is the 'tags' option expanded.
  
  
! taglist({expr})                                                       
*taglist()*
                Returns a list of tags matching the regular expression {expr}.
                Each list item is a dictionary with at least the following
                entries:
                        name            Name of the tag.
--- 7742,7754 ----
                for the current buffer.  This is the 'tags' option expanded.
  
  
! taglist({expr}[, {filename}])                         *taglist()*
                Returns a list of tags matching the regular expression {expr}.
+ 
+               If {filename} is passed it is used to prioritize the results
+               in the same way that |:tselect| does. See |tag-priority|.
+               {filename} should be the full path of the file.
+ 
                Each list item is a dictionary with at least the following
                entries:
                        name            Name of the tag.
*** ../vim-8.0.0498/src/evalfunc.c      2017-03-19 21:47:46.897119250 +0100
--- src/evalfunc.c      2017-03-21 16:56:27.592313015 +0100
***************
*** 824,830 ****
      {"tabpagenr",     0, 1, f_tabpagenr},
      {"tabpagewinnr",  1, 2, f_tabpagewinnr},
      {"tagfiles",      0, 0, f_tagfiles},
!     {"taglist",               1, 1, f_taglist},
  #ifdef FEAT_FLOAT
      {"tan",           1, 1, f_tan},
      {"tanh",          1, 1, f_tanh},
--- 824,830 ----
      {"tabpagenr",     0, 1, f_tabpagenr},
      {"tabpagewinnr",  1, 2, f_tabpagewinnr},
      {"tagfiles",      0, 0, f_tagfiles},
!     {"taglist",               1, 2, f_taglist},
  #ifdef FEAT_FLOAT
      {"tan",           1, 1, f_tan},
      {"tanh",          1, 1, f_tanh},
***************
*** 3589,3595 ****
      fold_count = foldedCount(curwin, lnum, &foldinfo);
      if (fold_count > 0)
      {
!       text = get_foldtext(curwin, lnum, lnum + fold_count - 1, &foldinfo, 
buf);
        if (text == buf)
            text = vim_strsave(text);
        rettv->vval.v_string = text;
--- 3589,3596 ----
      fold_count = foldedCount(curwin, lnum, &foldinfo);
      if (fold_count > 0)
      {
!       text = get_foldtext(curwin, lnum, lnum + fold_count - 1,
!                                                              &foldinfo, buf);
        if (text == buf)
            text = vim_strsave(text);
        rettv->vval.v_string = text;
***************
*** 12267,12272 ****
--- 12268,12274 ----
      static void
  f_taglist(typval_T *argvars, typval_T *rettv)
  {
+     char_u  *fname = NULL;
      char_u  *tag_pattern;
  
      tag_pattern = get_tv_string(&argvars[0]);
***************
*** 12275,12282 ****
      if (*tag_pattern == NUL)
        return;
  
      if (rettv_list_alloc(rettv) == OK)
!       (void)get_tags(rettv->vval.v_list, tag_pattern);
  }
  
  /*
--- 12277,12286 ----
      if (*tag_pattern == NUL)
        return;
  
+     if (argvars[1].v_type != VAR_UNKNOWN)
+       fname = get_tv_string(&argvars[1]);
      if (rettv_list_alloc(rettv) == OK)
!       (void)get_tags(rettv->vval.v_list, tag_pattern, fname);
  }
  
  /*
*** ../vim-8.0.0498/src/proto/tag.pro   2016-09-12 13:04:20.000000000 +0200
--- src/proto/tag.pro   2017-03-21 16:59:54.218805832 +0100
***************
*** 8,12 ****
  void tagname_free(tagname_T *tnp);
  void simplify_filename(char_u *filename);
  int expand_tags(int tagnames, char_u *pat, int *num_file, char_u ***file);
! int get_tags(list_T *list, char_u *pat);
  /* vim: set ft=c : */
--- 8,12 ----
  void tagname_free(tagname_T *tnp);
  void simplify_filename(char_u *filename);
  int expand_tags(int tagnames, char_u *pat, int *num_file, char_u ***file);
! int get_tags(list_T *list, char_u *pat, char_u *buf_fname);
  /* vim: set ft=c : */
*** ../vim-8.0.0498/src/Makefile        2017-03-19 21:36:52.825933116 +0100
--- src/Makefile        2017-03-21 17:02:01.857875019 +0100
***************
*** 2213,2218 ****
--- 2212,2218 ----
        test_tabpage \
        test_tagcase \
        test_tagjump \
+       test_taglist \
        test_tcl \
        test_textobjects \
        test_timers \
*** ../vim-8.0.0498/src/tag.c   2017-03-16 17:23:26.835815782 +0100
--- src/tag.c   2017-03-21 17:00:47.610416452 +0100
***************
*** 3876,3886 ****
  }
  
  /*
!  * Add the tags matching the specified pattern to the list "list"
!  * as a dictionary
   */
      int
! get_tags(list_T *list, char_u *pat)
  {
      int               num_matches, i, ret;
      char_u    **matches, *p;
--- 3876,3886 ----
  }
  
  /*
!  * Add the tags matching the specified pattern "pat" to the list "list"
!  * as a dictionary. Use "buf_fname" for priority, unless NULL.
   */
      int
! get_tags(list_T *list, char_u *pat, char_u *buf_fname)
  {
      int               num_matches, i, ret;
      char_u    **matches, *p;
***************
*** 3890,3896 ****
      long      is_static;
  
      ret = find_tags(pat, &num_matches, &matches,
!                                   TAG_REGEXP | TAG_NOIC, (int)MAXCOL, NULL);
      if (ret == OK && num_matches > 0)
      {
        for (i = 0; i < num_matches; ++i)
--- 3890,3896 ----
      long      is_static;
  
      ret = find_tags(pat, &num_matches, &matches,
!                               TAG_REGEXP | TAG_NOIC, (int)MAXCOL, buf_fname);
      if (ret == OK && num_matches > 0)
      {
        for (i = 0; i < num_matches; ++i)
*** ../vim-8.0.0498/src/testdir/test_alot.vim   2017-03-19 21:36:52.821933145 
+0100
--- src/testdir/test_alot.vim   2017-03-21 17:01:20.210178718 +0100
***************
*** 47,52 ****
--- 47,53 ----
  source test_tabpage.vim
  source test_tagcase.vim
  source test_tagjump.vim
+ source test_taglist.vim
  source test_timers.vim
  source test_true_false.vim
  source test_unlet.vim
*** ../vim-8.0.0498/src/testdir/test_taglist.vim        2017-03-21 
17:07:32.199466722 +0100
--- src/testdir/test_taglist.vim        2017-03-21 17:03:54.725052065 +0100
***************
*** 0 ****
--- 1,21 ----
+ " test 'taglist' function
+ 
+ func Test_taglist()
+   call writefile([
+       \ "FFoo\tXfoo\t1",
+       \ "FBar\tXfoo\t2",
+       \ "BFoo\tXbar\t1",
+       \ "BBar\tXbar\t2"
+       \ ], 'Xtags')
+   set tags=Xtags
+   split Xtext
+ 
+   call assert_equal(['FFoo', 'BFoo'], map(taglist("Foo"), {i, v -> v.name}))
+   call assert_equal(['FFoo', 'BFoo'], map(taglist("Foo", "Xtext"), {i, v -> 
v.name}))
+   call assert_equal(['FFoo', 'BFoo'], map(taglist("Foo", "Xfoo"), {i, v -> 
v.name}))
+   call assert_equal(['BFoo', 'FFoo'], map(taglist("Foo", "Xbar"), {i, v -> 
v.name}))
+ 
+   call delete('Xtags')
+   bwipe
+ endfunc
+ 
*** ../vim-8.0.0498/src/version.c       2017-03-21 15:50:03.713154799 +0100
--- src/version.c       2017-03-21 16:47:49.012075577 +0100
***************
*** 766,767 ****
--- 766,769 ----
  {   /* Add new patch number below this line */
+ /**/
+     499,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
178. You look for an icon to double-click to open your bedroom window.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui