From: Aurélien <orel_jf@yahoo.fr>
To: Daniel Shahaf <d.s@daniel.shahaf.name>, dana <dana@dana.is>
Cc: zsh-users <zsh-workers@zsh.org>
Subject: Re: help for writing GNU stow completion
Date: Tue, 20 Aug 2019 19:45:47 +0200 [thread overview]
Message-ID: <558a3ff8-d6f1-9ab0-3387-a17ca5e0e75b@yahoo.fr> (raw)
In-Reply-To: <0618d7fc-5334-4e51-829a-8684a81744c1@www.fastmail.com>
Le 17/08/2019 ?? 19:53, Daniel Shahaf a ??crit??:
> [moving to -workers@ since it's about an outstanding PR]
>
> Aur??lien wrote on Sat, 17 Aug 2019 07:51 +00:00:
>> local stow_dir
>> local -a stow_pkg_list
>>
>> eval set -A stow_dir $1
>> [[ -n $stow_dir ]] && stow_pkg_list=( $stow_dir/*(-/N:t) )
>>
>> if [[ ${#stow_pkg_list} -gt 0 ]]; then
>> _values -C "packages from $stow_dir" ${stow_pkg_list[@]}
>> else
>> _message "no packages found in $stow_dir"
>> fi
>>
>> and the completion of parameters such as'$HOME' or'~/' works well !
>>
>> I pushed my modifications on github. Thank you for the answers :-)
>
> Sorry, but I have to object to the PR as it stands. As I said, using
> ??eval $1?? causes expressions on the command line to be evaluated
> _when completion is attempted_. To me, that breaks the principle of
> least surprise, and could lead to unexpected and undesired results.
>
Okay, I understand the idea, so I tried to change the function to this:
__stow_complete_packages() {
local stow_dir=${(Q)1}
local -a stow_pkg_list=( $stow_dir/*(-/N:t) )
if [[ ${#stow_pkg_list} -gt 0 ]]; then
_values -C "packages from $stow_dir" ${stow_pkg_list[@]}
else
_message "no packages found in $stow_dir"
fi
}
But now if I do ?? stow --dir=$HOME/.dotfiles<TAB> ??, I get ????no packages
found in $HOME/.dotfiles????. Maybe I missed something???
> I would strongly prefer another solution, or to be corrected on my
> interpretation that this violates least surprise.
>
> Also, I don't think it's ideal to have ??foo --opt=$ARG<TAB>?? work and
> ??bar --opt=$ARG<TAB>?? not work.
>
To remove any ambiguity, I want to complete the stow packages
stow --dir $HOME/.dotfiles <TAB>
_packages from /home/username/.dotfiles_
git myrepos nano nvim ranger rofi [???]
And not the directories
stow --dir $HOME/.dotfiles/<TAB>
_directory_
git myrepos nano nvim ranger rofi [???]
My initial goal was to get a completion of the same type as what
password-store offers (see: line 127 at
https://git.zx2c4.com/password-store/tree/src/completion/pass.zsh-completion).
This is where the ????find???? in the first version of the script comes from.
Naively, as a user, when I do ????stow --dir $HOME/.dotfiles <TAB>???? and
the directory in question contains many subdirectories, if the
completion does not offer any packages, it is surprising.
Now, due to my limited experience in writing completion for zsh, I don't
know what would be the least bad of the solutions.
Thank you for your time.
--
Aur??lien
next prev parent reply other threads:[~2019-08-20 17:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1e5195bb-3126-8d0c-8a6a-1f5a5fd2a6c0@yahoo.fr>
[not found] ` <BAE67462-BF39-481A-BCD6-DE288FE6CC92@dana.is>
[not found] ` <d30637f3-cbbb-8b93-35f2-421a1a99e1dc@yahoo.fr>
2019-08-17 17:53 ` Daniel Shahaf
2019-08-17 21:44 ` dana
2019-08-20 17:45 ` Aurélien [this message]
2019-08-25 1:14 ` dana
2019-10-13 17:51 ` Aurélien
2019-10-16 1:14 ` dana
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=558a3ff8-d6f1-9ab0-3387-a17ca5e0e75b@yahoo.fr \
--to=orel_jf@yahoo.fr \
--cc=d.s@daniel.shahaf.name \
--cc=dana@dana.is \
--cc=zsh-workers@zsh.org \
/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).