Fork me on GitHub
#emacs
<
2022-10-07
>
Drew Verlee03:10:18

why does my .dir-locals.el file contain a list which immediately contains another list? this is how i have only ever seen dir-local files.

((nil . (
         (cider-clojure-cli-aliases  . "-A:dev")
         (cider-preferred-build-tool . clojure-cli)

         (cider-ns-refresh-before-fn . "reloaded.repl/suspend")
         (cider-ns-refresh-after-fn . "reloaded.repl/resume")

         )))

elken03:10:40

It's an alist of cons cells with (mode . list-of-vars) where nil mode just applies to every mode

👍 1
🙏 2
Drew Verlee03:10:28

what would including another top level list do?

Drew Verlee03:10:36

and thanks, that makes sense.

elken03:10:25

I imagine it'll either read it as normal still or do nothing, but I'm not 100%.

💪 1
Drew Verlee04:10:44

it says it "should hold a list" not what happens if you put more then one in. I would argue that if something has to do something, then remove the choice. In this case, just have the file contents get wrapped in alist. e.g

(clojure . (...))
vs
((clojure . (...)))
it feels like the top level list is for another program's convenience. idk. i'm learning emacs and elisp so i'm knit picking things. those dir-local.el files have been a headache of mine for years because i haven't learned elsip. Now that i know a tid bit, i still dont understand the list in list thing there from a UX perspective.

Drew Verlee04:10:38

i mean, if clojure files were like:

((ns core)) 
would also be weird to me.

elken04:10:53

The first example is just a single cons cell. You can have multiple modes, which is why an alist is needed

Drew Verlee04:10:15

(clojure ..)
(clojurescript ...)

elken04:10:04

Those are individual cells yeah, they still have to be in a list

Drew Verlee04:10:26

when you parse the file you can add the list. I'm saying they made it easy for the machine, not the humans.

elken04:10:44

They're best edited with M-x commands rather than manually add-dir-local-variable

Drew Verlee04:10:11

that is news. let me try that 🙂

Drew Verlee04:10:18

:mirror_ball:

Drew Verlee04:10:57

thanks @U043RSZ25HQ, ill be doing that from now on, autocomplete and everything. that's why i was poking at this, because it felt too hard.

elken04:10:39

No worries! 😄

Drew Verlee04:10:59

i need to stop saying "you" in conversations when talking about some obscure thing like emacs function that reads the dir-locals file. It's a terrible and lazy habit.

ag04:10:35

> when you parse the file you can add the list. I'm saying they made it easy for the machine, not the humans. Ya, after Clojure, Elisp may look weird and not very human-centric. Wait till you get to write some sizable elisp functions. In Clojure we have hashmap - simple and straightforward, universal structure. Elisp has alists, plists, hash tables, classes, cl-defstructs, and more.

👀 1
ag04:10:55

If Elisp wasn't a Lisp dialect and had syntax similar to I don't know C or even Lua, I'd probably hate it. I do tolerate it only because it's a Lisp.

👍 1
anonimitoraf10:10:57

I've recently started using cider-inspector a lot and it's awesome I was wondering what it would take to support highlighting to make it easier to read the (long) java methods?

r0man13:10:58

Hi @UR37CBF8D, I recently added support for Datafy and Nav to the Cider inspector. I documented some of what I learned in this document [1]. The backend (cider-nrepl) sends the data to be rendered to the frontend (Cider) under the :rendered key you can see here [2]. The content of :rendered is a protocol that has been adapted from SLIME. It contains some special directives to instruct the client how to render things. At the moment we support the rendering of string literals, and the special :newline and :value directives. I know that SLIME also had an :action directive, but we don't have this in Cider. At the moment I think none of these directives do support any styling. So, to get this working I believe the protocol or one of the directives might need to be extended. For Emacs only, maybe we could add some font lock rules which does the job? [1] https://github.com/clojure-emacs/orchard/blob/master/doc/inspector.org [2] https://github.com/clojure-emacs/orchard/blob/master/doc/inspector.org#inspecting-an-object

