Commits

ZyX_I committed f360c3b

Added AuLog OpenAny and AnnotateAny mappings

  • Participants
  • Parent commits 515ce24

Comments (0)

Files changed (5)

File doc/aurum.txt

     Open log for given repo. {opts} are the same as used by |:AuLog|.
     Local mappings (mgid=AuLog, current revision=revision under cursor):
                                                            *g:frawormap_AuLog*
-                        *g:frawormap_AuLog_File*  *g:frawormap_AuLog_Enter*
-                        *g:frawormap_AuLog_User*  *g:frawormap_AuLog_Update*
-                        *g:frawormap_AuLog_Rev*   *g:frawormap_AuLog_Branch*
-                        *g:frawormap_AuLog_Diff*  *g:frawormap_AuLog_FVdiff*
-                        *g:frawormap_AuLog_Fdiff* *g:frawormap_AuLog_RFVdiff*
-                        *g:frawormap_AuLog_Next*  *g:frawormap_AuLog_RFdiff*
-                        *g:frawormap_AuLog_Prev*  *g:frawormap_AuLog_Rdiff*
-                        *g:frawormap_AuLog_Open*  *g:frawormap_AuLog_Annotate*
-                        *g:frawormap_AuLog_Date*      *aurum-m-AuLog_Date*
-                            *aurum-m-AuLog_File*      *aurum-m-AuLog_Enter*
-                            *aurum-m-AuLog_User*      *aurum-m-AuLog_Update*
-                            *aurum-m-AuLog_Rev*       *aurum-m-AuLog_Branch*
-                            *aurum-m-AuLog_Diff*      *aurum-m-AuLog_Fdiff*
-                            *aurum-m-AuLog_Next*      *aurum-m-AuLog_RFdiff*
-                            *aurum-m-AuLog_Prev*      *aurum-m-AuLog_Rdiff*
-                            *aurum-m-AuLog_Open*      *aurum-m-AuLog_Annotate*
+                     *g:frawormap_AuLog_File*  *g:frawormap_AuLog_Enter*
+                     *g:frawormap_AuLog_User*  *g:frawormap_AuLog_Update*
+                     *g:frawormap_AuLog_Rev*   *g:frawormap_AuLog_Branch*
+                     *g:frawormap_AuLog_Diff*  *g:frawormap_AuLog_FVdiff*
+                     *g:frawormap_AuLog_Fdiff* *g:frawormap_AuLog_RFVdiff*
+                     *g:frawormap_AuLog_Rdiff* *g:frawormap_AuLog_RFdiff*
+                     *g:frawormap_AuLog_Next*  *g:frawormap_AuLog_AnnotateAny*
+                     *g:frawormap_AuLog_Prev*  *g:frawormap_AuLog_Annotate*
+                     *g:frawormap_AuLog_Open*  *g:frawormap_AuLog_OpenAny*
+                     *g:frawormap_AuLog_Date*  *g:frawormap_AuLog_Date*
+                         *aurum-m-AuLog_File*      *aurum-m-AuLog_Enter*
+                         *aurum-m-AuLog_User*      *aurum-m-AuLog_Update*
+                         *aurum-m-AuLog_Rev*       *aurum-m-AuLog_Branch*
+                         *aurum-m-AuLog_Diff*      *aurum-m-AuLog_FVdiff*
+                         *aurum-m-AuLog_Fdiff*     *aurum-m-AuLog_RFVdiff*
+                         *aurum-m-AuLog_Rdiff*     *aurum-m-AuLog_RFdiff*
+                         *aurum-m-AuLog_Next*      *aurum-m-AuLog_AnnotateAny*
+                         *aurum-m-AuLog_Prev*      *aurum-m-AuLog_Annotate*
+                         *aurum-m-AuLog_Open*      *aurum-m-AuLog_OpenAny*
     Mapname  LHS  Description ~
     Enter    <CR> Depending on element under cursor:
                   Element          Action ~
                   Accepts count, in this case first parent is taken {count} 
                   times ({count}=2: first parent of first parent)
     Open      o   Open one of the files changed in current revision
+    OpenAny   O   Open one of the files present in current revision
     Annotate  a   Open one of the files changed in current revision and 
                   annotate it
+    AnnotateAny
+              A   Open one of the files present in current revision and 
+                  annotate it
     Update    U   Update working directory to current revision
                   Accepts count: {count}=3: update to first parent of first 
                   parent of current revision
     0.1: Added |aurum#branch()| function.
 @aurum/cache:
     0.1: Added _r.cache.del().
+ftplugin/aurumlog:
+    0.1: Added OpenAny and AnnotateAny mappings.
 
 vim: ft=help:tw=78

File ftplugin/aurumlog.vim

 endif
 setlocal noswapfile
 setlocal nomodeline
-execute frawor#Setup('0.0', {'@aurum/cmdutils': '1.0',
+execute frawor#Setup('0.1', {'@aurum/cmdutils': '1.0',
             \                 '@aurum/bufvars': '0.0',
             \                    '@aurum/repo': '4.0',
             \                    '@aurum/edit': '1.0',
         return cmd.hex.' '.cs.parents[0]."\n"
     endif
 endfunction
