zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-workers@zsh.org
Cc: "Jörg Sommer" <joerg@alea.gnuu.de>
Subject: run-help as a widget
Date: Wed, 16 Dec 2009 11:59:00 +0000	[thread overview]
Message-ID: <20091216115900.45764c25@news01> (raw)
In-Reply-To: <a355a85f3bdb0aac910702825eeb0b302ba155a9.1260147415.git.joerg@alea.gnuu.de>

On Mon,  7 Dec 2009 01:57:10 +0100
Jörg Sommer <joerg@alea.gnuu.de> wrote:
> I know, this solution is a dirty hack, but it's quick. The better way is
> to fix zsh to call run-help with the whole commandline where the alias
> gets expanded and this commandline gets passed to the second run-help
> call.

I've been using this for a while, it's perhaps time something along these
lines got included in Functions/Zle.  I was a bit surprised to find I
hadn't.

With this it would be worth upgrading run-help and helpers to check if
there's already a full command line there, and to advance past precommand
modifiers.  I thought I'd done some of this, too, but maybe not...
I might simply have been thinking of expansion of aliases.

By the way, note this quotes all buffer words:

  ls foo; rm -rf ~<Esc>h

is safe even if it may not do quite what you actually want, which is quite
hard to guess.  (But I didn't try it quite like that anyway...)


# run-help-widget
#
# This is a widget to replace the builtin widget run-help.
# It passes the entire command line to run-help.  This is often
# more useful.
#
# Typical usage:
#   zle -N run-help run-help-widget

local -a line

if is-at-least 4.3.10; then
  line=(${(q-)${(z)BUFFER}})
else
  line=(${(qq)${(z)BUFFER}})
fi
zle push-line
BUFFER="run-help ${line}"
zle accept-line


-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


  parent reply	other threads:[~2009-12-16 12:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-07  0:57 [PATCH] run-help: ugly workaround for run-help-$X with alias for $X Jörg Sommer
2009-12-10  9:49 ` Peter Stephenson
2009-12-16 11:59 ` Peter Stephenson [this message]
2009-12-16 17:14   ` run-help as a widget Greg Klanderman
2009-12-18 16:59   ` Jörg Sommer
2009-12-18 23:28     ` Mikael Magnusson

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=20091216115900.45764c25@news01 \
    --to=pws@csr.com \
    --cc=joerg@alea.gnuu.de \
    --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).