Fork me on GitHub
#cider
<
2017-01-24
>
stuartrexking04:01:59

How do I load and run a top level form in the repl like Timothy Baldridge does here: http://www.youtube.com/watch?v=enwIIGzhahw&amp;t=1m24s. I don’t see the option to do it in the docs https://cider.readthedocs.io/en/latest/interactive_programming/

stuartrexking04:01:00

He steps through the file, loading and evaluating forms in a single step. I can load into the repl and hit Enter, but it means switching buffers which I want to avoid.

dpsutton04:01:12

(defun cider-insert-last-sexp-in-repl (&optional arg)
      "Insert the expression preceding point in the REPL buffer.
    If invoked with a prefix ARG eval the expression after inserting it."
      (interactive "P")
      (cider-insert-in-repl (cider-last-sexp) arg))

dpsutton04:01:18

looks like it might be this one

dpsutton04:01:57

which calls this

dpsutton04:01:01

(defun cider-insert-in-repl (form eval)
      "Insert FORM in the REPL buffer and switch to it.
    If EVAL is non-nil the form will also be evaluated."
      (while (string-match "\\`[ \t\n\r]+\\|[ \t\n\r]+\\'" form)
        (setq form (replace-match "" t t form)))
      (with-current-buffer (cider-current-connection)
        (goto-char (point-max))
        (let ((beg (point)))
          (insert form)
          (indent-region beg (point)))
        (when eval
          (cider-repl-return)))
      (cider-switch-to-repl-buffer))

dpsutton04:01:07

which unfortunately higlihgts the buffer

dpsutton04:01:11

i'm not sure why

dpsutton04:01:14

i wonder if in that version of cider it didn't focus the repl

dpsutton04:01:31

but you can ask him. he's quite active in the clojure channel

richiardiandrea04:01:25

I use this one:

(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)))

richiardiandrea04:01:17

@dpsutton there is a (cider-switch-to-repl-buffer), maybe you just need to take it away?

qqq11:01:33

every day that I use emacs is a day I regret the 15 years I spent using vim

dpsutton12:01:02

don't regret it. vim is quite handy. and when you're just shortly in a machine, knowing vim is quite nice.

dpsutton12:01:18

they are two great editors. speaking both of their languages can only be beneficial

dpsutton12:01:27

at that looks like the winner richiardi

qqq14:01:54

emacs isn't an editor though; (as Im still usin evil binding keys); I've just never realized that "my IDE is programmable"

qqq14:01:59

this changes all forms of things

dorianc.b16:01:47

Im having a weird issue where the the repl is not recognizing the file I opened it with. The prompt says user instead of the project name so every time I try to use a symbol defined in the file I keep getting the symbol undefined error.

qqq16:01:25

suppose I need to write my own inferior lisp mode, where can I get the documentaiton in inferior lisp and comint ? all I'm getting is https://www.gnu.org/software/emacs/manual/html_node/emacs/External-Lisp.html , which is very weak on documentation

norman16:01:14

@dorianc.b you need to switch to that namespace, and possibly load that namespace if nothing else in your startup us

norman16:01:28

specifically look at cider-load-buffer (C-c C-k) and cider-repl-set-ns (C-c M-n)

norman16:01:52

Just ask if it’s not clear what those are doing or why you need to do them

dorianc.b16:01:07

Thanks it was just weird because it was only on one file

norman16:01:46

I guess it depends on how you have it set up, but cider doesn’t normally switch the repl to the open file. (unless that’s a new thing)

qqq17:01:08

@bozhidar : I wanted something lightweight than cider, so I was looking for inferior-lisp clojure minimal bindings. Then, I found https://github.com/clojure-emacs/inf-clojure It turns out you own both of the top 2 most popular emacs/clojure interactive dev projects.

dorianc.b18:01:41

@norman thanks, using load buffer and set ns worked. For some reason the repl wasn't automatically loading the right namespace.

norman18:01:38

I don’t think your expectation that it should is correct

norman18:01:22

If you do nothing, the repl should go to the user namespace. Things like a :main in your project would influence that

norman18:01:58

Off the top of my head, there’s nothing else that would cause the repl to automatically go to another namespace

dpsutton19:01:40

Correct. Loading a file is independent of setting the namespace

norman19:01:31

And setting the namespace is independent of loading a clojure file

qqq20:01:00

what resource does cider use to lokoup the latest version of each package?

dpsutton20:01:05

I don't believe cider does

dpsutton20:01:15

I think clj refactor offers this though

richiardiandrea21:01:22

Have you guys ever encountered the following error in cljs:

Tue Jan 24 13:30:53 PST 2017
 [
server-loop
] WARN - 
opcode mismatch: pre: 1, now: 0

richiardiandrea21:01:37

I am evaluating (update-in @app-state [:node :colors] (constantly []))