From cf3c9f4a39dd6ddfc62f09b666cd2522c5ff522e Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Wed, 15 Jun 2016 08:52:00 -0400 Subject: Changed "find in files" API a bit. Changed `ui.find.FILTER` to `ui.find.find_in_files_filter` and added an optional filter argument to `ui.find.find_in_files()`. --- modules/textadept/find.lua | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'modules') diff --git a/modules/textadept/find.lua b/modules/textadept/find.lua index 2b88b3c7..561cae5b 100644 --- a/modules/textadept/find.lua +++ b/modules/textadept/find.lua @@ -106,8 +106,8 @@ local preferred_view -- @see find_in_files -- @see lfs.default_filter -- @class table --- @name FILTER -M.FILTER = lfs.default_filter +-- @name find_in_files_filter +M.find_in_files_filter = lfs.default_filter -- Text escape sequences with their associated characters and vice-versa. -- @class table @@ -240,16 +240,17 @@ end --- -- Searches directory *dir* or the user-specified directory for files that match --- search text and search options, and prints the results to a buffer titled --- "Files Found". +-- search text and search options (subject to optional filter *filter*), and +-- prints the results to a buffer titled "Files Found". -- Use the `find_text`, `match_case`, `whole_word`, and `lua` fields to set the --- search text and option flags, respectively. Use `FILTER` to set the search --- filter. +-- search text and option flags, respectively. -- @param dir Optional directory path to search. If `nil`, the user is prompted -- for one. --- @see FILTER +-- @param filter Optional filter for files and directories to exclude. The +-- default value is `ui.find.find_in_files_filter`. +-- @see find_in_files_filter -- @name find_in_files -function M.find_in_files(dir) +function M.find_in_files(dir, filter) dir = dir or ui.dialogs.fileselect{ title = _L['Find in Files'], select_only_directories = true, with_directory = io.get_project_root() or @@ -310,7 +311,7 @@ function M.find_in_files(dir) line_num = line_num + 1 end f:close() - end, M.FILTER) + end, filter or M.find_in_files_filter) if not found then buffer:append_text(_L['No results found']) end ui._print(_L['[Files Found Buffer]'], '') -- goto end, set save pos, etc. end -- cgit v1.2.3