[rc] Use 'fail' when the alternative file cannot be found
This makes it possible to implement a fallback strategy using 'try .. catch', for cases where the alternative file is not stored in a subdirectory
This commit is contained in:
parent
2f1be14b5f
commit
fac05f3ea0
|
@ -428,11 +428,11 @@ define-command -hidden c-family-alternative-file %{
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "echo -markup '{Error}extension not recognized'"
|
echo "fail 'extension not recognized'"
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
echo "echo -markup '{Error}alternative file not found'"
|
echo "fail 'alternative file not found'"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ define-command lua-alternative-file -docstring 'Jump to the alternate file (impl
|
||||||
case $kak_buffile in
|
case $kak_buffile in
|
||||||
*spec/*_spec.lua)
|
*spec/*_spec.lua)
|
||||||
altfile=$(eval printf %s\\n $(printf %s\\n $kak_buffile | sed s+spec/+'*'/+';'s/_spec//))
|
altfile=$(eval printf %s\\n $(printf %s\\n $kak_buffile | sed s+spec/+'*'/+';'s/_spec//))
|
||||||
[ ! -f $altfile ] && echo "echo -markup '{Error}implementation file not found'" && exit
|
[ ! -f $altfile ] && echo "fail 'implementation file not found'" && exit
|
||||||
;;
|
;;
|
||||||
*.lua)
|
*.lua)
|
||||||
path=$kak_buffile
|
path=$kak_buffile
|
||||||
|
@ -66,10 +66,10 @@ define-command lua-alternative-file -docstring 'Jump to the alternate file (impl
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
[ ! -d $altdir ] && echo "echo -markup '{Error}spec/ not found'" && exit
|
[ ! -d $altdir ] && echo "fail 'spec/ not found'" && exit
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "echo -markup '{Error}alternative file not found'" && exit
|
echo "fail 'alternative file not found'" && exit
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
printf %s\\n "edit $altfile"
|
printf %s\\n "edit $altfile"
|
||||||
|
|
|
@ -56,7 +56,7 @@ define-command moon-alternative-file -docstring 'Jump to the alternate file (imp
|
||||||
case $kak_buffile in
|
case $kak_buffile in
|
||||||
*spec/*_spec.moon)
|
*spec/*_spec.moon)
|
||||||
altfile=$(eval printf %s\\n $(printf %s\\n $kak_buffile | sed s+spec/+'*'/+';'s/_spec//))
|
altfile=$(eval printf %s\\n $(printf %s\\n $kak_buffile | sed s+spec/+'*'/+';'s/_spec//))
|
||||||
[ ! -f $altfile ] && echo "echo -markup '{Error}implementation file not found'" && exit
|
[ ! -f $altfile ] && echo "fail 'implementation file not found'" && exit
|
||||||
;;
|
;;
|
||||||
*.moon)
|
*.moon)
|
||||||
path=$kak_buffile
|
path=$kak_buffile
|
||||||
|
@ -68,10 +68,10 @@ define-command moon-alternative-file -docstring 'Jump to the alternate file (imp
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
[ ! -d $altdir ] && echo "echo -markup '{Error}spec/ not found'" && exit
|
[ ! -d $altdir ] && echo "fail 'spec/ not found'" && exit
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "echo -markup '{Error}alternative file not found'" && exit
|
echo "fail 'alternative file not found'" && exit
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
printf %s\\n "edit $altfile"
|
printf %s\\n "edit $altfile"
|
||||||
|
|
|
@ -102,11 +102,11 @@ define-command ruby-alternative-file -docstring 'Jump to the alternate file (imp
|
||||||
case $kak_buffile in
|
case $kak_buffile in
|
||||||
*spec/*_spec.rb)
|
*spec/*_spec.rb)
|
||||||
altfile=$(eval echo $(echo $kak_buffile | sed s+spec/+'*'/+';'s/_spec//))
|
altfile=$(eval echo $(echo $kak_buffile | sed s+spec/+'*'/+';'s/_spec//))
|
||||||
[ ! -f $altfile ] && echo "echo -markup '{Error}implementation file not found'" && exit
|
[ ! -f $altfile ] && echo "fail 'implementation file not found'" && exit
|
||||||
;;
|
;;
|
||||||
*test/*_test.rb)
|
*test/*_test.rb)
|
||||||
altfile=$(eval echo $(echo $kak_buffile | sed s+test/+'*'/+';'s/_test//))
|
altfile=$(eval echo $(echo $kak_buffile | sed s+test/+'*'/+';'s/_test//))
|
||||||
[ ! -f $altfile ] && echo "echo -markup '{Error}implementation file not found'" && exit
|
[ ! -f $altfile ] && echo "fail 'implementation file not found'" && exit
|
||||||
;;
|
;;
|
||||||
*.rb)
|
*.rb)
|
||||||
path=$kak_buffile
|
path=$kak_buffile
|
||||||
|
@ -119,10 +119,10 @@ define-command ruby-alternative-file -docstring 'Jump to the alternate file (imp
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
[ ! -d $altdir ] && echo "echo -markup '{Error}spec/ and test/ not found'" && exit
|
[ ! -d $altdir ] && echo "fail 'spec/ and test/ not found'" && exit
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "echo -markup '{Error}alternative file not found'" && exit
|
echo "fail 'alternative file not found'" && exit
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
echo "edit $altfile"
|
echo "edit $altfile"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user