From 3fded7315c3ea8140bc96d6cbd49ab40862a6d8f Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sat, 5 Apr 2025 11:26:01 +0200 Subject: [PATCH] fix: Parse EDITOR and VISUAL env vars with lower precedence Since the precedence now goes (from lowest to highest): defaults -> conf_file -> env -> cli existing EDITOR or VISUAL variables would overwrite those explicitly set in the conf file. While we do want the general precedence of env over conf file, this is a special case where we get the value of the _DEFAULT_ variable from the env, and only then start parsing our own options. So now, for these vars we do: default -> env (EDITOR/VISUAL) -> conf_file -> env (TOPEN_EDITOR) -> cli --- topen.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/topen.py b/topen.py index f016aca..4f1721d 100755 --- a/topen.py +++ b/topen.py @@ -22,7 +22,7 @@ DEFAULTS_DICT = { "notes_dir": "~/.local/share/task/notes", "notes_ext": "md", "notes_annot": "Note", - "notes_editor": "nano", + "notes_editor": os.getenv("EDITOR") or os.getenv("VISUAL") or "nano", "notes_quiet": "False", } @@ -56,7 +56,7 @@ def parse_env() -> dict: "notes_dir": os.getenv("TOPEN_DIR"), "notes_ext": os.getenv("TOPEN_EXT"), "notes_annot": os.getenv("TOPEN_ANNOT"), - "notes_editor": os.getenv("TOPEN_EDITOR") or os.getenv("EDITOR") or os.getenv("VISUAL"), + "notes_editor": os.getenv("TOPEN_EDITOR"), "notes_quiet": os.getenv("TOPEN_QUIET"), } )