From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: (qmail 28200 invoked from network); 4 May 2020 17:14:59 -0000 Received-SPF: pass (primenet.com.au: domain of zsh.org designates 203.24.36.2 as permitted sender) receiver=inbox.vuxu.org; client-ip=203.24.36.2 envelope-from= Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 4 May 2020 17:14:59 -0000 Received: (qmail 8037 invoked by alias); 4 May 2020 17:14:44 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 24818 Received: (qmail 1403 invoked by uid 1010); 4 May 2020 17:14:44 -0000 X-Qmail-Scanner-Diagnostics: from mail-il1-f173.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.2/25801. spamassassin: 3.4.4. Clear:RC:0(209.85.166.173):SA:0(-1.7/5.0):. Processed in 3.671847 secs); 04 May 2020 17:14:44 -0000 X-Envelope-From: dan1994@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.166.173 as permitted sender) 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=/AJVZCUCkq8cY3TOaz6fmbXaVXhfqXLy8LE4dhWApgU=; b=aT4VtCwr5fEpqtXbGb5QvHSYTBr2H3Cs6n8akR0M8asTR1TMLKA2/2LuC8860dwQ6X UzPzLPLVSXSW/3vO2Ho6Fjk8/VQp7u4nKIy/7IXkjjN4OGFr5vNKeEa5CLsPam0wbjHQ nfHrnaAMAcFzNC01a5mXbuRmpGpySmaqiLPcgOOeGwY09UmH89QpEbNXgEtj5QTCCuYp Aj7cUe59TjaJRXkunTPU5n1yZnolcAjFggWWPj9aXuf+Drxltb045jE7Xu9VPdY5BeaZ 1C8GDPrfcSW31cSyqZxrVmdn9l8rsskAtWsY7izA6JhK24zETKxYe3IssoHqt8ewMrO6 S9FQ== X-Gm-Message-State: AGi0Pua2GvIOIcwrGLzQ7DDsqhXjtoZMp6dNcKVz7Jq8imBnroPRJyp+ mnQ4r59tQN50f10z+tl6R2G+CciNUOG4BtlWJPKOYLJ1 X-Google-Smtp-Source: APiQypLy9C9++/058dEG8QcT9IlwFeUtCKBW9giHs5tbU6dW0ZNTu92aUg0rN/IvqSDJL9HrY0blumdmTBL/ApuMkQk= X-Received: by 2002:a92:bf06:: with SMTP id z6mr16014080ilh.191.1588612446807; Mon, 04 May 2020 10:14:06 -0700 (PDT) MIME-Version: 1.0 References: <20200503165802.6540ad48@tarpaulin.shahaf.local2> <20200504131830.3572e317@tarpaulin.shahaf.local2> In-Reply-To: <20200504131830.3572e317@tarpaulin.shahaf.local2> From: Dan Arad Date: Mon, 4 May 2020 20:13:51 +0300 Message-ID: Subject: Fwd: Help Request/Bug Report: comparguments causes _arguments to fail in certain cases To: zsh-users@zsh.org Content-Type: multipart/alternative; boundary="00000000000093ed7105a4d5a801" --00000000000093ed7105a4d5a801 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi there, I'm forwarding a conversation I started by mistake on the wrong mailing list (Sorry, I'm new to the concept). Any help on the topic would be greatly appreciated! Cheers, Dan ---------- Forwarded message --------- From: Daniel Shahaf Date: Mon, May 4, 2020 at 4:18 PM Subject: Re: Help Request/Bug Report: comparguments causes _arguments to fail in certain cases To: Dan Arad Good morning Dan, Would you re-send that to the mailing list, please? You sent it only to me. Thanks for tracking down the rich text issue =E2=80=94 it's much easier to = talk this way. =E2=98=BA Cheers, Daniel Dan Arad wrote on Mon, 04 May 2020 09:46 +0300: > First of all, thank you for your swift response! > > For future reference, you should have addressed your question to > > zsh-users@, as the answer to it doesn't involve a change to zsh itself. > > > Noted! I searched online for the zsh bug tracker, and stumbled into this > mail address. > > Furthermore, it would be helpful to configure your email client to > > generate a text/plain part that doesn't surround every line by asterisk= s > > and add spurious blank lines in code blocks. > > > > I was trying to copy paste the stack overflow entry through Word, so it > won't keep the web formatting, and that's probably why this happened... > > Well, for starters, if you =C2=ABshift words=C2=BB, you should decrement = CURRENT > > as well. > > > > However, _python uses the =C2=AB*::=E2=80=A6=C2=BB form of an _argument= s optspec, > > which should take care of $words/$NUMERIC for you. I assume the reason > > it didn't is that you used =C2=ABcompdef -p=C2=BB. Try -P instead? If= I'm not > > mistaken, that would also handle =C2=ABpython =E2=80=A6 script.py = =C2=BB for you > > (where the ellipsis stands for python's --options). > > > I tested the 4 possible options, and found that switching -p with -P > doesn't change anything, but shifting words and decrementing CURRENT works! > But... I feel like it's a hack I'm not supposed to do (correct me if I'm > wrong). > > Your second paragraph made me look back at a previous solution (that > doesn't work). I would be glad to discuss it if you have the time. > > I was using `#compdef -p *.py` before, and what I saw was that _python wa= s > being called before my script, and that my script didn't work well. What > was actually happening was that _python was shifting words before I was > being called, and that interfered with the logic of my script. > > In order to generate completions I rely on running what is currently > present in the command line, and so this may cause my script to generate no > completions (i.e. `python ps.py` becomes `ps.py` which can't be run, and > `python ./ps.py` becomes `./ps.py` which may or may not be run depending on > file permissions). > > I now tried using the BUFFER variable instead of words (since it remains > unchanged), but found that it also has caveats: The BUFFER variable > contains the raw value of the line, whereas the words array contains the > words after expansions (I think that's the right term). > To demonstrate this I tried running again completion for `python ps,py` > with `#compdef -P *`, and printing out BUFFER and words. The debug log (and > my terminal) showed the following: > First of all _python was called and dispatched my script which printed > `BUFFER=3Dpython ps.py` and `words=3Dps.py`. > After _python returned, my script was invoked again and printed > `BUFFER=3Dpython ps.py` and `words=3Dpython*3* ps.py` (note the 3). > > I do think the right solution is to be dispatched by _python with `#compdef > -P *.py`, but to be able to run I need the words array as seen by _python > or a to understand how BUFFER can be expanded/converted to its correct form. > If you have any input on this, I would very much appreciate it. > > Best Regards, > Dan > > > On Sun, May 3, 2020 at 7:58 PM Daniel Shahaf wrote: > > > Dan Arad wrote on Sun, 03 May 2020 10:40 +0300: > > > Hi there, > > > > > > From what I understand, bug reports should be mailed here. If I'm wrong > > I'd > > > be happy to be redirected to the correct medium. > > > > For future reference, you should have addressed your question to > > zsh-users@, as the answer to it doesn't involve a change to zsh itself. > > Furthermore, it would be helpful to configure your email client to > > generate a text/plain part that doesn't surround every line by asterisk= s > > and add spurious blank lines in code blocks. > > > > > What I want to report is probably not a bug, and stems from my > > > misunderstanding of compsys. Any help will be greatly appreciated. > > > The following is a copy paste of the a this question > > > < > > https://stackoverflow.com/questions/61560687/comparguments-causes-arguments= -to-fail-in-certain-cases > > > > > > I asked on stack overflow: > > > > > > > Thanks for the cross-reference. > > > > > *1. The script is invoked directly (e.g. ~/script.py)* > > > > > > *2. The script is invoked through python (e.g. python script.py)* > > > > > > *3. The script is invoked as a python module (e.g. python -m script)* > > > > > > > > > *I have so far managed to successfully handle the first case, but the > > > second case fails to retrieve any completions. Using zsh completion debug > > > log I was able to see where things went wrong:* > > =E2=8B=AE > > > *EDIT:* > > > > > > *In order to temporarily bypass the problem I tried adding a shift words > > > before calling _arguments. This caused comparguments to succeed (!), but > > > still causes _arguments to fail with a no arguments message later on.= * > > > > > > *I added the log for this case to the gist linked above.* > > > > Well, for starters, if you =C2=ABshift words=C2=BB, you should decremen= t CURRENT > > as well. > > > > However, _python uses the =C2=AB*::=E2=80=A6=C2=BB form of an _argument= s optspec, > > which should take care of $words/$NUMERIC for you. I assume the reason > > it didn't is that you used =C2=ABcompdef -p=C2=BB. Try -P instead? If= I'm not > > mistaken, that would also handle =C2=ABpython =E2=80=A6 script.py = =C2=BB for you > > (where the ellipsis stands for python's --options). > > > > Cheers, > > > > Daniel > > > > --=20 Dan Arad dan1994@gmail.com --00000000000093ed7105a4d5a801--