Commits

Takeshi NISHIDA  committed f6420a4

minor fix

  • Participants
  • Parent commits 8d52f1e
  • Tags 1.0

Comments (0)

Files changed (2)

File autoload/l9/tempbuffer.vim

 " a:bufname:
 " a:height: Window height. If 0, default height is used.
 "           If less than 0, the window becomes full-screen. 
-function l9#tempbuffer#openScratch(bufname, filetype, lines, topleft, vertical, height)
+" a:listener:
+"   a:listener.onClose(written)
+function l9#tempbuffer#openScratch(bufname, filetype, lines, topleft, vertical, height, listener)
   let openCmdPrefix = (a:topleft ? 'topleft ' : '')
         \           . (a:vertical ? 'vertical ' : '')
         \           . (a:height > 0 ? a:height : '')
   silent file `=a:bufname`
   call setline(1, a:lines)
   setlocal nomodified
+  augroup L9TempBuffer
+    autocmd! * <buffer>
+    execute printf('autocmd BufDelete   <buffer>        call s:onBufDelete  (%s)', string(a:bufname))
+    execute printf('autocmd BufWriteCmd <buffer> nested call s:onBufWriteCmd(%s)', string(a:bufname))
+  augroup END
   let s:dataMap[a:bufname] = {
         \   'bufNr': bufnr('%'),
+        \   'written': 0,
+        \   'listener': a:listener,
         \ }
 endfunction
 
-" a:bufname:
-" a:height: Window height. If 0, default height is used.
-"           If less than 0, the window becomes full-screen. 
-" a:listener:
-"   a:listener.onClose(written)
-"   a:listener.onWrite(lines)
-function l9#tempbuffer#openReadOnly(bufname, filetype, lines, topleft, vertical, height)
-  call l9#tempbuffer#openScratch(a:bufname, a:filetype, a:lines, a:topleft, a:vertical, a:height)
+"
+function l9#tempbuffer#openReadOnly(bufname, filetype, lines, topleft, vertical, height, listener)
+  call l9#tempbuffer#openScratch(a:bufname, a:filetype, a:lines, a:topleft, a:vertical, a:height, a:listener)
   setlocal nomodifiable readonly
 endfunction
 
 "   a:listener.onClose(written)
 "   a:listener.onWrite(lines)
 function l9#tempbuffer#openWritable(bufname, filetype, lines, topleft, vertical, height, listener)
-  call l9#tempbuffer#openScratch(a:bufname, a:filetype, a:lines, a:topleft, a:vertical, a:height)
+  call l9#tempbuffer#openScratch(a:bufname, a:filetype, a:lines, a:topleft, a:vertical, a:height, a:listener)
   setlocal buftype=acwrite
-  let s:dataMap[a:bufname].listener = a:listener
-  let s:dataMap[a:bufname].written = 0
-  augroup L9TempBuffer
-    autocmd! * <buffer>
-    execute printf('autocmd BufDelete   <buffer>        call s:onBufDelete  (%s)', string(a:bufname))
-    execute printf('autocmd BufWriteCmd <buffer> nested call s:onBufWriteCmd(%s)', string(a:bufname))
-  augroup END
 endfunction
 
 " makes specified temp buffer current.

File plugin/l9.vim

   function s:timerDump()
     L9TimerStop
     let lines = map(s:timerData, 'v:val.tag . repeat(" ", s:timerTagMaxLen - len(v:val.tag)) . v:val.time')
-    call l9#tempbuffer#openReadOnly('[l9-timer]', '', lines, 0, 0, 0)
+    call l9#tempbuffer#openReadOnly('[l9-timer]', '', lines, 0, 0, 0, {})
     let s:timerData = []
     let s:timerTagMaxLen = 0
   endfunction