add an ignored_files regex option whose matches are not used for completion

This commit is contained in:
Maxime Coste 2012-11-29 20:09:37 +01:00
parent 33482b0979
commit 956ac60d4a
2 changed files with 13 additions and 0 deletions

View File

@ -3,10 +3,13 @@
#include "buffer_manager.hh" #include "buffer_manager.hh"
#include "utils.hh" #include "utils.hh"
#include "file.hh" #include "file.hh"
#include "context.hh"
#include <dirent.h> #include <dirent.h>
#include <algorithm> #include <algorithm>
#include <boost/regex.hpp>
namespace Kakoune namespace Kakoune
{ {
@ -19,6 +22,11 @@ CandidateList complete_filename(const Context& context,
String dirprefix; String dirprefix;
String fileprefix = real_prefix; String fileprefix = real_prefix;
String ignored_files = context.options()["ignored_files"].as_string();
boost::regex ignored_files_regex;
if (not ignored_files.empty())
ignored_files_regex = boost::regex(ignored_files.c_str());
ByteCount dir_end = -1; ByteCount dir_end = -1;
for (ByteCount i = 0; i < real_prefix.length(); ++i) for (ByteCount i = 0; i < real_prefix.length(); ++i)
{ {
@ -45,6 +53,10 @@ CandidateList complete_filename(const Context& context,
if (filename.empty()) if (filename.empty())
continue; continue;
if (not ignored_files.empty() and
boost::regex_match(filename.c_str(), ignored_files_regex))
continue;
if (filename.substr(0, fileprefix.length()) == fileprefix) if (filename.substr(0, fileprefix.length()) == fileprefix)
{ {
String name = dirprefix + filename; String name = dirprefix + filename;

View File

@ -98,6 +98,7 @@ GlobalOptions::GlobalOptions()
set_option("eolformat", Option("lf")); set_option("eolformat", Option("lf"));
set_option("BOM", Option("no")); set_option("BOM", Option("no"));
set_option("complete_prefix", Option(1)); set_option("complete_prefix", Option(1));
set_option("ignored_files", Option(R"(^(\..*|.*\.(o|so|a))$)"));
} }
} }