Complete::Common - Common stuffs for completion routines
This document describes version 0.22 of Complete::Common (from Perl distribution Complete-Common), released on 2016-01-07.
This module defines some common arguments and settings. Complete::* modules should use the default from these settings, to make it convenient for users to change some behaviors globally.
Complete::*
The defaults are optimized for convenience and laziness for user typing and might change from release to release.
$Complete::Common::OPT_CI
If set to 1, matching is done case-insensitively.
In bash/readline, this is akin to setting completion-ignore-case.
completion-ignore-case
$Complete::Common::OPT_WORD_MODE
If set to 1, enable word-mode matching.
Word mode matching is normally only done when exact matching fails to return any candidate. To give you an idea of how word-mode matching works, you can run Emacs and try its completion of filenames (C-x C-f) or function names (M-x). Basically, each string is split into words and matching is tried for all available word even non-adjacent ones. For example, if you have dua-d and the choices are (dua-tiga, dua-empat, dua-lima-delapan) then dua-lima-delapan will match because d matches delapan even though the word is not adjacent. This is convenient when you have strings that are several or many words long: you can just type the starting letters of some of the words instead of just the starting letters of the whole string (which might need to be quite long before producing a unique match).
C-x C-f
M-x
dua-d
dua-tiga
dua-empat
dua-lima-delapan
d
delapan
$Complete::Common::OPT_CHAR_MODE
If set to 1, enable character-mode matching.
This mode is like word-mode matching, except it works on a character-by-character basis. Basically, it will match if a word contains any letters of the string in the correct order. For example, ap will match ap, amp, slap, or cramp (but will not match pa or pram).
ap
amp
slap
cramp
pa
pram
Character-mode matching is normally only done when exact matching and word-mode fail to return any candidate.
$Complete::Common::OPT_FUZZY
Enable fuzzy matching (matching even though there are some spelling mistakes). The greater the number, the greater the tolerance. To disable fuzzy matching, set to 0.
Fuzzy matching is normally only done when exact matching, word-mode, and char-mode matching fail to return any candidate.
$Complete::Common::OPT_MAP_CASE
This is exactly like completion-map-case in readline/bash to treat _ and - as the same when matching.
completion-map-case
_
-
All Complete::Path-based modules (like Complete::File, Complete::Module, or Complete::Riap) respect this setting.
$Complete::Common::OPT_EXP_IM_PATH
Whether to "expand intermediate paths". What is meant by this is something like zsh: when you type something like cd /h/u/b/myscript it can be completed to cd /home/ujang/bin/myscript.
cd /h/u/b/myscript
cd /home/ujang/bin/myscript
$Complete::Common::OPT_DIG_LEAF
(Experimental) When enabled, this option mimics what's seen on GitHub. If a directory entry only contains a single subentry, it will directly show the subentry (and subsubentry and so on) to save a number of tab presses.
Suppose you have files like this:
a b/c/d/e c
If you complete for b you will directly get b/c/d/e (the leaf).
b
b/c/d/e
This is currently experimental because if you want to complete only directories, you won't get b or b/c or b/c/d. Need to think how to solve this.
Set default for $Complete::Common::OPT_CI.
Set default for $Complete::Common::OPT_FUZZY.
Set default for $Complete::Common::OPT_WORD_MODE.
Set default for $Complete::Common::OPT_MAP_CASE.
Set default for $Complete::Common::OPT_EXP_IM_PATH.
Set default for $Complete::Common::OPT_DIG_LEAF.
Complete
Please visit the project's homepage at https://metacpan.org/release/Complete-Common.
Source repository is at https://github.com/perlancar/perl-Complete-Common.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Complete-Common
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
perlancar <perlancar@cpan.org>
This software is copyright (c) 2016 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Complete::Common, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Complete::Common
CPAN shell
perl -MCPAN -e shell install Complete::Common
For more information on module installation, please visit the detailed CPAN module installation guide.