From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@sunsite.dk
Subject: Re: Improving spelling correction prompt to generate aliases for future use
Date: Sun, 21 Oct 2007 14:45:11 -0700 [thread overview]
Message-ID: <071021144511.ZM31240@torch.brasslantern.com> (raw)
In-Reply-To: <200710211804.l9LI4w23004771@pws-pc.ntlworld.com>
On Oct 21, 7:04pm, Peter Stephenson wrote:
}
} You could "setopt promptsubst" and have typo output the prompt (as
} well as whatever else it's doing)
I don't think that'll do what Gwern is after. He wants to feed the
results (original and suggested replacement) of spelling correction
to "typo" as command-line arguments.
E.g. he wants to do
typo ${(%):-%R} ${(%):-%r}
but he can't because prompt substitution in parameters doesn't have
access to the SPROMPT escapes.
The following works for simple commands but not loop constructs or other
compound commands:
accept-line() {
emulate -L zsh
local -a words
words=(${(z)BUFFER})
typeset -g ACCEPTED_CMD=$words[1]
zle .accept-line "$@"
}
zle -N accept-line
preexec() {
emulate -L zsh
local -a words
words=(${(z)1})
if [[ $words[1] != $ACCEPTED_CMD ]]
then
typo $ACCEPTED_CMD $words[1]
fi
}
next prev parent reply other threads:[~2007-10-21 22:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-21 3:39 Gwern Branwen
2007-10-21 18:04 ` Peter Stephenson
2007-10-21 21:45 ` Bart Schaefer [this message]
2007-10-21 22:22 ` Gwern Branwen
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=071021144511.ZM31240@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-users@sunsite.dk \
/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).