Fork me on GitHub
#cider
<
2017-02-10
>
jfntn18:02:10

@richiardiandrea sorry for not following up the lein-cljs-repl issue, someone else dug in a little bit, and there’s more context here: https://github.com/clojure-emacs/cider/issues/1938

richiardiandrea18:02:21

thanks, I commented there 😄

richiardiandrea19:02:57

@dpsutton just because you are probably on the topic, why don't we have/add a simple function like this in cider?

(defun cider--get-repl-buffer ()
  (-when-let (repl-buffers (cider-repl-buffers))
    (if (= (length repl-buffers) 1)
        (car repl-buffers)
      (completing-read "Choose REPL buffer: "
                       (mapcar #'buffer-name repl-buffers)
                       nil t))))

dpsutton19:02:44

i thought this basically exists

dpsutton19:02:54

i think there's a notion of "cider go to repl buffer"

richiardiandrea19:02:28

yeah I thought the same, but I could not find it and all the functions in cider-interaction.el are actually taking the connection directly

dpsutton19:02:36

its oddly namedc

dpsutton19:02:42

but if i remember right, it normally visits the code

dpsutton19:02:46

but if in code it visits the repl

richiardiandrea19:02:22

I have a simple:

(defun cider-eval-sexp-at-point-in-repl ()
  (interactive)
  (let ((form (cider-sexp-at-point)))
    ;; Strip excess whitespace
    (while (string-match "\\`\s+\\|\n+\\'" form)
      (setq form (replace-match "" t t form)))
    (set-buffer (cider--get-repl-buffer))
    (goto-char (point-max))
    (insert form)
    (cider-repl-return)))

dpsutton19:02:23

cider--switch-to-repl-buffer

agile_geek19:02:37

was about to say that

richiardiandrea19:02:43

and all of a sudden it was broken becasue cider-get-repl-buffer got removed

agile_geek19:02:51

usually bound to C-c C-z

richiardiandrea19:02:00

oh ok, so I might have missed that one

dpsutton19:02:08

wait, is something broken?

dpsutton19:02:14

or the way you want to do something no longer works

richiardiandrea19:02:15

don't worry 😄

richiardiandrea19:02:30

it's a custom function

dpsutton19:02:30

just making sure. it's very easy to break corners of CIDER you don't often use

dpsutton19:02:37

and i was worried I clobbered something

richiardiandrea19:02:33

tell me about it 😄

onetom23:02:30

hi! im just trying to install cider as recommended on https://github.com/clojure-emacs/cider/ and http://www.braveclojure.com/basic-emacs/

M-x package-install [RET] cider [RET]
but i only see the following packages:
{cider-decompile | cider-profile | cider-spy | ac-cider | ac-cider-compliment}
what am i missing? i've got some SSL error message for , so i guess i dont have a complete latest package list? i've installed my emacs from https://emacsformacosx.com and added the configuration recommended by the mentioned braveclojure chapter.

dpsutton23:02:16

try M-x list-packages ret

dpsutton23:02:25

this should update the packages list

dpsutton23:02:32

search through with C-s cider

dpsutton23:02:41

i would say no

dpsutton23:02:51

i think marmalade has been disfavored

dpsutton23:02:54

go with melpa

onetom23:02:21

damn, ive accidentally pressed A i think...

arrdem23:02:48

Eh you probably won’t get owned this way. But yeah you can use melpa-stable

dpsutton23:02:50

no big deal

dpsutton23:02:03

melpa-stable is a good recommendation

dpsutton23:02:17

it runs "releases", whereas melpa tracks the current state

arrdem23:02:18

I have melpa and melpa-stable in my package config

dpsutton23:02:23

which has been known to break

onetom23:02:36

interestingly i can find cider in the list now, but if i say M-x package-install, then i cant see just cider

arrdem23:02:43

;; 00-packages.el

(require 'package)
(require 'cl)

(add-to-list 'load-path "~/.emacs.d/local")

(setq package-archives
      '(
        ("gnu" . "")
        ("marmalade" . "")
        ("melpa-stable" . "")
        ("melpa" . "")
        ; ("org" . "")
        ))

(package-initialize)

(add-to-list 'package-pinned-packages '(cider . "melpa-stable") t)
(add-to-list 'package-pinned-packages '(clj-refactor . "melpa-stable") t)

(defun arrdem:require (req &optional pkg)
  "A wrapper for ensuring that a package is installed, and requiring it.

Enables me to modularize the previously monolithic installation
of packages."

  (let ((pkg (or pkg req)))
    (package-install pkg)
    (require req)))

arrdem23:02:27

I may not need that (require ‘cl)...

arrdem23:02:16

onetom: you’ll need to refresh the package list

onetom23:02:20

@arrdem with M-x list-packages as mentioned above?

onetom23:02:32

or u mean after i changed the config?

arrdem23:02:28

if you’ve changed package-archives you’ll want to list-packages, and maybe press g in the package list buffer.

onetom23:02:31

interesting, in the braveclojure's example config init.el looks like this:

;; Define package repositories
(require 'package)
(add-to-list 'package-archives
             '("marmalade" . "") t)
(add-to-list 'package-archives
             '("tromey" . "") t)
(add-to-list 'package-archives
             '("melpa" . "") t)

;; (setq package-archives '(("gnu" . "")
;;                          ("marmalade" . "")
;;                          ("melpa" . "")))

onetom23:02:54

but anyway, thanks for putting me on the right track!

onetom23:02:37

i will nag the author to remedy this situation. i feel a bit embarrassed because im recommending the braveclojure book usually as a good starting point... 😕

dpsutton23:02:56

its a great book

dpsutton23:02:00

i'm not a fan of its cider setup

dpsutton23:02:09

it's a repo with byte compiled cider 0.8

dpsutton23:02:13

and updating is weird

dpsutton23:02:18

and i think there's been a change in the byte code

dpsutton23:02:27

i don't know why that way is recommended any longer

richiardiandrea23:02:10

talking about setup, I found emacs-live's approach the best, packages organized with git submodule

richiardiandrea23:02:29

actually the git submodule part is something I would like to improve

richiardiandrea23:02:45

but I can go in any subfolder and checkout a specific commit

richiardiandrea23:02:00

or work on the fix that break and use it right away

richiardiandrea23:02:19

needless to say that I have a fork of emacs live

onetom23:02:58

just to double confirm, u r talking about this?

dpsutton23:02:10

@onetom if you're looking for an up-to-date emacs config, checkout https://github.com/bbatsov/prelude

dpsutton23:02:21

its from the maintainer of cider as well

dpsutton23:02:27

it's very nice, no fuss, works, etc

onetom23:02:43

thanks, i will give these a try

dpsutton23:02:50

happy coding

onetom23:02:35

btw, i started clojure with sublime text ~2.5 yrs ago, tried light table, emacs 24, atom, vs code, night code and ended up using cursive, but i would like to keep an eye on the alternatives...

richiardiandrea23:02:56

@onetom yes, I keep my branch super up to date and don't follow emacs-live too much anymore apart from merging upstream every now and then

onetom23:02:16

we just had a poll at the clojure remote 2017 conference yesterday and emacs was still the number one editor

arrdem23:02:04

emacs was also like a 50% mindshare in the “state of clojure” survey iirc

richiardiandrea23:02:08

@onetom just to show you some magic, today I was working on this, I hope it is pretty readable):

(defun cider--eval-bindings (bindings)
  "Sends a (def bound-name expr) form to the cider repl for each
binding in bindings."
  (let ((bound-name (pop bindings))
        (init-expr (pop bindings)))
    (when bound-name
      (let ((form (concat "(def " bound-name " " init-expr ")")))
        (set-buffer (cider--get-repl-buffer))
        (insert form)
        (cider-repl-return)
        (cider--eval-bindings bindings)))))

richiardiandrea23:02:46

it deffes all the let bindings