zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] run-help compat with alias to noglob/nocorrect
@ 2013-08-07  7:50 Phil Pennock
  0 siblings, 0 replies; only message in thread
From: Phil Pennock @ 2013-08-07  7:50 UTC (permalink / raw)
  To: zsh-workers

From: Phil Pennock <pdpennock@users.sourceforge.net>

Given `alias fetch='noglob fetch'`, without this change `run-help fetch`
recurses to invoke itself on the noglob command, bringing up the help
for noglob.  Similarly for nocorrect.  Thus the user would have to quit
out of the pager, then avoid quitting out of the loop, so that they can
go into the second iteration and see the help for the second instance
found by `whence -a`, which happens to be the target of the alias.
With common pagers, that's thus 'q', 'not-q'.  Somewhat frustrating.

Without this change, `alias foo='noglob bar'` where `foo` is not
otherwise a command would _never_ show the help for `bar`, since it only
showed the help for `noglob` and there was no second line of whence
output to trigger the second pass.

With this change, aliases to `noglob|nocorrect` of a command somewhat
ignore the presence of that precommand modifier; if a command is aliased
to `noglob $itself`, then the result is that the first line of whence
output is shown, no pager is used, the user can immediately see a prompt
to continue and press something other-than-q to see the help for the
command.

If given `alias foo='noglob bar'` then `run-help foo` will immediately
show the help for bar.

This behaviour was chosen to be consistent with the existing alias
support, but just working better with the precommand modifier.
---
 Functions/Misc/run-help | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Functions/Misc/run-help b/Functions/Misc/run-help
index 6a9abb3..c817b67 100644
--- a/Functions/Misc/run-help
+++ b/Functions/Misc/run-help
@@ -56,6 +56,10 @@ do
     [[ -n $noalias && $what = *" is an alias "* ]] && continue
     builtin print -r $what
     case $what in
+    (*( is an alias for (noglob|nocorrect))*)
+	[[ ${what[(w)7]:t} != ${what[(w)1]} ]] &&
+	  run_help_orig_cmd=${what[(w)1]} run-help ${what[(w)7]:t}
+	;;
     (*( is an alias)*)
 	[[ ${what[(w)6]:t} != ${what[(w)1]} ]] &&
 	  run_help_orig_cmd=${what[(w)1]} run-help ${what[(w)6]:t}
-- 
1.8.0.1


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

only message in thread, other threads:[~2013-08-07  8:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-07  7:50 [PATCH] run-help compat with alias to noglob/nocorrect Phil Pennock

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