0

How to programmatically pop the last command from comint-input-history?

I tried something like (pop (cdr (cdr comint-input-ring))) but that does not work.

It seems to be an array, but I'm also stuck with (aref (cdr (cdr comint-input-ring)) 0)

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
PascalVKooten
  • 20,643
  • 17
  • 103
  • 160

1 Answers1

0

The comint-input-ring is a ring, and as such should be manipulated with ring functions. And, I'm not sure if you mean "last" as in the most recent (the "last" thing I typed) or "last" as in oldest.

If you want to remove the oldest (FIFO), you can do:

(ring-remove comint-input-ring)

If you want to remove the most recent (LIFO), you can do:

(ring-remove comint-input-ring (ring-size comint-input-ring))
Trey Jackson
  • 73,529
  • 11
  • 197
  • 229