Closed hgluka closed 1 year ago
@hgluka I still think that this solution is subpar. I think everything would become easier if next-source-position
returned a source object instead of an index. Then next/previous-source-p
would only check whether (next-source-position prompter {1,-1} source)
returns non-nil.
Ah, good point, I didn't think of that. Thanks for the help @aadcg!
@aadcg Thanks, it looks a lot better!
The only nitpick I have is the name adjacent-source
, since it only really makes sense for the case when (= steps 1)
.
Still, that's not a big deal so I think this can be merged.
@aadcg I just realized that we need next-source-p
and previous-source-p
to have a source
argument.
Slipped my mind when I looked at it earlier, but in Nyxt (in https://github.com/atlas-engineer/nyxt/pull/3202, at least) we want to use these functions on all the sources in a prompt buffer, not just the current-source
.
@hgluka you can still use adjacent-source
no?
Oh, adjacent-source
is exported as well, so yes I can.
Description
This PR adds
next-source-p
andprevious-source-p
as exported functions. I did this by making anext-source-position
function thatnext-source-p
andnext-source
can have in common.Discussion
The implementation might be inefficient, because of the repeated
(remove-if #'empty-source-p (sources prompter))
calls, but it seemed like the most elegant way to do it.CC @aadcg