Fork me on GitHub
Jakub Holý (HolyJak)06:04:50

Hello! I use Copy as Kill to copy whole forms. However it does not work in library files because they are read only. Is there another solution? Perhaps it could be modified to work in these files? Thanks!


Hah, I never really understood what the use for copy as kill could be, thanks for the idea 🙂 I mostly use expand selection until I get what I want and normal copy

👍 4

Someone somewhere talked about paredit/parinfer toggle being gone with 2020.1, and that it wasn't possible to find it in prefs either. Can't find the thread now, though. Any solution to this?

Jakub Holý (HolyJak)20:04:41

There is an issue for it in the cursive GH. Workaround is use the menu, under Smart Keys select Clojure therecitbis


I have this fixed and will hopefully have the fix out today.


Thanks Colin, updated to 1.9.2-eap and it works again!


Great! There’s actually a problem with the setting search due to an IntelliJ bug (I forgot to mention that in the release email) but hopefully no-one will need that if the widget is working again.


@cfleming alias doesn't seem to be interpreted correctly. It can't resolve s


try (alias 's 'clojure.string)


@helios doesn’t s need to be a symbol?


same for 'clojure.string


and reverse their order

✔️ 4

whoops, thanks guys 🙂 In reality we have a macro that does the quoting automatically and that cursive can't really resolve well


(defmacro ns-alias
  "Set up a custom alias for use with namespace keywords.

  (ns-alias com.nextjournal.journal.system sys)"
  [ns as]
     (create-ns '~ns)
     (alias '~as '~ns)))


@helios If you swap your args as potetm and imre suggest then you could resolve your macro as alias, which should work. However things may still be funky if that namespace doesn’t actually exist in your source code.


and we use it as (ns-alias foo bar) since the quoting happens in the macro. But bar is unresolved


now that’s a horse of a different color


Yeah, there is a way to do custom resolution, but it needs to mirror clojure constructs.


e.g. you can do a custom let-like macro and make it resolve


so my advice would be to make your ns-alias macro take proper symbols


I would find that more idiomatic anyways.


you could also try reversing the order there and tell cursive to interpret it as the ns macro perhaps?


you might get better completions that way?


not sure, haven't tried


@imre yeah doesn’t appear to work


the first “symbol” is resolved properly, but the second is highlighted




Yeah same. Probably best to just use symbols. Free-floating “symbols” are pretty bizarre in clojureland.


Cursive thinks a required namespace is unused when only used in a map with the namespace syntax. In the below example, foo is marked as "Unused alias".

(ns unused
    [foo :as foo]))

#::foo{:a "a"}


Thanks, I’m planning an upgrade to the unused marking, and I’ll fix that there.


@cfleming by default the REPL scrolls all the way down on a new result. When the result is long I often find myself scrolling up to where it started being printed. With a long REPL history, I sometimes can't easily find the beginning so I just clear the whole REPL and type *1 or eval again. This is definitely an anti-pattern. Is there a configuration setting to auto-scroll not to the bottom but to the top of the last REPL result?


There isn’t, but that’s an interesting idea. Let me think about this and see if I can come up with a general solution.


Is there a way to rename a symbol to a namspaced symbol? As soon as I type the / I get that error message and the Refactor button disables.


Hmm, interesting case, I’ll take a look at that.

👍 4

Cursive doesn't appear to be indenting docstrings on def or defn correctly in cljs


I'm on 1.9.1-2020.1


I just tested this, and it doesn’t do that in CLJ either. But that case is because there are only two lines in the docstring.


The way this works is that Cursive will find the shortest indent of all lines after the first one, and then trim that indent from all those lines. The first line is ignored because it usually has no indent due to the string itself being indented (like in your example).


If you add a third line after the second, indented to match the first one, then it works.


Unfortunately I think this is just an artifact of docstrings not being a great format for docs.

💯 4

I’m actually planning to implement markdown for docstrings shortly, which should hopefully make all this nicer.

👏 12

Hmm I understand the problem. We often will document functions like this:

(defn example
  "Pass in a map of options with the keys: 
    foo: configure foo
    bar: configure bar"
The rendered docstring is a lot harder to read. Perhaps the solution is to always have the first line long enough that you need to indent to the second line 🙂 Empty lines seem to be ignored so it'd need to be a line with actual text. Curious how markdown docstrings would solve this.


Markdown wouldn’t directly help that case, but does allow more control over formatting of docstrings.