Patch 7.4.1893
Problem:    Cannot easily get the window ID for a buffer.
Solution:   Add bufwinid().
Files:      src/eval.c, runtime/doc/eval.txt


*** ../vim-7.4.1892/src/eval.c  2016-06-04 17:40:59.682126379 +0200
--- src/eval.c  2016-06-04 17:48:17.730120353 +0200
***************
*** 500,505 ****
--- 500,506 ----
  static void f_bufloaded(typval_T *argvars, typval_T *rettv);
  static void f_bufname(typval_T *argvars, typval_T *rettv);
  static void f_bufnr(typval_T *argvars, typval_T *rettv);
+ static void f_bufwinid(typval_T *argvars, typval_T *rettv);
  static void f_bufwinnr(typval_T *argvars, typval_T *rettv);
  static void f_byte2line(typval_T *argvars, typval_T *rettv);
  static void byteidx(typval_T *argvars, typval_T *rettv, int comp);
***************
*** 8488,8493 ****
--- 8489,8495 ----
      {"bufloaded",     1, 1, f_bufloaded},
      {"bufname",               1, 1, f_bufname},
      {"bufnr",         1, 2, f_bufnr},
+     {"bufwinid",      1, 1, f_bufwinid},
      {"bufwinnr",      1, 1, f_bufwinnr},
      {"byte2line",     1, 1, f_byte2line},
      {"byteidx",               2, 2, f_byteidx},
***************
*** 10213,10223 ****
        rettv->vval.v_number = -1;
  }
  
- /*
-  * "bufwinnr(nr)" function
-  */
      static void
! f_bufwinnr(typval_T *argvars, typval_T *rettv)
  {
  #ifdef FEAT_WINDOWS
      win_T     *wp;
--- 10215,10222 ----
        rettv->vval.v_number = -1;
  }
  
      static void
! buf_win_common(typval_T *argvars, typval_T *rettv, int get_nr)
  {
  #ifdef FEAT_WINDOWS
      win_T     *wp;
***************
*** 10235,10248 ****
        if (wp->w_buffer == buf)
            break;
      }
!     rettv->vval.v_number = (wp != NULL ? winnr : -1);
  #else
!     rettv->vval.v_number = (curwin->w_buffer == buf ? 1 : -1);
  #endif
      --emsg_off;
  }
  
  /*
   * "byte2line(byte)" function
   */
      static void
--- 10234,10266 ----
        if (wp->w_buffer == buf)
            break;
      }
!     rettv->vval.v_number = (wp != NULL ? (get_nr ? winnr : wp->w_id) : -1);
  #else
!     rettv->vval.v_number = (curwin->w_buffer == buf
!                                         ? (get_nr ? 1 : curwin->w_id) : -1);
  #endif
      --emsg_off;
  }
  
  /*
+  * "bufwinid(nr)" function
+  */
+     static void
+ f_bufwinid(typval_T *argvars, typval_T *rettv)
+ {
+     buf_win_common(argvars, rettv, FALSE);
+ }
+ 
+ /*
+  * "bufwinnr(nr)" function
+  */
+     static void
+ f_bufwinnr(typval_T *argvars, typval_T *rettv)
+ {
+     buf_win_common(argvars, rettv, TRUE);
+ }
+ 
+ /*
   * "byte2line(byte)" function
   */
      static void
*** ../vim-7.4.1892/runtime/doc/eval.txt        2016-05-25 21:22:56.425828207 
+0200
--- runtime/doc/eval.txt        2016-06-04 17:49:44.110119165 +0200
***************
*** 1843,1848 ****
--- 1866,1872 ----
  bufloaded({expr})             Number  TRUE if buffer {expr} is loaded
  bufname({expr})                       String  Name of the buffer {expr}
  bufnr({expr} [, {create}])    Number  Number of the buffer {expr}
+ bufwinid({expr})              Number  window ID of buffer {expr}
  bufwinnr({expr})              Number  window number of buffer {expr}
  byte2line({byte})             Number  line number at byte count {byte}
  byteidx({expr}, {nr})         Number  byte index of {nr}'th char in {expr}
***************
*** 2538,2543 ****
--- 2562,2577 ----
                                                        *last_buffer_nr()*
                Obsolete name for bufnr("$"): last_buffer_nr().
  
+ bufwinid({expr})                                      *bufwinid()*
+               The result is a Number, which is the window ID of the first
+               window associated with buffer {expr}.  For the use of {expr},
+               see |bufname()| above.  If buffer {expr} doesn't exist or
+               there is no such window, -1 is returned.  Example: >
+ 
+       echo "A window containing buffer 1 is " . (bufwinid(1))
+ <
+               Only deals with the current tab page.
+ 
  bufwinnr({expr})                                      *bufwinnr()*
                The result is a Number, which is the number of the first
                window associated with buffer {expr}.  For the use of {expr},
*** ../vim-7.4.1892/src/version.c       2016-06-04 17:40:59.686126379 +0200
--- src/version.c       2016-06-04 17:51:04.058118065 +0200
***************
*** 755,756 ****
--- 755,758 ----
  {   /* Add new patch number below this line */
+ /**/
+     1893,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
40. You tell the cab driver you live at
    http://123.elm.street/house/bluetrim.html
41. You actually try that 123.elm.street address.

 /// 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