Subject: bug#21057: [PATCH] nnimap.el: add support for IMAP namespaces

From: Robert Pluim <[email-masked]>
Date: Mon, 23 Jul 2018 13:28:50 +0200

Nikolaus Rath <[email-masked]> writes:

Nitpicks below.

> Hi,
>
> Reworked patch is attached.
>
> I tested with and and without nnimap-use-namespaces on Emacs 25.1.1.
>
> Best,
> Nikolaus
>
> -- 
> GPG Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F
>
>              »Time flies like an arrow, fruit flies like a Banana.«
>
> From ff88c4969617ede5742e039136159fe3650ac693 Mon Sep 17 00:00:00 2001
> From: Nikolaus Rath <[email-masked]>
> Date: Mon, 23 Jul 2018 10:21:46 +0100
> Subject: [PATCH] Make nnimap support IMAP namespaces
>
> * lisp/gnus/nnimap.el (nnimap-use-namespaces): Introduce new
> server variable.
> (nnimap-group-to-imap, nnimap-get-groups): Transform IMAP group
> names to Gnus group name by stripping / prefixing personal
> namespace prefix.
> (nnimap-open-connection-1): Ask server for namespaces and store them.
>
> * lisp/gnus/nnimap.el (nnimap-request-group-scan)
> (nnimap-request-create-group, nnimap-request-delete-group)
> (nnimap-request-rename-group, nnimap-request-move-article)
> (nnimap-process-expiry-targets)
> (nnimap-request-update-group-status)
> (nnimap-request-accept-article, nnimap-request-list)
> (nnimap-retrieve-group-data-early, nnimap-change-group)
> (nnimap-split-incoming-mail): Use nnimap-group-to-imap.
> (nnimap-group-to-imap): New function to map Gnus group names to
> IMAP folder names.
> ---
>  doc/misc/gnus.texi  |  6 ++++
>  etc/NEWS            |  5 +++
>  lisp/gnus/nnimap.el | 93 +++++++++++++++++++++++++++++++++++++----------------
>  3 files changed, 77 insertions(+), 27 deletions(-)
>
> diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi
> index 6793ed..cd97cf 100644
> --- a/doc/misc/gnus.texi
> +++ b/doc/misc/gnus.texi
> @@ -14320,6 +14320,12 @@ fetch all textual parts, while leaving the rest on the server.
>  If non-@code{nil}, record all @acronym{IMAP} commands in the
>  @samp{"*imap log*"} buffer.
>  
> +@item nnimap-use-namespaces
> +If non-@code{nil}, omit the IMAP namespace prefix in nnimap group
> +names. If your IMAP mailboxes are called something like @samp{INBOX}
> +and @samp{INBOX.Lists.emacs}, but you'd like the nnimap group names to
> +be @samp{INBOX} and @samp{Lists.emacs}, you should enable this option.
> +
>  @end table
>

Does this also work for secondary servers? I imagine it does.

>  
> diff --git a/etc/NEWS b/etc/NEWS
> index fc2a5..57b51 100644
> --- a/etc/NEWS
> +++ b/etc/NEWS
> @@ -46,6 +46,11 @@ option --enable-check-lisp-object-type is therefore no longer as
>  useful and so is no longer enabled by default in developer builds,
>  to reduce differences between developer and production builds.
>  
> +** Gnus
> +
> ++++
> +*** The nnimap backend now has support for IMAP namespaces.
> +

This should mention the 'nnimap-use-namespaces' variable.

>  
>  * Startup Changes in Emacs 27.1
>  
> diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el
> index 3b397..efcb68 100644
> --- a/lisp/gnus/nnimap.el
> +++ b/lisp/gnus/nnimap.el
> @@ -55,6 +55,13 @@
>  If nnimap-stream is `ssl', this will default to `imaps'.  If not,
>  it will default to `imap'.")
>  
> +(defvoo nnimap-use-namespaces nil
> +  "Whether to use IMAP namespaces.
> +If in Gnus your folder names in all start with (e.g.) `INBOX',
> +you probably want to set this to t. The effects of this are
> +purely cosmetical, but changing this variable will affect the

cosmetical⇒cosmetic

Thanks

Robert