diff mbox series

[bug#45575] Add emacs-merlin

Message ID 87ble94ovj.fsf@asu.edu
State Accepted
Headers show
Series [bug#45575] Add emacs-merlin | expand

Checks

Context Check Description
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

John Soo Dec. 31, 2020, 10 p.m. UTC
I wanted to make autoloads and byte-compile the elisp provided by
merlin.  After fiddling with the emacs output of ocaml-merlin, I found
it much easier to just make an emacs package for merlin.  There is
further work to do to make a vim merlin package but I am not familiar
enough with vim to continue.

- John
diff mbox series

Patch

From 902849f8b8f586347dfd7810c46acc754a323592 Mon Sep 17 00:00:00 2001
From: John Soo <jsoo1@asu.edu>
Date: Thu, 31 Dec 2020 13:34:57 -0800
Subject: [PATCH] gnu: Add emacs-merlin.

* gnu/packages/emacs-xyz.scm (emacs-merlin): New variable.
* gnu/packages/ocaml.scm (ocaml-merlin): [arguments] Remove elisp from output,
[description] Note location of emacs package.
---
 gnu/packages/emacs-xyz.scm | 39 ++++++++++++++++++++++++++++++++++++++
 gnu/packages/ocaml.scm     | 11 +++++++++--
 2 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index 0d8d6837e1..a97bd5ce1e 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -135,6 +135,7 @@ 
   #:use-module (gnu packages haskell-apps)
   #:use-module (gnu packages ibus)
   #:use-module (gnu packages ncurses)
+  #:use-module (gnu packages ocaml)
   #:use-module (gnu packages python)
   #:use-module (gnu packages python-xyz)
   #:use-module (gnu packages telephony)
@@ -646,6 +647,44 @@  process, passing on the arguments as command line arguments.")
        "Magit-annex adds a few git-annex operations to the Magit interface.")
       (license license:gpl3+))))
 
+(define-public emacs-merlin
+  (package
+    (name "emacs-merlin")
+    (version "3.4.2")
+    (home-page "https://ocaml.github.io/merlin/")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/ocaml/merlin")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "0i2nwkdh6cfzmnsdsr8aw86vs8j1k5jkjzrs61b9384wnffdbbmj"))))
+    (build-system emacs-build-system)
+    (propagated-inputs
+     `(("emacs-auto-complete" ,emacs-auto-complete)
+       ("emacs-company" ,emacs-company)
+       ("emacs-iedit" ,emacs-iedit)
+       ("ocaml-merlin" ,ocaml-merlin)))
+    (arguments
+     `(#:tests? #f ; No tests
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'setup-emacs-build
+           (lambda* (#:key inputs #:allow-other-keys)
+             (let ((merlin (assoc-ref inputs "ocaml-merlin")))
+               (chdir "emacs")
+               (for-each make-file-writable (find-files "." "\\.el$"))
+               (emacs-substitute-variables "merlin.el"
+                 ("merlin-command"
+                  (string-append merlin "/bin/ocamlmerlin")))))))))
+    (synopsis "Context sensitive completion for OCaml in Emacs")
+    (description "Merlin is an editor service that provides modern IDE
+features for OCaml.  This package provides the Emacs support for Merlin.")
+    (license license:expat)))
+
 (define-public emacs-minions
   (package
     (name "emacs-minions")
diff --git a/gnu/packages/ocaml.scm b/gnu/packages/ocaml.scm
index bb5d6c4e92..5f8cf4613d 100644
--- a/gnu/packages/ocaml.scm
+++ b/gnu/packages/ocaml.scm
@@ -4070,12 +4070,19 @@  documentation always stays up-to-date.")
      `(("ocaml-dot-merlin-reader" ,ocaml-dot-merlin-reader)))
     (arguments
      `(#:package "merlin"
-       #:test-target "tests"))
+       #:test-target "tests"
+       #:phases
+       ;; FIXME: Make merlin.vim into a separate package.
+       (modify-phases %standard-phases
+         (add-after 'install 'remove-emacs
+           (lambda* (#:key outputs #:allow-other-keys)
+             (delete-file-recursively
+              (string-append (assoc-ref outputs "out") "/share/emacs")))))))
     (synopsis "Context sensitive completion for OCaml in Vim and Emacs")
     (description "Merlin is an editor service that provides modern IDE
 features for OCaml.  Emacs and Vim support is provided out-of-the-box.
 External contributors added support for Visual Studio Code, Sublime Text and
-Atom.")
+Atom.  To install the emacs specific package, use @code{emacs-ocaml-merlin}.")
     (license license:expat)))
 
 (define-public ocaml4.07-merlin
-- 
2.29.2