Readline history length

Hello,

I would like to increase the length of the swi prolog top-level history but I can’t find how to do it.
I’m on linux, so I suppose that swi prolog is using the readline library to store the history.

I managed to find the history files in ~/.config/swi-prolog/dir-history as documented here.
But none of the history files I have exceed 101 lines which makes me thing that the length of my history is 100 but I can’t find anywhere how to configure this ?

Readline manual says that when not configured the history length is unlimited.

The readline(3) documentation says how to set the initialization file (INPUTRC or ~/.inputrc or /etc/inputrc), and there’s a history-size setting.

Not answering your question, but if you run SWI-Prolog in an emacs terminal window (*shell*), you get almost unlimited history and scrollback.

So the weird thing is that the readline manual states that when not set, the history size is not limited:

       history-size (unset)
              Set the maximum number of history entries saved in the
              history list.  If set to zero, any existing history
              entries are deleted and no new entries are saved.  If set
              to a value less than zero, the number of history entries
              is not limited.  By default, the number of history entries
              is not limited.  If an attempt is made to set history-size
              to a non-numeric value, the maximum number of history
              entries will be set to 500.

Since I don’t have a ~/.inputrc file, I believe readline only reads /etc/inputrc, which on my system (fedora) does not set the history-size setting.

It would be nice know why my history is limited to 100 by default…
I suppose I’ll have to spend some time configuring readline now.

I’m more on the Vim camp myself :slight_smile: Which also provide unlimited scrollback.
But the problem is that I often restart vim which I know is not the habit of people using emacs ^^
By the way, is emacs shell able to capture the history of swi prolog queries ? like how readline does ?

/etc/inputrc
# do not bell on tab-completion
#set bell-style none

set meta-flag on
set input-meta on
set convert-meta off
set output-meta on

# Completed names which are symbolic links to
# directories have a slash appended.
set mark-symlinked-directories on

$if mode=emacs

# for linux console and RH/Debian xterm
"\e[1~": beginning-of-line
"\e[4~": end-of-line
# commented out keymappings for pgup/pgdown to reach begin/end of history
#"\e[5~": beginning-of-history
#"\e[6~": end-of-history
"\e[5~": history-search-backward
"\e[6~": history-search-forward
"\e[3~": delete-char
"\e[2~": overwrite-mode
"\e[5C": forward-word
"\e[5D": backward-word
"\e[1;5C": forward-word
"\e[1;5D": backward-word

# for rxvt
"\e[8~": end-of-line
"\eOc": forward-word
"\eOd": backward-word

# for non RH/Debian xterm, can't hurt for RH/DEbian xterm
"\eOH": beginning-of-line
"\eOF": end-of-line

# for freebsd console
"\e[H": beginning-of-line
"\e[F": end-of-line
$endif

I just tried copying /etc/inputrc into ~/.inputrc and added set history-size 10000 but it does not work.
I’m still limited to 100 entries in my history file…

Yes.
It keeps a history of all commands, including Prolog inputs (so, it somewhat overlaps the bash shell’s history).

  • Esc-P bound to comint-previous-input
  • Esc-R bound to comint-history-isearch-backward-regexp

Some of the history is saved across sessions, but I’m not sure exactly what.

FWIW, in the Sweep top-level (also in Emacs), you have top-level specific history (not mangled with the shell’s history) and you can control how and when history is persisted (see Top-level History (Sweep: SWI-Prolog Embedded in Emacs)). It is also a comint-mode derivative, just like shell-mode, so all the usual comint commands work (such as M-p and M-n for cycling through history). But unlike shell-mode, it has a bunch of Prolog-specific goodies :slight_smile:

No :slight_smile: using Emacs, history on non-Windows is provided by GNU readline or BSD editline, using the latter as default. History management is explicit in Prolog itself and controlled by the flag history. So, I think this should help in
~/.config/swi-prolog/init.pl:

:- set_prolog_flag(history, 1000).

I use 50, which sets the prompt to 100 and scrolling back it seems it restores the 50 entries as 50…100. 1…50 would have been cleaner …

I followed this but I still only get 100 entries in my ~/.config/swi-prolog/dir-history/HISTORY_FILE.
It seems to max out at 100 no matter what ?