zsh-workers
 help / color / mirror / code / Atom feed
From: Phil Pennock <zsh-workers+phil.pennock@spodhuis.org>
To: zsh-workers@zsh.org
Subject: [PATCH] run-help compat with alias to noglob/nocorrect
Date: Wed,  7 Aug 2013 03:50:14 -0400	[thread overview]
Message-ID: <1375861814-92270-1-git-send-email-zsh-workers+phil.pennock@spodhuis.org> (raw)

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


                 reply	other threads:[~2013-08-07  8:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1375861814-92270-1-git-send-email-zsh-workers+phil.pennock@spodhuis.org \
    --to=zsh-workers+phil.pennock@spodhuis.org \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).