unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Keith Amidon <camalot@picnicpark.org>
To: notmuch@notmuchmail.org
Subject: Re: Address Completion in Emacs
Date: Sat, 9 Dec 2023 00:26:33 -0800	[thread overview]
Message-ID: <71a3382b-3f1b-4b81-883c-b4a8bd710888@picnicpark.org> (raw)
In-Reply-To: <87y1e4xh8s.fsf@main.dwrz.net>

This thread inspired me to look a little more deeply into the address 
completion issues I've been having since switching to corfu as well. It 
was a rather long and twisted journey but I ended up getting completion 
using corfu working with the following in my init file:

    ;; Make corfu-based address completion work
    (defun kea/notmuch-address-message-capf ()
      "Return completion data for email addresses in notmuch-address.

Meant for use in `message-completion-alist'."
      (when (and (bound-and-true-p notmuch-address-completions))
        (let ((now (float-time))
              (end (save-excursion
                     (skip-chars-forward "^, \t\n")
                     (point)))
              (start (save-excursion
                       (skip-chars-backward "^, \t\n")
                       (point))))
          (when (> (- now notmuch-address-last-harvest) 86400)
            ;; Synchronously get completions now and update addresses in
            ;; background. Handles startup case where there might not be
            ;; anything in notmuch-address-completions because
            ;; notmuch-address-last-harvest will be 0.
            (notmuch-address-harvest (buffer-substring-no-properties 
start end) t)
            (notmuch-address-harvest-trigger))
          `(,start ,end ,notmuch-address-completions 'mail))))
    (defun kea/setup-notmuch-message-mode ()
      (setq notmuch-address-use-company nil)
      (setq message-completion-alist
            `((,message-newgroups-header-regexp . ,#'message-expand-group)
              (,message-email-recipient-header-regexp . 
,#'kea/notmuch-address-message-capf))))
    (add-hook 'notmuch-message-mode-hook #'kea/setup-notmuch-message-mode)

Note that I set mail-user-agent to notmuch-user-agent.

Cheers!   --- Keith
\r

  reply	other threads:[~2023-12-09  8:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-08 13:26 Address Completion in Emacs David Wen Riccardi-Zhu
2023-12-08 16:40 ` Sandra Snan
2023-12-09  2:05   ` David Wen Riccardi-Zhu
2023-12-09  8:26     ` Keith Amidon [this message]
  -- strict thread matches above, loose matches on Subject: below --
2014-12-12  8:22 Address completion " Lele Gaifax
2014-12-12 12:14 ` David Edmondson
2014-12-12 12:45   ` Lele Gaifax
2014-12-12 13:08     ` David Edmondson
2014-12-14 17:27 ` Tomi Ollila

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://notmuchmail.org/

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

  git send-email \
    --in-reply-to=71a3382b-3f1b-4b81-883c-b4a8bd710888@picnicpark.org \
    --to=camalot@picnicpark.org \
    --cc=notmuch@notmuchmail.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 public inbox

	https://yhetil.org/notmuch.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).