On Thu, Jan 12, 2012 at 9:31 AM, Ben Fritz <[email protected]> wrote:
>
>
> On Jan 12, 7:49 am, Nathan Neff <[email protected]> wrote:
>> Hello,
>>
>> I'm using Vim's QuickFix capabilities to display errors from a log file.
>> When an error occurs, I press a hotkey, and an external script is
>> run using cexpr system(~/myscript).  Vim reads the output from ~/myscript,
>> and loads the QuickFix window.
>>
>> The catch is that I see the same errors again and again, because
>> ~/myscript reads the entire log file each time I press the hotkey.
>>
>> Here's the behavior I want:
>>
>> 1) When an error occurs, I press a hotkey and Vim shows it to me.
>> 2) If I press the hotkey again, then Vim only shows me the errors that
>> have occurred since the last time I pressed the hotkey
>>
>> I have a klunky method of doing this now, which is
>> to track the last-read line number in a file.  When ~/myscript runs,
>> it reads the entire log file, then checks for a "last-line" file, and reads
>> the last line number from "last-line", and skips past those lines in the
>> log file.
>>
>> This method is klunky because if log file is truncated, then the script 
>> should
>> re-start the "last-read" file.  Also, the longer the log file becomes,
>> the longer
>> it will take the script to read in its entirety.
>>
>
> Maybe your hotkey could:
>
> 1. Save the current quickfix list to a variable, with getqflist()
> 2. Call your script to obtain a new list
> 3. Save the new list to another variable with getqflist()
> 4. Loop through the old list and remove any duplicate items from the
> new list
> 5. Set the quickfix list to the newly trimmed list, with setqflist()
>
> You could even consider using a QuickfixCmdPre and QuickFixCmdPost
> autocmd pair to make some of this automatic.
>
> --
> 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

Wow -- thanks for this suggestion -- it never occurred to me.  This seems
like a really robust solution.

Thanks,
--Nate

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

Reply via email to