unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: James N. V. Cash <james.nvc@gmail.com>
Cc: Juri Linkov <juri@linkov.net>,  emacs-devel@gnu.org
Subject: Re: [PATCH] Handle case where `beg` and `end` are strings instead of markers
Date: Sat, 30 Apr 2022 09:44:53 -0400	[thread overview]
Message-ID: <jwvmtg2ofhv.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87o80i3frf.fsf@occasionallycogent.com> (James N. V. Cash's message of "Sat, 30 Apr 2022 08:41:24 -0400")

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




  reply	other threads:[~2022-04-30 13:44 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-29  0:36 [PATCH] Handle case where `beg` and `end` are strings instead of markers James N. V. Cash
2022-04-29  1:10 ` James N. V. Cash
2022-04-29  7:05   ` Juri Linkov
2022-04-29 12:10     ` James N. V. Cash
2022-04-29 12:55       ` Stefan Monnier
2022-04-29 14:07         ` James N. V. Cash
2022-04-29 16:18           ` Stefan Monnier
2022-04-29 17:20             ` James N. V. Cash
2022-04-29 17:29             ` Juri Linkov
2022-04-29 21:05         ` Stefan Monnier
2022-04-30 12:41           ` James N. V. Cash
2022-04-30 13:44             ` Stefan Monnier [this message]
2022-04-30 15:48               ` James N. V. Cash
2022-05-01 18:06                 ` Juri Linkov
2022-05-02 15:32                   ` James N. V. Cash
2022-05-02 19:11                     ` Juri Linkov
2022-05-04 12:08                       ` James N. V. Cash
2022-05-04 19:27                         ` Juri Linkov
2022-05-04 21:09                           ` James N. V. Cash
2022-05-05 18:16                             ` Juri Linkov
2022-05-01 18:03               ` Juri Linkov
2022-05-01 18:37                 ` Stefan Monnier
2022-05-05 18:19                   ` Juri Linkov
2022-05-05 18:30         ` Exiting completion-in-region-mode (was: Handle case where `beg` and `end` are strings instead of markers) Juri Linkov
2022-05-19 18:52           ` Exiting completion-in-region-mode Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvmtg2ofhv.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=james.nvc@gmail.com \
    --cc=juri@linkov.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).