minad / consult

:mag: consult.el - Consulting completing-read
GNU General Public License v3.0
1.26k stars 106 forks source link

consult-history and ring-index #667

Closed jdtsmith closed 2 years ago

jdtsmith commented 2 years ago

A very useful feature of comint's ring-history search tools is that they record location. I.e, they set comint-input-ring-index to indicate where along the ring the command has been pulled from. This is necessary so that commands like comint-get-next-from-history can function. It's very convenient to select command from history, then use C-c C-x repeatedly to pull the next commands on the ring. consult-history does not permit this workflow, since it doesn't save location.

I looked for an obvious way to implement this but couldn't find one. One issue is that consult removes duplicates from the history ring (for good reason). If consult-history at least returned the user-selected string, some :filter-return advice on it utilizing ring-member could be added, to update comint-input-ring-index. I don't know if "saved place along a ring" is a generic RING concept, or specific to comint. If it's general and discoverable, perhaps consult could just do this itself.

minad commented 2 years ago

We could modify consult-mode-histories to support both cons pairs and three element lists and then update the index accordingly. The problem with duplicates will remain of course. If you are interested, I welcome a PR which adds this feature.

  '((eshell-mode eshell-history-ring eshell-history-index)
    (comint-mode comint-input-ring   comint-input-ring-index)
    (term-mode   term-input-ring     term-input-ring-index))
jdtsmith commented 2 years ago

See #669.