@@ -59,14 +59,33 @@ def _start_vim_loop(zo_paths: Iterable[Path], cfg: EditConfig) -> None:
59
59
"Vim loop will run as long as the keep alive file exists." ,
60
60
keep_alive_file = cfg .keep_alive_file ,
61
61
)
62
+ last_paths = zo_paths
62
63
while cfg .keep_alive_file .exists ():
64
+ if cfg .keep_alive_file .stat ().st_size == 0 :
65
+ paths = last_paths
66
+ else :
67
+ paths = last_paths = [
68
+ Path (p .strip ())
69
+ for p in cfg .keep_alive_file .read_text ().split ()
70
+ ]
71
+
63
72
cfg .keep_alive_file .unlink ()
64
73
vimala .vim (
65
- * [cfg .zettel_dir / p for p in zo_paths ],
74
+ * [cfg .zettel_dir / p for p in paths ],
66
75
commands = _process_vim_commands (cfg .zettel_dir , cfg .vim_commands ),
67
76
)
68
77
69
78
79
+ def _process_vim_commands (
80
+ zettel_dir : Path , vim_commands : Iterable [str ]
81
+ ) -> Iterator [str ]:
82
+ for vim_cmd in vim_commands :
83
+ if "{zdir}" in vim_cmd :
84
+ yield vim_cmd .format (zdir = zettel_dir )
85
+ else :
86
+ yield vim_cmd
87
+
88
+
70
89
@runner
71
90
def run_new (cfg : NewConfig ) -> int :
72
91
"""Runner for the 'new' command."""
@@ -112,14 +131,3 @@ def _build_template_in_dir(
112
131
else line
113
132
)
114
133
temp_template_path .write_text ("" .join (new_lines ))
115
-
116
-
117
- # TODO(bugyi): Move to config.py?
118
- def _process_vim_commands (
119
- zettel_dir : Path , vim_commands : Iterable [str ]
120
- ) -> Iterator [str ]:
121
- for vim_cmd in vim_commands :
122
- if "{zdir}" in vim_cmd :
123
- yield vim_cmd .format (zdir = zettel_dir )
124
- else :
125
- yield vim_cmd
0 commit comments