From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 28842 invoked from network); 14 Sep 2020 20:33:10 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 14 Sep 2020 20:33:10 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1600115590; b=oAb0q97xC7ncXivBPPgrKlAhQdlk0dEOHO+3INhqWuiufcLObX20VriYFnXsAbva7J6tYPxDLq FbiW6lt4Ilfmvi2u5cUzCYcxWuJn+r/fSR0a3qU9ihP0oWFHfiInQZinlzVAn+HdIEzHdZGVJd yUHE7TVK5rK44dVU5kQqUGLRjBGUi5azgVz3HerPtVovftXSeigscCqWY7O8GK3oh2Nax289jq p8+JWf/VozeU6K2JahjWW1BUMNu0znCZDjwcXyDFofjZ5t0eClYFsisQ4rix51/ue/ob/tvigL F6Kn0wj5Tqjsq5oiVIZb1DA+DmM8PdWSUSEyMhGYH3M0HA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-oo1-f51.google.com) smtp.remote-ip=209.85.161.51; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1600115590; bh=dXvpVk8bY3snavSpUaA6d6Je87Unsbn5Y4McuIyXUQE=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=ATb7VSFlqjKlHPfRAow0WiKYDjcRoqR49PBLEYOhUSC6wyLBNZfzJEqi8/jblhbZB3nj24bDvm SNS+HiFcjBec+LNTv5VCW29IDyii3c/TgrYg9xH/3H9XtC+JwNHqWlnNI4TGqtz4D/UvhZvkE7 ImOzQI3rEaD4MvQform9bRgfoA63x9CgdjOpOM/cATX7k3hQlxXDtv4Ys1MJgsEVPJEGsML55D JFebOjib7dolxBzydlJ6sqmCGHO6WmvH6zxIyb1c2/A3Q24FrO3eTxuI5/CcCgsPWIc+VMPJBT ++VtovrbOm+66ZTqbS86ec15D+AAcEQ1yUiubJryRtovPA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=0itA7p3YAOrOsUaG8/vZmo0E4EA0ru9I+57mANSkPIM=; b=tKdjbO6uiR8+xPESfBJ+2cDsZH yHNp40TC1smcONDKad1OkafE88okX5LusoDAnJaY/ZetlX7CvfLzh6D0nuhz4glANADS57RdoHjGc A/rFIgwh3lJQNHKX5gjpUFWaCDtWjSIXkexDI8o6+EStlvryFtNOxYpEN5HYyKDGNVpHxshToxOzC NJjLkG+x5a4k5JZm9WOIAj8iS0PWmk1ph3Fkmr4e3wprEcxto6Gby0TzyoKAB8JqI56BNsrd9NmEq KQKkksgRuaTBayFu0gqDtD7L6CDZdZOGzyHyNJr6SaCmOunQO/pcWsXGo/sM0ZQzQV7pNX/DrSkge T1I5p06g==; Received: from authenticated user by zero.zsh.org with local id 1kHv9u-0009TN-Sd; Mon, 14 Sep 2020 20:33:06 +0000 Authentication-Results: zsh.org; iprev=pass (mail-oo1-f51.google.com) smtp.remote-ip=209.85.161.51; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-oo1-f51.google.com ([209.85.161.51]:39224) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kHv9c-0009KF-BT; Mon, 14 Sep 2020 20:32:49 +0000 Received: by mail-oo1-f51.google.com with SMTP id s17so193956ooe.6 for ; Mon, 14 Sep 2020 13:32:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=0itA7p3YAOrOsUaG8/vZmo0E4EA0ru9I+57mANSkPIM=; b=EMuoyDG4wywGGnjpvAiB673Ko6TpanNrcuSu3PDqIaBR3Uok1M2OX8kfTJxucszMge JwVJ4Y1K9qlZNwAUjHHW4QEzQHy1OouxokrIXZKofizMe2Xu6uaMVGl5LQS4wNvqYoRl PKEqBPima+Th1WSNtnnRaIwbTCjul9ivffRVqfgtqsBD0VXfHZzZM95RJ0uPO1xMAg61 x6n/QSD1iJ8WbgoJ8IF5Zpa4LLcyzFobzUFfNmmCL7NU4aGFKxv8mWThi8lDEjAD6naj FcqCgt+rEj2SEi5SYa3l5ddYVEjzJAEuGC7Ok5pYiTnyi7ml/mXNzjX8pU+2nQc3XtX5 KAoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=0itA7p3YAOrOsUaG8/vZmo0E4EA0ru9I+57mANSkPIM=; b=FTnCGpSqWqGS9Y2axMv1+lFZkGSdUk5ROHbraQzP7tYKkgGBwzfB3dZ2A4vZneBidI 2bIpQDtpFiPA2S8/XcwHi8TTueXNpBM7LSRzjj2artTAPo0n9w1HePNrvKLthj0K+qGX nmkntFyjcCvM0IV0JggMYQOmlCgpvLKKskTLfVSxRTRo1hWbUm9ttL8+X752PwrwAc+H h9zGicbSvNxH0yvzrB13eANQU9yShIN2UqsXm2s4juUuX90IIBe59uhrndxHloyzROwe m6/coAMi2RrOWl1SAavbkQPHIUek9bKChDKvlT99LVHCJGVBMCnS2zvWmb5+G+PsaVUr z4dw== X-Gm-Message-State: AOAM531gUZ2BRZpSaOmkjt3+naYITRq1GOpeDMv8onoYlFbjRPWICK0n hhHMWrkkCeD/x4132vkuj28jbs7qM32RqKpajyRWPQ== X-Google-Smtp-Source: ABdhPJzd9UpqrRlIUC2nvynYDWvGCZvkG1ePdc/MHY1ZWxGBzRv9hDgBu3c5gpVcHDjk16hxEnYzZdGxYdaSK1sd6dQ= X-Received: by 2002:a4a:9bde:: with SMTP id b30mr11583148ook.82.1600115566353; Mon, 14 Sep 2020 13:32:46 -0700 (PDT) MIME-Version: 1.0 References: <20200913222122.GA4031@andrew.cmu.edu> In-Reply-To: <20200913222122.GA4031@andrew.cmu.edu> From: Bart Schaefer Date: Mon, 14 Sep 2020 13:32:35 -0700 Message-ID: Subject: Re: Use external tool if there are a large number of completions To: gi1242+zsh@gmail.com, "zsh-workers@zsh.org" Content-Type: text/plain; charset="UTF-8" X-Seq: 47389 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: On Sun, Sep 13, 2020 at 3:21 PM wrote: > > I was wondering if it's possible to use an external tool if there are > more than a certain number of completions. This is not directly possible for a few reasons. For one, the strings passed to the compadd builtin are allowed to be (and usually are) potential rather than actual matches, which the completion internals then filter down to the actual completions based on comparison to the command line. For another, once potential matches are collected via compadd there is (at least at present) no way other than by that comparison to remove non-matches from the set. That said ... I can think of a possible way to do it. Adopt a scheme similar to the one used by the _approximate completer, which creates a function wrapper around the compadd builtin to intercept the potential matches and apply corrections. I'm not going to attempt to write this, but the idea would be: 1) Build a wrapper around compadd that interposes the "-A array" option (via "builtin compadd") to collect the results in an array instead of adding them to the internal data structures. 2) In a comppostfuncs function, remove the wrapper and invoke your external command on the contents of that array. 3) When you have the result of the external command, compadd that as the single possible completion. It will require some considerable care for this to interact correctly with _approximate and _complete_help, if not some other completers. It will also mess up things like groups and explanations. You're likely to be better off with Oliver's suggestion of the complist module, or create a separate keybinding to delegate the entire process to rofi and when you encounter the "do you wish to see all 3069 possibilities?" prompt, say no and type your rofi binding.