Friday, September 27, 2019

Re: Best way to launch a URL from within VIM

I use this :

" Url
function! helper#job_out_cb(self, data) abort "{{{
let g:idx  += 1
let g:data .= string(g:idx)
let g:data .= a:data
let self  = a:self
try
let data  = remove(self.lines, -1) . a:data
catch /.*/
echomsg 'begin'.string(a:data).'end'
endtry
let lines = split(a:data, "\n", 1)
" echomsg string(lines)
call extend(self.lines, lines)
endfunction  "}}}
function! helper#job_exit_cb(self, data) abort   "{{{
let a:self.running = 0
let a:self.error   = a:data != 0
let self   = a:self
let g:self = self
endfunction  "}}}
function! helper#job_cb(fn, job, ch, data)  "{{{
call call(a:fn, [a:job, a:data])
endfunction  "}}}
fun! helper#openurl(...) "{{{
  let cmd_browse = 'rundll32 url.dll,FileProtocolHandler '
  let url_pat = '\w\+:\/\{2}[^ ''()]\+'
  let url     = matchstr(getline(line('.')), url_pat)
  if url != ''
let g:job = job_start(cmd_browse.url, {
\ 'out_cb'  : function('helper#job_cb', ['helper#job_out_cb' , {} ]),
\ 'exit_cb' : function('helper#job_cb', ['helper#job_exit_cb', {} ]),
\ 'out_mode': 'raw'
\})
  else
echomsg 'sorry, no url found on this cursor''line'
  endif
endfunction "}}}


Le vendredi 27 septembre 2019 17:53:15 UTC+2, J S a écrit :
>> I seek a simpler and, ideally, seamless (i.e., no "press any key"s) way.


> Isn't that what netrw's normal command `gx` provides?

Bingo! We have a winner! gx does exactly what I want. Thanks.

Note: All other commentary on this thread has been pretty much n/a.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/9497560d-4e85-46a1-971b-6b184f65ddce%40googlegroups.com.

No comments: