zsh-workers
 help / color / mirror / code / Atom feed
* [patch] _ed completer
@ 2018-05-03  3:22 Matthew Martin
  2018-05-04 13:00 ` Oliver Kiddle
  0 siblings, 1 reply; 4+ messages in thread
From: Matthew Martin @ 2018-05-03  3:22 UTC (permalink / raw)
  To: zsh-workers

Add completer for ed.

- Matthew Martin

diff --git a/Completion/Unix/Command/_ed b/Completion/Unix/Command/_ed
new file mode 100644
index 000000000..7ab40d341
--- /dev/null
+++ b/Completion/Unix/Command/_ed
@@ -0,0 +1,38 @@
+#compdef ed
+
+local -a args
+
+args=(
+  '(--prompt)'{-p,--prompt}'[specify prompt]:prompt: '
+  '(-s --quiet --silent)'{-s,--quiet,--silent}'[suppress diagnostics]'
+)
+
+if _pick_variant gnu=GNU unix --version; then
+  args+=(
+    '(-G --traditional)'{-G,--traditional}'[run in compatibility mode]'
+    '(- :)'{-h,--help}'[display help]'
+    '(-l --loose-exit-status)'{-l.--loose-exit-status}'[exit 0 even if a command fails]'
+    '(-r --restricted)'{-r,--restricted}'[run in restricted mode]'
+    '(- :)'{-V,--version}'[display version]'
+    '(-v --verbose)'{-v,--verbose}'[be verbose]'
+  )
+else
+  args=(${args:#*\)--*})
+  case $OSTYPE in
+    dragonfly*|freebsd*|netbsd*)
+      args+=(
+        '-x[prompt for an encryption key]'
+      )
+      ;|
+    netbsd*)
+      args+=(
+        '-E[enable extended regular expressions]'
+        '-S[disable ! command]'
+      )
+      ;;
+  esac
+fi
+
+_arguments -s -S -A '-*' \
+  $args \
+  ':file:_files'


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] _ed completer
  2018-05-03  3:22 [patch] _ed completer Matthew Martin
@ 2018-05-04 13:00 ` Oliver Kiddle
  2018-06-11  4:01   ` Matthew Martin
  0 siblings, 1 reply; 4+ messages in thread
From: Oliver Kiddle @ 2018-05-04 13:00 UTC (permalink / raw)
  To: zsh-workers

Matthew Martin wrote:
>
> +++ b/Completion/Unix/Command/_ed
> +  '(--prompt)'{-p,--prompt}'[specify prompt]:prompt: '

--prompt can exclude a following -p option and it is valid to have the
prompt immediately after -p or to have --prompt=. So, I think this line
can be:
  '(-p --prompt)'{-p+,--prompt=}'[specify prompt]:prompt'

> +  case $OSTYPE in
> +    dragonfly*|freebsd*|netbsd*)

 |solaris*

> +_arguments -s -S -A '-*' \

The -A '-*' option is not applicable to the GNU variant. It's fairly
common that GNU stuff allows options after normal arguments while
traditional Unix stuff doesn't.

Thanks

Oliver


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] _ed completer
  2018-05-04 13:00 ` Oliver Kiddle
@ 2018-06-11  4:01   ` Matthew Martin
  2018-06-11  4:26     ` Matthew Martin
  0 siblings, 1 reply; 4+ messages in thread
From: Matthew Martin @ 2018-06-11  4:01 UTC (permalink / raw)
  To: zsh-workers

On Fri, May 04, 2018 at 03:00:51PM +0200, Oliver Kiddle wrote:
> Matthew Martin wrote:
> >
> > +++ b/Completion/Unix/Command/_ed
> > +  '(--prompt)'{-p,--prompt}'[specify prompt]:prompt: '
> 
> --prompt can exclude a following -p option and it is valid to have the
> prompt immediately after -p or to have --prompt=. So, I think this line
> can be:
>   '(-p --prompt)'{-p+,--prompt=}'[specify prompt]:prompt'
> 
> > +  case $OSTYPE in
> > +    dragonfly*|freebsd*|netbsd*)
> 
>  |solaris*
> 
> > +_arguments -s -S -A '-*' \
> 
> The -A '-*' option is not applicable to the GNU variant. It's fairly
> common that GNU stuff allows options after normal arguments while
> traditional Unix stuff doesn't.

Thanks for the review and apologies for the long wait. Amended patch
below.


diff --git a/Completion/Unix/Command/_ed b/Completion/Unix/Command/_ed
new file mode 100644
index 000000000..cb206f492
--- /dev/null
+++ b/Completion/Unix/Command/_ed
@@ -0,0 +1,38 @@
+#compdef ed
+
+local -a args
+
+args=(
+  '(-p --prompt)'{-p+,--prompt=}'[specify prompt]:prompt:'
+  '(-s --quiet --silent)'{-s,--quiet,--silent}'[suppress diagnostics]'
+)
+
+if _pick_variant gnu=GNU unix --version; then
+  args+=(
+    '(-G --traditional)'{-G,--traditional}'[run in compatibility mode]'
+    '(- :)'{-h,--help}'[display help]'
+    '(-l --loose-exit-status)'{-l.--loose-exit-status}'[exit 0 even if a command fails]'
+    '(-r --restricted)'{-r,--restricted}'[run in restricted mode]'
+    '(- :)'{-V,--version}'[display version]'
+    '(-v --verbose)'{-v,--verbose}'[be verbose]'
+  )
+else
+  args=(-A '-*' ${args:#*\)--*})
+  case $OSTYPE in
+    dragonfly*|freebsd*|netbsd*|solaris*)
+      args+=(
+        '-x[prompt for an encryption key]'
+      )
+      ;|
+    netbsd*)
+      args+=(
+        '-E[enable extended regular expressions]'
+        '-S[disable ! command]'
+      )
+      ;;
+  esac
+fi
+
+_arguments -s -S \
+  $args \
+  ':file:_files'


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] _ed completer
  2018-06-11  4:01   ` Matthew Martin
@ 2018-06-11  4:26     ` Matthew Martin
  0 siblings, 0 replies; 4+ messages in thread
From: Matthew Martin @ 2018-06-11  4:26 UTC (permalink / raw)
  To: zsh-workers

On Sun, Jun 10, 2018 at 11:01:34PM -0500, Matthew Martin wrote:
> +    '(-l --loose-exit-status)'{-l.--loose-exit-status}'[exit 0 even if a command fails]'

dana pointed out there's a . not a , above.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-06-11  4:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-03  3:22 [patch] _ed completer Matthew Martin
2018-05-04 13:00 ` Oliver Kiddle
2018-06-11  4:01   ` Matthew Martin
2018-06-11  4:26     ` Matthew Martin

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).