Hi, On Sat, Oct 21, 2023 at 7:09 AM Lifepillar <lifepil...@lifepillar.me> wrote:
> I have a function that pipes a buffer into an external program, then > parses its output in a callback and adds the parsed results to > a location list. Simplified code for the callback: > > def Callback(channel: job, msg: string, winid: number, efm: string, > cwd: string) > silent execute "lcd" cwd > var what = getqflist({"lines": [msg], "efm": efm}) > silent lcd - > setloclist(winid, what.items, "a") > enddef > > The lines to be parsed have a pretty standard format: > > filename:line:col message > > The program reads from stdin, hence `filename` is passed as an argument > to the program. The program simply puts whatever filename it gets into > its output messages. > > This works fine for buffers backed up by a file: I pass the buffer's > name as the filename argument. My problem is that I don't know how to > create an entry in the location list for an unsaved buffer. Passing > something like '[No Name]', 'unnamed', or similar does not work. The > location list ends up having entries that look like this: > > unnamed|1 col 8 E123| some message > > If the unsaved buffer ia buffer 1, then the message above is parsed as: > > {'items': [{'bufnr': 2, 'lnum': 1, 'col': 8, 'text': 'some message', > ...}]} > > Therefore, selecting such entries causes a new buffer 2 to be created. > > How do I generate location list entries that refer to the proper unsaved > buffer? > > There is a item in the todo list for more than 20 years now for this: - Add %b to 'errorformat': buffer number. (Yegappan Lakshmanan / Suresh Govindachar) - Yegappan -- -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAAW7x7nVk9-jZ1f%2B-9hKuHUyBmvNLm56FG4-e02vuxHamvXX0g%40mail.gmail.com.