From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19737 invoked by alias); 4 Aug 2016 15:54:36 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 38995 Received: (qmail 15294 invoked from network); 4 Aug 2016 15:54:36 -0000 X-Qmail-Scanner-Diagnostics: from hermes.apache.org by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(140.211.11.3):SA:0(-1.3/5.0):. Processed in 0.149333 secs); 04 Aug 2016 15:54:36 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, RP_MATCHES_RCVD autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: danielsh@apache.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at apache.org does not designate permitted sender hosts) From: Daniel Shahaf To: zsh-workers@zsh.org Subject: [PATCH 3(a)/3] _man: Support _correct_word. Date: Thu, 4 Aug 2016 15:54:25 +0000 Message-Id: <1470326066-3241-4-git-send-email-danielsh@tarsus.local2> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1470326066-3241-1-git-send-email-danielsh@tarsus.local2> References: <1470326066-3241-1-git-send-email-danielsh@tarsus.local2> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 'compfiles' call in «man 8 foo» 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)) {