getting the full path of arguments in command completion=file

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

getting the full path of arguments in command completion=file

Martin Alaçam
Hello, 
 
command! -nargs=* -complete=file Loader call Test(<f-args>)

How would I get the <f-args> to be full paths to the arguments (file names)?
I am guessing it has to be done in the command, and not in the function being called (Test)? 

Thanks in advance, 

Martin 

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAHvr%2BSUFQvVPn4Ur_iUeZqZfLuWj65FEDv%3DZ-OTFBX2ZDFwXbQ%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: getting the full path of arguments in command completion=file

Martin Alaçam
Found it: 
command! -nargs=* -complete=file Loader for f in [<f-args>] | call Test(fnamemodify(f, ":p")) | endfor

On Sun, Mar 22, 2020 at 9:41 PM Martin Alaçam <[hidden email]> wrote:
Hello, 
 
command! -nargs=* -complete=file Loader call Test(<f-args>)

How would I get the <f-args> to be full paths to the arguments (file names)?
I am guessing it has to be done in the command, and not in the function being called (Test)? 

Thanks in advance, 

Martin 

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAHvr%2BSU3mb7cCwFdjSd1QO-EiszAuwVivxVhjRoCWtz%3DAtxL6w%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: getting the full path of arguments in command completion=file

Gary Johnson-4
In reply to this post by Martin Alaçam
On 2020-03-22, Martin Alaçam wrote:

> command! -nargs=* -complete=file Loader call Test(<f-args>)
>
> How would I get the <f-args> to be full paths to the arguments (file names)?
> I am guessing it has to be done in the command, and not in the function being
> called (Test)? 

Here's one way to do it.  Replace "echo path" by your actual
processing of each file.

    function! Test(...)
        for file in a:000
            let path = fnamemodify(file, ":p")
            echo path
        endfor
    endfunction

Regards,
Gary

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200322221328.GA25471%40phoenix.
Reply | Threaded
Open this post in threaded view
|

Re: getting the full path of arguments in command completion=file

Martin Alaçam
Ah, it works from within the function too, that is smart. And the nicer solution. Thanks! 

On Sun, Mar 22, 2020 at 11:15 PM Gary Johnson <[hidden email]> wrote:
On 2020-03-22, Martin Alaçam wrote:

> command! -nargs=* -complete=file Loader call Test(<f-args>)
>
> How would I get the <f-args> to be full paths to the arguments (file names)?
> I am guessing it has to be done in the command, and not in the function being
> called (Test)? 

Here's one way to do it.  Replace "echo path" by your actual
processing of each file.

    function! Test(...)
        for file in a:000
            let path = fnamemodify(file, ":p")
            echo path
        endfor
    endfunction

Regards,
Gary

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200322221328.GA25471%40phoenix.

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAHvr%2BSVCScYzWUJd1tPXgL-YnUVJ-enBhCXyfZ9qSkhGp7trNg%40mail.gmail.com.