This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-07
Channels
- # announcements (2)
- # babashka (34)
- # beginners (114)
- # biff (7)
- # calva (16)
- # cider (2)
- # clj-kondo (46)
- # clj-on-windows (14)
- # clojars (13)
- # clojure (33)
- # clojure-europe (17)
- # clojure-nl (2)
- # clojure-norway (8)
- # clojure-spec (3)
- # clojure-uk (3)
- # clojurescript (25)
- # community-development (1)
- # datalevin (1)
- # emacs (53)
- # fulcro (31)
- # gratitude (2)
- # jobs (1)
- # lambdaisland (12)
- # lsp (57)
- # malli (3)
- # nbb (1)
- # off-topic (92)
- # pathom (2)
- # pedestal (2)
- # releases (5)
- # shadow-cljs (25)
- # sql (3)
- # squint (1)
- # testing (6)
- # vim (11)
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")
)))
It's an alist of cons cells with (mode . list-of-vars)
where nil
mode just applies to every mode
what would including another top level list do?
and thanks, that makes sense.
gotcha.
it all explained in great detail in the manual. https://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html
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.i mean, if clojure files were like:
((ns core))
would also be weird to me.The first example is just a single cons cell. You can have multiple modes, which is why an alist is needed
(clojure ..)
(clojurescript ...)
when you parse the file you can add the list. I'm saying they made it easy for the machine, not the humans.
that is news. let me try that 🙂
:mirror_ball:
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.
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.
> 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.
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.
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?
I think @U0CKBRBD2 https://github.com/clojure-emacs/orchard/blob/master/doc/inspector.org#datafiableon cider inspector, maybe he knows?
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
Maybe @U051BLM8F has an idea how to best accomplish this?
Hey folks, I’m trying doom eMacs atm.
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?
Sure, just need to fetch my computer 😅
(after! cider
(add-hook 'clojure-mode-hook 'cider-fromat-buffer)
(add-hook 'clojurescript-mode-hook 'cider-fromat-buffer))
normally I’d set it withing the use package :config, but don’t know how to do it here
Ahh… how stupid. I did copy the wrong part
It needs to be the before-save hook :melting_face:
@U0J8XN37Y there is also a #C01GE5PD249 channel!
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)
@U043RSZ25HQ thx for your answer
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
would be awesome to have the (format +onsave) option configurable
but tbh I think I dislike the my current after! cider solution and am going to switch to a .dir-locals approach
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
@U043RSZ25HQ wow, didn’t know set-formater! did exist. That’s actually what I meant with configure format +onsave 🙂
thx for your in depth answer!
yup, a really nice coincidence 🙂
@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
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 🙂
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
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 😄
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!
👍 I joined it