# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0

PortGroup           github 1.0

github.setup        martanne vis 0.9 v
github.tarball_from archive
revision            0
categories          editors
maintainers         {en.sent.com:macports @Raimondi} openmaintainer
license             ISC
description         a highly efficient text editor
long_description    vis is a highly efficient screen-oriented text editor \
                    combining the strengths of both vi(m) and sam.

checksums           rmd160  69fbbd09844573ec110f52d0b6d7ac575f480f16 \
                    sha256  bd37ffba5535e665c1e883c25ba5f4e3307569b6d392c60f3c7d5dedd2efcfca \
                    size    456713

set lua_version     5.4
set lua_shortver    [string replace ${lua_version} 1 1]

depends_lib-append  port:ncurses    \
                    port:libtermkey \
                    port:tre        \
                    port:lua${lua_shortver} \
                    port:lua${lua_shortver}-lpeg

patchfiles-append   patch-configure-luaver.diff     \
                    patch-Makefile.diff             \
                    patch-man-vis-clipboard.1.diff  \
                    patch-man-vis-complete.1.diff   \
                    patch-man-vis-digraph.1.diff    \
                    patch-man-vis-menu.1.diff       \
                    patch-man-vis-open.1.diff       \
                    patch-man-vis.1.diff           \
                    patch-vis-lua.c.diff

pre-configure {
    reinplace -E "s|@@LUA_VERSION@@|${lua_version}|g" ${worksrcpath}/configure
}

post-patch {
    reinplace -W ${worksrcpath} "s|@VISEXEC@|vis-editor|g" Makefile
    reinplace -W ${worksrcpath}/man "s|@VISEXEC@|vis-editor|g" vis-clipboard.1 \
            vis-complete.1 vis-digraph.1 vis-menu.1 vis-open.1 vis.1

    reinplace -W ${worksrcpath} "s|@VISDIR@|vis|g" Makefile

    reinplace -W ${worksrcpath}/man "s|@VISMAN@|VIS-EDITOR|g" vis.1

    reinplace -W ${worksrcpath} "s|@PREFIX@|${prefix}|g" man/vis.1 vis-lua.c

    file rename ${worksrcpath}/man/vis.1 ${worksrcpath}/man/vis-editor.1
}
