zsh-workers
 help / color / mirror / code / Atom feed
From: doron.behar@gmail.com
To: zsh-workers@zsh.org
Subject: [PATCH] Add completion for zathura.
Date: Fri, 13 Jul 2018 22:52:59 +0300	[thread overview]
Message-ID: <20180713195259.8656-1-doron.behar@gmail.com> (raw)

From: Doron Behar <doron.behar@gmail.com>

Make it aware of the plugins installed on the machine.
---
 Completion/Unix/Type/_pspdf   |  2 +-
 Completion/X/Command/_zathura | 48 +++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+), 1 deletion(-)
 create mode 100644 Completion/X/Command/_zathura

diff --git a/Completion/Unix/Type/_pspdf b/Completion/Unix/Type/_pspdf
index 5bb8650b1..1df3f860c 100644
--- a/Completion/Unix/Type/_pspdf
+++ b/Completion/Unix/Type/_pspdf
@@ -1,4 +1,4 @@
-#compdef gsbj gsdj gsdj500 gslj gslp gsnd ps2ascii ghostview mgv pstoedit pstotgif zathura
+#compdef gsbj gsdj gsdj500 gslj gslp gsnd ps2ascii ghostview mgv pstoedit pstotgif
 
 local expl ext
 
diff --git a/Completion/X/Command/_zathura b/Completion/X/Command/_zathura
new file mode 100644
index 000000000..141cadf63
--- /dev/null
+++ b/Completion/X/Command/_zathura
@@ -0,0 +1,48 @@
+#compdef zathura
+
+(( $+functions[_zathura_files] )) ||
+_zathura_files(){
+  local -a plugins_files
+  local plugins_dir
+  for plugins_dir in \
+    ${(Qv)opt_args[(i)-p|--plugins-dir]}(#qN) \
+    {/usr/local,/usr,}/lib/zathura(#qN)
+  do
+    plugins_files=( $plugins_dir/*.so )
+    (( $#plugins_files )) && break
+  done
+  if [[ -z "${plugins_files}" ]]; then
+    _files -g "*.pdf(-.)"
+    return
+  fi
+  local -a supported_filetypes
+  local pf
+  for pf in "${plugins_files[@]}"; do
+    if [[ $pf =~ "mupdf" ]]; then
+      supported_filetypes+="pdf"
+      supported_filetypes+="epub"
+      supported_filetypes+="xps"
+    elif [[ $pf =~ "poppler" ]]; then
+      supported_filetypes+="pdf"
+    else
+      supported_filetypes+="${${pf%.so}#${plugins_dir}/lib}"
+    fi
+  done
+  _files -g "*.(${(j.|.)supported_filetypes})(-.)"
+}
+
+_arguments -s -S \
+  {-e,--reparent=}'[specify xid of window to reparent to]:xid:_x_window' \
+  {-c,--config-dir=}'[specify path to the config directory]:config directory:{_files -/}' \
+  {-d,--data-dir=}'[specify path to the data directory]:data directory:{_files -/}' \
+  {-p,--plugins-dir=}'[specify path to the directory containing plugins]:plugins directory:{_files -/}' \
+  {-w,--password=}"[specify a password for the document]:password: " \
+  {-P,--page=}'[open the document at the given page number]:page number: ' \
+  {-l,--log-level=}'[set log level]:log level:(debug info warning error)' \
+  {-x,--synctex-editor-command=}'[specify synctex editor command]:synctex editor command:_cmdstring' \
+  '--synctex-forward=[jump to the given position]:synctex position: ' \
+  '--synctex-pid=[specify pid of an instance having the correct file opened]:synctex pid:_pids' \
+  '--fork[fork into background]' \
+  '(- :)--version[display version string and exit]' \
+  '(- :)--help[display help and exit]' \
+  '*:file:_zathura_files'
-- 
2.18.0


             reply	other threads:[~2018-07-14  9:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-13 19:52 doron.behar [this message]
2018-07-16 17:24 ` Doron Behar
  -- strict thread matches above, loose matches on Subject: below --
2018-06-13 16:31 doron.behar
2018-07-01 17:11 ` Doron Behar
2018-07-01 19:06   ` dana
2018-07-13 12:29     ` Doron Behar
2018-07-13 16:55       ` dana
2018-07-13 19:53         ` Doron Behar

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=20180713195259.8656-1-doron.behar@gmail.com \
    --to=doron.behar@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).