aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--TODO5
-rw-r--r--manual/qpdf-manual.xml6
-rw-r--r--qpdf/qpdf.cc35
-rw-r--r--qpdf/qtest/qpdf/completion-decode-l-zsh.out2
-rw-r--r--qpdf/qtest/qpdf/completion-encrypt-40-zsh.out4
-rw-r--r--qpdf/qtest/qpdf/completion-encrypt-40.out1
-rw-r--r--qpdf/qtest/qpdf/completion-later-arg-zsh.out7
-rw-r--r--qpdf/qtest/qpdf/completion-top-arg-zsh.out7
9 files changed, 62 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 27a457ff..2db53cb8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2021-01-03 Jay Berkenbilt <ejb@ql.org>
+
+ * Don't include -o nospace with zsh completion setup so file
+ completion works normally. Fixes #473.
+
2021-01-02 Jay Berkenbilt <ejb@ql.org>
* Make QPDFPageObjectHelper methods pipeContents, parseContents,
diff --git a/TODO b/TODO
index 52520b21..7b620a96 100644
--- a/TODO
+++ b/TODO
@@ -1,11 +1,6 @@
Candidates for upcoming release
===============================
-* Open "next" issues
- * bugs
- * #473: zsh completion with directories
- * Investigate how serverless does completion
-
* Remember to check work `qpdf` project for private issues
* file with very slow page extraction
* big page even with --remove-unreferenced-resources=yes, even with --empty
diff --git a/manual/qpdf-manual.xml b/manual/qpdf-manual.xml
index c6e00791..f93f4a17 100644
--- a/manual/qpdf-manual.xml
+++ b/manual/qpdf-manual.xml
@@ -5021,6 +5021,12 @@ print "\n";
was broken for pages with multiple content streams.
</para>
</listitem>
+ <listitem>
+ <para>
+ Tweak zsh completion code to behave a little better with
+ respect to path completion.
+ </para>
+ </listitem>
</itemizedlist>
</listitem>
</itemizedlist>
diff --git a/qpdf/qpdf.cc b/qpdf/qpdf.cc
index c11f2486..0d1ab988 100644
--- a/qpdf/qpdf.cc
+++ b/qpdf/qpdf.cc
@@ -726,6 +726,8 @@ class ArgParser
OptionEntry oe_optionalParameter(param_arg_handler_t);
OptionEntry oe_requiredChoices(param_arg_handler_t, char const** choices);
+ void completionCommon(bool zsh);
+
void argHelp();
void argVersion();
void argCopyright();
@@ -1637,7 +1639,7 @@ ArgParser::argHelp()
}
void
-ArgParser::argCompletionBash()
+ArgParser::completionCommon(bool zsh)
{
std::string progname = argv[0];
std::string executable;
@@ -1657,8 +1659,16 @@ ArgParser::argCompletionBash()
progname = appimage;
}
}
- std::cout << "complete -o bashdefault -o default -o nospace"
- << " -C " << progname << " " << whoami << std::endl;
+ if (zsh)
+ {
+ std::cout << "autoload -U +X bashcompinit && bashcompinit && ";
+ }
+ std::cout << "complete -o bashdefault -o default";
+ if (! zsh)
+ {
+ std::cout << " -o nospace";
+ }
+ std::cout << " -C " << progname << " " << whoami << std::endl;
// Put output before error so calling from zsh works properly
std::string path = progname;
size_t slash = path.find('/');
@@ -1670,10 +1680,15 @@ ArgParser::argCompletionBash()
}
void
+ArgParser::argCompletionBash()
+{
+ completionCommon(false);
+}
+
+void
ArgParser::argCompletionZsh()
{
- std::cout << "autoload -U +X bashcompinit && bashcompinit && ";
- argCompletionBash();
+ completionCommon(true);
}
void
ArgParser::argJsonHelp()
@@ -3373,10 +3388,20 @@ ArgParser::addOptionsToCompletions()
iter != this->option_table->end(); ++iter)
{
std::string const& arg = (*iter).first;
+ if (arg == "--")
+ {
+ continue;
+ }
OptionEntry& oe = (*iter).second;
std::string base = "--" + arg;
if (oe.param_arg_handler)
{
+ if (zsh_completion)
+ {
+ // zsh doesn't treat = as a word separator, so add all
+ // the options so we don't get a space after the =.
+ addChoicesToCompletions(arg, base + "=");
+ }
completions.insert(base + "=");
}
if (! oe.parameter_needed)
diff --git a/qpdf/qtest/qpdf/completion-decode-l-zsh.out b/qpdf/qtest/qpdf/completion-decode-l-zsh.out
new file mode 100644
index 00000000..131a2470
--- /dev/null
+++ b/qpdf/qtest/qpdf/completion-decode-l-zsh.out
@@ -0,0 +1,2 @@
+--decode-level=all
+!--help
diff --git a/qpdf/qtest/qpdf/completion-encrypt-40-zsh.out b/qpdf/qtest/qpdf/completion-encrypt-40-zsh.out
new file mode 100644
index 00000000..82541e98
--- /dev/null
+++ b/qpdf/qtest/qpdf/completion-encrypt-40-zsh.out
@@ -0,0 +1,4 @@
+--annotate=n
+!----
+!--force-R5
+!--force-V4
diff --git a/qpdf/qtest/qpdf/completion-encrypt-40.out b/qpdf/qtest/qpdf/completion-encrypt-40.out
index 3a184a6b..a45c605f 100644
--- a/qpdf/qtest/qpdf/completion-encrypt-40.out
+++ b/qpdf/qtest/qpdf/completion-encrypt-40.out
@@ -1,3 +1,4 @@
--annotate=
+!----
!--force-R5
!--force-V4
diff --git a/qpdf/qtest/qpdf/completion-later-arg-zsh.out b/qpdf/qtest/qpdf/completion-later-arg-zsh.out
new file mode 100644
index 00000000..e4ed848c
--- /dev/null
+++ b/qpdf/qtest/qpdf/completion-later-arg-zsh.out
@@ -0,0 +1,7 @@
+--check
+--decode-level=all
+--encrypt
+!--completion-bash
+!--copyright
+!--help
+!--version
diff --git a/qpdf/qtest/qpdf/completion-top-arg-zsh.out b/qpdf/qtest/qpdf/completion-top-arg-zsh.out
new file mode 100644
index 00000000..ce613a59
--- /dev/null
+++ b/qpdf/qtest/qpdf/completion-top-arg-zsh.out
@@ -0,0 +1,7 @@
+--check
+--completion-bash
+--copyright
+--decode-level=none
+--encrypt
+--help
+--version