Fork me on GitHub
#cider
<
2024-03-08
>
lassemaatta16:03:28

I was trying to configure how *cider-log* is displayed by configuring display-buffer-alist, but my configuration did not seem to have an effect. Is it because cider-log.el uses switch-to-buffer-other-window to always open a window for the log?

lassemaatta16:03:08

my attempt was

(add-to-list
     'display-buffer-alist
     '("\\*cider-log\\*" (display-buffer-reuse-window display-buffer-same-window)))

lassemaatta16:03:45

I did try setting switch-to-buffer-obey-display-actions but that did not seem to help.

lassemaatta16:03:52

If I redefine cider-log--switch-to-buffer with my own variant, where switch-to-buffer-other-window is replaced with display-buffer then it works as I expected. But on the other hand I know almost nothing about elisp so maybe I'm just doing something wrong.

vemv16:03:26

I have

(add-to-list 'special-display-buffer-names '("*cider-log*" vemv.completions/split-window-vertically-small))
and it has worked reliably. I use special-display-buffer-names out of habit (it's a deprecated var / mechanism - display-buffer-alist is more modern). Maybe you can give it a quick try in case it helps for the time being

vemv16:03:12

> If I redefine cider-log--switch-to-buffer with my own variant, where switch-to-buffer-other-window is replaced with display-buffer then it works as I expected. Yeah maybe my setup works because it does something different. It would seem plausible that display-buffer is more flexible than switch-to-buffer-other-window , so we'd be open to a PR in that direction

lassemaatta16:03:29

mkay. Adding *cider-log* to special-display-buffer-names causes the buffer to open in separate frame entirely

vemv16:03:01

It depends, the function can do literally anything for you

vemv16:03:45

In my example, vemv.completions/split-window-vertically-small is a defun that receives a buffer - one can do whatever with it

lassemaatta16:03:07

I have no idea about what's the preferred way to do stuff in emacs, but https://www.masteringemacs.org/article/demystifying-emacs-window-manager is quite adamant that libraries shouldn't use switch-to-buffer and I guess that might apply to switch-to-buffer-other-window. > I find that some packages and functions disregard all rhyme and reason and use switch-to-buffer instead of display-buffer when they want to show a buffer to the user. > This is wrong. And the net result is that your display rules won’t apply if this variable is not set to t.

👍 1
vemv16:03:35

It's confirmed then :) PR welcome

lassemaatta16:03:23

haha, I can barely manage writing my emacs config, it'll be a while before I'm brave enought to even dare thinking about opening a elisp PR 🙂

vemv16:03:24

no issue, I'll give it a go soon then

lassemaatta17:03:36

great, thanks. but no hurry, I'm sure there's more important stuff than this to work on

lassemaatta17:03:23

In any case, the new logging functionality seems to work quite nicely, at least once I learn how to use logview better

vemv17:03:53

I've enjoyed it across a couple commercial projects by now, total game changer. I use timbre/with-context+ a lot now, those contexts end up accessible in the Inspector which one can easily pop up by hitting RET on a log entry

lassemaatta17:03:37

yeah, logging context stuff can be quite nice when debugging

lassemaatta17:03:56

does the cider+logview support filtering by context btw? Like if some log item has {:user 123 ...} can I then somehow apply a filter to show only those lines?

vemv17:03:47

Logjam (the JVM lib underpinning this stuff) says:

* `exceptions`
* `level`
* `pattern`
* `start-time`
* `end-time`
* `threads`
* `loggers-allowlist`
* `loggers-blocklist
` So no, it's not there at the moment. Could be an interesting feature indeed! tbh, normally I use the logging with "one interaction at a time" (one req/res cycle, one deftest, etc) so I don't need a lot of filtering, but yeah I could see it being useful You can create an issue https://github.com/clojure-emacs/logjam if you'd see yourself using it all the time.

👍 1