From aac6f1cf40034e14c5fde912878cce68e9bedd38 Mon Sep 17 00:00:00 2001 From: Lukas Date: Sun, 5 Jan 2025 21:26:07 +0100 Subject: [PATCH] Rewriting the docs showed the names of the filers for the watcher are misleading The keywords `only`/`not` give the options a very final sounding. Also `only` is not really true depending on the setting (depends on what the previous filters did). Thus, these keywords in the options are renamed to `inc`(lude)/`exc`(lude). In order to avoid confusion with the `inc-exc` option (which otherwise would really close to `inc-ext`), this option is also renamed to `filter`. --- args.md | 8 +++---- doc/args.tex | 8 +++---- doc/cluttealtex.tex | 22 ++++++++--------- src_teal/texrunner/option_spec.tl | 40 +++++++++++++++---------------- src_teal/texrunner/option_type.tl | 4 ++-- src_teal/texrunner/watcher.tl | 12 +++++----- 6 files changed, 47 insertions(+), 47 deletions(-) diff --git a/args.md b/args.md index 776978d..e98e676 100644 --- a/args.md +++ b/args.md @@ -40,8 +40,8 @@ | verbose | verbose | V | - | | version | version | v | - | | watch | watch[=watch] | - | auto | +| watch_exc_ext | watch-exc-ext=watch_exc_ext | - | - | +| watch_exc_path | watch-exc-path=watch_exc_path | - | - | | watch_inc_exc | - | - | - | -| watch_not_ext | watch-not-ext=watch_not_ext | - | - | -| watch_not_path | watch-not-path=watch_not_path | - | - | -| watch_only_ext | watch-only-ext=watch_only_ext | - | - | -| watch_only_path | watch-only-path=watch_only_path | - | - | +| watch_inc_ext | watch-inc-ext=watch_inc_ext | - | - | +| watch_inc_path | watch-inc-path=watch_inc_path | - | - | diff --git a/doc/args.tex b/doc/args.tex index fbe2a2c..187eadf 100644 --- a/doc/args.tex +++ b/doc/args.tex @@ -41,10 +41,10 @@ verbose & verbose & V & - \\ version & version & v & - \\ watch & watch[=watch] & - & auto \\ +watch\_exc\_ext & watch-exc-ext=watch\_exc\_ext & - & - \\ +watch\_exc\_path & watch-exc-path=watch\_exc\_path & - & - \\ watch\_inc\_exc & - & - & - \\ -watch\_not\_ext & watch-not-ext=watch\_not\_ext & - & - \\ -watch\_not\_path & watch-not-path=watch\_not\_path & - & - \\ -watch\_only\_ext & watch-only-ext=watch\_only\_ext & - & - \\ -watch\_only\_path & watch-only-path=watch\_only\_path & - & - \\ +watch\_inc\_ext & watch-inc-ext=watch\_inc\_ext & - & - \\ +watch\_inc\_path & watch-inc-path=watch\_inc\_path & - & - \\ \bottomrule \end{longtable} \ No newline at end of file diff --git a/doc/cluttealtex.tex b/doc/cluttealtex.tex index cb8cd6e..afe8c40 100644 --- a/doc/cluttealtex.tex +++ b/doc/cluttealtex.tex @@ -1040,7 +1040,7 @@ \subsubsection{Watch Mode} % doc new=2025-01-01, % doc updated=2025-01-01, doc keypath=cli, - doc name=watch-not-ext, + doc name=watch-exc-ext, doc parameter={=\meta{ext}}, doc description={default: none, initial: none}, }, @@ -1048,7 +1048,7 @@ \subsubsection{Watch Mode} % doc new=2025-01-01, % doc updated=2025-01-01, doc keypath=cli, - doc name=watch-not-path, + doc name=watch-exc-path, doc parameter={=\meta{path}}, doc description={default: none, initial: none}, }, @@ -1056,7 +1056,7 @@ \subsubsection{Watch Mode} % doc new=2025-01-01, % doc updated=2025-01-01, doc keypath=cli, - doc name=watch-ext, + doc name=watch-inc-ext, doc parameter={=\meta{ext}}, doc description={default: none, initial: none}, }, @@ -1064,7 +1064,7 @@ \subsubsection{Watch Mode} % doc new=2025-01-01, % doc updated=2025-01-01, doc keypath=cli, - doc name=watch-path, + doc name=watch-inc-path, doc parameter={=\meta{path}}, doc description={default: none, initial: none}, }, @@ -1084,8 +1084,8 @@ \subsubsection{Watch Mode} \begin{itemize} \item[Note:] The order of the argument matters. \item[Note:] No matter which of these options you use, the default is always to not watch a file. - So by only using \texttt{--watch-not-path=./aux/} you will end up by not watching any path. - You can of course change this by specifying \texttt{--watch-only-path=/} before. + So by only using \texttt{--watch-exc-path=./aux/} you will end up by not watching any path. + You can of course change this by specifying \texttt{--watch-inc-path=/} before. \end{itemize} \end{docKeys} @@ -1325,8 +1325,8 @@ \subsubsection{Filter watched files} There are the following \emph{rules}: \begin{itemize} - \item \iboxcmd{not} files matching this rule will be excluded - \item \iboxcmd{only} files matching this rule will be included + \item \iboxcmd{exc} files matching this rule will be excluded + \item \iboxcmd{inc} files matching this rule will be included \end{itemize} and the following \emph{matchers}: \begin{itemize} @@ -1336,15 +1336,15 @@ \subsubsection{Filter watched files} \begin{itemize} \item[Note:] A file continues to traverse the filters even if it was matched. - So for example \texttt{watch-only-ext="tex" watch-not-path="/usr/local/texlive"} will watch all \texttt{tex} files except the ones located in \texttt{/usr/local/texlive}. + So for example \texttt{watch-inc-ext="tex" watch-exc-path="/usr/local/texlive"} will watch all \texttt{tex} files except the ones located in \texttt{/usr/local/texlive}. \end{itemize} This is what happens to each file that is being a candidate for being watched: \begin{enumerate} - \item (In case you did not define any filtering (none of \texttt{watch-\{not,only\}-\{path,ext\}} passed), the file is marked was being watched and the following steps are skipped) + \item (In case you did not define any filtering (none of \texttt{watch-\{inc,exc\}-\{path,ext\}} passed), the file is marked was being watched and the following steps are skipped) \item The file always begins as being marked as \emph{not watched} \item Then it traverses all filters and might change (multiple times, no stopping if one filter matches\footnote{ - This enables you to use \texttt{--watch-only-path=/} to change the default easily + This enables you to use \texttt{--watch-inc-path=/} to change the default easily }) its state. \end{enumerate} diff --git a/src_teal/texrunner/option_spec.tl b/src_teal/texrunner/option_spec.tl index 9d44215..1350eca 100644 --- a/src_teal/texrunner/option_spec.tl +++ b/src_teal/texrunner/option_spec.tl @@ -324,14 +324,14 @@ _M.spec = { text = "Watch input files for change (Supported: auto, fswatch, inotifywait)\n[initial: auto]", }, }, - watch_only_path = { - long = "watch-only-path", + watch_inc_path = { + long = "watch-inc-path", param = true, no_cfg = true, handle_cli = function(options:option_t.Options, param:string|boolean) if param is string then - options.watch_inc_exc = options.watch_inc_exc or {} - table.insert(options.watch_inc_exc, {param=pathutil.abspath(param),type='only_path'}) + options.watch_filter = options.watch_filter or {} + table.insert(options.watch_filter, {param=pathutil.abspath(param),type='inc_path'}) else error("invalid param type") end @@ -342,14 +342,14 @@ _M.spec = { text = "Add filter to which files are being watched", }, }, - watch_not_path = { - long = "watch-not-path", + watch_exc_path = { + long = "watch-exc-path", param = true, no_cfg = true, handle_cli = function(options:option_t.Options, param:string|boolean) if param is string then - options.watch_inc_exc = options.watch_inc_exc or {} - table.insert(options.watch_inc_exc, {param=pathutil.abspath(param),type='not_path'}) + options.watch_filter = options.watch_filter or {} + table.insert(options.watch_filter, {param=pathutil.abspath(param),type='exc_path'}) else error("invalid param type") end @@ -360,14 +360,14 @@ _M.spec = { text = "Add filter to which files are not being watched", }, }, - watch_only_ext = { - long = "watch-only-ext", + watch_inc_ext = { + long = "watch-inc-ext", param = true, no_cfg = true, handle_cli = function(options:option_t.Options, param:string|boolean) if param is string then - options.watch_inc_exc = options.watch_inc_exc or {} - table.insert(options.watch_inc_exc, {param=param,type='only_ext'}) + options.watch_filter = options.watch_filter or {} + table.insert(options.watch_filter, {param=param,type='inc_ext'}) else error("invalid param type") end @@ -378,14 +378,14 @@ _M.spec = { text = "Add filter to which extensions are being watched", }, }, - watch_not_ext = { - long = "watch-not-ext", + watch_exc_ext = { + long = "watch-exc-ext", param = true, no_cfg = true, handle_cli = function(options:option_t.Options, param:string|boolean) if param is string then - options.watch_inc_exc = options.watch_inc_exc or {} - table.insert(options.watch_inc_exc, {param=param,type='not_ext'}) + options.watch_filter = options.watch_filter or {} + table.insert(options.watch_filter, {param=param,type='exc_ext'}) else error("invalid param type") end @@ -396,14 +396,14 @@ _M.spec = { text = "Add filter to which extensions are not being watched", }, }, - watch_inc_exc = { + watch_filter = { no_cli = true, accumulate = true, handle_cfg = function(options:option_t.Options, param: {any}) for _,i in ipairs(param) do - if i is option_t.WatchIncExc then - if i.type and i.param and (i.type == "not_ext" or i.type == "only_ext" or i.type == "not_path" or i.type == "only_path") then - table.insert(options.watch_inc_exc, i) + if i is option_t.WatchFilter then + if i.type and i.param and (i.type == "exc_ext" or i.type == "inc_ext" or i.type == "exc_path" or i.type == "inc_path") then + table.insert(options.watch_filter, i) end end end diff --git a/src_teal/texrunner/option_type.tl b/src_teal/texrunner/option_type.tl index 6ce5275..abe3800 100644 --- a/src_teal/texrunner/option_type.tl +++ b/src_teal/texrunner/option_type.tl @@ -32,7 +32,7 @@ local record Module synctex: string tex_extraoptions: {string} watch: string - watch_inc_exc: {WatchIncExc} + watch_filter: {WatchFilter} fmt: string makeindex: string sagetex: string @@ -43,7 +43,7 @@ local record Module hooks: Hooks end - record WatchIncExc + record WatchFilter type: string param: string end diff --git a/src_teal/texrunner/watcher.tl b/src_teal/texrunner/watcher.tl index 6245aad..78040ed 100644 --- a/src_teal/texrunner/watcher.tl +++ b/src_teal/texrunner/watcher.tl @@ -35,7 +35,7 @@ else end -- Helper function to determine whether a file should be watched based on user-specified filters -local function should_watch_file(fileinfo:common_t.Filemap_ele, filters: {options.WatchIncExc}): boolean +local function should_watch_file(fileinfo:common_t.Filemap_ele, filters: {options.WatchFilter}): boolean if not filters then -- If no filters are provided, watch all files by default return true @@ -43,22 +43,22 @@ local function should_watch_file(fileinfo:common_t.Filemap_ele, filters: {option local watch = false -- Loop through all filters and apply the inclusion/exclusion rules for _,v in ipairs(filters) do - if v.type == "only_path" then + if v.type == "inc_path" then -- Watch only files with a matching path prefix if string.sub(fileinfo.abspath, 1, #v.param) == v.param then watch = true end - elseif v.type == "only_ext" then + elseif v.type == "inc_ext" then -- Watch only files with a matching extension if pathutil.ext(fileinfo.abspath) == v.param then watch = true end - elseif v.type == "not_path" then + elseif v.type == "exc_path" then -- Exclude files with a matching path prefix if string.sub(fileinfo.abspath, 1, #v.param) == v.param then watch = false end - elseif v.type == "not_ext" then + elseif v.type == "exc_ext" then -- Exclude files with a matching extension if pathutil.ext(fileinfo.abspath) == v.param then watch = false @@ -74,7 +74,7 @@ local function gather_input_files_to_watch(max_watches: integer, options: option -- Iterate over the file list to determine files eligible for watching for _,fileinfo in ipairs(filelist) do if fileinfo.kind == "input" then - if should_watch_file(fileinfo, options.watch_inc_exc) then + if should_watch_file(fileinfo, options.watch_filter) then table.insert(input_files_to_watch, fileinfo.abspath) end end