diff options
author | 2016-06-15 08:52:00 -0400 | |
---|---|---|
committer | 2016-06-15 08:52:00 -0400 | |
commit | cf3c9f4a39dd6ddfc62f09b666cd2522c5ff522e (patch) | |
tree | f38df1dfbcc8c12ef668e93813b389ee922da13f /modules/textadept | |
parent | c90910baf4f9c81711b31697aedf40d359491228 (diff) | |
download | textadept-cf3c9f4a39dd6ddfc62f09b666cd2522c5ff522e.tar.gz textadept-cf3c9f4a39dd6ddfc62f09b666cd2522c5ff522e.zip |
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()`.
Diffstat (limited to 'modules/textadept')
-rw-r--r-- | modules/textadept/find.lua | 19 |
1 files changed, 10 insertions, 9 deletions
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 |