1. ZyX_I
  2. aurum

Commits

ZyX_I  committed ba3ebfa

@aurum: Added “:AuHyperlink lines”. Fixes #40

  • Participants
  • Parent commits 18a31f1
  • Branches default

Comments (0)

Files changed (3)

File doc/aurum.txt

View file
  • Ignore whitespace
               added to the URL and what line  should it refer to.
               Only for url=file and url=annotate.
               Default: not added unless range is other then default (e.g. the 
-              whole file), in which case first line of the range is used.
+              whole file), in which case the only line of the range is used 
+              (case when first line is not equal to last line is described 
+              below).
+    [no]lines Like above, but URL fragment now is assumed to point to a line 
+              range (and thus you should use “lines 5 7”: with two numbers). 
+              From what I know, only github supports this feature. Is used 
+              automatically if first line of the range is not equal to the 
+              last line.
     cmd       Command that is used to copy url to register.
               Default: "let @+=%s". Do not forget to escape spaces.
               Value of this option is used in this fashion: >
     0.3: Modified syntax of |:AuHyperlink|: made it accept range, but removed 
          “line 0” for referencing current line, it is now “.AuH”. Also made it 
          accept “noline”.
+    0.4: Added |:AuHyperlink| lines.
 @aurum/edit:
     1.0: Removed setlines function (moved it to @aurum/repo).
     1.1: Added “requiresbvar” _f.newcommand option.
     1.0: Added _r.getcrf(), removed cachebvars export
 ftplugin/aurumlog:
     0.1: Added OpenAny and AnnotateAny mappings.
+@aurum/drivers/common/hypsites:
+    0.1: Added dict.hlines key (see version 0.4 of @aurum).
 
 vim: ft=help:tw=78

File plugin/aurum.vim

View file
  • Ignore whitespace
 scriptencoding utf-8
 if !exists('s:_pluginloaded')
     "▶2 frawor#Setup
-    execute frawor#Setup('0.3', {'@/commands': '0.0',
+    execute frawor#Setup('0.4', {'@/commands': '0.0',
                 \               '@/functions': '0.0',
                 \                   '@/table': '0.0',
                 \                '@/mappings': '0.0',
 function s:hypfunc.function(line1, line2, opts)
     let opts=copy(a:opts)
     let utype=get(opts, 'url', 'html')
-    let line=((has_key(a:opts, 'line'))?
-                \(a:opts.line):
-                \((a:line1==1 && a:line2==line('$')) ? 0 : a:line1))
+    "▶2 Get line or line1+line2
+    let hasline=1
+    if has_key(a:opts, 'lines')
+        let line1=a:opts.lines[0]
+        let line2=a:opts.lines[1]
+    elseif has_key(a:opts, 'line')
+        let line=a:opts.line
+    elseif !(a:line1==1 && a:line2==line('$'))
+        if a:line1!=a:line2
+            let line1=min([a:line1, a:line2])
+            let line2=max([a:line1, a:line2])
+        else
+            let line=a:line1
+        endif
+    else
+        let hasline=0
+    endif
+    "▶2 Get repo, hex and file
+    "▶3 File needed: html, annotate, raw, filehist
     if utype is# 'html' || utype is# 'annotate' || utype is# 'raw'
                 \       || utype is# 'filehist'
         let [hasbuf, repo, rev, file]=s:_r.cmdutils.getrrf(a:opts, 'nocurf',
         call s:_r.cmdutils.checkrepo(repo)
         let file=s:F.urlescape(file)
         if rev is 0
-            if line && repo.functions.dirty(repo, file)
-                let line=0
+            if hasline && repo.functions.dirty(repo, file)
+                let hasline=0
                 call s:_f.warn('ldirty', file, repo.path)
             endif
             let hex=repo.functions.getworkhex(repo)
         else
             let hex=repo.functions.getrevhex(repo, rev)
         endif
+    "▶3 File not needed: others
     else
         let repo=s:_r.repo.get(a:opts.repo)
         call s:_r.cmdutils.checkrepo(repo)
             endif
         endif
     endif
+    "▲2
     let url=repo.functions.getrepoprop(repo, 'url')
     let [protocol, user, domain, port, path]=
                 \matchlist(url, '\v^%(([^:]+)\:\/\/)?'.
                 call s:_f.throw('uunsup', utype, repo.path, url)
             endif
             let r=eval(dict[utype])
-            if line && (utype is# 'html' || utype is# 'annotate')
-                let lkey=utype[0].'line'
+            if hasline && (utype is# 'html' || utype is# 'annotate')
+                if exists('line')
+                    let lkey=utype[0].'line'
+                else
+                    let lkey=utype[0].'lines'
+                endif
                 if has_key(dict, lkey)
                     let r.='#'.eval(dict[lkey])
                 else
-                    call s:_f.warn('uunsup', 'line', repo.path, url)
+                    call s:_f.warn('uunsup', lkey, repo.path, url)
                 endif
             endif
             let cmd=get(opts, 'cmd', 'let @+=%s')
             \                           '    ?rev   type ""'.
             \                           '    ?file  type ""'.
             \                           ' !+1?line  range 1 inf'.
+            \                           ' !+2?lines (range 1 inf)(range 1 inf)'.
             \                           '    ?cmd   type ""'.
             \                           '    ?url   in utypes ~start'.
             \                           '}', 'filter']

File plugin/aurum/drivers/common/hypsites.vim

View file
  • Ignore whitespace
 "▶1
 scriptencoding utf-8
 if !exists('s:_pluginloaded')
-    execute frawor#Setup('0.0', {'@/resources': '0.0',}, 0)
+    execute frawor#Setup('0.1', {'@/resources': '0.0',}, 0)
     finish
 elseif s:_pluginloaded
     finish
 \['domain is? "bitbucket.org"', s:bbdict],
 \['domain is? "github.com"',
 \ {     'html': '"https://".domain."/".'.s:ghpath.'."/blob/".hex."/".file',   'hline': '"L".line',
+\                                                                             'hlines': '"L".line1."-L".line2',
 \        'raw': '"https://".domain."/".'.s:ghpath.'."/raw/". hex."/".file',
 \   'annotate': '"https://".domain."/".'.s:ghpath.'."/blame/". hex."/".file', 'aline': '"LID".line',
 \   'filehist': '"https://".domain."/".'.s:ghpath.'."/commits/".hex."/".file',