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

PortSystem      1.0
PortGroup       github 1.0

epoch           2022121000
revision        0

# please keep it synchronized with cl-swank
github.setup    slime slime 2.28 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
categories      lang
platforms       any
license         Permissive
supported_archs noarch

# If you want to update SLIME, go ahead, but please first test with
# all the currently working Lisps 'abcl', 'ccl', 'clisp', 'ecl' and 'sbcl'.
maintainers {easieste @easye} openmaintainer

description An Emacs mode for unifying Common Lisp development

long_description    \
    SLIME extends Emacs with new support for interactive programming \
    in Common Lisp. The features are centred around `slime-mode', an \
    Emacs minor-mode that complements the standard `lisp-mode'. While \
    `lisp-mode' supports editing Lisp source files, `slime-mode' adds \
    support for interacting with a running Common Lisp process for \
    compilation, debugging, documentation lookup, and so on.

homepage        http://common-lisp.net/project/slime/

checksums           rmd160  7412a6f86733cdc2c50f015c7bd4c886b1201b78 \
                    sha256  c3d41bbbfd71533825d1e937edd96e6dbaf9d97c7a822455e703ef6d942e672e \
                    size    827019

use_configure   no

depends_build   port:texinfo

depends_lib     port:emacs

set slime_emacs_binary "${prefix}/bin/emacs"

variant app description "Build SLIME against editors/emacs-app" {
    depends_run-append port:emacs-app
    depends_run-delete port:emacs
    depends_lib-append port:emacs-app
    depends_lib-delete port:emacs

    set slime_emacs_binary "${applications_dir}/Emacs.app/Contents/MacOS/Emacs"
}

variant sbcl description "Require lang/sbcl for SLIME" {
    depends_run-append path:bin/sbcl:sbcl
}

variant clisp description "Require lang/clisp for SLIME" {
    depends_run-append port:clisp
}

variant abcl description "Require lang/abcl for SLIME" {
    depends_run-append port:abcl
}

variant ccl description "Require lang/ccl for SLIME" {
    depends_run-append port:ccl
}

variant ecl description "Require lang/ecl for SLIME" {
    depends_run-append port:ecl
}

post-patch {
    reinplace "s|/usr/local|${prefix}/share|g" \
        ${worksrcpath}/doc/Makefile
}

set slime_site_dir "${destroot}${prefix}/share/emacs/site-lisp/slime"
set slime_site_source "${slime_site_dir}/swank"
set slime_site_contrib "${slime_site_dir}/contrib"

build {
    system "cd ${worksrcpath} && make compile EMACS=\"$slime_emacs_binary\""
    system "cd ${worksrcpath}/doc && make slime.info"
}

destroot    {
    file mkdir ${destroot}${prefix}/share/emacs/site-lisp
    # realpath to work around base bug introduced by 7921b2e / PR #55
    file copy  [realpath ${worksrcpath}]  \
        ${destroot}${prefix}/share/emacs/site-lisp
}

notes "

To use SLIME, you need to have a Common Lisp installed with which you
wish to interact.  At the moment, 'sbcl', 'abcl', 'ccl', 'ecl' and
'clisp' all work.  As a convenience, port variants for SLIME exist
which require the installation of these Lisps.

Then put the following in your ~/.emacs:

(add-to-list 'load-path \"${prefix}/share/emacs/site-lisp/slime\")
(require 'slime-autoloads)
(setq slime-lisp-implementations
     \`((sbcl (\"${prefix}/bin/sbcl\"))
       (abcl (\"${prefix}/bin/abcl\"))
       (clisp (\"${prefix}/bin/clisp\"))))
(slime-setup  '(slime-repl slime-asdf slime-fancy slime-banner))

Populate the initialization list in SLIME-LISP-IMPLEMENTATIONS with
the correct paths to the Common Lisp exectuables you wish to use.

Then, 'M-x slime' from Emacs should connect you to the first Common
Lisp implementation in the list. 'C-- M-x slime' will present an
interactive chooser for additional implementations in the list.

"
