NeoMutt  2022-04-29-249-gaae397
Teaching an old dog new tricks
DOXYGEN
History file handling

Read/write command history from/to a file.

This history ring grows from 0..$history, with last marking the where new entries go:

0 the oldest entry in the ring
1 entry
...
x-1 most recently entered text
last-> x NULL (this will be overwritten next)
x+1 NULL
...
`$history` NULL

Once the array fills up, it is used as a ring. last points where a new entry will go. Older entries are "up", and wrap around:

0 entry
1 entry
...
y-1 most recently entered text
last-> y entry (this will be overwritten next)
y+1 the oldest entry in the ring
...
`$history` entry

When $history_remove_dups is set, duplicate entries are scanned and removed each time a new entry is added. In order to preserve the history ring size, entries 0..last are compacted up. Entries last+1..$history are compacted down:

0 entry
1 entry
...
z-1 most recently entered text
last-> z entry (this will be overwritten next)
z+1 NULL
z+2 NULL
...
the oldest entry in the ring
next oldest entry
`$history` entry

Functions

Function Description Links
dup_hash_dec() Decrease the refcount of a history string
dup_hash_inc() Increase the refcount of a history string
get_history() Get a particular history
init_history() Set up a new History ring buffer
mutt_hist_add() Add a string to a history
mutt_hist_at_scratch() Is the current History position at the 'scratch' place?
mutt_hist_free() Free all the history lists
mutt_hist_init() Create a set of empty History ring buffers
mutt_hist_next() Get the next string in a History
mutt_hist_prev() Get the previous string in a History
mutt_hist_read_file() Read the History from a file
mutt_hist_reset_state() Move the 'current' position to the end of the History
mutt_hist_save_scratch() Save a temporary string to the History
mutt_hist_search() Find matches in a history list
remove_history_dups() De-dupe the history
save_history() Save one history string to a file
shrink_histfile() Read, de-dupe and write the history file