zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Subject: Re: Auto-correct and newly-added commands
Date: Mon, 14 Nov 2011 20:16:08 -0800	[thread overview]
Message-ID: <111114201608.ZM11290@torch.brasslantern.com> (raw)
In-Reply-To: <4EC15E90.6020703@mandic.com.br>

On Nov 14,  4:31pm, Daniel Serodio (lists) wrote:
}
} It it possible to have zsh automatically run "rehash" after I reply no 
} to an auto-correct prompt, so it "learns" this new command?

Hrm.  The direct answer is "no" but:

That would certainly seem logical.  Also it seems strange to load up
the command tables and check them for proper spellings when the word
that is being checked is not in the command position to begin with.

What this patch does is reset the incremental path search in the event
the correction is rejected.  That allows whatever hashing options the
user has specified to kick in at the time the path is searched during
command execution, rather than having to test them all here.

Index: Src/utils.c
--- ../zsh-forge/current/Src/utils.c	2011-09-25 15:52:55.000000000 -0700
+++ Src/utils.c	2011-11-14 19:58:34.000000000 -0800
@@ -2498,16 +2498,18 @@
 	return;
     if (!(*s)[0] || !(*s)[1])
 	return;
-    if (shfunctab->getnode(shfunctab, *s) ||
-	builtintab->getnode(builtintab, *s) ||
-	cmdnamtab->getnode(cmdnamtab, *s) ||
-	aliastab->getnode(aliastab, *s)  ||
-	reswdtab->getnode(reswdtab, *s))
-	return;
-    else if (isset(HASHLISTALL)) {
-	cmdnamtab->filltable(cmdnamtab);
-	if (cmdnamtab->getnode(cmdnamtab, *s))
+    if (cmd) {
+	if (shfunctab->getnode(shfunctab, *s) ||
+	    builtintab->getnode(builtintab, *s) ||
+	    cmdnamtab->getnode(cmdnamtab, *s) ||
+	    aliastab->getnode(aliastab, *s)  ||
+	    reswdtab->getnode(reswdtab, *s))
 	    return;
+	else if (isset(HASHLISTALL)) {
+	    cmdnamtab->filltable(cmdnamtab);
+	    if (cmdnamtab->getnode(cmdnamtab, *s))
+		return;
+	}
     }
     t = *s;
     if (*t == Tilde || *t == Equals || *t == String)
@@ -2621,6 +2623,8 @@
 		fflush(shout);
 		zbeep();
 		x = getquery("nyae \t", 0);
+		if (cmd && x == 'n')
+		    pathchecked = path;
 	    } else
 		x = 'n';
 	} else


  reply	other threads:[~2011-11-15  4:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-14 18:31 Daniel Serodio (lists)
2011-11-15  4:16 ` Bart Schaefer [this message]
2011-11-18 12:50   ` Daniel Serodio
2011-11-18 15:07     ` Bart Schaefer
2011-11-23 20:21       ` Daniel Serodio (lists)

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=111114201608.ZM11290@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@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).