Fork me on GitHub

Is it possible to resolve symbols as fn or letfn in cursive? I have problem with this macro:

(defcmd :command/login
        (cofx [cmd ctx]
        (fx [cmd cofx]
which expands to something like this:
{:cmd-id :command/login
 :cofx (fn [cmd ctx]
 :fx (fn [cmd cofx]
cofx and fx are converted to anonymous function definition. But cursive marks possible function parameters as “cannot be resolved”. I think that marking symbols cofx and fx to be resolved as fn would solve the problem. What do you think?

Oliver George10:09:45

Quick thought in passing. I'd like to know which of my functions have a (s/fdef ...) spec associated with them so that I'm encouraged to add ones which are missing.

Oliver George10:09:23

A simple visual indication would be enough to be useful.

Oliver George10:09:40

Cursive Spec MVP FTW!


@olivergeorge Good idea, could you file an issue for that one please?


@cfleming Are there any plans to support tools.deps.alpha? That would be pretty snazzy.


@cfleming Per our conversion earlier about formatting: I made the CLI that wraps cljfmt It is working well so far. Although not incredibly important, the one place this breaks is in the REPL. I don't believe there is any way to get the REPL content as a string or file and reformat with an external tool.


The REPL content would need to be available as an external tool macro.


I suppose I could select all the REPL text, use the SelectedText macro, and then format that. Though it's not clear what is done with the output. Does it replace the selected text with the output of the external tool? Anyway, its not the cleanest solution anyway because you have to select all of the text.


@narek I’m actually working on the test integration right now, I’ll see if I can reproduce that.


Good to hear, thanks!


@tomas Unfortunately I don’t think you can use that in your case. The issue is that cofx and fx don’t resolve to anything, they’re special to the macro.


You’re right, but I can create var so cursive will see it and macro will shadow it for execution. Then I can mark fx/`cofx` to be resolved as fn

(defmacro defcmd [& args])
(defmacro cofx [& args])
(defmacro fx [& args])
(defcmd :solved.cmd/login
         (cofx  [cmd ctx])
         (fx [cmd cofx]))
It’s kind of hack, but can solve the problem for now…


Very true. I’m planning to add arbitrary “Resolve as…” support but haven’t done so yet. There’s a hack described here though:


Thanks a lot, that works!


Sadly there’s probably no good way to support that until I get better general macro support into Cursive.


@potetm Yes, I’ll probably support that soon. It currently doesn’t support everything that Cursive needs (e.g. source roots) so those will have to be manually set up.


@kenny Hmm, I’ll have to look at the External Tools part to see if there’s anything I can do about that.


If they don’t have something like a “Text content of current editor” macro then it might be difficult.


Yeah nothing like that exists right now. Upon further inspection, the "Macro preview" for SelectedText does not show text as being selected when it is selected in the REPL. It only shows selected text when text is selected in the editor.


Yeah, the REPL editor is special, some things may not work. I can imagine the External Tools functionality being built around editors editing files, since it has to be able to pass them to external tools somehow.


I’m surprised it doesn’t support directly piping text better, though.