zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: [PATCH 3(a)/3] _man: Support _correct_word.
Date: Thu,  4 Aug 2016 15:54:25 +0000	[thread overview]
Message-ID: <1470326066-3241-4-git-send-email-danielsh@tarsus.local2> (raw)
In-Reply-To: <1470326066-3241-1-git-send-email-danielsh@tarsus.local2>

The 'compfiles' call in «man 8 foo<TAB>» resulted in glob patterns of the form
«.../foo*», so the would-be targets of spelling correction would not have been
provided to the completion code by the globbing code.

Fix this by mimicking the only other callsite of compfiles, _path_files, which
passes a flag (${_comp_correct:+"-"}) that is only set by _approximate and
causes cfp_opt_pats() to be skipped.  This enables spelling correction to work,
however, it is unknown what side effects it may have.
---
 Completion/Unix/Command/_man |  2 +-
 Src/Zle/computil.c           | 15 +++++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/Completion/Unix/Command/_man b/Completion/Unix/Command/_man
index ffe53be..3900cba 100644
--- a/Completion/Unix/Command/_man
+++ b/Completion/Unix/Command/_man
@@ -131,7 +131,7 @@ _man_pages() {
   fi
 
   pages=( ${(M)dirs:#*$sect_dirname/} )
-  compfiles -p pages '' '' "$matcher" '' dummy "*${sect}*"
+  compfiles -p${_comp_correct:+"-"} pages '' '' "$matcher" '' dummy "*${sect}*"
   pages=( ${^~pages}(N:t) )
 
   (($#mrd)) && pages[$#pages+1]=($(awk $awk $mrd))
diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c
index e8f0a6f..0028ac1 100644
--- a/Src/Zle/computil.c
+++ b/Src/Zle/computil.c
@@ -4480,6 +4480,10 @@ cfp_matcher_pats(char *matcher, char *add)
     return add;
 }
 
+/*
+ * ### This function call is skipped by _approximate, so "opt" probably means "optimize".
+ */
+
 static void
 cfp_opt_pats(char **pats, char *matcher)
 {
@@ -4811,6 +4815,17 @@ cf_remove_other(char **names, char *pre, int *amb)
     return NULL;
 }
 
+/*
+ * SYNOPSIS:
+ *     1. compfiles -p  parnam1 parnam2 skipped matcher sdirs parnam3 varargs [..varargs]
+ *     2. compfiles -p- parnam1 parnam2 skipped matcher sdirs parnam3 varargs [..varargs]
+ *     3. compfiles -P  parnam1 parnam2 skipped matcher sdirs parnam3 
+ *
+ *     1. Set parnam1 to an array of patterns....
+ *     2. Like #1 but without calling cfp_opt_pats().  (This is only used by _approximate.)
+ *     3. Like #1 but varargs is implicitly set to  char *varargs[2] = { "*(-/)", NULL };.
+ */
+
 static int
 bin_compfiles(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
 {


  parent reply	other threads:[~2016-08-04 15:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-04 15:54 [PATCH 0/3] A set of _man fixes — explanation for 3(a)/3 and 3(b)/3 Daniel Shahaf
2016-08-04 15:54 ` [PATCH 1/3] _man: Drop (b): it's incorrect when $sect contains '|' Daniel Shahaf
2016-08-04 15:54 ` [PATCH 2/3] _man: Fix two bugs when completing manpage filenames in separate-sections mode Daniel Shahaf
2016-08-04 15:54 ` Daniel Shahaf [this message]
2016-08-04 15:54 ` [PATCH 3(b)/3] _man: Support _correct_word Daniel Shahaf
2016-08-04 16:08   ` Peter Stephenson
2016-08-04 16:28     ` Bart Schaefer
2016-08-04 19:54       ` Bart Schaefer
2016-08-04 21:47       ` Daniel Shahaf

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=1470326066-3241-4-git-send-email-danielsh@tarsus.local2 \
    --to=d.s@daniel.shahaf.name \
    --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).