home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 6.1.125 < prev    next >
Encoding:
Internet Message Format  |  2002-07-05  |  4.3 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.1.125
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=ISO-8859-1
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 6.1.125
  11. Problem:    Explorer plugin asks for saving a modified buffer even when it's
  12.         open in another window as well.
  13. Solution:   Count the number of windows using the buffer.
  14. Files:        runtime/plugin/explorer.vim
  15.  
  16.  
  17. *** ../vim61.124/runtime/plugin/explorer.vim    Sat Feb 16 11:50:58 2002
  18. --- runtime/plugin/explorer.vim    Wed Jun 12 22:05:16 2002
  19. ***************
  20. *** 1,7 ****
  21.   "=============================================================================
  22.   " File: explorer.vim
  23.   " Author: M A Aziz Ahmed (aziz@acorn-networks.com)
  24. ! " Last Change:    2002 Feb 16
  25.   " Version: 2.5 + changes
  26.   " Additions by Mark Waggoner (waggoner@aracnet.com) et al.
  27.   "-----------------------------------------------------------------------------
  28. --- 1,7 ----
  29.   "=============================================================================
  30.   " File: explorer.vim
  31.   " Author: M A Aziz Ahmed (aziz@acorn-networks.com)
  32. ! " Last Change:    2002 Jun 12
  33.   " Version: 2.5 + changes
  34.   " Additions by Mark Waggoner (waggoner@aracnet.com) et al.
  35.   "-----------------------------------------------------------------------------
  36. ***************
  37. *** 332,337 ****
  38. --- 332,356 ----
  39.   endfunction
  40.   
  41.   "---
  42. + " Determine the number of windows open to this buffer number.
  43. + " Care of Yegappan Lakshman.  Thanks!
  44. + fun! s:BufInWindows(bnum)
  45. +   let cnt = 0
  46. +   let winnum = 1
  47. +   while 1
  48. +     let bufnum = winbufnr(winnum)
  49. +     if bufnum < 0
  50. +       break
  51. +     endif
  52. +     if bufnum == a:bnum
  53. +       let cnt = cnt + 1
  54. +     endif
  55. +     let winnum = winnum + 1
  56. +   endwhile
  57. +   return cnt
  58. + endfunction
  59.   " If this is the only window, open file in a new window
  60.   " Otherwise, open file in the most recently visited window
  61.   "
  62. ***************
  63. *** 344,371 ****
  64.       call s:OpenEntry()
  65.     " Other windows exist
  66.     else
  67. !     " Check if the previous buffer is modified - ask if they want to
  68. !     " save!
  69. !     let bufname = bufname(winbufnr(winnr()))
  70. !     if &modified
  71.         let action=confirm("Save Changes in " . bufname . "?","&Yes\n&No\n&Cancel")
  72.         " Yes - try to save - if there is an error, cancel
  73.         if action == 1
  74. !     let v:errmsg = ""
  75. !     silent w
  76. !     if v:errmsg != ""
  77. !       echoerr "Unable to write buffer!"
  78. !       wincmd p
  79. !       return
  80. !     endif
  81.         " No, abandon changes
  82.         elseif action == 2
  83. !     set nomodified
  84. !     echomsg "Warning, abandoning changes in " . bufname
  85.         " Cancel (or any other result), don't do the open
  86.         else
  87. !     wincmd p
  88. !     return
  89.         endif
  90.       endif
  91.       wincmd p
  92. --- 363,391 ----
  93.       call s:OpenEntry()
  94.     " Other windows exist
  95.     else
  96. !     " Check if the previous buffer is modified - ask if they want to save!
  97. !     " Was it modified, and is it the only window open to this file
  98. !     if &modified && s:BufInWindows(winbufnr(winnr())) < 2
  99. !       let bufname = bufname(winbufnr(winnr()))
  100.         let action=confirm("Save Changes in " . bufname . "?","&Yes\n&No\n&Cancel")
  101.         " Yes - try to save - if there is an error, cancel
  102.         if action == 1
  103. !         let v:errmsg = ""
  104. !         silent w
  105. !         if v:errmsg != ""
  106. !           echoerr "Unable to write buffer!"
  107. !           wincmd p
  108. !           return
  109. !         endif
  110.         " No, abandon changes
  111.         elseif action == 2
  112. !         set nomodified
  113. !         echomsg "Warning, abandoning changes in " . bufname
  114.         " Cancel (or any other result), don't do the open
  115.         else
  116. !         wincmd p
  117. !         return
  118.         endif
  119.       endif
  120.       wincmd p
  121. *** ../vim61.124/src/version.c    Thu Jul  4 21:59:55 2002
  122. --- src/version.c    Sat Jul  6 19:30:38 2002
  123. ***************
  124. *** 608,609 ****
  125. --- 608,611 ----
  126.   {   /* Add new patch number below this line */
  127. + /**/
  128. +     125,
  129.   /**/
  130.  
  131. -- 
  132. BEDEVERE: How do you know so much about swallows?
  133. ARTHUR:   Well you have to know these things when you're a king, you know.
  134.                  "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
  135.  
  136.  ///  Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net  \\\
  137. ///   Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim   \\\
  138. \\\           Project leader for A-A-P -- http://www.a-a-p.org           ///
  139.  \\\  Help me helping AIDS orphans in Uganda - http://iccf-holland.org  ///
  140.