Commits

ZyX_I committed da94865

@aurum: Modified syntax of :AuHyperlink: made it accept range,
removed “line 0” and
added “noline”

Comments (0)

Files changed (2)

                    process all changesets in order to find out files matching 
                    pattern(s) given in “files” option.
 
-AuHyperlink {opts}                                              *:AuHyperlink*
+[range]AuHyperlink {opts}                                       *:AuHyperlink*
     Constructs a URL and puts it into system clipboard (see |quote+|).
     Possible options:
     Option    Description ~
                   log       URL of the commit log
                   clone     URL of the repository, read-only
                   push      URL of the repository, read-write
-    line      Determines whether URL fragment refering to given line should be 
-              added to the URL. Only for url=file and url=annotate.
-              Default: not added. If given line is 0 then current line number 
-              will be used unless “rev” or “file” options are given or refered 
-              file is not the current one.
+    [no]line  Determines whether URL fragment refering to given line should be 
+              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.
     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: >
 @aurum:
     0.1: Added |:AuBranch| and |:AuName|.
     0.2: Added |:AuOther|.
+    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”.
 @aurum/edit:
     1.0: Removed setlines function (moved it to @aurum/repo).
     1.1: Added “requiresbvar” _f.newcommand option.
 scriptencoding utf-8
 if !exists('s:_pluginloaded')
     "▶2 frawor#Setup
-    execute frawor#Setup('0.2', {'@/commands': '0.0',
+    execute frawor#Setup('0.3', {'@/commands': '0.0',
                 \               '@/functions': '0.0',
                 \                   '@/table': '0.0',
                 \                '@/mappings': '0.0',
     " TODO :AuExplore
     let s:addargs={'Update': {'bang': 1}, 'Move': {'bang': 1},
                 \  'Branch': {'bang': 1}, 'Name': {'bang': 1},
-                \   'Other': {'bang': 1}}
+                \   'Other': {'bang': 1},
+                \   'Hyperlink': {'range': '%'}}
     for s:cmd in ['Update', 'Move', 'Junk', 'Track', 'Hyperlink', 'Grep',
                 \ 'Branch', 'Name', 'Other']
         let s:part=tolower(s:cmd[:3])
             \'\V+ type ""', '+ (path)', ''))
 "▶1 hypfunc
 " TODO diff ?
-function s:hypfunc.function(opts)
+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))
     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 has_key(opts, 'line') && repo.functions.dirty(repo, file)
-                call remove(opts, 'line')
+            if line && repo.functions.dirty(repo, file)
+                let line=0
                 call s:_f.warn('ldirty', file, repo.path)
             endif
             let hex=repo.functions.getworkhex(repo)
                 call s:_f.throw('uunsup', utype, repo.path, url)
             endif
             let r=eval(dict[utype])
-            if (utype is# 'html' || utype is# 'annotate') &&
-                        \has_key(opts, 'line')
+            if line && (utype is# 'html' || utype is# 'annotate')
                 let lkey=utype[0].'line'
                 if has_key(dict, lkey)
-                    if opts.line
-                        let line=opts.line
-                    elseif hasbuf
-                        let line=line('.')
-                    endif
-                    if exists('line')
-                        let r.='#'.eval(dict[lkey])
-                    endif
+                    let r.='#'.eval(dict[lkey])
                 else
                     call s:_f.warn('uunsup', 'line', repo.path, url)
                 endif
     endfor
     call s:_f.throw('uknurl', url, repo.path)
 endfunction
-let s:hypfunc['@FWC']=['-onlystrings {?repo '.s:_r.cmdutils.nogetrepoarg.
-            \                       ' ?rev   type ""'.
-            \                       ' ?file  type ""'.
-            \                       ' ?line  range 0 inf'.
-            \                       ' ?cmd   type ""'.
-            \                       ' ?url   in utypes ~start'.
-            \                       '}', 'filter']
+let s:hypfunc['@FWC']=['-onlystrings _ _ {   ?repo '.s:_r.cmdutils.nogetrepoarg.
+            \                           '    ?rev   type ""'.
+            \                           '    ?file  type ""'.
+            \                           ' !+1?line  range 1 inf'.
+            \                           '    ?cmd   type ""'.
+            \                           '    ?url   in utypes ~start'.
+            \                           '}', 'filter']
 call add(s:hypcomp,
             \substitute(substitute(substitute(s:hypfunc['@FWC'][0],
             \'\Vfile\s\+type ""', 'file path',           ''),