From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@sunsite.dk
Subject: PATCH: Apply spell correction to autocd
Date: Sun, 27 Feb 2005 20:44:07 +0000 [thread overview]
Message-ID: <1050227204407.ZM19297@candle.brasslantern.com> (raw)
I don't know whether this is going to require tweaking for wide-char file
names, but it's at least as good as the current bin_cd() implementation.
Index: Src/utils.c
===================================================================
RCS file: /extra/cvsroot/zsh/zsh-4.0/Src/utils.c,v
retrieving revision 1.21
diff -c -r1.21 utils.c
--- Src/utils.c 18 Feb 2005 17:05:17 -0000 1.21
+++ Src/utils.c 27 Feb 2005 20:35:06 -0000
@@ -1652,6 +1664,7 @@
char ic = '\0';
int ne;
int preflen = 0;
+ int autocd = cmd && isset(AUTOCD) && strcmp(*s, ".") && strcmp(*s, "..");
if ((histdone & HISTFLAG_NOEXEC) || **s == '-' || **s == '%')
return;
@@ -1720,6 +1733,19 @@
if (!*t && cmd) {
if (hashcmd(guess, pathchecked))
return;
+ if (autocd) {
+ char **pp, *g = guess;
+ for (pp = cdpath; *pp; pp++) {
+ char *buf = zhtricat(*pp, "/", *s);
+ spckword(&buf, 0, 0, 0);
+ if (best && strcmp(best, guess)) {
+ best = buf + strlen(*pp) + 1;
+ break;
+ } else if (u != g)
+ best = u;
+ }
+ guess = g;
+ }
d = 100;
scanhashtable(reswdtab, 1, 0, 0, spscan, 0);
scanhashtable(aliastab, 1, 0, 0, spscan, 0);
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
next reply other threads:[~2005-02-27 20:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-27 20:44 Bart Schaefer [this message]
2005-02-28 6:54 ` Bart Schaefer
2005-02-28 10:44 ` Peter Stephenson
2005-02-28 18:14 ` Bart Schaefer
2005-02-28 18:17 ` Clint Adams
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=1050227204407.ZM19297@candle.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-workers@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).