# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

NEED_EMACS="29.1"

inherit elisp

DESCRIPTION="GNU Emacs major mode for the Unison language"
HOMEPAGE="https://www.unison-lang.org/docs/usage-topics/editor-setup/
	https://github.com/fmguerreiro/unison-ts-mode/"

if [[ "${PV}" == *9999* ]] ; then
	inherit git-r3

	EGIT_REPO_URI="https://github.com/fmguerreiro/${PN}"
else
	SRC_URI="https://github.com/fmguerreiro/${PN}/archive/refs/tags/v${PV}.tar.gz
		-> ${P}.gh.tar.gz"

	KEYWORDS="~amd64 ~x86"
fi

LICENSE="GPL-3+"
SLOT="0"

RDEPEND="
	>=app-editors/emacs-${NEED_EMACS}:*[tree-sitter(+)]
"
BDEPEND="
	${RDEPEND}
"

DOCS=( README.md )
SITEFILE="50${PN}-gentoo.el"

elisp-enable-tests ert . -l "${PN}-autoloads.el" -l "${PN}-tests.el"

src_compile() {
	elisp_src_compile
	elisp-make-autoload-file
}

src_install() {
	rm -f unison-ts-mode-tests.el unison-ts-mode-tests.elc || die
	elisp_src_install
}