From: Marlon Richert <marlon.richert@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>,
Zsh hackers list <zsh-workers@zsh.org>
Subject: [PATCH] Let run-help try to show function source from file (was Re: [RFC][PATCH] Try calling command with help flags in run-help)
Date: Wed, 2 Jun 2021 21:26:48 +0300 [thread overview]
Message-ID: <CAHLkEDueeqLkvOrsqTEQ3mVus+Majw-DAT7RhDq2my1RWzTuhA@mail.gmail.com> (raw)
In-Reply-To: <CAH+w=7Y1M-TkTJNb0q8LECy6-fViN=As5cn6KohneyeDLdPv4Q@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 456 bytes --]
Here's part of workers 48926 as a separate patch.
On Tue, May 25, 2021 at 11:57 PM Bart Schaefer
<schaefer@brasslantern.com> wrote:
>
> On Tue, May 25, 2021 at 1:49 PM Marlon Richert <marlon.richert@gmail.com> wrote:
> >
> > When there isn't a man page, try calling the command with --help or -h.
>
> This is not a good idea, because we can't predict what will happen if
> a given command does not support those options, or interprets them
> differently.
[-- Attachment #2: 0001-Let-run-help-try-to-show-function-source-from-file.txt --]
[-- Type: text/plain, Size: 1276 bytes --]
From 4cbb4642bb9c4f06fbc6729ecf2995e498cf3d61 Mon Sep 17 00:00:00 2001
From: Marlon Richert <marlon.richert@gmail.com>
Date: Wed, 2 Jun 2021 21:22:59 +0300
Subject: [PATCH] Let run-help try to show function source from file
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
…because parsed functions don't contain comments.
---
Functions/Misc/run-help | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/Functions/Misc/run-help b/Functions/Misc/run-help
index e351dd6a6..b5e692198 100644
--- a/Functions/Misc/run-help
+++ b/Functions/Misc/run-help
@@ -69,7 +69,18 @@ do
(comp*) man zshcompsys;;
(zf*) man zshftpsys;;
(run-help) man zshcontrib;;
- (*) builtin functions ${what[(w)1]} | ${=PAGER:-more};;
+ ( * )
+ local func=$what[(w)1]
+
+ # Try to show function source from file, because parsed functions
+ # don't contain comments.
+ autoload +X -Uz $func
+ if [[ -n $functions_source[$func] ]]; then
+ ${=PAGER:-more} -- $functions_source[$func]
+ else
+ builtin functions $func | ${=PAGER:-more}
+ fi
+ ;;
esac;;
(*( is a * builtin))
case ${what[(w)1]} in
--
2.30.1 (Apple Git-130)
next prev parent reply other threads:[~2021-06-02 18:27 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-25 20:47 [RFC][PATCH] Try calling command with help flags in run-help Marlon Richert
2021-05-25 20:57 ` Bart Schaefer
2021-06-02 18:26 ` Marlon Richert [this message]
2021-06-20 21:23 ` [PATCH] Let run-help try to show function source from file (was Re: [RFC][PATCH] Try calling command with help flags in run-help) Lawrence Velázquez
2021-07-18 18:38 ` Lawrence Velázquez
2021-07-28 2:03 ` Bart Schaefer
2021-06-02 20:58 ` Let run-help filter cmd_args before calling run-help-<command> " Marlon Richert
2021-06-03 4:34 ` Bart Schaefer
2021-06-03 4:38 ` Bart Schaefer
2021-06-03 21:26 ` Marlon Richert
2021-06-03 21:45 ` Lawrence Velázquez
2021-06-03 21:52 ` Bart Schaefer
2021-06-03 22:00 ` Lawrence Velázquez
2021-06-03 23:33 ` Bart Schaefer
2021-06-05 19:15 ` Marlon Richert
2021-06-20 18:01 ` Lawrence Velázquez
2021-07-18 18:45 ` Lawrence Velázquez
2021-07-28 17:58 ` Bart Schaefer
2021-07-29 12:11 ` Marlon Richert
2021-07-30 16:55 ` Bart Schaefer
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=CAHLkEDueeqLkvOrsqTEQ3mVus+Majw-DAT7RhDq2my1RWzTuhA@mail.gmail.com \
--to=marlon.richert@gmail.com \
--cc=schaefer@brasslantern.com \
--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).