From: Bart Schaefer <schaefer@brasslantern.com>
To: "zsh-users@zsh.org" <zsh-users@zsh.org>
Subject: Re: compinit causes completion to fail?
Date: Mon, 30 Apr 2012 07:37:25 -0700 [thread overview]
Message-ID: <120430073725.ZM9968@torch.brasslantern.com> (raw)
In-Reply-To: <-840557096841281898@unknownmsgid>
On Apr 30, 1:04am, TJ Luoma wrote:
}
} So it went like this:
}
} * uncomment last file-to-source from within .zshenv
} * start a new shell
} * test to see if command and 'cd' completion worked
} * exit shell (deleting ~/.zcompdump)
}
} * uncomment last-1 file-to-source from within .zshenv
} * start a new shell
} * test to see if command and 'cd' completion worked
} * exit shell (deleting ~/.zcompdump)
}
} and so on.
Future hint: Uncomment half the lines, then try. If it works, leave
those uncommented and uncomment half the remaining lines. If it fails,
re-comment half way back to the last place it succeeded. Repeat.
(Binary search usually takes fewer comparisons than linear search.)
} Everything worked fine UNTIL I put the IFS line in at the top of the
} .zshenv. When I did that, completion broke. When I took it out,
} completion worked.
Did some quick comparison of the output of "setopt xtrace" with IFS=$'\n'
vs. the default.
I wrote:
> IFS shouldn't affect parsing of scripts etc., it should only affect
> "read" and parameter substitution.
Turns out compinit uses "read" to parse #compdef lines while walking
$fpath. When IFS=$'\n' the entire line is in the first element of
the array, so compdef is run with the wrong arguments. Then compdef
itself uses "read" to parse bindkey output, etc.
I'm not sure if it's worthwhile to fix this as having IFS=$'\n' during
a whole interactive shell session is likely to cause all sorts of havoc,
but here's a patch anyway.
Index: Completion/compinit
===================================================================
retrieving revision 1.19
diff -u -r1.19 compinit
--- Completion/compinit 20 Dec 2011 17:13:37 -0000 1.19
+++ Completion/compinit 30 Apr 2012 14:28:21 -0000
@@ -326,7 +326,7 @@
[[ $2 = .menu-select ]] && zmodload -i zsh/complist
zle -C "$1" "$2" "$func"
if [[ -n $new ]]; then
- bindkey "$3" | read -A opt
+ bindkey "$3" | IFS=$' \t' read -A opt
[[ $opt[-1] = undefined-key ]] && bindkey "$3" "$1"
else
bindkey "$3" "$1"
@@ -353,7 +353,7 @@
# And bind the keys...
for i; do
if [[ -n $new ]]; then
- bindkey "$i" | read -A opt
+ bindkey "$i" | IFS=$' \t' read -A opt
[[ $opt[-1] = undefined-key ]] || continue
fi
bindkey "$i" "$func"
@@ -469,7 +469,7 @@
if [[ -f "$_comp_dumpfile" ]]; then
if [[ -n "$_i_check" ]]; then
- read -rA _i_line < "$_comp_dumpfile"
+ IFS=$' \t' read -rA _i_line < "$_comp_dumpfile"
if [[ _i_autodump -eq 1 && $_i_line[2] -eq $#_i_files &&
$ZSH_VERSION = $_i_line[4] ]]
then
@@ -491,7 +491,7 @@
_i_name="${_i_file:t}"
(( $+_i_test[$_i_name] + $_i_wfiles[(I)$_i_file] )) && continue
_i_test[$_i_name]=yes
- read -rA _i_line < $_i_file
+ IFS=$' \t' read -rA _i_line < $_i_file
_i_tag=$_i_line[1]
shift _i_line
case $_i_tag in
@@ -527,7 +527,7 @@
# If the default completer set includes _expand, and tab is bound
# to expand-or-complete, rebind it to complete-word instead.
-bindkey '^i' | read -A _i_line
+bindkey '^i' | IFS=$' \t' read -A _i_line
if [[ ${_i_line[2]} = expand-or-complete ]] &&
zstyle -a ':completion:' completer _i_line &&
(( ${_i_line[(i)_expand]} <= ${#_i_line} )); then
--
Barton E. Schaefer
next prev parent reply other threads:[~2012-04-30 14:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-29 5:21 TJ Luoma
2012-04-29 6:57 ` TJ Luoma
2012-04-29 18:29 ` Peter Stephenson
2012-04-30 0:24 ` Bart Schaefer
2012-04-30 5:04 ` TJ Luoma
2012-04-30 14:37 ` Bart Schaefer [this message]
2012-04-30 14:50 ` TJ Luoma
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=120430073725.ZM9968@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).