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 17234 invoked from network); 4 Aug 2022 09:33:40 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 4 Aug 2022 09:33:40 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1659605620; b=sqNAG6bnwml2Fziu7/qwdQoCWYI57C9dr5lzYJfsj+37PKO2D80gMJW/EbqWSBi2E+6P3bj3EH Mp5CAOwnLYNHXMU05y7tFxS5qlBGv3D66BBZpeET0cHG5NZuAP8t7FfkKKAO0kRWcmlioIUaw2 0nwgWOgypl9WmTe4af3W+TrfuUyJWpGll/ypEzXf8Rfhs+ess9AI6oXM8MErYIZMdFnhOueqi3 Yh8bIf5hb6ycYL6b1A9hFYRz1t/u6gVFGCvtVasTexYSUdjSIHfAqFe30wAcxqnBNMh/kmynZX 1ru3mYZel/a2N++fbfLpucfL2sxP7h/UJmpTB020DVue3A==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (snd01012-bg.im.kddi.ne.jp) smtp.remote-ip=27.86.113.28; dmarc=none header.from=kba.biglobe.ne.jp; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1659605620; bh=Poyl4Ar4DM6VZYqW/jkP8wTt+kxFEC8bDMT+9Dvqeww=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Message-ID:In-Reply-To:To:References:Date:Subject: MIME-Version:Content-Transfer-Encoding:Content-Type:From:DKIM-Signature; b=V9jjywunhtYLQmR2z7bfcBBlcsWPRoVE5tl8oWMXQ9Bd1it88j0/5KYABZfxUcOCsgOJM8PX+d B5oWNjmlmUhME0MLuxZK8towHEHEW56pSN+IixPWiW6D67G012lM/ZYywAs104rSJgh0clhQPC xX/zPCL8gwGRhov7IRZOb45w8B/NyvIMRdwvwLhWGytIdKukaX124Fo9uxo+AIqOEFCsjDUWXU T2f9z8nKnIkdKxFArjKtsKPDLSnxkXMx0tXdlNckE3NbWz7IY+XOsolL6G1NsjDhhCVAuYkRUR IrofMYMkYQHcrjpoTnDcIjJHbk0oCZGHlyMY4hXvnbYOIA==; 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:Message-Id:In-Reply-To:To:References: Date:Subject:Mime-Version:Content-Transfer-Encoding:Content-Type:From: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=jAebAWJfMpvfs9F3jZOPBHDBgB0rYF6LrvbQnf+t2Vo=; b=UDTS49P4kM7wB7kW8rEauA9EKu 8LjG7CiouRM0XNc+/7Ak+4Jci3sfM2uAd96PPT/58MIo6i7YPEb5vCaySEaB3jOX5zzJ/P3kKDgGq T5FXk4dy+Jiemf8Dm4poBRwb2hd7d3aUDnsGCO1bk75O/kwaFCo+Ue2BRc4JnYKrY8Fi4ayxet/Qn DlpIP8bXEU3sTjrFVFOJvoy6z9wnBLSxzcgEyE0N/ZR3NOjDuGxL9lPNNfNh8T7K1FJwNzPhuBqvy lPGHW02qNwwrWxD+JmLuYbXLufqMptYe6TjYqfJhvE2DqfeHjSfmU5C7Cq/v1oml7g1i9x9whtQeq PU6h4rvQ==; Received: from authenticated user by zero.zsh.org with local id 1oJXEZ-000ECl-Uw; Thu, 04 Aug 2022 09:33:39 +0000 Authentication-Results: zsh.org; iprev=pass (snd01012-bg.im.kddi.ne.jp) smtp.remote-ip=27.86.113.28; dmarc=none header.from=kba.biglobe.ne.jp; arc=none Received: from snd01012-bg.im.kddi.ne.jp ([27.86.113.28]:55521 helo=dfmta1009.biglobe.ne.jp) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1oJXEF-000DrQ-52; Thu, 04 Aug 2022 09:33:19 +0000 Received: from mail.biglobe.ne.jp by omta1009.biglobe.ne.jp with ESMTP id <20220804093313670.MWIQ.13671.mail.biglobe.ne.jp@biglobe.ne.jp> for ; Thu, 4 Aug 2022 18:33:13 +0900 From: Jun T Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.21\)) Subject: Re: [PATCH 0/3] completion: make: various improvements Date: Thu, 4 Aug 2022 18:33:13 +0900 References: <20220730010310.3383526-1-felipe.contreras@gmail.com> To: zsh-workers@zsh.org In-Reply-To: Message-Id: <1D49B7B5-5B13-4700-93EF-6818676BF846@kba.biglobe.ne.jp> X-Mailer: Apple Mail (2.3445.104.21) X-Biglobe-Sender: takimoto-j@kba.biglobe.ne.jp X-Seq: 50444 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: As pointed out by Felipe Contreras, the biggest problem with the current _make (with call-cammand on) is that it actually runs make to build all. This is serious and need be fixed. I will soon push slightly modified = patch (see the end of this post) unless any problem is found. > 2022/08/03 23:36, Felipe Contreras wrote: >=20 > On Wed, Aug 3, 2022 at 3:54 AM Jun T = wrote: >>=20 >> If 'call-command' style is set to false, then these targets are not >> offered (as a possible target). >=20 > But if you set it to true they are. >=20 > We are talking about the *current code*. The current code already has > this behavior. # I was thinking we were talking about how we can improve the # current code. Without your patch, if call-command is on, 'make ' at the top level of the zsh source tree gives, after a very long wait, huge number of possible targets (a few hundreds or more?), but most of them are not valid targets. With your patch it immediately gives about 60 candidates. (Most of them are valid, but they still include configure.ac.) So I thought (probably mistakenly) that part of the objectives of the patch was to offer only valid targets. But anyway, I think it is better to filter out invalid targets if it is easy to do so. >> zstyle ':completion:*:make:*:' tag-order 'targets variables' >=20 > Sure, in that case those files won't be listed initially, but they > still will be completed. I think files are completed only if there is no matching targets. This is enough for me, but maybe not for everyone. The patch below is basically [1/3]+[2/3], with a few additions: (1) In _make-parseDataBase(), filter out targets following the line '# Not a target', and variables following '# environment'. I think not offering environment variables is OK, but not sure everyone agrees with this. (2) Use make option -q instead of -s (as in your awk-version). (3) add options -C and -S to _arguments. (4) Do not call _make-parse{Makefile,DataBase}() when completing options for 'make -'. # As you write, this is much slower than your awk-version. diff --git a/Completion/Unix/Command/_make = b/Completion/Unix/Command/_make index ae91440f0..510368e8b 100644 --- a/Completion/Unix/Command/_make +++ b/Completion/Unix/Command/_make @@ -118,10 +118,34 @@ _make-parseMakefile () { done } =20 +_make-parseDataBase () { + local input var TAB=3D$'\t' IFS=3D skip=3D0 + + while read input + do + if [[ $skip =3D 1 ]]; then + skip=3D0 + continue + fi + case "$input " in + (\# Not a target*|\# environment*) + skip=3D1 # skip next line + ;; + ([[:alnum:]][[:alnum:]_]#[" "$TAB]#(\?|:|::|)=3D*) + var=3D${input%%[ $TAB]#(\?|:|::|)=3D*} + VARIABLES[$var]=3D1 + ;; + ([[*?[:alnum:]$][^$TAB:=3D%]#:[^=3D]*) + TARGETS+=3D( ${input%%:*} ) + ;; + esac + done +} + _make() { =20 local prev=3D"$words[CURRENT-1]" file expl tmp is_gnu incl match = basedir nul=3D$'\0' - local context state state_descr line + local curcontext=3D$curcontext state state_descr line local -a option_specs local -A VARIABLES VAR_ARGS opt_args local -aU TARGETS keys @@ -185,7 +209,7 @@ _make() { ) fi =20 - _arguments -s $option_specs \ + _arguments -C -S -s $option_specs \ '*:make target:->target' && ret=3D0 =20 [[ $state =3D cdir ]] && cdir=3D-2 @@ -214,6 +238,10 @@ _make() { ;; =20 (target) + # target name starting with '-' is allowed only after '--' + if [[ $words[CURRENT] =3D -* ]] && (( ${words[(i)--]} > CURRENT )); = then + return ret + fi file=3D${(v)opt_args[(I)(-f|--file|--makefile)]} if [[ -n $file ]] then @@ -239,7 +267,7 @@ _make() { if [[ $is_gnu =3D=3D gnu ]]=20 then if zstyle -t ":completion:${curcontext}:targets" call-command; = then - _make-parseMakefile < <(_call_program targets "$words[1]" = -nsp --no-print-directory -f "$file" --always-make 2> /dev/null) + _make-parseDataBase < <(_call_program targets "$words[1]" = -nqp --no-print-directory -f "$file" .DEFAULT 2> /dev/null) else _make-parseMakefile < $file fi