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
This commit is contained in:
Marty Oehme 2025-04-05 11:26:01 +02:00
parent 96422d254b
commit 3fded7315c
Signed by: Marty
GPG key ID: 4E535BC19C61886E

View file

@ -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"),
}
)