[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Handle case where `beg` and `end` are strings instead of mar
From: |
James N . V . Cash |
Subject: |
Re: [PATCH] Handle case where `beg` and `end` are strings instead of markers |
Date: |
Sat, 30 Apr 2022 08:41:24 -0400 |
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>>> + (let ((beg (if (number-or-marker-p beg)
>>> + beg
>>> + (save-excursion
>>> + (goto-char (minibuffer-prompt-end))
>>> + (search-forward beg))))
>>> + (end (if (number-or-marker-p end)
>>> + end
>>> + (save-excursion
>>> + (goto-char (point-max))
>>> + (search-backward end)))))
>>
>> What if there are several matches for `beg` and/or for `end` in
>> the buffer? How do we know we got the intended one?
>
> IIUC part of the purpose of using strings rather than positions is to
> account for the case where the text was modified between the moment the
> *Completions* list was created and the moment the user selects one of
> the options. So another question is what to do if the search fails (the
> above code signals an error in that case, which is probably not what we
> want).
That is a good question. That would happen, I guess, if you had selected
multiple candidates in a CRM, started completing, then deleted the
previously entered candidates, then selected one. I suppose I'd expect
it to add the completed candidate to the end of the remaining list?
So something like
(let ((beg (if (number-or-marker-p beg)
beg
(save-excursion
(goto-char (minibuffer-prompt-end))
(or (search-forward beg nil t)
(search-forward-regexp crm-separator nil t)
(minibuffer-prompt-end)))))
James
- [PATCH] Handle case where `beg` and `end` are strings instead of markers, James N. V. Cash, 2022/04/28
- Re: [PATCH] Handle case where `beg` and `end` are strings instead of markers, James N . V . Cash, 2022/04/28
- Re: [PATCH] Handle case where `beg` and `end` are strings instead of markers, Juri Linkov, 2022/04/29
- Re: [PATCH] Handle case where `beg` and `end` are strings instead of markers, James N . V . Cash, 2022/04/29
- Re: [PATCH] Handle case where `beg` and `end` are strings instead of markers, Stefan Monnier, 2022/04/29
- Re: [PATCH] Handle case where `beg` and `end` are strings instead of markers, James N . V . Cash, 2022/04/29
- Re: [PATCH] Handle case where `beg` and `end` are strings instead of markers, Stefan Monnier, 2022/04/29
- Re: [PATCH] Handle case where `beg` and `end` are strings instead of markers, James N . V . Cash, 2022/04/29
- Re: [PATCH] Handle case where `beg` and `end` are strings instead of markers, Juri Linkov, 2022/04/29
- Re: [PATCH] Handle case where `beg` and `end` are strings instead of markers, Stefan Monnier, 2022/04/29
- Re: [PATCH] Handle case where `beg` and `end` are strings instead of markers,
James N . V . Cash <=
- Re: [PATCH] Handle case where `beg` and `end` are strings instead of markers, Stefan Monnier, 2022/04/30
- Re: [PATCH] Handle case where `beg` and `end` are strings instead of markers, James N . V . Cash, 2022/04/30