Fork me on GitHub
#cider
<
2020-06-21
>
Quentin Le Guennec12:06:53

Hi, I need to be able do detach the cider process such as when I exit emacs, cider-jack-in-cljs doesn't fetch dependencies again. Is that possible?

practicalli-john13:06:12

Unless I miss-understand what you are doing, project dependencies for projects are saved locally, so unless you update the versions of dependencies then they are only downloaded once.

Quentin Le Guennec13:06:38

yes, but for some reason, there are still fetches happening. When I deactivate my VPN (where the dependencies are downloaded), I cannot jack-in.

Ed10:06:55

You can start the JVM process from a shell and then connect to it from Emacs using cider-connect or cider-connect-cljs . If you need to know what Cider is running when you call cider-jack-in, you could look in *messages* where Emacs logs to, or jack in and look in your process list, but it tries to detect what you're using to start your REPL (lein, boot, clj) and injects some dependencies for things like Cider middleware. These are controlled by your settings in Cider.

Quentin Le Guennec12:06:34

(the issue here is that in my case, fetching dependencies takes a lot of time, and I restart emacs quite often)

Ed10:06:44

Why are you restarting Emacs so often? I only restart when I reboot. I start Emacs with --daemon and run emacsclient -c -nw file.clj when I want to edit something from the terminal (and C-x # to tell Emacs I'm done editing that file or C-x 5 0 to close the frame). I also have this in my .zshrc - bindkey -s "^x^f" $'^aemacsclient -c -nw ' for those times when I accidentally hit C-x C-f in the terminal ;)

practicalli-john13:06:26

Is there a list of all the variables I can set in CIDER? I am creating some example .dir-locals.el files and would like to know what is possible. There are many examples sprinkled in the documentation, https://docs.cider.mx/cider/0.25/config/basic_config.html but it would be useful to have a list of them for reference. Are they all defcustom names in the cider project? If so, I can use helm-ag to grab them.

dpsutton14:06:43

That’s probably essentially all of them.

dpsutton14:06:02

You could probably use emacs apropos to grab them

dpsutton14:06:10

If there’s a version for just vars

practicalli-john15:06:58

I created this list from all the defcustom definitions in the CIDER project, there are quite a few. https://practicalli.github.io/spacemacs/reference/cider/configuration-variables.html

dpsutton15:06:29

Can you easily add the docstrings to that?

dpsutton15:06:31

That would be a lovely reference

dpsutton15:06:45

To browse and point people to when asking about features

bozhidar15:06:24

M-x customize-group RET cider RET 😉

dpsutton15:06:38

i never use customize. i prefer to set them explicitly in my init

bozhidar16:06:47

I never use it myself, but it’s still a great way to list all the config options of a certain package.

practicalli-john17:06:06

@dpsutton good idea about the docstrings... I will test my Emacs-fu 🙂

dpsutton17:06:02

haha. its great as is since the names are usually descriptive but pointing people to this who might not have the emacs chops to search for vars or know how to do that would be nice. also, maybe a little tutorial on the header of how to do this inside emacs

practicalli-john18:06:28

I am wondering how to do a search across a project that shows the matching line and the line below. I have helm, helm-swoop and projectile. helm-swoop does multi-line but doesnt seem to work across a whole project.

dpsutton18:06:49

i think using elisp to do this would be easier. then you could use sexp-navigation as it should be defcustom name docstring value or defcustom name value. you could capture that and use parseedn to perhaps spit it out as edn?

practicalli-john18:06:29

Oh, if only I had learned elips already... I am still at the copy something from the internet stage...

dpsutton18:06:35

yeah its clunky at times. i feel slow in it but if you wrote it every day i think it would be easy

dpsutton19:06:34

(let (defcustoms)
  (dolist (file (directory-files "/Users/dan/projects/dev/cider" t "\.el"))
    (unless (string-match-p "dir-locals" file)
      (with-current-buffer (find-file file)
        (goto-char (point-min))
        (while (re-search-forward "defcustom" nil t)
          (let ((custom (substring-no-properties (progn (paredit-forward 1)
                                                        (thing-at-point 'sexp))))
                (docstring (substring-no-properties (progn (paredit-forward 2)
                                                           (or (thing-at-point 'sexp)
                                                               "no docstring provided")))))
            (push (list (file-name-nondirectory file) custom docstring)
                  defcustoms))))))
  (with-current-buffer (get-buffer-create "*defcustoms-from-cider*")
    (dolist (dc defcustoms)
      (insert (car dc) " : " (cadr dc) " : " (caddr dc) "\n"))))

dpsutton19:06:49

replace the directory-files location with your own

dpsutton19:06:04

nrepl-client.el : nrepl-message-colors : "Colors used in the messages buffer."
==============
nrepl-client.el : nrepl-log-messages : "If non-nil, log protocol messages to an nREPL messages buffer.
This is extremely useful for debug purposes, as it allows you to inspect
the communication between Emacs and an nREPL server.  Enabling the logging
might have a negative impact on performance, so it's not recommended to
keep it enabled unless you need to debug something."
==============
nrepl-client.el : nrepl-hide-special-buffers : "Control the display of some special buffers in buffer switching commands.
When true some special buffers like the server buffer will be hidden."

dpsutton19:06:15

use this version

dpsutton19:06:18

(let (defcustoms)
  (dolist (file (directory-files "/Users/dan/projects/dev/cider" t "\.el"))
    (unless (string-match-p "dir-locals" file)
      (with-current-buffer (find-file file)
        (goto-char (point-min))
        (while (re-search-forward "defcustom" nil t)
          (let ((custom (substring-no-properties (progn (paredit-forward 1)
                                                        (thing-at-point 'sexp))))
                (docstring (substring-no-properties (progn (paredit-forward 2)
                                                           (or (thing-at-point 'sexp)
                                                               "no docstring provided")))))
            (push (list (file-name-nondirectory file) custom docstring)
                  defcustoms))))))
  (with-current-buffer (get-buffer-create "*defcustoms-from-cider*")
    (erase-buffer)
    (dolist (dc defcustoms)
      (insert (car dc) " : " (cadr dc) " : " (caddr dc) "\n==============\n"))))

practicalli-john00:06:13

Hmm, when I run this script in ielm it openes all the .el files and then seems to stop. A defcustoms-from-cider buffer is not created, or if it is its deleted (assuming that may be what (erase-buffer) does. but I only get nil as the return value, so maybe the information is output elsewhere, but I dont understand where.. Its time for me to sleep, so will take another look in the morning.