👀 1
r0man13:10:30

Maybe @U051BLM8F has an idea how to best accomplish this?

dev-hartmann18:10:17

Hey folks, I’m trying doom eMacs atm.

dev-hartmann18:10:14

I’m trying to add an on-save hook to cider-format-buffer but can’t get it working somehow. Does someone know how to do it?

ag19:10:54

Can you post your snippet in #C01GE5PD249?

dev-hartmann19:10:25

Sure, just need to fetch my computer 😅

dev-hartmann19:10:35

(after! cider
  (add-hook 'clojure-mode-hook 'cider-fromat-buffer)
  (add-hook 'clojurescript-mode-hook 'cider-fromat-buffer))

dev-hartmann19:10:17

normally I’d set it withing the use package :config, but don’t know how to do it here

dev-hartmann19:10:07

Ahh… how stupid. I did copy the wrong part

dev-hartmann19:10:28

It needs to be the before-save hook :melting_face:

lread22:10:01

@U0J8XN37Y there is also a #C01GE5PD249 channel!

dev-hartmann08:10:36

@UE21H2HHD thx! didn’t know that

👍 1
elken07:10:43

All you've done there is run the function when the mode is started. Doom already comes with an autoformatter (that is currently undergoing a refactor) :editor format with an optional +onsave flag, I would recommend this instead. If you insist on using cider-format-buffer, you'd have to create a function to check if the major-mode is clojure-mode/`clojurescript-mode` and add it to after-save-hook to run cider-format-buffer (And yes, as others have pointed out this is better suited to #C01GE5PD249)

dev-hartmann08:10:40

team policy is using cljfmt, so it’s not really my call 🙂 I found the after! macro in doom and wrote an after! cider fn that adds cider-buffer-format to the save-hook

dev-hartmann08:10:13

would be awesome to have the (format +onsave) option configurable

dev-hartmann08:10:43

but tbh I think I dislike the my current after! cider solution and am going to switch to a .dir-locals approach

elken09:10:19

I see. The refactor is what I'm working on & I was going to move to cljfmt anyway. > team policy is using cljfmt, so it’s not really my call You can use set-formatter! to change which formatter is called > would be awesome to have the (format +onsave) option configurable In what way? > but tbh I think I dislike the my current after! cider solution and am going to switch to a .dir-locals approach I don't think either are particularly cleaner, but if you have ideas on improving it there's a discourse post on it here https://discourse.doomemacs.org/t/editor-format-refactor/2644

dev-hartmann09:10:06

@U043RSZ25HQ wow, didn’t know set-formater! did exist. That’s actually what I meant with configure format +onsave 🙂

dev-hartmann09:10:21

thx for your in depth answer!

elken09:10:55

Ah I see 😄 Glad I could answer there then haha

dev-hartmann09:10:17

yup, a really nice coincidence 🙂

dev-hartmann09:10:53

@U043RSZ25HQ since you know way more about it than myself, would you set cljfmt as a formatter or cider-buffer-format, which seems to be a wrapper arround that

elken09:10:21

I haven't dug into what cider formatting does really, so I'd lean to the former personally. But the new module refactor will also let you use elisp functions as well as shell commands; so it could be moot. As long as it produces clojure code that satisfies work constraints; that's what matters 🙂

dev-hartmann09:10:42

that’s true 🙂 it’s just that the cider-format fn does everything I need and I haven’t used cljfmt from the cli so I need to read it’s documentation

elken09:10:21

If the after! does what you need it to then I'd probably say stick to that. I'm endeavouring to get the refactor done as fast as I can, so hopefully when that goes up it should simplify things 😄

dev-hartmann09:10:36

makes, sense. It was just that little voice in my head trying to find ‘a nicer way’ … will leave it for no, but at least I have a deeper understanding of doom now, thanks for that!

elken09:10:13

No worries 🙂 I think I pointed it out before but there's also #C01GE5PD249 here too 😄

dev-hartmann09:10:41

👍 I joined it