On 27-Oct-2010 10:48, Marc Weber wrote:
> I'd like to append lines to background buffers.
> Which is the best way to do it?
>
> 5 choices come to my mind:
> a) use python. It can do it
> b) use bufdo (??) and a if bufnr == target then append() endif hack
> c) sp the buf, append, close (bad?, will cause much redrawing)
> d) Delay adding lines. Use setbufvar to keep a list of lines to be added.
> Add them on bufenter event when buffer is shown anyway
> e) extend append and more functions so that you can pass a bufnr ?
To me, c) is the most straightforward choice. Maybe temporary 'lazyredraw' can
help with the screen updates. a) is least favorable due to the dependency to the
language runtime. (But read on, I'll later contradict myself!)
> I"d like to help making the asystem patch more usable. And appending lines to
> buffers is essential.
How is that essential; can you elaborate on its uses? (I assume you're still
using Vim mainly as a text editor, not as a runtime environment for arbitrary
applications (like Emacs ;-))
I have written many plugins, but didn't have the need for this so far. Well,
except for a custom completion that wants to generate the list of completion
candidates from open windows, loaded buffers, etc. (like Vim's 'complete'
option), and would have needed an efficient way to pattern-match and extract
from loaded Vim buffers and arbitrary files. Due to the complexity that you've
brought up, I have so far only implemented a search through open windows, but
not all loaded buffers; a true 80:20 solution.
My point: Having an enhanced getline({lnum} [, {end} [, {bufnr}]]) function
would certainly have helped, but still use of Ex and normal mode commands would
be precluded. Some functions like search() would be difficult to enhance (what
to do with the notion of cursor position without an associated window?!). Maybe
it's actually wiser to accept the limitations of existing Ex commands and Vim
functions, and delegate such "application-level scripting" to the embedded
languages like Python, Perl, etc. (Assuming they possess a high-performance
access to Vim buffers.)
Anyway, I think this is a valid issue, would like to hear more about your
intended uses, and hope for additional insights from others!
-- regards, ingo
--
-- Ingo Karkat -- /^-- /^-- /^-- /^-- /^-- /^-- http://ingo-karkat.de/ --
-- http://vim.sourceforge.net/account/profile.php?user_id=9713 --
--
You received this message from the "vim_dev" 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