Subject: [clisp-list] Re: clisp command history

From: Bruno Haible <[email-masked]>
Date: Sun Jul 18 05:45:01 2004

Pascal Bourguignon wrote:
> the source of clisp should be edited to add this feature
> at the readline level.  One problem of this, is that we often have
> several bash or clisp sessions running at the same time, and the
> history saving overwrites all but the last saved history.

This would be a bug in the implementation of history handling. You can do
better. Here is how to achieve that
  - the saved history consists of the input that have been terminated up to
    a given point,
  - the history in a particular session is not influenced by input that
    is occurring in other sessions at the same time, or by other sessions
    terminate.

Namely:
  - When the session starts, read the history from the file into an in-memory
    buffer1.
    Clear an in-memory buffer2.
  - Let readline operations see the concatenation of buffer1 and buffer2. I.e.,
    new lines are added at the end of buffer2, but history searching considers
    both buffer1 and buffer2.
  - When you need to write the history (e.g. when the session ends), read the
    history from the file again into buffer3. Then save buffer3 + buffer2 into
    the file immediately, and forget about buffer3 again.

Bruno

---

From: Sam Steingold <[email-masked]>
Date: Sun Jul 18 07:08:01 2004

> * Bruno Haible <[email-masked]> [2004-07-18 14:33:02 +0200]:
>

readline library already offers functions for this.
See <http://article.gmane.org/gmane.lisp.clisp.general:8603>.
Specifically:

CUSTOM:*HISTORY-FILE* - pathname designator or NIL (disable).
  history should be read _after_ ~/.clisprc so that it can be enabled
  or disabled from there.  defaults to ~/.clisp_history or NIL (vote)

CUSTOM:*HISTORY-FILE-TRUNCATE* - positive integer or NIL (disable)
  default to 500 (like bash)

(EXT:READ-HISTORY file &key (start 0) (end nil))
  call read_history_range()

(EXT:WRITE-HISTORY file &key (append t) (truncate nil))
  call either write_history() or append_history(),
  then, optionally, history_truncate_file()
  (maybe :TRUNCATE should default to CUSTOM:*HISTORY-FILE-TRUNCATE*?)

I hope Elvin Peterson, the original requester, will do this.

-- 
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.honestreporting.com>
Politically Correct Chess: Translucent VS. Transparent.