[Pkg-zsh-devel] Bug#941214: mutt zsh completion broken, -a does not take email address

Daniel Shahaf danielsh at apache.org
Fri Dec 31 02:16:19 GMT 2021


David Bremner wrote on Sun, Dec 26, 2021 at 07:54:35 -0400:
> David Bremner <david at tethera.net> writes:
> 
> > martin f krafft <madduck at debian.org> writes:
> >
> >> Package: notmuch
> >> Version: 0.29.1-2
> >> Severity: normal
> >> File: /usr/share/zsh/vendor-completions/_email-notmuch
> >>
> >> mutt has a command-line switch '-a' for attachments, and the Zsh 
> >> completer offers files and directories for its argument.
> >>
> >> As of late, _email-notmuch also adds all addresses into the mix:
> >>
> >> % mutt -a ^D
> >> directory
> >> […]
> >> file attachment
> >> […]
> >> email address (notmuch)
> >> […]
> >>
> >>
> >> In the context of '-a', no email addresses should be offered. Maybe 
> >> this is actually a problem with Zsh or Mutt, I can't figure it out. 
> >> But since I see mainly notmuch in the output, I am filing here…
> >
> > As far as I can tell, the whole point of _email-notmuch is to provide
> > addresses, so maybe it shouldn't be called there? To me that suggests
> > the bug should be reassigned to mutt. I am CCing the mutt maintainers,
> > in case they want to weigh in.
> >
> > d
> 
> My mistake, the mutt completion is actually shipped by zsh. I've
> attached _email-notmuch (installed by package notmuch) for feedback. If
> something looks wrong with it, please let me know. Otherwise I think I
> should reassign this bug to zsh, where it can at least get some more
> expert consideration.

By code inspection:

Email addresses are offered because the function _mutt (from the file of
the same name shipped by zsh-common) contains:
.
    _arguments -s -S \
      '::recipient:_email_addresses -n mutt' \
      '*-a[attach file using MIME]::file attachment:_files' \
.
which is as self-explanatory as it gets, of course ☺

The two consecutive colons on the -a line mean the -a option takes an
optional argument.  Therefore, «mutt -a <TAB>» completes both arguments
to -a, using _files, and email addresses, using «_email_addresses -n
mutt» (which presumably calls _email-notmuch along with other _email-*
functions).  Still by code inspection, if you remove one of the two
consecutive colons on the -a line, email addresses shouldn't be offered
any more.

If the above analysis is correct, this bug report belongs to zsh-common.

Furthermore, if invocations such as «mutt -a foo at example.com» and «mutt
-a» without further arguments are errors (they are in older mutts, but I
haven't tested in sid), then the report is valid and the fix would be to
drop the second consecutive colon from the -a line in _mutt.

Cheers,

Daniel



More information about the Pkg-zsh-devel mailing list