+"▶1 getfile
+function s:F.getfile(bvar, files, hex, more)
+    if empty(a:files)
+        return 0
+    endif
+    if has_key(a:bvar.opts, 'files') &&
+                \!has_key(a:bvar.opts.ignorefiles, 'open')
+        if a:more
+            let files=[]
+            let rej=copy(a:files)
+            for pattern in a:bvar.opts.filepats
+                call filter(rej, 'v:val!~#pattern || [0, add(files, v:val)][0]')
+            endfor
+        else
+            let files=copy(a:bvar.opts.csfiles[a:hex])
+            call filter(files, 'index(a:files, v:val)!=-1')
+        endif
+        if empty(files)
+            call s:_f.throw('novfilesff', a:hex)
+        endif
+    else
+        let files=a:files
+        if empty(files)
+            call s:_f.throw('novfiles', a:hex)
+        endif
+    endif
+    let file=0
+    if len(files)==1
+        let file=files[0]
+    else
+        let choice=inputlist(['Select file (0 to cancel):']+
+                    \        map(copy(files), '(v:key+1).". ".v:val'))
+        if choice
+            let file=files[choice-1]
+        endif
+    endif
+    return file
+endfunction
 "▶1 gethexfile
-function s:F.gethexfile()
+function s:F.gethexfile(...)
     let bvar=s:_r.bufvars[bufnr('%')]
     let [blockstart, blockend, hex]=bvar.getblock(bvar)
     let spname=s:F.findCurSpecial(bvar, hex, blockstart[0])
         " XXX If fileN special exists, then files property was definitely added, 
         " so no need to use getcsprop()
         let file=cs.files[str2nr(spname[4:])]
-    " Above is not applicable if we don't know exactly whether such special 
-    " exists
-    elseif !empty(bvar.repo.functions.getcsprop(bvar.repo, cs, 'files'))
-        if has_key(bvar.opts, 'files') &&
-                    \!has_key(bvar.opts.ignorefiles, 'open')
-            let files=copy(bvar.opts.csfiles[hex])
-            call filter(files, 'index(cs.files, v:val)!=-1')
-            if empty(files)
-                call s:_f.throw('novfilesff', hex)
-            endif
-        else
-            let files=cs.files
-            if empty(files)
-                call s:_f.throw('novfiles', hex)
-            endif
-        endif
-        if len(files)==1
-            let file=files[0]
-        else
-            let choice=inputlist(['Select file (0 to cancel):']+
-                        \        map(copy(files), '(v:key+1).". ".v:val'))
-            if choice
-                let file=files[choice-1]
-            endif
-        endif
+    else
+        let file=s:F.getfile(bvar,
+                    \        bvar.repo.functions.getcsprop(bvar.repo, cs,
+                    \                                      (((a:0 && !a:1))?
+                    \                                           ('allfiles'):
+                    \                                           ('files'))),
+                    \        hex, (a:0 && !a:1))
     endif
     return [hex, file]
 endfunction
 "▶1 open
-function s:F.open()
-    let [hex, file]=s:F.gethexfile()
+function s:F.open(...)
+    let [hex, file]=call(s:F.gethexfile, a:000, {})
     if file is 0
         return 0
     endif
     return 1
 endfunction
 "▶1 annotate
