Fork me on GitHub
#spacemacs
<
2020-06-02
>
Yehonathan Sharvit08:06:06

Is there a way to display the current namespace instead of the filename in the bottom of a Clojure buffer?

practicalli-johnny08:06:26

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.

Yehonathan Sharvit08:06:42

I am wondering why the clojure mode doesn’t dispayl the current namespace in modeline. It seems to me like a basic need.

practicalli-johnny09:06:58

I don't understand why it would be considered a basic need, can you elaborate?

Yehonathan Sharvit10:06:51

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

practicalli-johnny11:06:38

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.

Yehonathan Sharvit19:06:27

Thanks for the info about doom-modeline I’ll give it a try

plexus06:06:40

@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

Yehonathan Sharvit06:06:42

Awesome! How do I use this package in spacemacs?

plexus06:06:25

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

plexus06:06:25

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

Yehonathan Sharvit18:06:18

Thanks a lot. Will try it!

plexus06:06:40

@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