sbt-mode won't compile if hydra is not installed
hvesalai opened this issue · comments
...
Compiling file /home/masplund/.emacs.d/elpa/sbt-mode-20160728.2250/sbt-mode-buffer.el at Thu Aug 11 10:43:17 2016
Entering directory `/home/masplund/.emacs.d/elpa/sbt-mode-20160728.2250/'
Compiling file /home/masplund/.emacs.d/elpa/sbt-mode-20160728.2250/sbt-mode-comint.el at Thu Aug 11 10:43:17 2016
Compiling file /home/masplund/.emacs.d/elpa/sbt-mode-20160728.2250/sbt-mode-hydra.el at Thu Aug 11 10:43:17 2016
sbt-mode-hydra.el:18:1:Error: Cannot open load file: no such file or directory, hydra
Compiling file /home/masplund/.emacs.d/elpa/sbt-mode-20160728.2250/sbt-mode-project.el at Thu Aug 11 10:43:17 2016
...
I was discussing this with @fommil and my understanding was it is ok to introduce hydra as prerequisite to use sbt-mode
.
It should have been introduced as optional, not required.
Any hint how this can be achieved appreciated.
Seems it should be easy to fix, I will look at this on this week hackday.
OK, nice. At least you should be able to do (require 'hydra "hydra" 't)
(i.e. fail quietly if no hydra is available).
string-suffix-p
is emacs 24.4. Currently ensime claims to work on 24.3+. If you want to continue using string-suffix-p, then the ensime doc needs to be updated on this.- add the following to the beginnin of the file:
(eval-when-compile
(defun sbt-test-hydra/body ()))
- I get warnings on your use of cl library:
sbt-mode-hydra.el:665:1:Warning: the following functions might not be defined
at runtime: cl-mapcar, cl-remove-if-not
This is because in elisp you should only use cl macros not functions.
In all, please see that when you compile the .el files with make
, there are no errors or warnings.
I'm not getting any warnings about cl
library when running make
. I'm using GNU Emacs 24.5.1. Anyway what is recommended workaround when you are not supposed to use cl functions? Is there some package I can use instead? I don't want to reimplement cl-mapcar
from scratch.
Could you just use mapcar
? It's a elisp function. cl-mapcar
is just a wrapper around it.
We should really add a CI to this project. Right now we're not even protected against a stray bracket. It should be easy to add compile support. Ideally we'd want testing too. It's easy enough to add the infrastructure.
We have a few optional dependencies in ensime, unfortunately package
doesn't really have the concept of an optional package so if you don't have the optional package it will still result in an unpleasant compile error for people when they install it through package
, but it is harmless. Perhaps we could investigate some macro approach to skipping the compile of certain files if the optional is not available.
Ok. I'm not in the emacs scene at the moment, but by quick googling it seems to me that cl
has been deprecated and you should include cl-lib
if you really need cl.
so instead of
(eval-when-compile (require 'cl)) ;; only need cl macros
you do
(require 'cl-lib)
This removes the warnings for me.
I believe I can replace cl-mapcar
by mapcar
, but I would than need dash.el
as a dependency. But since ensime
depends on dash.el
I assume it wouldn't be a problem.
I'm using cl-mapcar
like so
(let ((seq1 '(1 1 1))
(seq2 '(2 2 2))
(seq3 '(3 3 3)))
(cl-mapcar (lambda (a b c)
(+ a b c)) seq1 seq2 seq3)) ;=> (6 6 6)
I can do the same thing with mapcar
if I reorganise seq1
seq2
and seq3
into:
(mapcar (lambda (i) (apply '+ i)) '((1 2 3) (1 2 3) (1 2 3))) ;=> (6 6 6)
Now suggest.el
is saying to use -zip
for the transformation:
;; Inputs (one per line):
'(1 1 1)
'(2 2 2)
'(3 3 3)
;; Desired output:
'((1 2 3) (1 2 3) (1 2 3))
;; Suggestions:
(-zip '(1 1 1) '(2 2 2) '(3 3 3)) ;=> '((1 2 3)
;(1 2 3)
;(1 2 3))
@VlachJosef also you need to include
ELISP_FILES += $(MODE_NAME)-hydra
so that the hydra file is compiled (and this is why you didn't get the warnings).
@VlachJosef sbt-mode must be completely independent of ensime, so please no extra dependencies. Instead see my comment about cl-lib
above.
And apologies for this late code review :-) didn't have time to properly get into this before.
@hvesalai I didn't mean to introduce ensime
as a dependency, just dash.el
, but if (require 'cl-lib)
is a solutions, than that is the best option for me.
dash is awesome
I'm not sure melpa uses the Makefile
, does it? The latest thing all the cool kids are doing is using Cask
to manage the build, and melpa definitely supports that.
Go with (require 'cl-lib).
Melpa doesn't use Makefile, but you can use it when developing to see the warnings and errors of compiling the el's.