From e949c601236c774b595d403bb6aa23c76293f5cb Mon Sep 17 00:00:00 2001 From: Rafal Gwozdzinski Date: Wed, 15 Nov 2023 12:15:46 +0100 Subject: [PATCH 1/3] Change flag name from `-cache-period` to `-cache-lifespan` --- doc/dev/CACHING.md | 2 +- emacs/merlin.el | 6 +++--- src/frontend/ocamlmerlin/new/new_merlin.ml | 2 +- src/kernel/mconfig.ml | 10 +++++----- src/kernel/mconfig.mli | 2 +- tests/test-dirs/config/dot-merlin-reader/quoting.t | 2 +- tests/test-dirs/server-tests/cache-time.t | 6 +++--- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/doc/dev/CACHING.md b/doc/dev/CACHING.md index c422cb40c0..a272e6633d 100644 --- a/doc/dev/CACHING.md +++ b/doc/dev/CACHING.md @@ -78,7 +78,7 @@ to be used anymore. `Mocaml.flush_caches` remove all files that have changed on disk or that haven't been used for some time. By default, `ocamlmerlin_server` remove entries that haven't been used in the last 5 minutes. This behavior can be -changed with `--cache-period` flag. +changed with `-cache-lifespan` flag. Since this involve stating each entry, the check is done after answering. diff --git a/emacs/merlin.el b/emacs/merlin.el index bc2df647cb..3f79d97481 100644 --- a/emacs/merlin.el +++ b/emacs/merlin.el @@ -194,7 +194,7 @@ a new window or not." "If non-nil, use this file for the log file (should be an absolute path)." :group 'merlin :type 'file) -(defcustom merlin-cache-period nil +(defcustom merlin-cache-lifespan nil "If non-nil, use this value for cache period (measured in minutes)." :group 'merlin :type 'natnum) @@ -554,8 +554,8 @@ argument (lookup appropriate binary, setup logging, pass global settings)" (cons "-flags" merlin-buffer-flags)) (when filename (cons "-filename" filename)) - (when merlin-cache-period - (cons "-cache-period" (number-to-string merlin-cache-period))) + (when merlin-cache-lifespan + (cons "-cache-lifespan" (number-to-string merlin-cache-lifespan))) args)) ;; Log last commands (setq merlin-debug-last-commands diff --git a/src/frontend/ocamlmerlin/new/new_merlin.ml b/src/frontend/ocamlmerlin/new/new_merlin.ml index 213835b0fb..2d6f16808b 100644 --- a/src/frontend/ocamlmerlin/new/new_merlin.ml +++ b/src/frontend/ocamlmerlin/new/new_merlin.ml @@ -92,7 +92,7 @@ let run = function Logger.with_log_file Mconfig.(config.merlin.log_file) ~sections:Mconfig.(config.merlin.log_sections) @@ fun () -> Mocaml.flush_caches - ~older_than:(float_of_int (60 * Mconfig.(config.merlin.cache_period))) (); + ~older_than:(float_of_int (60 * Mconfig.(config.merlin.cache_lifespan))) (); File_id.with_cache @@ fun () -> let source = Msource.make (Misc.string_of_file stdin) in let pipeline = Mpipeline.make config source in diff --git a/src/kernel/mconfig.ml b/src/kernel/mconfig.ml index d9d859c102..93ef775227 100644 --- a/src/kernel/mconfig.ml +++ b/src/kernel/mconfig.ml @@ -94,7 +94,7 @@ type merlin = { failures : string list; extension_to_reader : (string * string) list; - cache_period : int + cache_lifespan : int } let dump_merlin x = @@ -131,7 +131,7 @@ let dump_merlin x = "reader", `String reader; ]) x.extension_to_reader ); - "cache_period" , Json.string (string_of_int x.cache_period) + "cache_lifespan" , Json.string (string_of_int x.cache_lifespan) ] module Verbosity = struct @@ -361,9 +361,9 @@ let merlin_flags = [ " Change path of ocaml standard library" ); ( - "-cache-period", + "-cache-lifespan", Marg.param "int" (fun prot merlin -> - try {merlin with cache_period = (int_of_string prot)} + try {merlin with cache_lifespan = (int_of_string prot)} with _ -> invalid_arg "Valid value is int"; ), "Change file cache retention period. It's measured in minutes. \ @@ -638,7 +638,7 @@ let initial = { failures = []; extension_to_reader = [(".re","reason");(".rei","reason")]; - cache_period = 5; + cache_lifespan = 5; }; query = { filename = "*buffer*"; diff --git a/src/kernel/mconfig.mli b/src/kernel/mconfig.mli index 6042ba6fbf..e219f4b4fe 100644 --- a/src/kernel/mconfig.mli +++ b/src/kernel/mconfig.mli @@ -50,7 +50,7 @@ type merlin = { failures : string list; extension_to_reader : (string * string) list; - cache_period : int + cache_lifespan : int } val dump_merlin : merlin -> json diff --git a/tests/test-dirs/config/dot-merlin-reader/quoting.t b/tests/test-dirs/config/dot-merlin-reader/quoting.t index c420427db7..b9ae8c7eee 100644 --- a/tests/test-dirs/config/dot-merlin-reader/quoting.t +++ b/tests/test-dirs/config/dot-merlin-reader/quoting.t @@ -67,7 +67,7 @@ "reader": "reason" } ], - "cache_period": "5" + "cache_lifespan": "5" } $ rm .merlin diff --git a/tests/test-dirs/server-tests/cache-time.t b/tests/test-dirs/server-tests/cache-time.t index 0069d3e3dd..010b8373d7 100644 --- a/tests/test-dirs/server-tests/cache-time.t +++ b/tests/test-dirs/server-tests/cache-time.t @@ -16,18 +16,18 @@ > EOF Let's populate file cache - $ $MERLIN server errors -log-file merlin_logs -cache-period 45 \ + $ $MERLIN server errors -log-file merlin_logs -cache-lifespan 45 \ > -filename main.ml 1> /dev/null -filename main.ml 1> /dev/null | tail -1 | sed 's/\ ".*\"//' keeping When cache time is set to 0, file cache gets flushed - $ $MERLIN server errors -log-file merlin_logs -cache-period 0 \ + $ $MERLIN server errors -log-file merlin_logs -cache-lifespan 0 \ > -filename main.ml 1> /dev/null | tail -1 | sed 's/\ ".*\"//' From d3eb391975c16bdc6fcf674f5e7931b033dec46b Mon Sep 17 00:00:00 2001 From: Rafal Gwozdzinski Date: Wed, 15 Nov 2023 12:21:51 +0100 Subject: [PATCH 2/3] Add changelog entry for #1705 --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 7e9ec7d4d6..cb7142e965 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,7 @@ merlin NEXT_VERSION =================== + merlin binary + - Rename `-cache-period` flag to `-cache-lifespan`. (#1705) - Fix a follow-up issue to the preference of non-ghost nodes introduced in #1660 (#1690, fixes #1689) - Add `--cache-period` flag, that sets cache invalidation period. (#1698) - Fix Merlin locate not fallbacking on the correct file in case of ambiguity From af05ab81b6162edf3cf8ad0628a5302ed524d359 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulysse=20G=C3=A9rard?= Date: Wed, 15 Nov 2023 14:05:20 +0100 Subject: [PATCH 3/3] Merge changelog entries for #1698 and #1705) --- CHANGES.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index cb7142e965..3ff87c4b3a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,9 +2,9 @@ merlin NEXT_VERSION =================== + merlin binary - - Rename `-cache-period` flag to `-cache-lifespan`. (#1705) - Fix a follow-up issue to the preference of non-ghost nodes introduced in #1660 (#1690, fixes #1689) - - Add `--cache-period` flag, that sets cache invalidation period. (#1698) + - Add `-cache-lifespan` flag, that sets cache invalidation period. (#1698, + #1705) - Fix Merlin locate not fallbacking on the correct file in case of ambiguity (@goldfirere, #1699) + editor modes