[SCM] Vim packaging branch, debian, updated. upstream/7.1.285-146-g4b01109

James Vega jamessan at debian.org
Sat Jun 14 18:05:31 UTC 2008


The following commit has been merged in the debian branch:
commit 4b01109ba3c4132cd2c1ed78cdd9e69c3797324c
Author: James Vega <jamessan at debian.org>
Date:   Sat Jun 14 14:04:56 2008 -0400

    Merge LaunchPad bug completion from Ubuntu.
    
    Signed-off-by: James Vega <jamessan at debian.org>

diff --git a/runtime/ftplugin/debchangelog.vim b/runtime/ftplugin/debchangelog.vim
index bee09d0..b70d77c 100644
--- a/runtime/ftplugin/debchangelog.vim
+++ b/runtime/ftplugin/debchangelog.vim
@@ -295,27 +295,61 @@ endif
 
 fun! DebCompleteBugs(findstart, base)
   if a:findstart
-    " it we are just after an '#', the completion should start at the '#',
-    " otherwise no completion is possible
     let line = getline('.')
-    let colidx = col('.')
-    if colidx > 1 && line[colidx - 2] =~ '#'
-      let colidx = colidx - 2
-    else
-      let colidx = -1
-    endif
+
+    " try to detect whether this is closes: or lp:
+    let g:debchangelog_complete_mode = 'debbugs'
+    let try_colidx = col('.') - 1
+    let colidx = -1 " default to no-completion-possible
+
+    while try_colidx > 0 && line[try_colidx - 1] =~ '\s\|\d\|#\|,\|:'
+      let try_colidx = try_colidx - 1
+      if line[try_colidx] == '#' && colidx == -1
+        " found hash, where we complete from:
+        let colidx = try_colidx
+      elseif line[try_colidx] == ':'
+        if try_colidx > 1 && strpart(line, try_colidx - 2, 3) =~ '\clp:'
+          let g:debchangelog_complete_mode = 'lp'
+        endif
+        break
+      endif
+    endwhile
     return colidx
-  else
-    if ! filereadable('/usr/sbin/apt-listbugs')
-      echoerr 'apt-listbugs not found, you should install it to use Closes bug completion'
-      return
+  else " return matches:
+    if g:debchangelog_complete_mode == 'lp'
+      if ! has('python')
+        echoerr 'vim must be built with Python support to use LP bug completion'
+        return
+      endif
+      let pkgsrc = DebGetPkgSrcName(line('.'))
+      python << EOF
+import vim
+from launchpadbugs import connector
+buglist = connector.ConnectBugList()
+bl = list(buglist('https://bugs.launchpad.net/ubuntu/+source/%s' % vim.eval('pkgsrc')))
+bl.sort(None, int)
+liststr = '['
+for bug in bl:
+    liststr += "'#%d - %s'," % (int(bug), bug.summary.replace('\'', '\'\''))
+liststr += ']'
+vim.command('silent let bug_lines = %s' % liststr)
+EOF
+    else
+      if ! filereadable('/usr/sbin/apt-listbugs')
+        echoerr 'apt-listbugs not found, you should install it to use Closes bug completion'
+        return
+      endif
+      let pkgsrc = DebGetPkgSrcName(line('.'))
+      let listbugs_output = system('/usr/sbin/apt-listbugs -s ' . g:debchangelog_listbugs_severities . ' list ' . pkgsrc . ' | grep "^ #" 2> /dev/null')
+      let bug_lines = split(listbugs_output, '\n')
     endif
-    let pkgsrc = DebGetPkgSrcName(line('.'))
-    let listbugs_output = system('/usr/sbin/apt-listbugs -s ' . g:debchangelog_listbugs_severities . ' list ' . pkgsrc . ' | grep "^ #" 2> /dev/null')
-    let bug_lines = split(listbugs_output, '\n')
     let completions = []
     for line in bug_lines
       let parts = matchlist(line, '^\s*\(#\S\+\)\s*-\s*\(.*\)$')
+      " filter only those which match a:base:
+      if parts[1] !~ "^" . a:base
+        continue
+      endif
       let completion = {}
       let completion['word'] = parts[1]
       let completion['menu'] = parts[2]

-- 
Vim packaging



More information about the pkg-vim-maintainers mailing list