unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* How to flush history ?
@ 2009-08-02  9:22 Roberto Rosetti
  2009-08-14 21:39 ` Neil Jerram
  0 siblings, 1 reply; 4+ messages in thread
From: Roberto Rosetti @ 2009-08-02  9:22 UTC (permalink / raw)
  To: guile-user ML

[-- Attachment #1: Type: text/plain, Size: 468 bytes --]

Hi all,

I'm wondering how to flush the recent readline history to a file. I need
this feature for an educational project.
The purpose is to permit the REPL user to save his entire history with a
simple command. Something like (flush-history <params>)
I've read something about (loggin logger) module but there are not
examples about hooks and coding.
I'm not a guile hacker,I'm still learning.. 
Thanks in advance.

-- 

Roberto Rosetti

OpenPGP Public key: 30575161

[-- Attachment #2: Type: text/html, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to flush history ?
  2009-08-02  9:22 How to flush history ? Roberto Rosetti
@ 2009-08-14 21:39 ` Neil Jerram
  2009-08-15 17:01   ` Roberto Rosetti
  0 siblings, 1 reply; 4+ messages in thread
From: Neil Jerram @ 2009-08-14 21:39 UTC (permalink / raw)
  To: rob.rosetti; +Cc: guile-user ML

Roberto Rosetti <rob.rosetti@gmail.com> writes:

> Hi all,
>
> I'm wondering how to flush the recent readline history to a file. I need this
> feature for an educational project.
> The purpose is to permit the REPL user to save his entire history with a simple
> command. Something like (flush-history <params>)
> I've read something about (loggin logger) module but there are not examples
> about hooks and coding.
> I'm not a guile hacker,I'm still learning..
> Thanks in advance.

Hi Roberto,

The readline history is already saved to a file, ~/.guile_history.
Does that provide what you need?

(I'm not sure offhand if it is saved after every line is entered, or
when you quit Guile; but maybe that difference is not important for
you anyway.)

     Neil




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to flush history ?
  2009-08-14 21:39 ` Neil Jerram
@ 2009-08-15 17:01   ` Roberto Rosetti
  2009-08-26 21:38     ` Neil Jerram
  0 siblings, 1 reply; 4+ messages in thread
From: Roberto Rosetti @ 2009-08-15 17:01 UTC (permalink / raw)
  To: guile-user ML

On  friday, 14/08/2009 alle 22.39 +0100, Neil Jerram writes:
> 
> > Hi all,
> >
> > I'm wondering how to flush the recent readline history to a file. I need this
> > feature for an educational project.
> > The purpose is to permit the REPL user to save his entire history with a simple
.....
> Hi Roberto,
> 
> The readline history is already saved to a file, ~/.guile_history.
> Does that provide what you need?
> 
> (I'm not sure offhand if it is saved after every line is entered, or
> when you quit Guile; but maybe that difference is not important for
> you anyway.)

>      Neil

Well, thanks for the answer Neil. I know about the existence of
~/.guile_history, but my problem is more complex: I need a hook to the
history buffer, like a port or something. A way to flush the history to
its file at a given command. Just to grab everything written before and
then manipulate (a copy of) the history file.
For the moment, I've written a simple wrapper for readline, that process
the input and save every command to a specific text file, after checking
it for correctness. 
An alternate solution may be to change the GUILE_HISTORY envrironment
variable at run-time, but I thing it's not an elegant solution at all.

Rob


-- 

Roberto Rosetti

OpenPGP Public key: 30575161





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to flush history ?
  2009-08-15 17:01   ` Roberto Rosetti
@ 2009-08-26 21:38     ` Neil Jerram
  0 siblings, 0 replies; 4+ messages in thread
From: Neil Jerram @ 2009-08-26 21:38 UTC (permalink / raw)
  To: rob.rosetti; +Cc: guile-user ML

Roberto Rosetti <rob.rosetti@gmail.com> writes:

> Well, thanks for the answer Neil. I know about the existence of
> ~/.guile_history, but my problem is more complex: I need a hook to the
> history buffer, like a port or something. A way to flush the history to
> its file at a given command. Just to grab everything written before and
> then manipulate (a copy of) the history file.
> For the moment, I've written a simple wrapper for readline, that process
> the input and save every command to a specific text file, after checking
> it for correctness. 

Well I wasn't aware of it before, but I just looked at
guile-readline/readline.c and noticed that there is a write-history
primitive:

SCM_DEFINE (scm_write_history, "write-history", 1, 0, 0, 
            (SCM file),
"")
#define FUNC_NAME s_scm_write_history
{
  char *filename;
  SCM ret;

  filename = scm_to_locale_string (file);
  ret = scm_from_bool (!write_history (filename));
  free (filename);
  return ret;
}
#undef FUNC_NAME

Is that a solution for you?

Regards,
        Neil





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-08-26 21:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-02  9:22 How to flush history ? Roberto Rosetti
2009-08-14 21:39 ` Neil Jerram
2009-08-15 17:01   ` Roberto Rosetti
2009-08-26 21:38     ` Neil Jerram

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).