Pop last command from comint-input-history

114 Views Asked by At

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)

1

There are 1 best solutions below

0
On

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))