Friday, January 25, 2013

Scripting with Python, capturing command output and using signs

Hi everyone,

This is really two questions in one, but both related. I'm the author of Vdebug, a plugin for Vim written mostly in Python (http://github.com/joonty/vdebug).

I've asked two questions on Stack Overflow, but I thought I would be a bit more targeted and ask in the Vim group! I'll summarise here, but the questions are:

http://stackoverflow.com/questions/14502710/query-position-of-sign-in-vim-with-sign-id/14503016
http://stackoverflow.com/questions/14504403/capture-output-of-vim-command-in-python/14506534


I've come across a situation where I need to retrieve a previously placed sign, and check its line number. I have the ID of the sign. I know that I can use `:sign place` to retrieve a list of all signs, and then parse it, but I was wondering whether anyone knew of a more efficient way that didn't involve throwing away a bunch of information. I know this doesn't exist yet, but it would be great if there was a Vim function to access signs (maybe `getsigns()` and `getsign(id)`) - does anyone know if there are any plans to implement this?

The second part of the question is about capturing command output when using Python. If I use `vim.command()`, the output of the command isn't returned. The only way I can see that I can capture the output is with something like:

vim.command('redir => myvar')
vim.command('silent sign place')
vim.command('redir END')
output = vim.eval('myvar')

Is this the best way of doing it or am I missing something?

Thanks guys

--
--
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

No comments: