-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

On Thu, Nov 27, 2008 at 2:24 AM, Jean-Philippe Bernardy  wrote:
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEAREKAAYFAkkvFh8ACgkQvpDo5Pfl1oKuZQCfamk8/ptaKf2enU1+aehIXfRs
Wa8An16DCrU2NlHY6Ot2hbLxda2nr+Iw
=2n8V
-----END PGP SIGNATURE-----

>
> On Thu, Nov 27, 2008 at 3:22 AM, Gwern Branwen <[EMAIL PROTECTED]> wrote:
>>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA512
>>
>> On Wed, Nov 26, 2008 at 5:03 PM, Gwern Branwen  wrote:
>>> setBufferContents doesn't seem to exist. At least, recursive grep
>>> can't find anything but setBuffer.
>>
>> OK, so I found two ways to do this:
>>
>>> setBufferContents :: (MonadEditor m) => String -> m BufferRef
>>> setBufferContents article = withEditor $ stringToNewBuffer "Ireader 
>>> article" (B.fromString article)
>
> You can use the replaceBufferContent function that I pointed to.
>
>> [Attempts to read the buffer contents into a String]
>
>> We really need to make this stuff easier. I vote that we start by
>> adding some basic primitives like a getCurrentBuffer :: YiM String...
>
> It's not difficult if you know where to look. Reading Yi.Buffer.HighLevel
> would help you here. In general all the buffer-manipulation API are in
> the BufferM monad. You can lift it to YiM by using withBuffer. The function
> will then operate on the current buffer.
>
> Cheers,
> JP.

I looked at HighLevel many times; I didn't find it very helpful. For
example, the simplest way to write a getBufferContents seems to be
something like this:

> getBufferContents :: BufferM String
> getBufferContents = do topB
>                        str <- liftM unlines $ whileB (liftM not $ atEof) 
> (readLnB)
>                        return str

(And I suspect this is less than optimal - presumably this would not
respect the user's current position?)

All the BufferM String functions are for too little things - like the
current line, or current line from point, or region. None seem to do a
simple thing like 'entire buffer'.

--
gwern

--~--~---------~--~----~------------~-------~--~----~
Yi development mailing list
yi-devel@googlegroups.com
http://groups.google.com/group/yi-devel
-~----------~----~----~----~------~----~------~--~---

Reply via email to