all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Filipp Gunbin <fgunbin@fastmail.fm>
To: Alexander Adolf <alexander.adolf@condition-alpha.com>
Cc: emacs-devel@gnu.org
Subject: Re: [PATCH] EUDC email addresses via completion-at-point in message-mode
Date: Sat, 30 Apr 2022 02:04:05 +0300	[thread overview]
Message-ID: <m2h76b8pay.fsf@fastmail.fm> (raw)
In-Reply-To: <a716dd7df19c059f337c0605e22783f3@condition-alpha.com> (Alexander Adolf's message of "Thu, 28 Apr 2022 19:15:15 +0200")

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.



  parent reply	other threads:[~2022-04-29 23:04 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-09 16:24 [PATCH] EUDC email addresses via completion-at-point in message-mode Alexander Adolf
2022-04-12 21:12 ` Thomas Fitzsimmons
2022-04-13 14:44   ` Alexander Adolf
2022-04-14  0:26     ` Thomas Fitzsimmons
2022-04-15 21:23       ` Alexander Adolf
2022-04-14 13:02     ` Eric S Fraga
2022-04-14 13:27       ` Thomas Fitzsimmons
2022-04-14 13:52         ` Eric S Fraga
2022-04-15 21:39           ` Alexander Adolf
2022-04-17 12:12             ` Eric S Fraga
2022-04-15 21:35       ` Alexander Adolf
2022-04-17 12:20         ` Eric S Fraga
2022-04-17 13:58           ` Thomas Fitzsimmons
2022-04-17 17:21             ` Eric S Fraga
2022-04-14 14:02     ` Stefan Monnier
2022-04-15 21:58       ` Alexander Adolf
2022-04-15 22:57         ` Eric Abrahamsen
2022-04-14  1:44 ` Eric Abrahamsen
2022-04-14 13:04   ` Eric S Fraga
2022-04-14 15:17     ` Eric Abrahamsen
2022-04-14 15:26       ` Stefan Monnier
2022-04-15 16:31         ` Eric Abrahamsen
2022-04-15 17:17           ` Stefan Monnier
2022-04-15 22:30           ` Alexander Adolf
2022-04-15 22:16   ` Alexander Adolf
2022-04-15 22:58     ` Stefan Monnier
2022-04-26 14:39 ` Alexander Adolf
2022-04-26 18:58   ` Filipp Gunbin
2022-04-28 17:15     ` Alexander Adolf
2022-04-29 14:43       ` Thomas Fitzsimmons
2022-05-02 17:10         ` Alexander Adolf
2022-05-03 18:03           ` Thomas Fitzsimmons
2022-05-05 16:32             ` Alexander Adolf
2022-05-05 16:57               ` Thomas Fitzsimmons
2022-05-10 21:16                 ` Thomas Fitzsimmons
2022-05-16 12:35                   ` Alexander Adolf
2022-04-29 23:04       ` Filipp Gunbin [this message]
2022-05-02 21:38         ` Alexander Adolf
2022-05-02 22:32           ` Filipp Gunbin
2022-05-03 16:18             ` Alexander Adolf
2022-05-03 16:22   ` Alexander Adolf

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

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

  git send-email \
    --in-reply-to=m2h76b8pay.fsf@fastmail.fm \
    --to=fgunbin@fastmail.fm \
    --cc=alexander.adolf@condition-alpha.com \
    --cc=emacs-devel@gnu.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.