From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5403 invoked by alias); 13 Jan 2016 04:58:57 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 37600 Received: (qmail 427 invoked from network); 13 Jan 2016 04:58:56 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=tAgSnY1wbeN1hInfIgkcaFpvm2FOCHeuDksEZpWy5x4=; b=uxeOS3NZBocSXBc8BIciDI1mrI5/S/mjxkr80Ll70QmVV2psDbpdJQd4g6zBWjCI0j GOAcfJ4zjUdFoEFkL6D6or+eq5xW4TdwuP5fUub8Vt3/v4ZXR6tjK2TdZCTzpx76pbEH 3RtSYWlvT150mSjLeEOm2ZOufX05XOOXkpHWDyvfOwg/8ibkCnYBOTvQLXi2Q16XKOoO SuslhtAfmzGWWJIr6+KNDIkvMkjyW3+7Mu6sOtiA+aYgdB+XGR/9D2Q37LjhOMBeN4D+ MTXaitE3Xn8XwbC//UMR4IL7t+CgAw3FlHPYWgZC00O+MDhCw1oBtoiPKkMrK6wX5EZL THKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=tAgSnY1wbeN1hInfIgkcaFpvm2FOCHeuDksEZpWy5x4=; b=cUk5amtMERkgfMxJqQ+0NGCPNybflg+HoaMtuXL2dv2Wd4DSQrUPTSQA20APOtx+ac qJs2KqkT58XawkZ/G8Vdbz8dDtksIfnjDfg4x9syzNp4M/58ssEeeBAe826U91C9JbrB ex6ZVJWDZmBJqtLEIf4R6dfE55yxm+L0W5CHnngGA3Re+vg9gRzIJux7y3GcW3BCegDN X3zdwB96aOPvX9V03Wou+qbd5CJ5II9k/hDGF4eOTphd7k3v9GRY8qcS4XmW71zUYz8J 1L4IAVEsdYF7ACmj0pgS/fHbAhLsGbAZRhaamx3N4qTBV3MMgr9M+cwVwamF8ykHp4Pk pu6g== X-Gm-Message-State: ALoCoQnYXQaVjmfkZYgIkQJa3cSZrOH5l6+b0/+oMhUh9KtaFuPzOUK3Z9edp5NrDRN4ehcACqJskR49lfzOzKt4qCNK1J5Y0g== X-Received: by 10.182.40.167 with SMTP id y7mr100444032obk.10.1452661134767; Tue, 12 Jan 2016 20:58:54 -0800 (PST) Date: Tue, 12 Jan 2016 22:58:53 -0600 From: Matthew Martin To: Daniel Shahaf Cc: zsh-workers@zsh.org Subject: Re: [patch] Completions for cu, fw_update, and rcctl Message-ID: <20160113045853.GB9030@CptOrmolo.darkstar> References: <20160110075141.GA15837@CptOrmolo.darkstar> <20160110195322.GD11464@tarsus.local2> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160110195322.GD11464@tarsus.local2> User-Agent: Mutt/1.5.24 (2015-08-30) On Sun, Jan 10, 2016 at 07:53:22PM +0000, Daniel Shahaf wrote: > Matthew Martin wrote on Sun, Jan 10, 2016 at 01:51:41 -0600: > > Few completers for OpenBSD utilities that have been sitting in my tree. > > > > Not sure if listing line speeds is overkill (fine by me to remove them > > if anyone thinks it is). > > I think it's a nice touch. When I work with cu the last thing I want is > to have to remember whether the magic number is 115200 or 112500 ??? > > > diff --git a/Completion/BSD/Command/_cu b/Completion/BSD/Command/_cu > > new file mode 100644 > > index 0000000..d4658e3 > > --- /dev/null > > +++ b/Completion/BSD/Command/_cu > > @@ -0,0 +1,7 @@ > > +#compdef cu > > + > > +_arguments -s -A '-*' \ > > + '-d[do not block waiting for a carrier to be detected]' \ > > + '-l[line to use]:line:(/dev/cuaU#<->(%))' \ > > I'm surprised a glob pattern works inside the parentheses. I'd have > expected a call to _files would be needed. > > On Linux the device is called /dev/ttyS0, so the pattern could be: > /dev/(cuaU#<->|ttyS<->)(N%c) > ? [with (N) to support other OSes] > > Maybe encapsulate this as Completion/Unix/Type/_tty_lines so screen(1) > and friends can reuse it in the future? Like so? Made a _tty_speeds too. diff --git a/Completion/BSD/Command/_cu b/Completion/BSD/Command/_cu index bdd5795..7b5ab7e 100644 --- a/Completion/BSD/Command/_cu +++ b/Completion/BSD/Command/_cu @@ -2,6 +2,6 @@ _arguments -s -A '-*' \ '-d[do not block waiting for a carrier to be detected]' \ - '-l[line to use]:line:(/dev/(cuaU#<->|ttyS<->)(N%c))' \ - '-s[line speed]:line speed:(75 110 300 1200 2400 4800 9600 19200 38400 57600 115200)' \ + '-l[line to use]:line:_tty_lines' \ + '-s[line speed]:line speed:_tty_speeds' \ '(-*)1:host:' diff --git a/Completion/Unix/Command/_gdb b/Completion/Unix/Command/_gdb index e9c3339..77f0001 100644 --- a/Completion/Unix/Command/_gdb +++ b/Completion/Unix/Command/_gdb @@ -37,9 +37,7 @@ else (-[csx]) _files && return 0 ;; (-e) _description files expl executable _files "$expl[@]" -g '*(-*)' && return 0 ;; - (-b) _wanted -V values expl 'baud rate' \ - compadd 0 50 75 110 134 150 200 300 600 1200 1800 2400 4800 \ - 9600 19200 38400 57600 115200 230400 && return 0 ;; + (-b) _tty_speeds && return 0 ;; esac w=( "${(@)words[2,-1]}" ) diff --git a/Completion/Unix/Command/_joe b/Completion/Unix/Command/_joe index 96ad0a4..7ac85df 100644 --- a/Completion/Unix/Command/_joe +++ b/Completion/Unix/Command/_joe @@ -3,7 +3,7 @@ _arguments \ '-asis[characters with codes >127 will be displayed non-inverted]' \ '-backpath[backup file directory]:backup file directory:_files -/' \ - '-baud[inserts delays for baud rates below 19200]:baud rate:(57600 38400 19200 9600 4800 2400 1200 300)' \ + '-baud[inserts delays for baud rates below 19200]:baud rate:_tty_speed' \ '-beep[beep on command errors or when cursor goes past extremes]' \ '-columns[sets the number of screen columns]:num of columns' \ '-csmode[continued search mode]' \ diff --git a/Completion/Unix/Command/_screen b/Completion/Unix/Command/_screen index 510fd71..b08a729 100644 --- a/Completion/Unix/Command/_screen +++ b/Completion/Unix/Command/_screen @@ -97,9 +97,9 @@ if [[ -n $state ]]; then case $state in normal) if (( CURRENT == 1 )) && [[ $PREFIX == /dev/* ]]; then - _path_files -g '*(%)' + _tty_lines elif (( CURRENT == 2 )) && [[ ${words[1]} == /dev/* ]]; then - _message "baud rate" + _tty_speeds elif (( CURRENT > 2 )) && [[ ${words[1]} == /dev/* ]]; then _message "no more parameters" else diff --git a/Completion/Unix/Type/_tty_lines b/Completion/Unix/Type/_tty_lines new file mode 100644 index 0000000..2d9d097 --- /dev/null +++ b/Completion/Unix/Type/_tty_lines @@ -0,0 +1,7 @@ +#autoload + +local expl + +_description files expl 'tty line' + +_files -g '/dev/(cuaU#<->|ttyS<->)(N%c)' diff --git a/Completion/Unix/Type/_tty_speeds b/Completion/Unix/Type/_tty_speeds new file mode 100644 index 0000000..ac82d60 --- /dev/null +++ b/Completion/Unix/Type/_tty_speeds @@ -0,0 +1,7 @@ +#autoload + +local expl + +_description 'tty speed' expl 'tty speed' + +compadd -- 75 110 300 1200 2400 4800 9600 19200 38400 57600 115200