ZyX_I avatar ZyX_I committed e6052e1

@%aurum/powerline: Fixed some exceptions

Comments (0)

Files changed (4)

autoload/aurum/cmdutils.vim

 "▶1
 scriptencoding utf-8
-execute frawor#Setup('4.1', {'@/resources': '0.0',
+execute frawor#Setup('4.2', {'@/resources': '0.0',
             \                       '@/os': '0.0',
             \               '@%aurum/repo': '5.0',
             \               '@%aurum/edit': '1.0',
             let file=expand('%')
         else
             let repo=s:_r.repo.get(':')
-            call s:r.checkrepo(repo)
-            if a:act isnot# 'getrr'
+            if type(repo)==type({}) && a:act isnot# 'getrr'
                 let file=repo.functions.reltorepo(repo, expand('%'))
             endif
         endif
         "▶2 repo
         if !exists('repo')
             let repo=s:_r.repo.get(a:opts.repo)
-            call s:r.checkrepo(repo)
-            if file isnot 0
+            if type(repo)==type({}) && file isnot 0
                 let file=repo.functions.reltorepo(repo, file)
             endif
         endif
         endif
         "▲2
     endif
+    if type(repo)!=type({})
+        let file=0
+        let rev=0
+        if a:failmsg isnot 0
+            call s:_f.throw('nrepo')
+        endif
+    endif
     return [hasbuf, exists('repo') ? repo : 0, rev,
                 \((a:act is# 'getfiles')?
                 \   ((exists('files'))?

autoload/aurum/powerline.vim

 scriptencoding utf-8
 execute frawor#Setup('0.0', {'@aurum/cache': '2.3',
             \                '@%aurum/repo': '5.0',
-            \            '@%aurum/cmdutils': '4.0',
+            \            '@%aurum/cmdutils': '4.2',
             \                    '@/python': '1.0',})
 python import aurum.powerline
 "▶1 plwipe
 aurum.powerline.sid     = str(int(vim.eval('s:_sid')))
 aurum.powerline.started = True
 EOF
+"▶1 VimEnter
+function s:F.define_local_themes()
+return
+python <<EOF
+powerline.add_local_theme("aurum.powerline.is_commit", {
+    u"default_module": u"aurum.powerline",
+    u"segments": {
+        u"left": [
+            {
+                u"type": u"string",
+                u"contents": u"Commit",
+                u"highlight": [u"line_current_symbol"],
+            },
+        ],
+    }
+})
+EOF
+augroup AuAddPowerlineThemes
+    autocmd!
+augroup END
+augroup! AuAddPowerlineThemes
+endfunction
+
+augroup AuAddPowerlineThemes
+    autocmd! VimEnter * call s:F.define_local_themes()
+augroup END
 "▶1 _unload
 function s:._unload()
     python reload(aurum.powerline)
     3.1: Added _r.cmdutils.update (moved from @aurum/repo).
     4.0: Moved _r.cmdutils.update to @%aurum/maputils
     4.1: Made _r.cmdutils.getrrf recognize “getrr” action
+    4.2: Made _r.cmdutils.getrrf not throw “nrepo” in case a:failmsg is zero
 @%aurum:
     0.1: Added |aurum#branch()| function.
 @aurum/cache:

python/aurum/powerline.py

     if bufnr in fname_cache and (time()-fname_cache[bufnr][1]) < get_repo_interval():
         return funcs_cache[bufnr][0], fname_cache[bufnr][0]
 
-    vim_repo, rev, fname = get_rrf()
+    try:
+        vim_repo, rev, fname = get_rrf()
+    except:
+        vim_repo = None
+        fname = None
+
     funcs = process_repo(vim_repo)
 
     if not fname or fname == '0':
     if bufnr in funcs_cache and (time()-funcs_cache[bufnr][1]) < get_repo_interval():
         return funcs_cache[bufnr][0]
 
-    vim_repo = get_repo(':')
+    try:
+        vim_repo = get_repo(':')
+    except:
+        vim_repo = None
 
     return set_bufnr_cache(funcs_cache, bufnr, process_repo(vim_repo))
 
 
 def wipe_buffer(bufnr):
     if bufnr in buffers:
-        for value in buffers[bufnr].itervalues():
+        for value in buffers[bufnr]['rcids'].itervalues():
             rc.remove(value)
         buffers.pop(bufnr)
 
 def wipe_key(key):
     for bdict in buffers.itervalues():
-        if key in bdict:
-            rc.get(bdict[key], now=True)
+        if key in bdict['rcids']:
+            rc.get(bdict['rcids'][key], now=True)
 
 def wipe_buffer_key(bufnr, key):
     if bufnr in buffers and key in buffers[bufnr]:
     if not started:
         vim.eval('FraworLoad(@%aurum/powerline)')
 
-    if bufnr not in buffers:
-        vim.command('autocmd! AuRemovePowerlineRC BufWipeOut,BufFilePost <buffer='+str(bufnr)+'> '+
-                ':python aurum.powerline.wipe_buffer('+str(bufnr)+')')
-        bdict = {}
+    newbuffer = (bufnr not in buffers)
+    if newbuffer:
+        bdict = {'rcids': {}}
         buffers[bufnr] = bdict
 
         if not funcs:
     if not funcs:
         return None
 
-    if func_name not in bdict:
-        bdict[func_name] = rc.new(get_interval(func_name), getattr(funcs, func_name), *args)
+    if func_name not in bdict['rcids']:
+        bdict['rcids'][func_name] = rc.new(get_interval(func_name), getattr(funcs, func_name), *args)
         if func_name == 'status':
             vim.command('autocmd! AuRemovePowerlineRC BufWritePost <buffer='+str(bufnr)+'> '+
                     ':python aurum.powerline.wipe_buffer_key('+str(bufnr)+', '+repr(func_name)+')')
+        if newbuffer:
+            vim.command('autocmd! AuRemovePowerlineRC BufWipeOut,BufFilePost <buffer='+str(bufnr)+'> '+
+                    ':python aurum.powerline.wipe_buffer('+str(bufnr)+')')
 
-    return bdict[func_name]
+
+    return bdict['rcids'][func_name]
 
 def branch():
     bsetup = setup_buffer(vim.current.buffer.number, 'branch')
             'highlight': ['file_vcs_status_'+statchar, 'file_vcs_status']
            }
 
+def xxx_uncommon():
+    return 'TEXT'
+
+def is_commit():
+    return vim.eval('&ft') == 'aurumcommit'
+
 # vim: ft=python ts=4 sw=4 sts=4 et tw=120
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.