From: Matthew Martin <phy1729@gmail.com>
To: Daniel Shahaf <d.s@daniel.shahaf.name>
Cc: zsh-workers@zsh.org
Subject: Re: [patch] Completions for cu, fw_update, and rcctl
Date: Tue, 12 Jan 2016 22:58:53 -0600 [thread overview]
Message-ID: <20160113045853.GB9030@CptOrmolo.darkstar> (raw)
In-Reply-To: <20160110195322.GD11464@tarsus.local2>
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
next prev parent reply other threads:[~2016-01-13 4:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-10 7:51 Matthew Martin
2016-01-10 19:53 ` Daniel Shahaf
2016-01-13 4:58 ` Matthew Martin [this message]
2016-01-13 5:04 ` Matthew Martin
2016-01-14 0:13 ` Daniel Shahaf
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=20160113045853.GB9030@CptOrmolo.darkstar \
--to=phy1729@gmail.com \
--cc=d.s@daniel.shahaf.name \
--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).