[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: |
Stefan Monnier |
Subject: |
Re: [PATCH] Handle case where `beg` and `end` are strings instead of markers |
Date: |
Sat, 30 Apr 2022 09:44:53 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
James N. V. Cash [2022-04-30 08:41:24] wrote:
> 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)))))
This makes it specific to CRM. I think we should try and think more
locally, without paying too much attention about the various possible
external cases: what do we want the `beg` and `end` strings to *mean*?
Maybe instead of strings, they should be functions, so CRM can set them
to functions that first look for the separator and then search for some
leading/trailing string?
Stefan
- Re: [PATCH] Handle case where `beg` and `end` are strings instead of markers, (continued)
- 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, 2022/04/30
- Re: [PATCH] Handle case where `beg` and `end` are strings instead of markers,
Stefan Monnier <=
- Re: [PATCH] Handle case where `beg` and `end` are strings instead of markers, James N . V . Cash, 2022/04/30