Fork me on GitHub
#cursive
<
2020-04-23
>
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!

imre09:04:52

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
grav09:04:22

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

cfleming21:04:44

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

grav06:04:21

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

cfleming10:04:26

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.

helios14:04:19

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

imre14:04:08

try (alias 's 'clojure.string)

potetm14:04:13

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

potetm14:04:32

same for 'clojure.string

imre14:04:45

and reverse their order

✔️ 4
helios14:04:45

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

helios14:04:55

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

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

cfleming21:04:40

@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.

helios14:04:22

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

potetm14:04:12

now that’s a horse of a different color

potetm14:04:56

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

potetm14:04:09

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

potetm14:04:26

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

potetm14:04:53

I would find that more idiomatic anyways.

imre14:04:13

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

4
imre14:04:36

you might get better completions that way?

imre14:04:41

not sure, haven't tried

potetm14:04:02

@imre yeah doesn’t appear to work

potetm14:04:27

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

imre14:04:09

:man-shrugging::skin-tone-3:

potetm14:04:07

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

kenny16:04:04

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
  (:require
    [foo :as foo]))

#::foo{:a "a"}

cfleming21:04:08

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

denik18:04:37

@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?

cfleming21:04:54

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.

16
spellman19:04:02

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.

cfleming21:04:47

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

👍 4
kenny22:04:36

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

kenny22:04:56

I'm on 1.9.1-2020.1

cfleming03:04:36

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.

cfleming03:04:36

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).

cfleming03:04:00

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

cfleming03:04:22

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

💯 4
cfleming03:04:43

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

👏 12
kenny14:04:51

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"
  [opts])
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.

cfleming22:04:07

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