aboutsummaryrefslogtreecommitdiff
path: root/modules/textadept/find.lua
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2018-09-13 14:50:15 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2018-09-13 14:50:15 -0400
commit862763418ae440a6d1d69f6340e35a1d8cb7ec7c (patch)
treef41224bec5d33a1c7435626039cd753dbeca94c7 /modules/textadept/find.lua
parenta862a098aca9715e996ffeb2f69d79cba2eaa6eb (diff)
downloadtextadept-862763418ae440a6d1d69f6340e35a1d8cb7ec7c.tar.gz
textadept-862763418ae440a6d1d69f6340e35a1d8cb7ec7c.zip
Replaced `ui.find.find_in_files_filter` with `ui.find.find_in_files_filters`.
This allows for per-project "find in files" filters.
Diffstat (limited to 'modules/textadept/find.lua')
-rw-r--r--modules/textadept/find.lua49
1 files changed, 24 insertions, 25 deletions
diff --git a/modules/textadept/find.lua b/modules/textadept/find.lua
index 4f6ce774..796c8434 100644
--- a/modules/textadept/find.lua
+++ b/modules/textadept/find.lua
@@ -89,29 +89,11 @@ events.FIND_WRAPPED = 'find_wrapped'
local preferred_view
---
--- The table of Lua patterns matching files and directories to exclude when
--- finding in files.
--- The filter table contains:
---
--- + Lua patterns that match filenames to exclude.
--- + Optional `folders` sub-table that contains patterns matching directories
--- to exclude.
--- + Optional `extensions` sub-table that contains raw file extensions to
--- exclude.
--- + Optional `symlink` flag that when `true`, excludes symlinked files (but
--- not symlinked directories).
--- + Optional `folders.symlink` flag that when `true`, excludes symlinked
--- directories.
---
--- Any patterns starting with '!' exclude files and directories that do not
--- match the pattern that follows.
--- The default value is `lfs.default_filter`, a filter for common binary file
--- extensions and version control directories.
--- @see find_in_files
--- @see lfs.default_filter
+-- Map of file paths to filters used in `ui.find.find_in_files()`.
-- @class table
--- @name find_in_files_filter
-M.find_in_files_filter = lfs.default_filter
+-- @name find_in_files_filters
+-- @see find_in_files
+M.find_in_files_filters = {}
-- Keep track of find text and found text so that "replace all" works as
-- expected during a find session ("replace all" with selected text normally
@@ -221,11 +203,28 @@ end
-- prints the results to a buffer titled "Files Found", highlighting found text.
-- Use the `find_text`, `match_case`, `whole_word`, and `regex` fields to set
-- the search text and option flags, respectively.
+-- A filter is a table that contains:
+--
+-- + Lua patterns that match filenames to exclude.
+-- + Optional `folders` sub-table that contains patterns matching directories
+-- to exclude.
+-- + Optional `extensions` sub-table that contains raw file extensions to
+-- exclude.
+-- + Optional `symlink` flag that when `true`, excludes symlinked files (but
+-- not symlinked directories).
+-- + Optional `folders.symlink` flag that when `true`, excludes symlinked
+-- directories.
+--
+-- Any filter patterns starting with '!' exclude files and directories that do
+-- not match the pattern that follows.
+-- If *filter* is `nil`, the filter from the `ui.find.find_in_files_filters`
+-- table is used. If that filter does not exist, `lfs.default_filter` is used.
-- @param dir Optional directory path to search. If `nil`, the user is prompted
-- for one.
-- @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
+-- default value is `lfs.default_filter` unless a filter for *dir* is defined
+-- in `ui.find.find_in_files_filters`.
+-- @see find_in_files_filters
-- @name find_in_files
function M.find_in_files(dir, filter)
dir = dir or ui.dialogs.fileselect{
@@ -291,7 +290,7 @@ function M.find_in_files(dir, filter)
end
ref_time = os.time()
end
- end, filter or M.find_in_files_filter)
+ end, filter or M.find_in_files_filters[dir] or lfs.default_filter)
if not found then ff_buffer:append_text(_L['No results found']) end
buffer:delete() -- delete temporary buffer
ui._print(_L['[Files Found Buffer]'], '') -- goto end, set save pos, etc.