Commits

ZyX_I  committed 5119c23

@%aurum/annotate, @%aurum/bufvars, @%aurum/commit, @%aurum/vimdiff:
Made some feedkeys() calls end with
@%aurum/edit: Added possibility to override aurum://edit writing function

  • Participants
  • Parent commits a520de5

Comments (0)

Files changed (6)

File autoload/aurum/annotate.vim

         execute 'autocmd BufWipeOut,BufHidden <buffer='.a:annbuf.'> '.
                     \':if bufexists('.buf.') | '.
                     \   'call feedkeys("\<C-\>\<C-n>'.
-                    \                 ':silent! bw '.buf.'\n") | '.
+                    \                 ':silent! bw '.buf.'\n\<C-l>") | '.
                     \ 'endif'
     augroup END
 endfunction

File autoload/aurum/bufvars.vim

             call feedkeys("\<C-\>\<C-n>:call ".
                     \      "call(".eval."('s:bufvars[".buf."].bwfunc'), ".
                     \           "[".eval."('s:bufvars[".buf."]')], {}) | ".
-                    \"call ".eval."('remove(s:bufvars, ".buf.")')\n", 'n')
+                    \"call ".eval."('remove(s:bufvars, ".buf.")')\n\<C-l>", 'n')
             return
         endif
         unlet s:bufvars[buf]

File autoload/aurum/commit.vim

         call a:bvar.bwfunc(a:bvar)
         let a:bvar.bwfunc=a:bvar.sbvar.bwfunc
     endif
-    call feedkeys("\<C-\>\<C-n>:bwipeout!\n")
+    call feedkeys("\<C-\>\<C-n>:bwipeout!\n\<C-l>")
 endfunction
 "▶1 commfunc
 function s:cmd.function(opts, ...)

File autoload/aurum/edit.vim

 "▶1
 scriptencoding utf-8
-execute frawor#Setup('1.4', {'@/resources': '0.0',
+execute frawor#Setup('1.5', {'@/resources': '0.0',
             \                       '@/os': '0.0',
             \               '@%aurum/repo': '5.0',
             \          '@%aurum/lineutils': '0.0',
     return r
 endfunction
 "▶1 copy
-function s:F.copy(read, file)
+function s:F.copy(buf, read, file)
     call s:_r.lineutils.setlines(readfile(a:file, 'b'), a:read)
     if !a:read
-        let s:_r.bufvars[bufnr('%')]={'file': a:file, 'command': 'copy'}
+        let s:_r.bufvars[a:buf]={'file': a:file, 'command': 'copy'}
         if exists('#filetypedetect#BufRead')
             execute 'doautocmd filetypedetect BufRead' fnameescape(a:file)
         endif
     endif
 endfunction
 "▶1 edit
-function s:F.edit(rw, file)
+function s:F.ewrite(bvar, lines, file)
+    return writefile(a:lines, a:file, 'b')
+endfunction
+function s:F.edit(buf, rw, file)
     if a:rw>=0
-        call s:F.copy(a:rw, a:file)
+        call s:F.copy(a:buf, a:rw, a:file)
         if !a:rw
             setlocal buftype=acwrite nomodified modifiable noreadonly
-            let s:_r.bufvars[bufnr('%')]={'file': a:file, 'command': 'edit'}
+            let s:_r.bufvars[a:buf]={'file': a:file, 'command': 'edit',
+                        \            'write': s:F.ewrite}
         endif
     elseif a:rw==-1
-        call writefile(s:_r.lineutils.wtransform(getline(1, '$')), a:file, 'b')
+        let bvar=s:_r.bufvars[a:buf]
+        call bvar.write(bvar, s:_r.lineutils.wtransform(getline(1, '$')), a:file)
         setlocal nomodified
     endif
 endfunction
     let command=tolower(matchstr(tail, '\v^\w+'))
     let tail=tail[len(command)+1:]
     if command is# 'copy' && (a:rw==0 || a:rw==1)
-        return s:F.copy(a:rw, tail)
+        return s:F.copy(buf, a:rw, tail)
     elseif command is# 'edit' && abs(a:rw)<=1
-        return s:F.edit(a:rw, tail)
+        return s:F.edit(buf, a:rw, tail)
     endif
     call s:F.checkcmd(command)
     "▶2 Launch bvar.write if applicable

File autoload/aurum/vimdiff.vim

     let toremove=keys(filter(copy(a:ddbvars),
                 \            '!v:val.existed && bufexists(v:val.bufnr)'))
     if !empty(toremove)
-        call feedkeys("\<C-\>\<C-n>:silent bwipeout ".join(toremove)."\n", 'n')
+        call feedkeys("\<C-\>\<C-n>:silent bwipeout ".join(toremove)."\n\<C-l>",
+                    \ 'n')
     endif
 endfunction
 "▶2 diffrestore.call

File doc/aurum.txt

     1.2: Added “mgroup” _f.newcommand option and mrun resource.
     1.3: Added prevbuf function.
     1.4: Added “plstrgen” _f.newcommand option.
+    1.5: Added possibility to use custom writer function for aurum://edit
 @%aurum/vimdiff:
     0.1: Added full, untracked, onlymodified and files options to |:AuVimDiff|
     0.2: Added _r.vimdiff.full.