-function s:F.annotate()
-    if s:F.open()
+function s:F.annotate(...)
+    if call(s:F.open, a:000, {})
         AuAnnotate
     endif
 endfunction
                 \                   '('.string(string(a:000))[2:-3].')'')<CR>'
 endfunction
 call s:_f.mapgroup.add('AuLog', {
-            \   'Enter': {'lhs': "\n", 'rhs': s:m('cr'),                      },
-            \    'File': {'lhs': 'gF', 'rhs': s:F.filehistory                 },
-            \    'User': {'lhs': 'gu', 'rhs': s:m('cr', 'user')               },
-            \    'Date': {'lhs': 'gM', 'rhs': s:m('cr', 'time')               },
-            \  'Branch': {'lhs': 'gb', 'rhs': s:m('cr', 'branch')             },
-            \     'Rev': {'lhs': 'gr', 'rhs': s:m('cr', 'rev')                },
-            \  'FVdiff': {'lhs': 'gD', 'rhs': s:F.fvdiff                      },
-            \ 'RFVdiff': {'lhs': 'gC', 'rhs': [1],         'func': s:F.fvdiff },
-            \   'Fdiff': {'lhs': 'gd', 'rhs': s:m('cr', 'curdiff')            },
-            \  'RFdiff': {'lhs': 'gc', 'rhs': s:m('cr', 'revdiff')            },
-            \    'Diff': {'lhs':  'd', 'rhs': s:m('diff', 1)                  },
-            \   'Rdiff': {'lhs':  'c', 'rhs': s:m('diff')                     },
-            \   'Vdiff': {'lhs':  'D', 'rhs': s:m('vimdiff', 1)               },
-            \  'RVdiff': {'lhs':  'C', 'rhs': s:m('vimdiff')                  },
-            \    'Next': {'lhs':  'K', 'rhs': s:F.next                        },
-            \    'Prev': {'lhs':  'J', 'rhs': s:F.prev                        },
-            \    'Open': {'lhs':  'o', 'rhs': s:m('open')                     },
-            \'Annotate': {'lhs':  'a', 'rhs': s:m('annotate')                 },
-            \  'Update': {'lhs':  'U', 'rhs': s:F.update                      },
-            \    'Exit': {'lhs':  'X', 'rhs': ':<C-u>bwipeout<CR>'            },
+            \      'Enter': {'lhs': "\n", 'rhs': s:m('cr'),             },
+            \       'File': {'lhs': 'gF', 'rhs': s:F.filehistory        },
+            \       'User': {'lhs': 'gu', 'rhs': s:m('cr', 'user')      },
+            \       'Date': {'lhs': 'gM', 'rhs': s:m('cr', 'time')      },
+            \     'Branch': {'lhs': 'gb', 'rhs': s:m('cr', 'branch')    },
+            \        'Rev': {'lhs': 'gr', 'rhs': s:m('cr', 'rev')       },
+            \     'FVdiff': {'lhs': 'gD', 'rhs': s:F.fvdiff             },
+            \    'RFVdiff': {'lhs': 'gC', 'rhs': [1], 'func': s:F.fvdiff},
+            \      'Fdiff': {'lhs': 'gd', 'rhs': s:m('cr', 'curdiff')   },
+            \     'RFdiff': {'lhs': 'gc', 'rhs': s:m('cr', 'revdiff')   },
+            \       'Diff': {'lhs':  'd', 'rhs': s:m('diff', 1)         },
+            \      'Rdiff': {'lhs':  'c', 'rhs': s:m('diff')            },
+            \      'Vdiff': {'lhs':  'D', 'rhs': s:m('vimdiff', 1)      },
+            \     'RVdiff': {'lhs':  'C', 'rhs': s:m('vimdiff')         },
+            \       'Next': {'lhs':  'K', 'rhs': s:F.next               },
+            \       'Prev': {'lhs':  'J', 'rhs': s:F.prev               },
+            \       'Open': {'lhs':  'o', 'rhs': s:m('open')            },
+            \    'OpenAny': {'lhs':  'O', 'rhs': s:m('open', 0)         },
+            \   'Annotate': {'lhs':  'a', 'rhs': s:m('annotate')        },
+            \'AnnotateAny': {'lhs':  'A', 'rhs': s:m('annotate', 0)     },
+            \     'Update': {'lhs':  'U', 'rhs': s:F.update             },
+            \       'Exit': {'lhs':  'X', 'rhs': ':<C-u>bwipeout<CR>'   },
             \}, {'func': s:F.cr, 'silent': 1, 'mode': 'n'})
 delfunction s:m
 "▶1

File test/maps-log.in

 a0
 :call WriteFile(bufname('%'))
 :bwipeout!
+:W{{{1 O
+:R AuLog
+O4
+:WW
+:bwipeout!
+:W{{{1 A
+:R AuLog
+A4
+:WW
+:bwipeout!
 :W{{{1 K, J
 :R AuLog
 /\VAdded blines.lst

File test/maps-log.ok

 w$: 2
 {{{1 cancel a
 aurum://log:%ETMPDIR%%-test%-maps-logrepo:showfiles:1,
+{{{1 O
+*1: aurum://file:%ETMPDIR%%-test%-maps-logrepo:504f74154456dbb0e9441326514e42ce66279e62:alines.lst
+{{{1 A
+#1: aurum://annotate:%ETMPDIR%%-test%-maps-logrepo:504f74154456dbb0e9441326514e42ce66279e62:alines.lst
+*2: aurum://file:%ETMPDIR%%-test%-maps-logrepo:504f74154456dbb0e9441326514e42ce66279e62:alines.lst
 {{{1 K, J
 | | o | |  Changeset 8:250ba7cd831ee91c3ba5bef1faebc38c5dbca5f8 (branch C)
 | | o  Changeset 6:9fe0c28c3e1dd175e8372b742f13cbb7bd6799fe (branch B)

File test/wine/maps-log.ok

 w$: 2
 {{{1 cancel a
 aurum:\\log:%ETMPDIR%%+test%+maps-logrepo:showfiles:1,
+{{{1 O
+*1: aurum:\\file:%ETMPDIR%%+test%+maps-logrepo:504f74154456dbb0e9441326514e42ce66279e62:alines.lst
+{{{1 A
+#1: aurum:\\annotate:%ETMPDIR%%+test%+maps-logrepo:504f74154456dbb0e9441326514e42ce66279e62:alines.lst
+*2: aurum:\\file:%ETMPDIR%%+test%+maps-logrepo:504f74154456dbb0e9441326514e42ce66279e62:alines.lst
 {{{1 K, J
 | | o | |  Changeset 8:250ba7cd831ee91c3ba5bef1faebc38c5dbca5f8 (branch C)
 | | o  Changeset 6:9fe0c28c3e1dd175e8372b742f13cbb7bd6799fe (branch B)