From 7e736289ce3de1ac788fa9236552407c6935896b Mon Sep 17 00:00:00 2001 From: Olivier Perret Date: Thu, 5 Nov 2020 16:55:05 +0100 Subject: [PATCH] c-family: allow specifying absolute alt directory paths alt-dirs which start with a / are considered to be absolute --- rc/filetype/c-family.kak | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rc/filetype/c-family.kak b/rc/filetype/c-family.kak index 4f056857f..0af8fcff7 100644 --- a/rc/filetype/c-family.kak +++ b/rc/filetype/c-family.kak @@ -415,7 +415,10 @@ define-command -hidden c-family-alternative-file %{ *.c|*.cc|*.cpp|*.cxx|*.C|*.inl|*.m) for alt_dir in "$@"; do for ext in h hh hpp hxx H; do - altname="${dir}/${alt_dir}/${file_noext}.${ext}" + case "$alt_dir" in + /*) altname="${alt_dir}/${file_noext}.${ext}" ;; + *) altname="${dir}/${alt_dir}/${file_noext}.${ext}" ;; + esac if [ -f ${altname} ]; then printf 'edit %%{%s}\n' "${altname}" exit @@ -426,7 +429,10 @@ define-command -hidden c-family-alternative-file %{ *.h|*.hh|*.hpp|*.hxx|*.H) for alt_dir in "$@"; do for ext in c cc cpp cxx C m; do - altname="${dir}/${alt_dir}/${file_noext}.${ext}" + case "$alt_dir" in + /*) altname="${alt_dir}/${file_noext}.${ext}" ;; + *) altname="${dir}/${alt_dir}/${file_noext}.${ext}" ;; + esac if [ -f ${altname} ]; then printf 'edit %%{%s}\n' "${altname}" exit