Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: run-help: Support for svn and git
- X-seq: zsh-workers 24332
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: <joerg@xxxxxxxxxxxx>, zsh-workers@xxxxxxxxxx
- Subject: Re: run-help: Support for svn and git
- Date: Mon, 31 Dec 2007 08:19:12 -0800
- In-reply-to: <slrnfnhn1q.cgh.joerg@xxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <slrnfnfrql.cgh.joerg@xxxxxxxxxxxx> <071230200204.ZM32486@xxxxxxxxxxxxxxxxxxxxxx> <slrnfnhn1q.cgh.joerg@xxxxxxxxxxxx>
On Dec 31, 12:10pm, joerg@xxxxxxxxxxxx wrote:
} Subject: Re: run-help: Support for svn and git
}
} > run-help-svn () {
} > local cmd_args
} > cmd_args=( ${@:#-*} )
} > svn help $cmd_args[1]
}
} I'm not very familiar with zsh programming. So this question might sound
} stupid, but why do you create a new variable? Why don't you use
} ${${@:#-*}[1]} ?
No particular reason except that the above evolved from a couple of
earlier attempts that had the "getln" part in the helper instead of
in run-help.
} Is it possible to get the point where run-help was called? Maybe for
}
} ssh -option <1> host cmd <2>
Not from within the run-help shell function. For that one would need
information that's only available inside the ZLE widget. In fact,
that's probably why nobody has bothered with improving run-help much
before: Most people just hit TAB at those places and rely on the help
strings from the completion function to tell them what they can do.
One could replace the run-help widget itself with something that takes
the line apart with $LBUFFER and $RBUFFER and analyzes it in more
detail, and if run-help had been invented after user-defined widgets
were, it would probably never have been designed the way it is.
} > + if whence -w "run-help-$1" >/dev/null
}
} Why do you use -w, while you throw the output away.
Evolution again. At one point I thought I cared what type of command
it was.
} > + cmd_args=( ${${(z)cmd_args}[2,-1]} )
} > + eval "run-help-$1 $cmd_args[@]"
}
} Where do you remove the part before $1, e.g. LANG=bla?
Ah, I missed that bit. I wondered why you were doing ${full_cmd#*$1}.
Yours doesn't quite work, either; consider something like
PATH=/opt/cvs/bin:$PATH cvs commit ...
(which admittedly is contrived, but demonstrative).
} Why do you have to use eval? Doesn't run-help-$1 work?
Aliases would not be expanded without the eval, and I wanted one to
be able to do e.g.: alias run-help-perl=perldoc
Here's a new patch.
Index: run-help
===================================================================
RCS file: /extra/cvsroot/zsh/zsh-4.0/Functions/Misc/run-help,v
retrieving revision 1.3
diff -c -r1.3 run-help
--- run-help 30 May 2007 03:36:56 -0000 1.3
+++ run-help 31 Dec 2007 16:13:25 -0000
@@ -85,7 +85,24 @@
man zshmisc
;;
(*)
- ((! didman++)) && man $@
+ if ((! didman++))
+ then
+ if whence "run-help-$1:t" >/dev/null
+ then
+ local cmd_args
+ builtin getln cmd_args
+ builtin print -z "$cmd_args"
+ cmd_args=( ${(z)cmd_args} )
+ # Discard environment assignments, etc.
+ while [[ $cmd_args[1] != $1 ]]
+ do
+ shift cmd_args
+ done
+ eval "run-help-$1:t ${(@)cmd_args[2,-1]}"
+ else
+ man $@:t
+ fi
+ fi
;;
esac
if ((i < $#places && ! didman))
--
Messages sorted by:
Reverse Date,
Date,
Thread,
Author