emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] EUDC email addresses via completion-at-point in message-mode


From: Filipp Gunbin
Subject: Re: [PATCH] EUDC email addresses via completion-at-point in message-mode
Date: Sat, 30 Apr 2022 02:04:05 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (darwin)

Hello Alexander,

On 28/04/2022 19:15 +0200, Alexander Adolf wrote:

>>> +      (progn
>>> +        (setq-local completion-styles '(substring partial-completion))
>>> +        (let* ((beg (save-excursion
>>> +                      (if (re-search-backward "\\([:,]\\|^\\)[ \t]*"
>>> +                                              (point-at-bol) 'move)
>>
>> t instead of 'move?
>
> Hm. Quoting from the docstring (re-search-forward in this case):
> ---------------------------- Begin Quote -----------------------------
> The optional third argument NOERROR indicates how errors are handled
>   when the search fails. If it is nil or omitted, emit an error; if it
>   is t, simply return nil and do nothing; if it is neither nil nor t,
>   move to the limit of search and return nil.
> ----------------------------- End Quote ------------------------------
>
> This reads as if t ("do nothing") vs. 'move ("move to the limit of
> search") should make a difference? A few quick experiments seem to
> indicate that in practice both seem to behave the same though. In this
> light, I'm fine with changing 'move to t.

Well honestly I was fooled by save-excursion, and didn't notice the
return value of (point), with which the value we're talking about _may_
matter.  However, your regexp will always match, due to \\|^ branch
which will find bol, so you can just do:

(save-excursion
  (re-search-backward "\\([:,]\\|^\\)[ \t]*")
  (match-end 0))

>> Can it be done in some other way?
>
> Short answer: I don't think so.
>
> Longer answer:
>
> The motivation for putting this is that completion-at-point filters the
> completion tables based on completion-styles. Thus, if completion-styles
> is set too restrictive, useful results may not be offered to the user.
> The default completion-styles in message-mode is '(basic
> partial-completion emacs22). I wanted 'substring to be the primary as it
> matches the search term anywhere within the candidate, as opposed to
> 'basic which matches it at the beginning only. In this respect, you
> might view 'substring as a super-set of 'basic.
>
> That said, it would probably be desirable for message mode to have
> different values for both, completion-at-point-functions and
> completion-styles, depending on where point is (email header, newsgroup
> header, message body, etc.). But this seems like a wider discussion
> about the architecture of message.el rather than this patch.

Yes, sounds like another use case for completion-category-overrides.

Thanks.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]