Skip to content

Instantly share code, notes, and snippets.

@sunaku
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sunaku/07b3634dcf9f6c8788c3 to your computer and use it in GitHub Desktop.
Save sunaku/07b3634dcf9f6c8788c3 to your computer and use it in GitHub Desktop.
vim-fetch issue #7
calling function fetch#visual(1)
line 1: " get text between last visual selection marks
line 2: " adapted from http://stackoverflow.com/a/6271254/990363
line 3: let [l:startline, l:startcol] = getpos("'<")[1:2]
line 4: let [l:endline, l:endcol] = getpos("'>")[1:2]
line 5: let l:endcol = min([l:endcol, col([l:endline, '$'])]) " 'V' col nr. bug
line 6: let l:endcol -= &selection is 'inclusive' ? 0 : 1
line 7: let l:lines = getline(l:startline, l:endline)
line 8: if visualmode() isnot? 'v' " block-wise selection
line 9: let l:endexpr = 'matchstr(v:val, "\\m^.*\\%'.string(l:endcol).'c.\\?")'
line 10: call map(l:lines, 'strpart('.l:endexpr.', '.string(l:startcol-1).')')
line 11: else
line 12: let l:lines[-1] = matchstr(lines[-1], '\m^.*\%'.string(l:endcol).'c.\?')
line 13: let l:lines[0] = strpart(l:lines[0], l:startcol-1)
line 14: endif
line 15: let l:selection = join(l:lines, "\n")
line 16:
line 17: " test for a trailing spec
line 18: if !empty(l:selection)
line 19: let l:line = getline(l:endline)
line 20: for l:spec in values(s:specs)
line 21: if match(l:line, l:spec.pattern, l:endcol) is l:endcol
line 22: let l:match = matchstr(l:line, l:spec.pattern, l:endcol)
line 23: call s:dovisual(a:count.'gf') " leverage Vim's |gf| to get the file
line 24: return s:setpos(l:spec.parse(l:selection.l:match)[1])
line 25: endif
line 26: endfor
line 20: for l:spec in values(s:specs)
line 21: if match(l:line, l:spec.pattern, l:endcol) is l:endcol
line 22: let l:match = matchstr(l:line, l:spec.pattern, l:endcol)
line 23: call s:dovisual(a:count.'gf') " leverage Vim's |gf| to get the file
line 24: return s:setpos(l:spec.parse(l:selection.l:match)[1])
line 25: endif
line 26: endfor
line 20: for l:spec in values(s:specs)
line 21: if match(l:line, l:spec.pattern, l:endcol) is l:endcol
line 22: let l:match = matchstr(l:line, l:spec.pattern, l:endcol)
line 23: call s:dovisual(a:count.'gf') " leverage Vim's |gf| to get the file
line 24: return s:setpos(l:spec.parse(l:selection.l:match)[1])
line 25: endif
line 26: endfor
line 20: for l:spec in values(s:specs)
line 21: if match(l:line, l:spec.pattern, l:endcol) is l:endcol
line 22: let l:match = matchstr(l:line, l:spec.pattern, l:endcol)
line 23: call s:dovisual(a:count.'gf') " leverage Vim's |gf| to get the file
line 24: return s:setpos(l:spec.parse(l:selection.l:match)[1])
line 25: endif
line 26: endfor
line 20: for l:spec in values(s:specs)
line 21: if match(l:line, l:spec.pattern, l:endcol) is l:endcol
line 22: let l:match = matchstr(l:line, l:spec.pattern, l:endcol)
line 23: call s:dovisual(a:count.'gf') " leverage Vim's |gf| to get the file
line 24: return s:setpos(l:spec.parse(l:selection.l:match)[1])
line 25: endif
line 26: endfor
line 27: endif
line 28:
line 29: " fall back to Vim's |gF|
line 30: call s:dovisual(a:count.'gF')
calling function fetch#visual..<SNR>318_dovisual('1gF')
line 1: let l:cmd = index(['v', 'V', '^V'], mode()) is -1 ? 'gv'.a:command : a:command
line 2: execute 'normal!' l:cmd
line 2: normal! gv1gF
Error detected while processing function fetch#visual..<SNR>318_dovisual:
line 2:
E447: Can't find file "LICENSE:10:15" in path
function fetch#visual..<SNR>318_dovisual returning #-1
continuing in function fetch#visual
function fetch#visual returning #-1
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Oct 20 2014 16:09:47)
Included patches: 1-273
Modified by pkg-vim-maintainers@lists.alioth.debian.org
Compiled by buildd@
Huge version with GTK2 GUI. Features included (+) or not (-):
+acl +farsi +mouse_netterm +syntax
+arabic +file_in_path +mouse_sgr +tag_binary
+autocmd +find_in_path -mouse_sysmouse +tag_old_static
+balloon_eval +float +mouse_urxvt -tag_any_white
+browse +folding +mouse_xterm +tcl
++builtin_terms -footer +multi_byte +terminfo
+byte_offset +fork() +multi_lang +termresponse
+cindent +gettext -mzscheme +textobjects
+clientserver -hangul_input +netbeans_intg +title
+clipboard +iconv +path_extra +toolbar
+cmdline_compl +insert_expand +perl +user_commands
+cmdline_hist +jumplist +persistent_undo +vertsplit
+cmdline_info +keymap +postscript +virtualedit
+comments +langmap +printer +visual
+conceal +libcall +profile +visualextra
+cryptv +linebreak +python +viminfo
+cscope +lispindent -python3 +vreplace
+cursorbind +listcmds +quickfix +wildignore
+cursorshape +localmap +reltime +wildmenu
+dialog_con_gui +lua +rightleft +windows
+diff +menu +ruby +writebackup
+digraphs +mksession +scrollbind +X11
+dnd +modify_fname +signs -xfontset
-ebcdic +mouse +smartindent +xim
+emacs_tags +mouseshape -sniff +xsmp_interact
+eval +mouse_dec +startuptime +xterm_clipboard
+ex_extra +mouse_gpm +statusline -xterm_save
+extra_search -mouse_jsbterm -sun_workshop +xpm
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
system gvimrc file: "$VIM/gvimrc"
user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
system menu file: "$VIMRUNTIME/menu.vim"
fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/freetype2 -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -I/usr/include/tcl8.6 -D_REENTRANT=1 -D_THREAD_SAFE=1 -D_LARGEFILE64_SOURCE=1
Linking: gcc -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -L/build/buildd/ruby2.1-2.1.2/debian/lib -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,--as-needed -o vim -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lnsl -lselinux -lacl -lattr -lgpm -ldl -L/usr/lib -llua5.2 -Wl,-E -fstack-protector -L/usr/local/lib -L/usr/lib/x86_64-linux-gnu/perl/5.20/CORE -lperl -ldl -lm -lpthread -lcrypt -L/usr/lib/python2.7/config-x86_64-linux-gnu -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lieee -lm -lruby-2.1 -lpthread -lgmp -ldl -lcrypt -lm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment