This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-02
Channels
- # announcements (37)
- # babashka (9)
- # beginners (172)
- # calva (7)
- # cestmeetup (28)
- # chlorine-clover (27)
- # clj-kondo (2)
- # cljs-dev (45)
- # cljsrn (8)
- # clojure (185)
- # clojure-dev (27)
- # clojure-europe (6)
- # clojure-finland (3)
- # clojure-nl (5)
- # clojure-uk (13)
- # clojuredesign-podcast (4)
- # clojurescript (54)
- # conjure (19)
- # core-typed (1)
- # cursive (40)
- # datomic (9)
- # emacs (5)
- # figwheel-main (34)
- # fulcro (238)
- # graphql (14)
- # hugsql (3)
- # leiningen (4)
- # malli (6)
- # off-topic (12)
- # pedestal (5)
- # portkey (19)
- # protorepl (8)
- # rdf (2)
- # re-frame (23)
- # reagent (3)
- # reitit (16)
- # shadow-cljs (29)
- # spacemacs (12)
- # sql (1)
- # xtdb (15)
Is there a way to display the current namespace instead of the filename in the bottom of a Clojure buffer?
The Spacemacs Madeline is very customisable and there are several themes and you can also create your own custom mode line https://github.com/syl20bnr/spacemacs/blob/develop/doc/DOCUMENTATION.org#mode-line I assume you would need to write a function to get the current namespace and add a hook to call it when ever you open or switch to a buffer, then update the mode line. There are scripts like the battery indicator that might give you clues. Not something I would personally invest the time in as the namespace partly made from the file name anyway.
I am wondering why the clojure mode doesn’t dispayl the current namespace in modeline. It seems to me like a basic need.
I don't understand why it would be considered a basic need, can you elaborate?
When I switch to a buffer, I’d like to know what buffer I am in.
Currently only the short buffer name is displayed (e.g. core.clj
) which is sometimes not enough to get the context
Edit: short answer: try the doom
modeline theme, update .spacemacs with:
dotspacemacs-mode-line-theme '(doom)
Original long answer...
I believe there are options to configure how much of the path is shown and different mode-line themes have different defaults. I assume showing more of the path would be less work for you to configure than writing a function that extracts the Clojure namespace of a file open in a buffer.
If its a nested namespace then yes more context could be useful, although I am wondering how much of the namespace would need to be shown in order to be useful. There is only a limited amount of space on the mode line and it would not be as useful as simply jumping to the top of the buffer and back again. Having the full project path should give you as much context as the actual namespace (as they should be the same, baring a - and _ difference.
I guess I don't rely on the mode line in Emacs that much, the file name is more than sufficient for me or using g g
to jump to the top of the buffer and look at the ns
declaration, which would provide much greater context as it shows the interned namespaces and functions, so far more than could be shown in the mode-line.
I avoid core
as a namespace, although that does give sufficient meaning to me as it should be the main entry into the project. The file name is next to the project name, as I use a workspace for each project. The REPL connection also has the project name too, so I wouldnt need any other information if I had core.clj
name in the prompt.
I have been using more meaningful namespace names especially now I use deps.edn and clj-new
, rather than use Leiningnen to generate projects.
Thanks for the info about doom-modeline I’ll give it a try
@viebel I have a package that does exactly that. https://github.com/plexus/plexmacs/blob/master/clj-ns-name/clj-ns-name.el could stand to be improved and it's sorely missing error handling, which means that I sometimes need to disable it to be able to open a file (e.g. babashka scripts where the parser trips over the shebang), but works 99% of the time, been using this for a few years already
Awesome! How do I use this package in spacemacs?
see the comments, you just call (clj-ns-name-install)
in your config. You'll need to install walkclj as well. That one is on melpa, this package isn't
I load this as part of a custom layer but probably easier to just drop it in your config and require it like any other elisp file https://github.com/plexus/plexmacs/blob/master/layers/plexus-clojure-extras/packages.el#L14
Thanks a lot. Will try it!
@viebel I have a package that does exactly that. https://github.com/plexus/plexmacs/blob/master/clj-ns-name/clj-ns-name.el could stand to be improved and it's sorely missing error handling, which means that I sometimes need to disable it to be able to open a file (e.g. babashka scripts where the parser trips over the shebang), but works 99% of the time, been using this for a few years already