Fork me on GitHub
#cider
<
2023-07-25
>
vemv11:07:09

How do I get the repl to scroll to stdout when it is emitted? In (much) older cider versions, new stdout was always visible. Nowadays, it may be invisible until you realise there is new stdout at all, and you manually scroll up the repl.

oyakushev12:07:01

This is what has broken it.

vemv12:07:06

ah yes, that commit/discussion was vaguely on my mind :) the upside is that printing is indeed far faster than it used to be

vemv12:07:26

...Probably it can make sense to selectively, temporarily bind that var when doing stuff that expects a println

oyakushev12:07:57

Just a sec, I'll share my hack with you

oyakushev12:07:09

@U45T93RA6 Do you use cider-repl-clear-buffer?

vemv12:07:40

yep, quite often

oyakushev12:07:19

(defun cider-clear-repl-buffer-with-shift ()
    "Needed to side-step ."
    (interactive)
    (cider-repl-clear-buffer)
    (insert "(symbol \"\")")
    (cider-repl-return))

oyakushev12:07:32

I use this function instead of it.

oyakushev12:07:00

The effect is that when I clear the buffer, it looks like this.

oyakushev12:07:37

The cursor is not on the first line, and thus the printed output does not get hidden above.

oyakushev12:07:22

Why (symbol "") ? Because it is a command that once evaluated, does not trigger any printed REPL response, so it looks a bit cleaner.

vemv12:07:17

I see! I'm having success with a simple (setq cider-repl-display-output-before-window-boundaries t) though. Defaulting to nil and binding it during a couple key commands seems workable to me.

❤️ 2
bozhidar06:07:21

Well, for people who don’t care about the performance impact just enabling this permanently is probably the best option.

bozhidar06:07:04

The main reason I agreed to disable this was that it seemed it was the biggest contributor to REPL slowdowns after excessively long lines.

bozhidar06:07:46

Probably we could have named the config variable a bit better. 🙂

Charles Comstock20:07:35

I've noticed recently that cider-find-dwim doesn't seem to be looking up the whole symbol in certain cases. As example, if I attempt to run M-. on bytes->string, with the point somewhere in the word bytes, it gives a prompt "Jump to: bytes-", instead of bytes->string, and likewise if the point is in string, it will prompt for "Jump to: string". If I type in the part of the symbol that was elided, it will jump to the source of function under point, but it's awkward it's not finding the whole symbol by default. I think I have subword-mode on for other reasons so maybe that's a strange interaction on the boundary there, but wasn't sure if anyone has an idea why it's not detecting the whole symbol. I'm also running a recent build of emacs, so it's possible some behavior has changed there too, but was curious if anyone else has encountered this or found a workaround. Related to this, I had to switch back to cider-find-dwim a while back and disable cider-use-xref as the xref support stopped working for me in cider (it always looks for a TAGS file instead of using cider runtime lookup). I'd love to switch back to the xref backend, but also curious if anyone has that working.

vemv20:07:43

For the first issue, it seems quite easy to check the elisp code, e.g. • what is exactly grabbed / how? ◦ check the source, play on ielm / with M-: • what is sent to cider-nrepl? ◦ checkable by enabling nrepl-log-messages and perusing the related buffer ◦ mostly a redundant step given the previous one, it's just to make sure

vemv20:07:45

re: xref, we have a PR, with this conclusion: https://github.com/clojure-emacs/cider/pull/3349#issuecomment-1604846650 I'm in a good availability to take it - just had forgotten about with with all the other CIDER stuff I'm up to these days :) but if you happen to have the time, we'd appreciate the extra hands!

Charles Comstock21:07:18

Ok, good to know on the second, which sounds like it's just broken for now so it's not my setup that is to blame. I don't know as I have time at the moment, but I will see.

Charles Comstock21:07:00

As to the cider-find-dwim it looks like the input symbol-file is only getting bytes- , but I'm not following from what that input is coming from. I hardcoded define-key "M-." to cider-find-dwim in the cider keymap because I thought that was the old function before xref-find-definitions. Is there a different entrypoint intended?

