From f22c4d04ccd109a7c06a21143d12c4d7679a6ea4 Mon Sep 17 00:00:00 2001 From: Erik Flodin Date: Sun, 18 Oct 2020 21:03:46 +0200 Subject: [PATCH] Add support for the extension "condition" This special condition doesn't affect the selection process and is only supported to support syntax highlighting and language detection for alt files as reported in #239. --- test/test_alt.py | 1 + yadm | 4 ++++ yadm.1 | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/test/test_alt.py b/test/test_alt.py index 96c3129..5430c72 100644 --- a/test/test_alt.py +++ b/test/test_alt.py @@ -81,6 +81,7 @@ def test_relative_link(runner, paths, yadm_alt): @pytest.mark.usefixtures('ds1_copy') @pytest.mark.parametrize('suffix', [ '##default', + '##default,e.txt', '##default,extension.txt', '##o.$tst_sys', '##os.$tst_sys', '##d.$tst_distro', '##distro.$tst_distro', '##c.$tst_class', '##class.$tst_class', diff --git a/yadm b/yadm index d0ab8a3..83c774c 100755 --- a/yadm +++ b/yadm @@ -175,6 +175,10 @@ function score_file() { label=${field%%.*} value=${field#*.} [ "$field" = "$label" ] && value="" # when .value is omitted + # extension isn't a condition and doesn't affect the score + if [[ "$label" =~ ^(e|extension)$ ]]; then + continue + fi score=$((score + 1000)) # default condition if [[ "$label" =~ ^(default)$ ]]; then diff --git a/yadm.1 b/yadm.1 index 80156a8..38df0bd 100644 --- a/yadm.1 +++ b/yadm.1 @@ -526,6 +526,11 @@ and trimming off any domain. .TP .B default Valid when no other alternate is valid. +.TP +.BR extension , " e +A special "condition" that doesn't affect the selection process. Its purpose is +instead to allow the alternate file to end with a certain extension to +e.g. make editors highlight the content properly. .LP .BR NOTE :