summaryrefslogtreecommitdiff
path: root/src/history.c
diff options
context:
space:
mode:
authorBernhard R. Link <brlink@debian.org>2008-06-12 18:10:37 +0200
committerShawn <sabetts@juicebox.(none)>2008-10-22 14:24:26 -0700
commit7214b8c52e230fdb52a99ce1ed20092c6944dcd3 (patch)
treea7dd9d9982aa6dcb2082b3dad4b5ebfe78d0d02d /src/history.c
parent4a15061f631b5b85c0cff068407c51bfb315a497 (diff)
downloadratpoison-7214b8c52e230fdb52a99ce1ed20092c6944dcd3.zip
add 'set historysize' and 'set historycompaction' (defaulting to true) to compact history
Diffstat (limited to 'src/history.c')
-rw-r--r--src/history.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/history.c b/src/history.c
index bc6baa5..a04d580 100644
--- a/src/history.c
+++ b/src/history.c
@@ -228,6 +228,18 @@ history_add_upto (int history_id, const char *item, size_t max)
history_add_upto (hist_SHELLCMD, p, max);
}
+ if (defaults.history_compaction && max != INT_MAX) {
+ struct list_head *l;
+
+ for (l = h->head.prev ; l != &h->head ; l = l->prev) {
+ if (!strcmp (list_entry(l, struct history_item, node)->line, item)) {
+ list_del (l);
+ list_add_tail (l, &h->head);
+ return;
+ }
+ }
+ }
+
while (h->count >= max) {
list_first (i, &h->head, node);
if (!i) {