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: Tue, 23 Feb 2021 22:39:22 +0100	[thread overview]
Message-ID: <31598-1614116362.902856@aI-l.maGv.3QD7> (raw)
In-Reply-To: <CEA9AD4E-D429-43F1-AB41-92B40693B693@gmail.com>

Jacob Gelbman wrote:
> I wrote a completion script for the ctags program. Someone might be able to use it:

Which ctags!?
This doesn't match what I have installed on any of my systems. There
are multiple implementations of ctags, with it often being just a link
to etags - for which there is a completion albeit not a well maintained
one. One of the main reasons, a completion doesn't already exist is
that it would ideally need to detect the variant and at least have sane
fallbacks for variants that aren't handled. It could be useful to check
what the existing _etags is handling - that might be the exhuberant or
emacs variant.

In general, please follow the conventions outlined in
Etc/completion-style-guide in the zsh source distribution. For example,
completion functions usually use just 2 spaces for indentation.

> #compdef ctags
>
> local state

If you use states, you need to also handle the context which means
either passing -C to _arguments and setting up $curcontext or declaring
context local and passing it to later functions like _values.

>     "--alias-<lang>=[add a pattern detecting a name, can be used as an alt name for lang]:pattern" \
>     "--input-encoding-<lang>=[specify encoding of the <lang> input files]:encoding" \
>     "--kinddef-<lang>=[define new kind for <lang>]:kind" \
>     "--kinds-<lang>=[enable/disable tag kinds for <lang>]:kind" \

These would not complete especially helpfully. I suspect that <lang> there is
supposed to be substituted.

> if [ "$state" = "language" ]; then
>     compadd `ctags --list-languages | cut -d" " -f1`

It would be nicer to use a description by calling for example, _wanted
here.

> elif [ "$state" = "languages" ]; then
>     _values -s , "languages" `ctags --list-languages | cut -d" " -f1`
> fi

I'd probably use _sequence here as it is smaller and simpler. But
_values is fine if none of the languages contain characters that need
quoting from it.

The return status from this function will not be correct in all cases.
This can have effects like approximate completion being activated
despite matches having been added by earlier completers. Where states
are needed, you nearly always need to either save the status from
_arguments, typically via a ret variable or check $compstate[nmatches]
on exit.

Oliver


  parent reply	other threads:[~2021-02-23 21:39 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 [this message]
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
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=31598-1614116362.902856@aI-l.maGv.3QD7 \
    --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).