Charles Comstock21:07:07

Should I have bound it to cider-find-var instead?

vemv21:07:35

Taking a quick look at the source, doesn't it boil down to a (cider-symbol-at-point 'look-back) call? What does that sexpr return if evaluated with M-: when the cursor is over bytes->string ?

vemv21:07:15

I do see the correct result in the minibuffer, following that M-:

Charles Comstock21:07:26

if the cursor is on the - that's what I get yea, "bytes->string"

vemv21:07:51

(I'm back later, maybe tomorrow)

Charles Comstock21:07:13

I think the answer is I shouldn't be using cider-find-dwim, but instead of cider-find-var

Charles Comstock21:07:23

I'm just not sure what cider-find-dwim is for

Charles Comstock21:07:21

Yep, double checking the normal cider-repl-mode-map "M-." defaults to cider-find-var if cider-use-xref is nil. I think I know why I hardcoded it though, cider-use-xref only happens at load time, and I made the mistake of setting it after cider was loaded so it wasn't actually doing anything, so I hardcoded it to what I thought it was supposed to be instead of cider-find-var. Still not sure what the intended use case is for cider-find-dwim, but binding to cider-find-var fixes things for this use case.

vemv21:07:45

> I'm just not sure what cider-find-dwim is for me neither atm. if you could fully describe how you set it up? my understanding is that you bound it to M-. . but cider-find-dwim (symbol-file) expects one argument - how is it exactly passed from M-.?

vemv21:07:13

on the other topic, I don't use xref, but cider-find-var instead

Charles Comstock21:07:28

(define-key map (kbd "M-.") #'cider-find-dwim) was the setup I used (inside of a (let ((map cider-mode-map)))). I also see there is a mouse version of cider-dwim so maybe that is the intended use case? I don't actually understand how the unary arg was being passed to cider-find-dwim I think that's some emacs magic with default interactive arguments?

vemv21:07:53

it ultimately calls (thing-at-point 'filename) , that was the issue

Charles Comstock21:07:12

Gotcha, that is weird but I guess makes sense. Re cider-use-xref, I wonder if instead of setting a defcustom to modify the bindings, the default should be to use cider-find-var, and then add a minor mode to toggle the xref bindings so the load order isn't important? I always find it really frustrating to find a defcustom that has a load order dependency.

vemv21:07:29

I agree it's a bad default. I didn't have input in its introduction Probably it's too late to change it. With the https://github.com/clojure-emacs/cider/pull/3349 its default shouldn't matter all that much ...I'll allocate tomorrow to fixing it, Thu at most, we want to have a pretty cider 1.8.0 https://github.com/clojure-emacs/cider/blob/master/CHANGELOG.md

bozhidar05:07:42

I didn’t read this conversation in great detail, but cider-find-dwim is supposed to work with everything and cider-find-var is supposed to work only with vars.

bozhidar05:07:14

The symbol at point logic in both should be the same, though.

bozhidar05:07:40

(`cider-find-dwim` should work with vars, keywords, filenames, etc)

bozhidar05:07:50

As for the cider-use-xref config - it’s kind of hard to do it differently unless we add some wrapper lookup function that checks the value itself. I was hesitant to do this, as it’d obscure a bit what exactly is being called when people use lookup, but I agree that it’s also confusing if a configuration change requires a mode to be restarted.

vemv11:07:19

> (`cider-find-dwim` should work with vars, keywords, filenames, etc) When used interactively, it uses (thing-at-point 'filename) , which will not take the whole foo->bar token. This may or not may be the intended behavior. Note the arg name in defun cider-find-dwim (symbol-file) . Because it says "file", it seemingly makes sense to use (thing-at-point 'filename) . Perhaps this could be better documented.

bozhidar04:07:11

Yeah, the documentation should be improved. It seems it stayed the same between the introduction of the command https://github.com/clojure-emacs/cider/pull/1036 and it’s expansion of functionality https://github.com/clojure-emacs/cider/pull/2510