Subject: 28.0.50; gnus-search notmuch can't find files when using nnimap

From: Kevin Brubeck Unhammer <[email-masked]>
Date: Fri, 12 Mar 2021 11:49:14 +0100

If I have a gnus backend for a local dovecot instance like

                          '(nnimap "mbsync"
                                         (nnimap-address "localhost")
                                         (gnus-search-engine notmuch
                                                             (config-file "/home/me/.notmuch-config")
                                                             (remove-prefix "/home/me/.Maildir/"))
                                         (nnimap-shell-program "MAIL=maildir:$HOME/.Maildir /usr/lib/dovecot/imap")
                                         (nnimap-stream shell))

then Gnus isn't able to translate the filenames returned from notmuch
(e.g. inbox/cur/1615384505.697011_1.laptop,U=5667)
into article numbers. It seems to look up using a function that assumes
you're using nnmaildir:

(if (string-match-p "\\`[[:digit:]]+\\'" article)
			(string-to-number article)
		      (nnmaildir-base-name-to-article-number
		       (substring article 0 (string-match ":" article))
		       group nil))

Here the string-match fails because the filename includes hostname and
U= parts, so we get sent to nnmaildir-base-name-to-article-number which
tries to look up current nnmaildir server which is nil and the end
result is that the computed article number is nil and we get no search
results.

I don't know what the correct way to do this is;
there's https://www.emacswiki.org/emacs/NotMuch#h5o-1 which goes via
message-id's, but maybe there's some better way.

In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw3d scroll bars)
 of 2020-12-03 built on laptop
Repository revision: cf448f6bcc7ab3f8ea03bcb8868a67cf0b39d412
Repository branch: feature/native-comp-erc-network-symbol-harfbug2
Windowing system distributor 'The X.Org Foundation', version 11.0.12009000
System Description: Ubuntu 20.04.2 LTS

Configured using:
 'configure --prefix=/home/me/PREFIX/emacs --with-libsystemd
 --with-pop=yes --with-sound=alsa --without-gconf --with-mailutils
 --with-json --with-cairo --with-nativecomp --with-x=yes
 --with-x-toolkit=lucid'

Configured features:
XAW3D XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND GPM DBUS GSETTINGS GLIB
NOTIFY INOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT
LIBOTF ZLIB TOOLKIT_SCROLL_BARS LUCID X11 XDBE XIM MODULES NATIVE_COMP
THREADS LIBSYSTEMD JSON PDUMPER LCMS2

Important settings:
  value of $LANG: nn_NO.UTF-8
  locale-coding-system: utf-8