zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: complete after rpm -q --whatprovides
@ 2015-03-05 14:37 Peter Stephenson
  0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 2015-03-05 14:37 UTC (permalink / raw)
  To: Zsh Hackers' List

Long standing gripes that act as displacement activities, latest in a
series.

The rpm manual page says "rpm -q --whatprovides" queries a CAPABILITY.
It neglects to say what a CAPABILITY actually is, but files certainly
work as well as packages.  Using a package is supported, but as far as I
can see the "--whatprovides" is then redundant.

As only absolute paths to files work (I've tested this), I've used the
leading / as a discriminator --- otherwise completion is really slow
because it needs to compile a package list, which is a waste of time for
files.

pws

diff --git a/Completion/Redhat/Command/_rpm b/Completion/Redhat/Command/_rpm
index 696c12f..d5e55c1 100644
--- a/Completion/Redhat/Command/_rpm
+++ b/Completion/Redhat/Command/_rpm
@@ -32,6 +32,8 @@
 #    complete a RPM package file name
 #  package_or_file
 #    the previous two together
+#  file_or_package
+#    an absolute path to any file (not a package file) or a package
 #  tags
 #    complete a tag name
 #  capability
@@ -66,7 +68,7 @@ _rpm () {
     {-g,--group}'[query packages in one of specified groups]'
     --fileid --hdrid --pkgid --tid --querybynumber
     '--triggeredby'
-    '--whatprovides'
+    '--whatprovides:*:provided file:->file_or_package'
     '--whatrequires'
   )
   sopts=${selectopts%\[*}\ --specfile
@@ -246,6 +248,13 @@ _rpm () {
     package_or_file)
       state=package_file
       ;;
+    file_or_package)
+      if [[ $PREFIX = /* ]]; then
+	_wanted files expl 'file' _files
+      else
+	state=package
+      fi
+      ;;
     package)
       if ( [[ ${+_rpms} -eq 0 ]] || _cache_invalid RPMs ) &&
 	 ! _retrieve_cache RPMs;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-03-05 14:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-05 14:37 PATCH: complete after rpm -q --whatprovides Peter Stephenson

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).