zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <opk@zsh.org>
To: Jacob Gelbman <gelbman@gmail.com>
Cc: zsh-workers@zsh.org
Subject: Re: Completion script for the ctags program
Date: Mon, 29 Mar 2021 01:29:47 +0200	[thread overview]
Message-ID: <81051-1616974187.275911@6nTa.K7Pn.vjul> (raw)
In-Reply-To: <742BD09C-6FE4-4B89-9B8F-824FB67EDEED@gmail.com>

On 11 Mar, Jacob Gelbman wrote:
> Yes, here it is: 

Thanks for sending the update. I've committed it as-is to the repository
because it is a definite improvement on the earlier file and that
doesn't prevent us from further iterating on it. It is easier if you can
send changes as patches. Use the diff -u, or git diff commands to create
patches rather than posting full files. The previous files also had DOS
line endings - if someone other than me pushes any updates, please
ensure we only have Unix line endings.

> #compdef ctags arduino-ctags ctags-exuberant ctags-universal

exuberant is installed as exctags on my system so that name could be
added.

> local context state line expl
> local -A opt_args
> local -a arguments
>
> if [ -z "$_ctags_type" ]; then
>   local output=`ctags --version 2>&1`
>   if [[ "$output" = *Universal\ Ctags* ]]; then
>     _ctags_type="universal"
>   elif [[ "$output" = *Exuberant\ Ctags* ]]; then
>     _ctags_type="exuberant"
>   elif [[ "$output" = *usage:\ ctags* ]]; then
>     _ctags_type="bsd"
>   elif [[ "$output" = *Emacs* ]]; then
>     _ctags_type="etags"
>   else
>     _ctags_type="universal"
>   fi
> fi

As was mentioned in a previous review, use _pick_variant for this. It
does exactly this in a generic manner and handles things like caching
results. This code above will cache one result even if the user has both
ctags and ctags-exuberant installed.

> if [ "$_ctags_type" = "etags" ]; then
>   _etags
>   return $?
> fi

WE should perhaps pull the contents of _etags into this function and
handle them all together.

>   if [[ "$PREFIX" = -* ]]; then

If the prefix-needed style is set to false, that condition is not
applicable. If generating the list of languages is fast enough, I would
generate it unconditionally and store the result in an array so that it
can be used from a variety of places.

>     local -a languages=(`_ctags_languages`)

In general, I would recommend using $(...) instead of `...` because it
is simple to nest. That doesn't matter here as such.

>     local -a languages2

That variable isn't used.

>     for language in $languages; do
>       arguments+=("--$language-kinds=-:kinds")

The latter kinds should be singular - kind. You can actually avoid the
need for a for loop by using --${^languages}"-kinds=-:kind"

If you keep the for loop, language does need to be declared local.

> if [ "$state" = "language" ]; then

The [[ ... ]] condition form is usually preferable to [ ... ] because
the parser handles it and avoids certain tricky issues. A case statement
would work here though. Or even better, make _ctags_languages a proper
completion function so that you can call it directly with options such
as -S = or with _sequence for the comma-separated list.

Thanks,

Oliver


  parent reply	other threads:[~2021-03-28 23:30 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-23  3:11 Jacob Gelbman
2021-02-23 10:11 ` Peter Stephenson
2021-02-23 22:20   ` Oliver Kiddle
2021-02-23 22:45     ` Bart Schaefer
2021-02-23 23:51       ` Oliver Kiddle
2021-02-24  0:52         ` Bart Schaefer
2021-02-24 13:47           ` Daniel Shahaf
2021-02-23 23:05     ` Mikael Magnusson
2021-02-23 21:39 ` Oliver Kiddle
2021-02-24  4:45   ` Jacob Gelbman
2021-02-24  7:20     ` Jacob Gelbman
2021-02-24  9:26       ` Peter Stephenson
2021-02-24 14:24       ` Daniel Shahaf
2021-02-24 18:58         ` Jacob Gelbman
2021-02-24 19:01           ` Bart Schaefer
2021-03-03 20:02         ` Daniel Shahaf
2021-03-03 20:39           ` Jacob Gelbman
2021-03-03 21:40             ` Peter Stephenson
2021-03-03 22:06             ` Daniel Shahaf
2021-03-03 22:08           ` Jacob Gelbman
2021-03-03 23:28             ` Aaron Schrab
2021-03-03 23:43               ` Daniel Shahaf
2021-03-03 23:35             ` Daniel Shahaf
2021-03-07 19:18         ` Jacob Gelbman
2021-03-07 21:42           ` Daniel Shahaf
2021-03-07 21:57             ` Jacob Gelbman
2021-03-07 22:10               ` Daniel Shahaf
2021-03-11 16:15                 ` Daniel Shahaf
2021-03-11 17:08                   ` Jacob Gelbman
2021-03-20  1:43                     ` Lawrence Velázquez
2021-03-27 16:14                       ` Lawrence Velázquez
2021-03-27 20:43                         ` Daniel Shahaf
2021-03-28 23:29                     ` Oliver Kiddle [this message]
2021-03-29  8:54                       ` Peter Stephenson
2021-03-29 15:07                         ` EOL normalization? (Was: Completion script for the ctags program) Lawrence Velázquez
2021-03-29 15:34                           ` Daniel Shahaf
2021-03-29 15:41                             ` Lawrence Velázquez
2021-02-24 21:54       ` Completion script for the ctags program dana

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=81051-1616974187.275911@6nTa.K7Pn.vjul \
    --to=opk@zsh.org \
    --cc=gelbman@gmail.com \
    --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).