* Improve completion of modprobe module parameters
@ 2008-09-22 16:55 Jörg Sommer
0 siblings, 0 replies; only message in thread
From: Jörg Sommer @ 2008-09-22 16:55 UTC (permalink / raw)
To: zsh-workers
Hi,
commit e19e7fa39f7dcd9de4cb42463f142f7ff2483936
Author: Jörg Sommer <joerg@alea.gnuu.de>
Date: Mon Sep 22 18:24:47 2008 +0200
Add the option --field of modinfo
diff --git a/Completion/Linux/Command/_modutils b/Completion/Linux/Command/_modutils
index 7322903..7cc539f 100644
--- a/Completion/Linux/Command/_modutils
+++ b/Completion/Linux/Command/_modutils
@@ -18,6 +18,8 @@ case "$service" in
'(-)'{-l,--license}"[display the module's license]" \
'(-)'{-n,--filename}"[display the module's filename]" \
'(-)'{-p,--parameters}'[display the typed parameters that a module may support]' \
+ '(-)'{-F,--field}"[display only selected module's information]:module_field:(
+ alias author depends description filename license parm)" \
'1:module file:->all_modules' && ret=0
;;
commit d682cfc8640bfc6bd706cb8d113db1d1d7ee9de5
Author: Jörg Sommer <joerg@alea.gnuu.de>
Date: Mon Sep 22 18:27:02 2008 +0200
Return 0 if a modules parameter was completed
diff --git a/Completion/Linux/Command/_modutils b/Completion/Linux/Command/_modutils
index 7cc539f..e2efb53 100644
--- a/Completion/Linux/Command/_modutils
+++ b/Completion/Linux/Command/_modutils
@@ -88,7 +88,7 @@ case "$state" in
_message -e value 'parameter value'
else
_values 'module parameter' \
- ${(f)^"$(_call_program module_parameter modinfo -F parm "$words[2]" 2>/dev/null)"//:/\=[}\]
+ ${(f)^"$(_call_program module_parameter modinfo -F parm "$words[2]" 2>/dev/null)"//:/\=[}\] && ret=0
fi
;;
esac
commit 4be6a9fffb837f7647a3a836589870d150149593
Author: Jörg Sommer <joerg@alea.gnuu.de>
Date: Mon Sep 22 18:29:28 2008 +0200
Declare val_args as local array
As requested in the documention of _values in zshcompsys(1), declare the
array as local.
diff --git a/Completion/Linux/Command/_modutils b/Completion/Linux/Command/_modutils
index e2efb53..5b063e4 100644
--- a/Completion/Linux/Command/_modutils
+++ b/Completion/Linux/Command/_modutils
@@ -87,6 +87,8 @@ case "$state" in
if compset -P '*='; then
_message -e value 'parameter value'
else
+ typeset -A val_args
+
_values 'module parameter' \
${(f)^"$(_call_program module_parameter modinfo -F parm "$words[2]" 2>/dev/null)"//:/\=[}\] && ret=0
fi
commit 0e0292d0b0068e521e7fe8ebedd36fd2c1631b2f
Author: Jörg Sommer <joerg@alea.gnuu.de>
Date: Mon Sep 22 18:33:44 2008 +0200
Improve module parameter completion
First, do not embedd the = in the parameter by define it a
parameter‐value separator; -S =.
Second, look for already given parameters in all words; -w.
Third, use the curcontext variable; -C.
Forth, distinct between boolean and non‐boolean parameters, i.e. do not
append a = to the end. And include the type of the parameter in the help
message. This information is only given in the full output of modinfo,
not in the narrowed output with --field.
diff --git a/Completion/Linux/Command/_modutils b/Completion/Linux/Command/_modutils
index 5b063e4..f422fac 100644
--- a/Completion/Linux/Command/_modutils
+++ b/Completion/Linux/Command/_modutils
@@ -87,10 +87,17 @@ case "$state" in
if compset -P '*='; then
_message -e value 'parameter value'
else
- typeset -A val_args
+ local params
+ params=( ${${(M)${(f)"$(_call_program module_parameter modinfo "$words[2]" 2>/dev/null)"}:#parm:*}##parm:[[:space:]]##} )
+ if [[ $#params -eq 0 ]]; then
+ _message -e parameter "This modules doesn't have parameters"
+ else
+ typeset -A val_args
- _values 'module parameter' \
- ${(f)^"$(_call_program module_parameter modinfo -F parm "$words[2]" 2>/dev/null)"//:/\=[}\] && ret=0
+ _values -S = -C -w 'module parameter' \
+ ${${${(M)params:#*(:bool|\(bool\))}/:/[}/(bool| \(bool\))/]} \
+ ${^${params:#*(:bool|\(bool\))}/:/[}"]:auto added argument: " && ret=0
+ fi
fi
;;
esac
Bye, Jörg.
--
Fazit: „Schießen Sie nicht mit dem Geiger!“
<news:46778c4c$0$6396$9b4e6d93@newsspool2.arcor-online.net>
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-09-22 17:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-22 16:55 Improve completion of modprobe module parameters Jörg Sommer
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).