Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [patch] Completion for _deborphan and _xrandr
- X-seq: zsh-workers 41906
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: gi1242+zsh@xxxxxxxxx, zsh-workers@xxxxxxx
- Subject: Re: [patch] Completion for _deborphan and _xrandr
- Date: Sun, 15 Oct 2017 23:00:24 +0200
- Authentication-results: amavisd4.gkg.net (amavisd-new); dkim=pass (2048-bit key) header.d=yahoo.co.uk
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1508101227; bh=RoxQOUOmLMarbjv8QfS4cI2tBwtZE3g8Aogv3loRAkk=; h=From:References:To:Subject:Date:From:Subject; b=Nt2Xe2sXj/eoEWl27Z3ADLmXVvKIdLM94EuhfIAynUMZFjH+I/ASwuX4qRTbkDuZmi8mAaBjO2HjJGDoXnjqrqdcJCTufrrqe638GmzpfsfsTgEo8yreXigF1IP2hhjy5zY4gbtfgKycQA/sySBv/GcVCEGOQ4xej59b10MC3o59XAfWfDWqKLvSArVUWE3dobNMAbwiZ9qqRVatgSiIf1REHULSoQShvg19HcVQ1S0cA6mkNTlhtpVU6npHv59t+SImHjN3YuG4eVHWRnEGEz0uWe0HuXeAErX3q5m176B6XcFmcFLFLNjYz1VIj8eGG6AJ9vNYnbNbWARrNXMBFA==
- In-reply-to: <20171015185931.ano4dq3c5tevu5jf@andrew.cmu.edu>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20171015185931.ano4dq3c5tevu5jf@andrew.cmu.edu>
gi1242+zsh@xxxxxxxxx wrote:
>
> I wrote a rudimentary completion script for deborphan (which probably
> belongs with the Debian completion commands).
Thanks for this.
> I also fixed the xrandr completion to separate outputs into two groups
> (connected and disconnected). Patch, and whole file attached. If there
Is it useful to complete a disconnected output then? If it's only
relevant with some options then we could have separate states for
completing all vs. only connected outputs.
> is a preferred way to submit this (e.g. by forking a git repository) let
> me know and I would be happy to do so.
The preferred way to submit this is by posting a patch, exactly as you
have done.
I've got a couple of minor comments and suggestions on the function:
> + _alternative \
> + 'connected:connected outputs:('${(j: :)${(uo)${(M)xrandr_output:#* connected*}%% *}}')' \
> + 'disconnected:disconnected outputs:('${(j: :)${(uo)${(M)xrandr_output:#* disconnected*}%% *}}')' \
> + && return 0
The normal convention is for the group descriptions to be singular: they
describe what comes on the command line rather than the matches
collectively. So, "connected output" rather than "connected outputs".
> local keep=/var/lib/deborphan/keep
> _arguments : \
> {--help,-h}'[help]' \
> {--status-file,-f}'[statusfile]:file:_files' \
The description here is rather terse.
> {--exclude,-e}'[work as if packages in LIST were not installed]:LIST:' \
I'm guessing that LIST here has come from the --help output. The
description's inclusion of "LIST" makes less sense without corresponding
text saying something like [ --exclude LIST ]. The word "specify" is
often used when rewording these. Also, is it not perhaps valid to
complete a list of installed packages here. So:
{--exclude,-e}'[work as if specified packages were not installed]:package:_sequence _deb_packages - installed' \
That is assuming a comma-separated list. If deborphan allows you to pass
-e pkg1 -e pkg2
Then you need to prefix the _arguments spec with a *:
\*{--exclude,-e}'[....
> {--force-hold,-H}'[Ignore hold flags.]' \
This description is inconsistent with the earlier ones. Our normal
convention is to neither capitalise the first word nor finish with a
full stop.
> {--priority,-p}'[PRIOR Select only packages with priority >= PRIOR.]:PRIOR:' \
The same comment I made about LIST applies here and in some later
places. Is there a default priority. It can be good to provide hints,
perhaps:
:priority (1-100) [50]'
I'm assuming the priorities are just numbers.
> {--del-keep,-R}"[PKGS.. Remove PKGS from the 'keep' file.]:*:package:_values package $(< $keep)" \
Is _values really needed here or would compadd do the job?
I'd also be inclined to try to avoid it dumping error messages to the
terminal if the $keep file doesn't exist. Perhaps:
keep=( /var/lib/deborphan/keep(N) /dev/null)
..
compadd $(<$keep[1]})
Thanks again.
Oliver
Messages sorted by:
Reverse Date,
Date,
Thread,
Author