Re: anjuta2 indent plugin



Hi Glenn,

On Wed, 2003-01-29 at 16:05, Glenn Pierce wrote:
> I have been looking into writing a plug-in for anjuta2.
> I am new to a lot of the concepts involved so please go easy on me :)
> 
> I have written an indent plug-in that operates on the current buffer.
> 
> The files required are available at
> 
> http://software.linux-dev.fortune-cookie.com/anjuta-doc.c.patch
> 
> and
> 
> http://software.linux-dev.fortune-cookie.com/indent.tar.gz
> 
> 
> The indent dialog has two options indent size and Kernighan and Ritchie
> style, there shall be more options when I know which to include.
> However these options currently have no affect as I not sure of the best
> method to parse these options to indent would be.
> 
> I would be most grateful for some feedback.

Ok, you asked for it, so here you go :-)

- You should be using libglade for your dialog.  It really makes things
easier to maintain, plus it's a better approach for UI construction.

- The whole pipe/fork stuff can be done automatically for you using
g_spawn_async_with_pipes().

- Getting the whole buffer in a single call can be very expensive in
terms of memory usage, since for a moment, you have the whole file
replicated three times: the open document itself, the CORBA buffer and
the strndup'ed string.  It would be much better if you fed the spawned
program by smaller chunks in a loop.

- You shouldn't close the GIOChannel at the end of the output callback,
since there is probably more data to be read.

- Use anjuta_dialog_error() to display the message when getting the text
from the editor fails.

As for the options to pass to indent, I'm not sure what do mean by
parsing.  Just adding more arg[n] = ... lines should work.

That's all.  I hope I didn't discourage you :-)  Oh, one more thing: you
don't need to include the built files (.o and .lo) in your tar file. 
That makes it much smaller so you can attach it in your message.

Regards,
Gustavo


PS: it would be great if the you could indent just the selected region
of the file.  To do this the EditorBuffer interface has to be extended,
since currently there's no way to get the currently selected text
(proposals and patches welcome ;-).  Maybe for the 0.2 version :-)





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]