zsh-users
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: Felix Rosencrantz <f_rosencrantz@yahoo.com>,
	zsh-users <zsh-users@sunsite.auc.dk>
Subject: Re: Using buffer for history-incremental-search-backward
Date: Fri, 6 Jul 2001 08:24:47 +0000	[thread overview]
Message-ID: <1010706082447.ZM11356@candle.brasslantern.com> (raw)
In-Reply-To: <20010706063230.6788.qmail@web10402.mail.yahoo.com>

On Jul 5, 11:32pm, Felix Rosencrantz wrote:
} Subject: Re: Using buffer for history-incremental-search-backward
}
} I was sort of under the impression that the completion system could
} only complete a single word at time, and not sets of words, like a
} previous command line would be.

It is pretty much oriented around completing the current single word.
However, if that word happens to be the first one on the line (or the
first one in a "command position") then you can safely use that word
as a search key to complete entire commands.  You just need to use the
-U option of compadd to cause that word to be erased and replaced by
the command that was looked up.

For example, this may be enough for your w2k F7 key widget; I confess
not to know how anything on w2k really works:

    #compdef -k menu-select \e[18~
    (( CURRENT == 1 && $#words == 1 )) &&
    compadd -QU "${(@)history[(R)*$words[CURRENT]*]}"

You can try it without the `&& $#words == 1' part, too, but note that
it only completes when the cursor is in the first word.

One problem with the above is that it bypasses the completion function
system, so you don't get the benefit of all the context analysis that
goes on in _main_complete et al.  For that you need to tie in:

    #compdef -k menu-select \e[18~
    # The following depends on the FUNCTION_ARGZERO option.
    # Use the file base name instead of $0 if that's not set.
    if [[ $_comps[-command-] != $0 ]]; then
        # We've not been called before, so:
	#  set a trap to restore state safely ...
	trap "_comps[-command-]='$_comps[-command-]'" EXIT INT
	#  make ourself be called for command words ...
	_comps[-command-]=$0
	#  and then call the regular completion system.
	_main_complete
    else
	# The completion system has called us back; add matches.
	compadd -QU "${(@)history[(R)*$words[CURRENT]*]}"
    fi

} But what if I had a command that only has long options that I
} wanted to complete all at once as a group ( for example for GNU tar
} "--extract --gzip --file archive" , "--create --gzip --file archive",
} etc.) Can the completion system handle that?

As long as what you need to replace is only one word, the thing that
replaces it can have more than one word.

} Thanks very much, Bart, for your help with the h-i-s-b, it works just
} like I want.

You're welcome!

-- 
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   


  reply	other threads:[~2001-07-06  8:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-06  6:32 Felix Rosencrantz
2001-07-06  8:24 ` Bart Schaefer [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-07-03  7:30 Felix Rosencrantz
2001-07-03  8:34 ` Bart Schaefer
2001-07-04  6:14   ` Felix Rosencrantz
2001-07-04 14:39     ` 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=1010706082447.ZM11356@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --cc=f_rosencrantz@yahoo.com \
    --cc=zsh-users@sunsite.auc.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).