From 956ac60d4ac1048ca8a5713c9ccc90941288aff0 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 29 Nov 2012 20:09:37 +0100 Subject: [PATCH] add an ignored_files regex option whose matches are not used for completion --- src/completion.cc | 12 ++++++++++++ src/option_manager.cc | 1 + 2 files changed, 13 insertions(+) diff --git a/src/completion.cc b/src/completion.cc index da5e1387..793b67b2 100644 --- a/src/completion.cc +++ b/src/completion.cc @@ -3,10 +3,13 @@ #include "buffer_manager.hh" #include "utils.hh" #include "file.hh" +#include "context.hh" #include #include +#include + namespace Kakoune { @@ -19,6 +22,11 @@ CandidateList complete_filename(const Context& context, String dirprefix; 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; for (ByteCount i = 0; i < real_prefix.length(); ++i) { @@ -45,6 +53,10 @@ CandidateList complete_filename(const Context& context, if (filename.empty()) continue; + if (not ignored_files.empty() and + boost::regex_match(filename.c_str(), ignored_files_regex)) + continue; + if (filename.substr(0, fileprefix.length()) == fileprefix) { String name = dirprefix + filename; diff --git a/src/option_manager.cc b/src/option_manager.cc index 60a60c78..2472f9dd 100644 --- a/src/option_manager.cc +++ b/src/option_manager.cc @@ -98,6 +98,7 @@ GlobalOptions::GlobalOptions() set_option("eolformat", Option("lf")); set_option("BOM", Option("no")); set_option("complete_prefix", Option(1)); + set_option("ignored_files", Option(R"(^(\..*|.*\.(o|so|a))$)")); } }