Fork me on GitHub
#cider
<
2017-12-08
>
gonewest81801:12:49

…copying a debugging question over from github to get more eyes on it. I have a function cider-pprint-eval-defun-to-comment. It’s a variant of cider-eval-defun-to-comment (C-c M-;) where the output is pretty-printed across multiple lines where necessary.

gonewest81801:12:16

When the function is invoked via a keybinding it works as expected. When the function is invoked via M-x cider-pprint-eval-defun-to-comment the function completes without appearing to insert anything into the current buffer. However, as soon as I type any other character (including navigation like C-f, C-b) that’s when the inserted comment appears.

gonewest81801:12:06

(☝️ I’m referring to the same cider pull request I mentioned last night….)

gonewest81801:12:30

Anyone willing to help look into this?

grzm01:12:10

I'm really new to elisp, but I'll look at it in a couple of hours. I want this patch to get it!

daveliepmann08:12:50

@fommil I know this is reaching way back in time, but did you ever find a solution to white-backgrounded stacktraces? https://clojurians-log.clojureverse.org/cider/2016-03-19.html "I have a dark theme (darcula) and when I get a stacktrace or test failure the default faces are all dark text on a white background." I'm experiencing the same issue.

bozhidar09:12:48

> @ag resolve in the repl, could probably wrap it up in a cider command.

bozhidar09:12:04

Indeed. That should be trivial to do.

bozhidar09:12:51

@gonewest818 I can’t imagine what might be different. There’s no real difference between running a command with M-x or via a keybinding.

bozhidar09:12:13

And I don’t see anything special happening in the wrapper command.

bozhidar09:12:06

I think what you should do is instrumenting the command with the Elisp debugger (`C-u C-M-x` while inside its body) and just step through the code and see what’s going on.

gonewest81816:12:39

annoyingly, bug doesn’t occur when I instrument the command with the debugger…

gonewest81819:12:00

I think the issue is occurring in execute-extended-command in simple.el, in particular there seems to be a delay while it figures out a suggested shorthand for the new command: (`You can run the command 'cider-pprint-eval-defun-to-comment' with M-x -p-d-t RET`).

gonewest81819:12:29

If I use the suggested shorthand M-x -p-d-t the bug doesn’t occur. Likewise if I just turn the feature off (setq suggest-key-bindings nil).

gonewest81819:12:48

So I’m looking at the implementation in simple.el.

gonewest81819:12:56

Interesting, there’s a “fixme” comment in the implementation that says “Can be slow. Cache it maybe?” https://github.com/emacs-mirror/emacs/blob/d20161b25e9cd184d841ba9e36ee5141c01fd75f/lisp/simple.el#L1801-L1803

gonewest81819:12:22

so… one workaround is if there is a valid keybinding for the function. In that case it just reminds you what the keybinding is, without trying to compute a shortened string.

bozhidar09:12:17

That’s always the best approach to solving such problems.

bozhidar09:12:09

> Does anyone know how to get emacs to respect cider indentation metadata? Would like to share formatting options across the team and it would be nice to have emacs editor support.

bozhidar09:12:14

@tyler This only work when CIDER is running. There’s nothing special that you need to do - you just have to have this metadata attached to some definition and evaluate it.

bozhidar09:12:55

> As far as I can tell cider-format-buffer dispatches to cljfmt, but even when I set up cljfmt in the project, cider doesn’t seem to do anything when I try to format using that command. When I run lein cljfmt fix it identifies the formatting errors correctly.

bozhidar09:12:27

Well, what CIDER does is that it uses the cljfmt API to do the formatting. Not sure what you’d expect it to do.

bozhidar09:12:44

I’ve been thinking recently about the usefulness of this, because it’s very annoying that results produced by clojure-mode + CIDER would normally differ from cljfmt. Maybe I’ll just remove this functionality at some point, as I doubt it’s useful to make people. When this was added I hope cljfmt would eventually add support for out metadata format as well.

bozhidar09:12:13

> I thought the cljfmt readme had claimed emacs support for years

bozhidar09:12:06

@gfredericks The README is referring just to this. That you can use this straight from CIDER, nothing more.

bozhidar09:12:31

The only real advantage over running the external command is that using the API in CIDER is fast, as you don’t have to wait for a process to start every time. This command was intended to used as something you’d use as file save hook for instance.

bozhidar09:12:03

But yeah, as I said, I think this didn’t turn out to be useful, so the chance of it being removed at this point is pretty big.