# -*- 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
# $Id$

PortSystem      1.0
PortGroup       github 1.0

epoch           2016081500
github.setup    slime slime 2.18 v
revision        0
categories      lang
platforms       darwin
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 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  514c7db1184a1fb31aff31eafbfe5541ccfb58f7 \
    sha256  a0a260387fe690b6e5d101b4895fddba4de237a37cade3ca096692711ad33ce1


use_configure   no
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 port: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
    file copy  ${workpath}/${worksrcdir}  \
        ${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.

"