zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: zsh-workers@zsh.org, pkg-zsh-devel@alioth-lists.debian.net
Subject: Re: apt autocompletion issue
Date: Wed, 31 Jul 2019 00:13:03 +0200	[thread overview]
Message-ID: <95111-1564524783.256179@YmUe.6pjL.n2dY> (raw)
In-Reply-To: <20190730145353.k2eonyy6w2z7luau@sym.noone.org>

Axel Beckert wrote:
> TL;DR: I recommend to just complete all packages upon
> "apt list --upgradable <Tab>".

Thanks, so this updated patch uses installed with --installed and avail
otherwise. After checking the man page, I also added completion of
reinstall and auto-removal for - and + suffixes.

> > On 26 Jul, "Hauser, Felix (MRT)" wrote:
> > > which is easily done in the normal bash file.

Just for note Felix, while technically possible, I'd really recommend
against trying to ever use bash completions with zsh.

> Daniel Shahaf wrote:
> > ??aptitude search -F %p '?upgradable'?? would print the right set of
> > packages, I think, but aptitude isn't part of a minimal installation so
> > can't be assumed available.

A _deb_packages_update_upgradable function could check
(( $+commands[aptitude] )) and offer all packages as a fallback.
Or one of the options Axel mentions - if someone wants to do that.

> > Cc += Debian zsh packagers.
>
> Thanks. I read Felix initial mail, but just adding three hard coded
> long options seemed rather trivial...

It's often not as trivial as it might first seem without a copy of the
command to test combinations against. I probably need to install yet
another VM to cover Debian given a large number of Debian specific
completions. Out of interest, what is the recommended apt* tool these
days? Is aptitude the best or most powerful with apt as the simplified
interface and apt-get just a historic relic?

Oliver

diff --git a/Completion/Debian/Command/_apt b/Completion/Debian/Command/_apt
index 4486aa26d..4d60cd249 100644
--- a/Completion/Debian/Command/_apt
+++ b/Completion/Debian/Command/_apt
@@ -399,7 +399,13 @@ _apt-cmd () {
     -o,--option:arbitem \
     -t,--target-release:release \
     -- \
-    /$'list\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" avail' \# \| \
+    /$'list\0'/ \( \
+      \( \
+        /$'--installed\0'/ ':packages::_deb_packages "$expl_packages[@]" installed' \# /'[]'/ \| \
+        // %-% /$'--[^\0]#\0'/ ':options:option:(--installed --upgradable --all-versions)' \
+      \| \) \
+      /$'[^-\0][^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" avail' \# \
+    \) \| \
     /$'search\0'/ /$'[^\0]#\0'/ ':strings:pattern:' \| \
     /$'showsrc\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" avail' \# \| \
     /$'show\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" avail' \# \| \
@@ -409,15 +415,14 @@ _apt-cmd () {
     /$'update\0'/ \| \
     \( \
       /$'(install|download|source|build-dep)\0'/ -'subcmd=${match%?}' \
-      /$'[^\0]#\0'/ ':packages::_deb_packages -qr "\n\t\- /=" "$expl_packages[@]" avail' \# \
+      /$'[^\0]#\0'/ ':packages::_deb_packages -qr "\n\t\- /=+-" "$expl_packages[@]" avail' \# \
       \( \
 	// '%(.|)/%' -'[[ $subcmd = install ]]' /'[]'/ ':files: :_deb_files -c' \| \
 	/$'[^\0/=]#\/'/ /'[]'/ ':apt-releases:release name:_apt_releases' \| \
 	/$'[^\0/=]#='/ /'[]'/ ':apt-package-versions:package version:_apt_versions_of_binary_package' \| \
       \) \
     \) \| \
-    /$'remove\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" installed' \# \| \
-    /$'purge\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" installed' \# \| \
+    /$'(remove|reinstall|purge)\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" installed' \# \| \
     /$'upgrade\0'/ \| \
     /$'autoclean\0'/ \| \
     /$'changelog\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" avail' \# \| \
@@ -425,7 +430,7 @@ _apt-cmd () {
     /$'full-upgrade\0'/ \| \
     /$'dist-upgrade\0'/ \| \
     /$'edit-sources\0'/ \| \
-    /"[]"/	':argument-1::compadd "$expl_action[@]" list search showsrc show depends rdepends policy update install download source build-dep remove upgrade full-upgrade dist-upgrade edit-sources autoclean changelog autoremove purge'
+    /"[]"/ ':argument-1::compadd "$expl_action[@]" list search showsrc show depends rdepends policy update install reinstall download source build-dep remove upgrade full-upgrade dist-upgrade edit-sources autoclean changelog autoremove purge'
 
   _apt-cmd () {
     local expl_action expl_packages subcmd

  reply	other threads:[~2019-07-30 22:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-26 16:20 Hauser, Felix (MRT)
2019-07-29 23:53 ` Oliver Kiddle
2019-07-30 11:49   ` Hauser, Felix (MRT)
2019-07-30 13:02     ` Daniel Shahaf
2019-07-30 14:53   ` Axel Beckert
2019-07-30 22:13     ` Oliver Kiddle [this message]
2019-07-30 23:21       ` aptitude vs apt vs apt-get (was: Re: [Pkg-zsh-devel] apt autocompletion issue) Axel Beckert

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

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

  git send-email \
    --in-reply-to=95111-1564524783.256179@YmUe.6pjL.n2dY \
    --to=okiddle@yahoo.co.uk \
    --cc=pkg-zsh-devel@alioth-lists.debian.net \
    --cc=zsh-workers@zsh.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://git.vuxu.org/mirror/zsh/

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 NNTP newsgroup(s).