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.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 18620 invoked from network); 2 Aug 2022 23:08:45 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 2 Aug 2022 23:08:45 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1659481725; b=a5OXoJLkNJIwPZr20rkMj3FKYgKPQsIZUgWX1yiWAfnOOnzG54LcnkkrnjjQnatmHI0vPzutAZ Zgt0rBTdOMAnLt2ukm62O5nwLk9h+vh4cHvBpvbluC5U5N6sVo51DwXTKesV6F1M40t7W4abOM VQyKSD4QlXEwqWjpGwFMPa7McsFsPbZqmbSpZA+xO29iP8ZQVxhrt798XxYJ+nu8fmH8db66ye ErbErlwoNzaxha7U/pXEtY/GYSxLosWxonhTHcp1HI7JgIS3NGojdahntkwQzp4nmGzpB5Xifh sBBW71ikh/62+mVdwwHyEQZi8GA/yUKcKRhNrM2NTGaIwA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ed1-f46.google.com) smtp.remote-ip=209.85.208.46; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1659481725; bh=M2N2+qIMeLcY76IVK094+R5sYvpqKBQBZsFNY9qAWcs=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=PJ+LqMsJZrSb/QwYO6EUZ+8flWEQWu6pMMvNeBXFOLO7TL3HjAriX3rVVVOP/b0XWaTpZuhwpD 1txgzNTXGaXoH0fQeloOTVKYWV2t2GpgAQj+nVlalGSo5IH+VlCb1JfUCZKNFJcQMre3EuWiaq Zd1ZyaLIO1mB5MkvQVMKRJBPgPPK0wT30Q2n/jcIQTT9lgSt/gxJEW3D2yo0irGy7krAf8uMZ4 zAfWc6sE/NkcB9NwfPfVPoxLx90GOjIqRP+QZiMBgLWc/Xcb5uVyWz2VOeo/AMs6aN2TMrP/Af YeXV4WlvhL1oc42y0SINMnQftkcZkCSThJY8GGmAeqQCVQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=nW608TBkHZBeV+C/Nfx05LGEqzqZAqSkvV+82jfLiAk=; b=DOPyyqFc/zw88zG/qke4uYTufC S04DBjNt3W4n2zwbvc5v/O6Jp0HJ+rY9WUJeTchjS9XNyT6Bxjo5sr7/qZ2V7ASY4Tk1DK0sL9HDm r0xXDed8u2nyKWdKrd7Gsg/WvNAOt+J6rAmVlYp36sqkXYLaNWfTEf12erSjZbXpGHJaVM7B2XQnN 3ca6s6IgxTOU9tRrOwykr30VaKztrUHy/E2d2dWL13EdWzO1DcL/l1DB6qaAaUsEr/5dIT4vwQvy0 Eatr+vFmn2+4eiR1KhLBe/R7YvR22/W+S9DNn7cgRuf4ZqJl9PpiKkug86/kgTNex21+4GWGaDma5 R550xvPQ==; Received: from authenticated user by zero.zsh.org with local id 1oJ10F-0002W1-JU; Tue, 02 Aug 2022 23:08:43 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ed1-f46.google.com) smtp.remote-ip=209.85.208.46; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-ed1-f46.google.com ([209.85.208.46]:40476) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1oJ0uo-00020M-VI; Tue, 02 Aug 2022 23:03:08 +0000 Received: by mail-ed1-f46.google.com with SMTP id f22so8405890edc.7 for ; Tue, 02 Aug 2022 16:03:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=nW608TBkHZBeV+C/Nfx05LGEqzqZAqSkvV+82jfLiAk=; b=Thu5Cu7JHRZUwt6z/t8I01O8kZcsiQkF59ZAJBI6s1dk4/ERAv/M0aHxbW5HvHau6x Lrb0OcTT7Yt/dQSO9QkCM/mKJI+ei/4g/jlBXvjU5xrehPThR+4Pahh8KSNiRIKhSiph sZBpbz4GH0G5ffupRspNmXQUyUkdJa8aqLJH7c+XIptXOIKxKxu5vYdAchNp2mRdQ8kQ ms1qvdwb2rjYkWv0w9Zh4Ua/ApOg4XGTS6qd0yUgMJwyVnBApKmafk+pa3b2sjfFYir+ lOeSvBASRplI8C/kXC72/PwEUny3OfsRCl8O7x7qM8azPO21Q+xFQF8UD93nm+vA/KQu gDTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=nW608TBkHZBeV+C/Nfx05LGEqzqZAqSkvV+82jfLiAk=; b=JY58erTILlHRL6znLDOdjxBQci7Fbsbc3cTKrPSxky58I9Uo+IAiK2+qJIxaPYfZHm km3Lmil7jlpN8KT5Xfeh7Ur6qX+sLIByR9+YScZAJj4IMt+Alx4vriBF5tAMHCe7Yi2r 8/+rZvziRuVUn039n2t3oBK6TnvtlzRrCZF6nmOmdYcbaAtqCleCPiaMYHBz3ZJhBzpW mTMgB7tEu86PtIeN+nM7OU8oSfSNM/MrjOvi+6Z2VK90FJcLKul7BvBARMN+ORZ/iPoK Y3C2oIKF6cUX2KHlPguPMBcQMTsPy6eQBnsDsQ9+jPXPT3FRGehQpPZ7qx1qsFJIIA61 kf9w== X-Gm-Message-State: AJIora+n6s501YQ7bt3LMf17/duLR8k8CTa5FXc2OAHjORSIXIGXctOj ROMmfO18Aii9t20AHTi5n8wgPeY5wL3RMLKU8qw= X-Google-Smtp-Source: AGRyM1s6gYVXq1u6KXv13NyDYQohsVPFYOwLaG8ck+avoj2bigPxvBKX0/p7X3nWsy0eNW94/2LXe/WNmboWSzH1Iwk= X-Received: by 2002:a05:6402:2b88:b0:43a:6c58:6c64 with SMTP id fj8-20020a0564022b8800b0043a6c586c64mr23477904edb.348.1659481386305; Tue, 02 Aug 2022 16:03:06 -0700 (PDT) MIME-Version: 1.0 References: <20220730010310.3383526-1-felipe.contreras@gmail.com> In-Reply-To: From: Felipe Contreras Date: Tue, 2 Aug 2022 18:02:55 -0500 Message-ID: Subject: Re: [PATCH 0/3] completion: make: various improvements To: Jun T Cc: zsh-workers@zsh.org Content-Type: text/plain; charset="UTF-8" X-Seq: 50440 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: On Tue, Aug 2, 2022 at 5:43 AM Jun T wrote: > > > 2022/07/30 10:03, Felipe Contreras wrote: > > > > While using `call-command` I found very serious issues, for starters > > trying to complete `make` in the zsh source code takes several minutes > > to complete. > > > > zstyle ':completion:*:make:*:targets' call-command true > [PATCH 1/3] > > At least in GNU make 4.3 the -n option is *not* respected and > > --always-make builds everything. > > This is indeed serious; just hitting for completion should > _never_ build anything. > > > Instead use a fake .DEFAULT target the way bash-completion does. > > If there is a target .DEFAULT in the user's Makefile, its recipe > is not executed (due to the -n option) but is echoed to stdout > (although the -s option is passed to make; I don't know why). > In the _worst_ case this may confuse make-parseDataBase(). > For example, if Makefile has the following two lines: > > .DEFAULT: > echo foo: bar > > then the output of 'make -nsp .DEFAULT' contains a line > > echo foo: bar > > and 'echo foo' will be offered as a possible target. > But I think we can ignore such (extremely) rare cases. That's right. I used .DEFAULT because that's what bash-completion does, but in their script they ignore everything before the Files section in the GNU make database output, so that's not a problem. We could alternatively use ":" which I believe is impossible to name a target that way. I've seen comments online using that, but I decided to go for something that was tried-and-true. I don't care either way. Anything that doesn't build all the targets is fine by me. > [PATCH 2/3] > > The make program does all the heavy lifting, there's no need to use a > > full parser. > > With this patch, if I type 'make ' in the zsh src directory, > it offers the following files as targets: > configure.ac, Makefile.in, aclocal.m4 etc. > These are not make targets, and in the output of 'make -nsp', > these are preceded by a line > > # Not a target: > > I think a (wrong) target after this line should be ignored. The current code which uses _make-parseMakefile already offers those targets anyway, so there is no change. Even if _make-parseDataBase was smarter and ignored those non-targets, configure.ac is a file and will still be completed by _files. Personally I don't like the current design, which is why I don't use the official make completion, and use my own instead [1]. I think only the targets returned by make should be completed (no _files), and anything with "# Not a target" be ignored. For that I use this script in my version: awk -v RS= -F: -v PRX="$1" '!match($1, "^" PFX) { next } $1 ~ /^[^#%]+$/ { print $1 }' This parses paragraph by paragraph, and since "# Not a target" is a paragraph which starts with a comment, it's ignored. I'm fine implementing something like that in _make-parseDataBase, but that would be a new feature, and anyway I don't use that code. I sent these patches not because I use them, but because while doing tests I found these low hanging fruit. I believe these can be applied as-is, with further improvements later on (by somebody else). They are still an improvement from the current situation by orders of magnitude: from several minutes to milliseconds. Cheers. [1] https://github.com/felipec/dotfiles/blob/master/.zsh/_make -- Felipe Contreras