output port into a string?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

output port into a string?

Graham Percival
Hi all,

I'm trying to un-gimpify the text markup list.  This is part of the
automatically generated notation appendices.  In particular, I'm
trying to remove the @node ... @appendixsec   from the auto-generated
file, so that those commands can be in the notation-appendices.tely
file so that we can safely regenerate the @menu...@end menu sections.

A shorter explanation: scheme generates a file.  I want to generate
that file without the first two lines.

I succeeded with mark-list-commands.tely.  Unfortunately,
markup-commands.tely is generated by dumping text into a port, which
is a file -- instead of the (IMO much more sensible) way of generating
a string, them putting that string into a file.  The other notation
appendices are generated that way.

One option is to copy the dump-node definition in
scm/documentation-lib.scm, name the copy dump-non-node, and remove the
@node @section portion of the function.  But this feels like a crappy
"solution" to me.


Can scheme redirect an output port into a file?  If I could convert
this into a string, I can happily cut off the first 20 chars or so,
then dump the remainder into a file.

An alternate, and probably much better, solution is to rewrite
markup-doc-node in scm/document-markup.scm so that it returns a string
rather than using the <texi-node> thing, but I'm not eager to get into
such a rewrite.

If anybody has other suggestions for handling markup-commands.tely, or
wants to work on this themselves, that would be quite nice.  :)


This patch does the markup-line-commands.tely stuff:
http://codereview.appspot.com/2140041

Cheers,
- Graham

---
----
Join the Frogs!

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: output port into a string?

Carl Sorensen



On 9/2/10 10:13 AM, "Graham Percival" <[hidden email]> wrote:

> Hi all,
>
> I'm trying to un-gimpify the text markup list.  This is part of the
> automatically generated notation appendices.  In particular, I'm
> trying to remove the @node ... @appendixsec   from the auto-generated
> file, so that those commands can be in the notation-appendices.tely
> file so that we can safely regenerate the @menu...@end menu sections.
>
> A shorter explanation: scheme generates a file.  I want to generate
> that file without the first two lines.
>
> I succeeded with mark-list-commands.tely.  Unfortunately,
> markup-commands.tely is generated by dumping text into a port, which
> is a file -- instead of the (IMO much more sensible) way of generating
> a string, them putting that string into a file.  The other notation
> appendices are generated that way.
>
> One option is to copy the dump-node definition in
> scm/documentation-lib.scm, name the copy dump-non-node, and remove the
> @node @section portion of the function.  But this feels like a crappy
> "solution" to me.
>
>
> Can scheme redirect an output port into a file?  If I could convert
> this into a string, I can happily cut off the first 20 chars or so,
> then dump the remainder into a file.

Ports can be files, strings, or void.  See

<http://www.gnu.org/software/guile/manual/html_node/String-Ports.html#String
-Ports>

for information on how you can use the function with a port to return a
string, which you can then modify and send out to the file (in the form of
the original port).

I haven't followed up on all of the details, but I think these calls should
work for you.

HTH,

Carl



---
----
Join the Frogs!

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: output port into a string?

Graham Percival
On Thu, Sep 02, 2010 at 06:17:11PM -0600, Carl Sorensen wrote:
>
> Ports can be files, strings, or void.  See
>
> <http://www.gnu.org/software/guile/manual/html_node/String-Ports.html#String
> -Ports>

Thanks!  I was searching for "display port string" and not finding
helpful stuff; that was exactly what I needed.  Doing a final test
now, then I'll send the patch to -devel for commentary.  (I'm
skipping the normal frog review step)

Cheers,
- Graham

---
----
Join the Frogs!

Loading...