zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers@sunsite.dk
Subject: Re: 'loop' vs 'loop=device' in _mount
Date: Thu, 27 Aug 2009 21:37:31 +0100	[thread overview]
Message-ID: <20090827213731.28833f55@pws-pc> (raw)
In-Reply-To: <alpine.LNX.2.01.0908261753090.18590@hp.internal>

On Wed, 26 Aug 2009 18:03:32 -0400 (EDT)
"Benjamin R. Haskell" <zsh@benizi.com> wrote:
> When using completion for mount options, I often run into the annoyance 
> that the 'loop' option prompts for the loopback devide to use.  Really, 
> though, one needn't specify any device in particular...  Says the man-page 
> for 'mount':
> 
> '''
> If no explicit loop device is mentioned (but just an option `-o loop' is 
> given), then mount will try to find some unused loop device and use that.
> '''
> 
> I'll likely just patch my own completion script to change:
> 
> Completion/Unix/Command/_mount, line 325:
> -      'loop[use loopback device]:loopback device:_files'
> +      'loop[use loopback device]'
> 
> since I couldn't tell how to incorporate an '-o' option that accepts an 
> optional argument.

It should be just a question of doubling the first colon, as follows
(see the documentation for _values).  However, I couldn't get the suffix
(i.e. the "=") added to be removed when I typed ",", i.e. tried to add a
new list option instead of an argument... until it finally occurred to
me after an astonishing amount of looking in completely the wrong place
that I hadn't told it when to remove it (patch to _values---so non-final
optional arguments to values were always a bit inconvenient).

The following should do more or less what you want; the behaviour is
like that after "/" in file names, but the "," will cause the
auto-remove behaviour of the "=", too.

Index: Completion/Base/Utility/_values
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Utility/_values,v
retrieving revision 1.11
diff -u -r1.11 _values
--- Completion/Base/Utility/_values	13 Jan 2009 12:19:53 -0000	1.11
+++ Completion/Base/Utility/_values	27 Aug 2009 20:34:30 -0000
@@ -59,7 +59,7 @@
       _describe "$descr" \
         noargs "$sep[@]" -M 'r:|[_-]=* r:|=*' -- \
         args -S "${argsep}" -M 'r:|[_-]=* r:|=*' -- \
-        opts -qS "${argsep}" -M 'r:|[_-]=* r:|=*'
+        opts -qS "${argsep}" -r "${argsep}${sep} \\t\\n\\-" -M 'r:|[_-]=* r:|=*'
 
       curcontext="$oldcontext"
 
Index: Completion/Unix/Command/_mount
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_mount,v
retrieving revision 1.29
diff -u -r1.29 _mount
--- Completion/Unix/Command/_mount	4 Jun 2009 15:32:22 -0000	1.29
+++ Completion/Unix/Command/_mount	27 Aug 2009 20:34:31 -0000
@@ -322,7 +322,7 @@
       '(nosuid)suid[use suid and sgid bits]'
       '(async)sync[do I/O synchronously]'
       'dirsync[perform directory updates synchronously]'
-      'loop[use loopback device]:loopback device:_files'
+      'loop[use loopback device]::loopback device:_files'
       'encryption[enable encryption]:cypher'
       'keybits[set number of bits in encryption key]:key size:(64 128 160 192 256)'
       'offset[specify data start for loopback mount]:offset (bytes)'

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


  reply	other threads:[~2009-08-28 11:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-26 22:03 Benjamin R. Haskell
2009-08-27 20:37 ` Peter Stephenson [this message]
2009-08-28 14:59   ` Benjamin R. Haskell

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=20090827213731.28833f55@pws-pc \
    --to=p.w.stephenson@ntlworld.com \
    --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).