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

2021-12-30 Thread Daniel Shahaf
martin f krafft wrote on Fri, Dec 31, 2021 at 15:26:24 +1300:
> Regarding the following, written by "Daniel Shahaf" on 2021-12-31 at 02:16 
> Uhr +:
> > The two consecutive colons on the -a line mean the -a option takes an
> > optional argument.
> 
> Herein lies the problem:
> 
> ```
>   -a  [...] --  attach file(s) to the message
>   the list of files must be terminated with the "--" sequence
> ```
> 
> So it's neither optional, nor even a single word by necessity.

Good catch.

I think it's possible to teach _mutt how to complete this in the general
case, but the details are better hashed out upstream (zsh-work...@zsh.org).

Cheers,

Daniel



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

2021-12-30 Thread martin f krafft

Regarding the following, written by "Daniel Shahaf" on 2021-12-31 at 02:16 Uhr 
+:
The two consecutive colons on the -a line mean the -a option takes 
an optional argument.


Herein lies the problem:

```
  -a  [...] --  attach file(s) to the message
the list of files must be terminated with the "--" sequence
```

So it's neither optional, nor even a single word by necessity.

--
 .''`.   martin f. krafft  @martinkrafft
: :'  :  proud Debian developer
`. `'`   http://people.debian.org/~madduck
  `-  Debian - when you have better things to do than fixing systems
 
"the college students who are using lsd and marijuana today do not

 comprise a criminal class. they are not drug addicts seeking to
 escape. they're your best educated, your most creative, and your
 most couragious, young people. and like it or not, they might build
 you a new civilisation."   -- porcupine tree, voyage 34


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

2021-12-30 Thread Daniel Shahaf
David Bremner wrote on Sun, Dec 26, 2021 at 07:54:35 -0400:
> David Bremner  writes:
> 
> > martin f krafft  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 » 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 f...@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