From: Bart Schaefer <schaefer@brasslantern.com>
To: "Zsh Hackers' List" <zsh-workers@zsh.org>
Subject: Word breaks around aliased tokens (was Re: PATCH: Removing aliases from history, 2015 style (was capturing output of !! not working))
Date: Wed, 25 Mar 2015 20:43:05 -0700 [thread overview]
Message-ID: <150325204305.ZM1653@torch.brasslantern.com> (raw)
In-Reply-To: <150325124032.ZM32185@torch.brasslantern.com>
On Mar 25, 12:40pm, Bart Schaefer wrote:
}
} torch% echo foo&&bar
} foo foobar
}
} If this were going to change, I would recommend using something akin to
} my patch from workers/34738 to add the second space, rather than attempt
} to remove the first one.
That would be as below, which is almost identical to 34738 (the salient
difference being use of INP_ALIAS instead of INP_CONT).
I think this makes sense[*]:
torch% alias -g '&&'=AND
torch% echo foo&&bar
foo AND bar
(the pre-patch output is "foo ANDbar") but I will wait for feedback before
pushing.
[*] To the extent I think aliasing these tokens makes sense at all.
diff --git a/Src/lex.c b/Src/lex.c
index 6d0079c..4c1555e 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -1747,6 +1747,16 @@ checkalias(void)
if (an && !an->inuse &&
((an->node.flags & ALIAS_GLOBAL) ||
(incmdpos && tok == STRING) || inalmore)) {
+ if (!lexstop) {
+ /*
+ * Tokens that don't require a space after, get one,
+ * because they are treated as if preceded by one.
+ */
+ int c = hgetc();
+ hungetc(c);
+ if (!iblank(c))
+ inpush(" ", INP_ALIAS, 0);
+ }
inpush(an->text, INP_ALIAS, an);
if (an->text[0] == ' ' && !(an->node.flags & ALIAS_GLOBAL))
aliasspaceflag = 1;
diff --git a/Test/A02alias.ztst b/Test/A02alias.ztst
index fe7155e..08163eb 100644
--- a/Test/A02alias.ztst
+++ b/Test/A02alias.ztst
@@ -67,7 +67,7 @@
fc -l -2' 2>/dev/null
0:Aliasing reserved tokens
>begin
->zsh: command not found: echoend
+>end
*>*4*{ begin
*>*5*{end
next prev parent reply other threads:[~2015-03-26 3:43 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-19 1:49 capturing output of !! not working Vin Shelton
2015-03-19 2:28 ` Bart Schaefer
2015-03-19 10:57 ` Peter Stephenson
2015-03-19 12:27 ` Vin Shelton
2015-03-19 12:53 ` Peter Stephenson
2015-03-20 10:57 ` Peter Stephenson
2015-03-20 16:04 ` Bart Schaefer
2015-03-22 18:35 ` Peter Stephenson
2015-03-22 19:18 ` Peter Stephenson
2015-03-22 23:22 ` Bart Schaefer
2015-03-23 21:34 ` Peter Stephenson
2015-03-24 0:54 ` Testing interactive features (Re: capturing output of !! not working) Bart Schaefer
2015-03-24 4:12 ` Bart Schaefer
2015-03-24 4:45 ` Bart Schaefer
2015-03-24 16:09 ` Bart Schaefer
2016-05-23 14:53 ` Mikael Magnusson
2015-03-25 15:48 ` PATCH: Removing aliases from history, 2015 style (was " Peter Stephenson
2015-03-25 17:57 ` PATCH: Removing aliases from history, 2015 style Peter Stephenson
2015-03-25 18:42 ` Mikael Magnusson
2015-03-27 10:06 ` Peter Stephenson
2015-03-27 15:25 ` Bart Schaefer
2015-03-27 15:41 ` Peter Stephenson
2015-03-27 17:17 ` Bart Schaefer
2015-03-27 17:47 ` Peter Stephenson
2015-03-29 18:38 ` Peter Stephenson
2015-03-25 18:58 ` Bart Schaefer
2015-03-25 19:40 ` PATCH: Removing aliases from history, 2015 style (was capturing output of !! not working) Bart Schaefer
2015-03-26 3:43 ` Bart Schaefer [this message]
2015-03-30 18:04 ` Word breaks around aliased tokens (was Re: PATCH: Removing aliases from history, 2015 style (was capturing output of !! not working)) Daniel Shahaf
2015-03-30 20:05 ` Mikael Magnusson
2015-03-30 18:08 ` Daniel Shahaf
2015-03-26 9:41 ` PATCH: Removing aliases from history, 2015 style (was capturing output of !! not working) Peter Stephenson
2015-03-26 15:22 ` 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=150325204305.ZM1653@torch.brasslantern.com \
--to=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).