* (Fwd) Re: compctl -y problem.
@ 2001-05-25 16:56 Bart Schaefer
0 siblings, 0 replies; only message in thread
From: Bart Schaefer @ 2001-05-25 16:56 UTC (permalink / raw)
To: zsh-users
Sorry about the duplication to zsh-workers recipients ... I meant to change
the destination address but then clicked Send too quickly.
--- Forwarded mail from <schaefer@candle.brasslantern.com> ("Bart Schaefer")
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
Date: Fri, 25 May 2001 16:35:08 +0000
To: zsh-workers@sunsite.dk
Subject: Re: compctl -y problem.
Cc: Cesar Crusius <crusius@barcelonadesign.com>
(Part of this thread went to zsh-workers ... returning now to zsh-users
with a workaround)
On May 25, 3:11pm, Bart Schaefer wrote:
}
} I know Sven won't be thrilled about being asked to fix anything in the
} old compctl code ... perhaps we should just remove the `-y' option, as
} it's new since 3.0 anyway, and document the correct way to achieve the
} same effect by using the new completion system (which, incidentally, I
} don't know how to do ... `compadd -d' doesn't quite cut it).
On further reading of the compadd doc, `compadd -ld ...' appears to be
the thing to do, though it's a bit convoluted.
autoload -U compinit
compinit
function _aecd {
local change_descriptions reply
# Force change_descriptions to be a one-element array
change_descriptions=("$(aereport changes -unf | grep -v completed)")
# The name "reply" is not special here, I just happened to use it
reply=($(aereport changes -terse | grep -v completed | sed -e 's/ .*$//'))
# Display the change_descriptions in place of the first completion
compadd -ld change_descriptions $reply[1]
# Add the rest of the completions, but don't display them in the list
compadd -na 'reply[2,-1]'
# Force the list to appear so the descriptions are visible
compstate[list]='list force'
}
compdef _aecd aecd
It does appear that "compadd -d" still produces a sub-optimal display in
this case if there are any lines in $change_descriptions that have exactly
$COLUMNS characters; but it properly returns the cursor to the right spot
even so.
I don't know what the output of `aereport changes` looks like, so it may
be that there's a simpler solution. For example, if the same number of
lines will be returned by `aereport changes -unf` and `... -terse`, this
will work:
function _aecd {
local change_descriptions reply
change_descriptions=(${(f)"$(aereport changes -unf | grep -v completed)"})
reply=($(aereport changes -terse | grep -v completed | sed -e 's/ .*$//'))
compadd -ld change_descriptions -a reply
compstate[list]='list force'
}
You may also wish to drop that compstate[list] assignment and instead use
the force-list style to control it:
zstyle ':completion:*:aecd' force-list always
See the manual for more.
--
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
---End of forwarded mail from <schaefer@candle.brasslantern.com> ("Bart Schaefer")
--
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2001-05-25 16:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-25 16:56 (Fwd) Re: compctl -y problem Bart Schaefer
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).