Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: Re: Rpm completion problem



Bart Schaefer wrote:

> On Aug 5,  5:08pm, Bart Schaefer wrote:
> }
> } On Aug 5, 12:25am, Wayne Davison wrote:
> } }
> } } I've noticed a problem in rpm completions when I specify the 'p'
> } } (package file) option bunched up with other options.
> } 
> } This was discussed in the thread referenced by zsh-workers/11752, and
> } I think the patch in 11985 was supposed to provide a way to fix it, but
> } _rpm never got updated.
> 
> The last word in that discussion appears to have been   Sven, do you
> recall whether you every did anything specific to this?

The patch is in 11876. I didn't touch _rpm, though (as you saw).

> I remarked in 11742:
> 
> } Currently _rpm uses `-p+' as the spec for the -p option.  That means that
> } anything that will follow the -p (including package file name) is allowed
> } to appear in the same word, or in the next word.
> } 
> } If we remove the `+', then "rpm -qpc" doesn't match the spec `-p', and so
> } completion doesn't enter the `package_file' state -- it instead enters the
> } `package_or_file' state (the default spec from the `query' state).
> 
> This is no longer the problem; remove the `+' and `rpm -qpc <TAB>' completes
> package file names exactly as it should.  However, `rpm -qp<TAB>' inserts a
> space rather than completing `c' et al.
> 
> Based on my exchange with Sven as quoted in 11793, I'd say that _rpm needs
> another ->state in order to handle bunched query options following -qp, or
> at least that the package_file state needs to be tweaked somehow.  In the
> meantime, if you don't mind having to make `p' be the last option in any
> bunch beginning with `-q', just remove the `+' on line 62 of _rpm.

There were to buglets. ca_get_sopt() (the function that checks if we
are in a multi-single-letter-option string) returned the wrong option,
namely the `i' in `-qip'. And then we should handle the option
argument in the same word only if we have a `-o+' option.

As far as I can see, it should work correctly now. Or does rpm accept
a filename directly after the -p in the same word? In that we have to
put back the `+' in _rpm.

Bye
 Sven

Index: Completion/Linux/_rpm
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Linux/_rpm,v
retrieving revision 1.16
diff -u -r1.16 _rpm
--- Completion/Linux/_rpm	2000/08/02 13:45:52	1.16
+++ Completion/Linux/_rpm	2000/08/08 12:02:29
@@ -59,7 +59,7 @@
   )
   packageopts=(
     '-a[query all packages]'
-    '-p+[query uninstalled package file]:*:RPM package file:->package_file'
+    '-p[query uninstalled package file]:*:RPM package file:->package_file'
     '-f[specify file to query owner of]:file:_files'
     '--triggeredby:RPM package:->package'
     '--whatprovides:RPM capability:->capability'
Index: Src/Zle/computil.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/computil.c,v
retrieving revision 1.40
diff -u -r1.40 computil.c
--- Src/Zle/computil.c	2000/08/08 10:32:49	1.40
+++ Src/Zle/computil.c	2000/08/08 12:02:38
@@ -1108,6 +1108,7 @@
 			line++;
 		    *end = line;
 		}
+		pp = p;
 		break;
 	    }
 	} else if (!p || (p && !p->active))
@@ -1429,7 +1430,9 @@
 	    if (!state.oargs[state.curopt->num])
 		state.oargs[state.curopt->num] = znewlinklist();
 
-	    ddef = state.def = state.curopt->args;
+	    state.def = state.curopt->args;
+	    ddef = (state.curopt->type == CAO_NEXT && cur == compcurrent ?
+		    NULL : state.def);
 	    dopt = state.curopt;
 	    doff = pe - line;
 	    state.optbeg = state.argbeg = state.inopt = cur;

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author