zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: Zsh workers <zsh-workers@zsh.org>
Subject: PATCH: new completion for zeal offline documentation viewer
Date: Thu, 23 Aug 2018 18:12:46 +0200	[thread overview]
Message-ID: <21857.1535040766@hydra> (raw)

This adds completioin for zeal - https://zealdocs.org/

Oliver

diff --git a/Completion/X/Command/_zeal b/Completion/X/Command/_zeal
new file mode 100644
index 000000000..334331d40
--- /dev/null
+++ b/Completion/X/Command/_zeal
@@ -0,0 +1,43 @@
+#compdef zeal
+
+local curcontext="$curcontext" cfg docset setdir mbegin mend ret=1
+local -a state line expl suf docsets globbed match
+local -A opt_args dsets
+
+_arguments -S \
+  ':query:->queries' \
+  + '(opt)' \
+  {-h,--help}'[display help information]' \
+  {-v,--version}'[display version information]' \
+  {-f,--force}'[force the application to run]' && ret=0
+
+if [[ -n $state ]]; then
+  cfg=${XDG_CONFIG_HOME:-~/.config}/Zeal/Zeal.conf
+  if [[ -r $cfg ]]; then
+    docsets=${${(M)${(f)"$(<$cfg)"}:#path=*}#path=}
+  else
+    docsets=${XDG_DATA_HOME:-~/.local/share}/Zeal/Zeal/docsets
+  fi
+  for docset in $docsets/*.docset/Contents/Info.plist(N); do
+    setdir=${docset:h:h:r:t:l:gs/+/p}
+    [[ $(<$docset) = *DocSetPlatformFamily\<[^\<]#\<string\>(#b)([^\<]#)* ]] ||
+	match=( ${docset:h:h:r:t:l:gs/+/p} )
+    dsets+=( $match[1] ${docset:h} )
+  done
+  if compset -P 1 '*:'; then
+    globbed=( ${dsets[${IPREFIX%:}]}/Resources/docSet.dsidx(N[1]) )
+    if (( $+commands[sqlite3] )) && [[ -e $globbed ]]; then
+      _description queries expl 'query'
+      compadd "$expl[@]" - ${(f)"$(_call_program queries
+	  sqlite3 $globbed 'select name from searchIndex')"} && ret=0
+    else
+      _message -e queries 'query'
+    fi
+  else
+    compset -S ':*' || suf=( -qS : )
+    _description docsets expl 'docset'
+    compadd "$expl[@]" $suf -k dsets && ret=0
+  fi
+fi
+
+return ret


                 reply	other threads:[~2018-08-23 16:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=21857.1535040766@hydra \
    --to=okiddle@yahoo.co.uk \
    --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).