zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: Akinori MUSHA <knu@iDaemons.org>
Cc: zsh-workers@sunsite.dk
Subject: Re: _chflags
Date: Thu, 02 Aug 2001 17:19:53 +0100	[thread overview]
Message-ID: <3B697DA9.3443713E@yahoo.co.uk> (raw)
In-Reply-To: <86snfak2zm.wl@archon.local.idaemons.org>

Akinori MUSHA wrote:
> 
> Ah, OK, I'm getting the hang of it.  Every point you addressed above
> is correct.  Now what about the attached one? :)

That's great.

> And I have a couple of questions:
> 
> 1. How can I prevent _values from sorting the values?

Er. Sven? -V doesn't work so you probably can't. Why do you want to? To
group flags with their no variants by any chance? In the latest zsh 4.1,
it might be better to use '(noarch arch)'{arch,noarch}'[archived flag]'
which would put arch and noarch on the same line with a shared
description.

You can use styles to group no and non-no flags separately if that is
what you want to do. Can anyone else please enlighten me if there is a
style to affect the sort order?

> 2. How can I let zsh automatically add `R' when one chooses -[LHP]?

Again, I don't know/don't think it can be done. You would need to get it
to be added as an (auto-removable) suffix which I don't think _arguments
can handle.

> (( $+functions[__chflags] )) ||
> __chflags() {

I take it that you copied this from _kld or _bsd_pkg which is fine. I
prefer to use states with _arguments to defining separate functions
within completion functions. In the case of _chflags, neither is
actually necessary.

>   if [[ CURRENT -eq 2 || $words[CURRENT-1] = -* ]]; then

_arguments takes care of that

>        '(noarch)arch[set the archived flag (super-user only)]' \

What I've done is removed `(super-user only)' from the descriptions and
made it only complete those flags for the super-user (EUID=0). I have
also got it to only complete files which the user owns. This follows the
way that _chown works. Incidentally, symlinks are followed for this and
chown so when I commit this, I'll add `req=( -$^req )' before the _files
call in _chown. 

About these descriptons again: I'm not too sure how useful the
description `set the dump flag' is although that type of description is
quite common for zsh completions. I think the chances are that someone
using chflags can work out that `chflags opaque' sets the opaque flag
and noopaque unsets the flag. However, I wouldn't have a clue what the
significance of the opaque file flag is. To an extent I blame that man
page because it doesn't explain either. So I'd be tempted (for 4.1 only)
to change the flags to along the lines of:
'(dump nodump)'{dump,nodump}'[backup file when dump(8) is next run]'

Note that that description for the dump flag could be completely wrong.
In 4.1 this looks roughly like this when completed:

file flag
dump    nodump    --  backup file when dump(8) is next run

The aliases for the flags could then also be added. What do you reckon?

And, if you can check this updated function below please.

Oliver

#compdef chflags

local flags own='-g *(-u$EUID)'

flags=(
  '(noopaque)opaque[set the opaque flag]'
  '(opaque)noopaque[unset the opaque flag]'
  '(dump)nodump[set the nodump flag]'
  '(nodump)dump[unset the nodump flag]'
  '(nouappnd)uappnd[set the user append-only flag]'
  '(uappnd)nouappnd[unset the user append-only flag]'
  '(nouchg)uchg[set the user immutable flag]'
  '(uchg)nouchg[unset the user immutable flag]'
)

if (( ! EUID )); then
  flags=( $flags[@]
    '(noarch)arch[set the archived flag]'
    '(arch)noarch[unset the archived flag]'
    '(nosappnd)sappnd[set the system append-only flag]'
    '(sappnd)nosappnd[unset the system append-only flag]'
    '(noschg)schg[set the system immutable flag]'
    '(schg)noschg[unset the system immutable flag]'
  )
  unset own
fi

if [[ $OSTYPE = freebsd* ]]; then
  flags=( $flags[@]
    '(nouunlnk)uunlnk[set the user undeletable flag]'
    '(uunlnk)nouunlnk[unset the user undeletable flag]'
  )
  (( EUID )) || flags=( $flags[@]
    '(nosunlnk)sunlnk[set the system undeletable flag]'
    '(sunlnk)nosunlnk[unset the system undeletable flag]'
  )
fi

_arguments -s -A "-*" \
  '(-L -P)-H[follow symlinks on the command line (specify with -R)]' \
  '(-H -P)-L[follow all symlinks (specify with -R)]' \
  '(-L -H)-P[do not follow symlinks (specify with -R)]' \
  '-R[recurse directories]' \
  ':file flag:_values -s , "file flags" $flags[@]' \
  '*:file:_files "$own"'

_____________________________________________________________________
This message has been checked for all known viruses by the 
MessageLabs Virus Scanning Service. For further information visit
http://www.messagelabs.com/stats.asp


  reply	other threads:[~2001-08-02 16:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-01 18:39 _chflags Akinori MUSHA
2001-08-02 12:21 ` _chflags Oliver Kiddle
2001-08-02 13:25   ` _chflags Akinori MUSHA
2001-08-02 16:19     ` Oliver Kiddle [this message]
2001-08-02 17:40       ` _chflags Akinori MUSHA
2001-08-03 11:46         ` _chflags Oliver Kiddle
2001-08-03  8:25       ` _chflags Sven Wischnowsky
2001-08-06 11:36         ` grouping inverses and sorting in completion lists (was _chflags) Oliver Kiddle

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=3B697DA9.3443713E@yahoo.co.uk \
    --to=okiddle@yahoo.co.uk \
    --cc=knu@iDaemons.org \
    --cc=zsh-workers@sunsite.dk \
    /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).