[PATCH 0/3] emacs: allow opting out of notmuch's address completion

Subject: [PATCH 0/3] emacs: allow opting out of notmuch's address completion

Date: Mon, 9 Nov 2020 00:11:47 +0100

To: notmuch@notmuchmail.org

Cc:

From: Jonas Bernoulli


Hello

Notmuch's address completion didn't work well for me.  I read the
respective code and found some issues, some of which are difficult
to address.

I wrote my own implementation, which might eventually be suitable as
a replacement for the current implementation, but it is not ready yet.

In a first step I would like to make it possible to use notmuch and
some other address completion mechanism without having to advice a
notmuch-address.el function to prevent it making destructive changes.
The second commit in this series does that.  Here is the hack I am
currently using instead:

,----
| ;;; Counteract notmuch-address.el
| 
| (defun notmuch-address-setup--noop (_fn)
|   "Prevent modification of `message-completion-alist'.")
| (advice-add 'notmuch-address-setup :around
|             'notmuch-address-setup--noop)
`----

You can find my implementation (named notmuch-addr.el because it is
like notmuch-address.el, but "smaller") here:

,----
| https://git.sr.ht/~tarsius/notmuch-addr
`----

The main reason I am not trying to improve that until it can serve as
a replacement for notmuch-address.el is that it depends on Emacs 27.1,
which was just released. (Aside from that it also omits features that
*I* don't need.)

The main reason I am listing defects of notmuch-address.el below is
that by the time we can fix all of them (when we drop support for
Emacs releases before 27.1) I will have forgotten about them, so it
seem like a good idea to document them.

* Emacs' address completion API used to be rather wacky and that was
  not fixed until version 27.1. "Callers" didn't merely have to
  provide a list of completion candidate, instead they actually had to
  perform completion themselves.  Starting with 27.1 the completion-
  at-point API is respected but there are kludges to support the old
  style as well, see https://git.savannah.gnu.org/cgit/emacs.git/com
  mit/?id=47a767c24e9cc4323432e29103b0a2cc46f8f3e4.

  Using capf API has the advantage that many things don't have to be
  re-implemented.  For example `company-mode' just works.  Notmuch
  currently has to implement support explicitly in notmuch-company.el.

* Some essentially random completion candidate is used as the "initial
  input".  The last commit in this series (which see) fixes that.

* The special cases when there is not matching candidate or just a
  single match are handled specifically, which IMO is an optimization
  that makes things worse.  That should also be an easy fix, but since
  it might also be a controversial change, I did not implement it.

* Completion candidates are pre-filered based on the text that was
  already at-point before at-point completion was invoked, which makes
  it possible to choose candidates that that initial text does not
  match.  IMO that's another optimization that badly back fires.

  I was surprised to learn that notmuch shared this feature/defect
  with the current default address implementation in Emacs 27.1.

  The initial commit of my implementation also shares this defect;
  but only so that I can use the second commit to demonstrate how
  that can be fixed.

     Cheers,
     Jonas

Jonas Bernoulli (3):
  emacs: notmuch-address-setup: cosmetics
  emacs: allow opting out of notmuch's address completion
  emacs: notmuch-address-expand-name: use the actual initial-input

 emacs/notmuch-address.el | 57 ++++++++++++++++++++--------------------
 1 file changed, 29 insertions(+), 28 deletions(-)

-- 
2.29.1
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: