Hi guys, I switched from doom emacs to building my own emacs from the ground up. Today I set up everything related to Clojure. However, somehow clojure-mode won‘t allow my to indent code by myself when I press TAB
. The reason why I believe clojure-mode is causing this is because after removing clojure-mode I was able to use TAB
again. Has anybody encountered that? Is this standard behavior? Because in doom emacs it was possible to manually indent with TAB
in clojure source files. I‘m using evil-mode as well in case that‘s related to this issue.
to find out what command is run by a keybinding, try C-c h tab
. for me its company-indent-or-complete-common
. personally i wouldn't want to indent with tab as newlines should already be correctly aligned. and for formatting i hit M-q
to format the current top level form
For me that is the command: indent-for-tab-command
and that's not indenting?
No, but only in Clojure source files. When I try to TAB on an empty line then nothing happens.
and if you disable clojure-mode can you indent?
Yes, I tried to delete clojure mode and afterwards it works
i was thinking with just m-x clojure-mode
would turn it off
is it the same function when clojure-mode is enabled?
C-c h tab
with clojure-mode is the same as a non-clojure mode buffer?
Yes, they are the same ... hmm
ok. so i did C-h f indent-for-tab-command
and it mentions
> The function called to actually indent the line or insert a tab is given by the variable ‘indent-line-function’.
and in clojure-mode this is
(defun clojure-indent-line ()
"Indent current line as Clojure code."
(if (clojure-in-docstring-p)
(save-excursion
(beginning-of-line)
(when (and (looking-at "^\\s-*")
(<= (string-width (match-string-no-properties 0))
(string-width (clojure-docstring-fill-prefix))))
(replace-match (clojure-docstring-fill-prefix))))
(lisp-indent-line)))
Does that mean that actually „lisp-indent-line“ is called when outside of docstrings ?
yes exactly
I see! Thanks! I already spent quite some time on that, thanks to you I have a new direction which I can check.
can you post a form with |
where your cursor is and what the form looks like before you indent it?
I don‘t completely understand. At the moment I can‘t do any indentation by myself
for instance, when i type
(let [thing 1])
when i press enter after the 1
i get it automatically indented
(let [thing 1
<cursor>])
i don't indent anything, it just indents for me
Oh yes, that works quite well for me too
yeah. so i was wondering how you get into a state where indentation is necessary
and if i erase all of the spaces introduced for me and hit tab, it indents it back to the correct level
Maybe it is a bad habit. But sometimes I am in this situation:
(defn some-fn)
|
to me the only valid indentation level there is against the margin where your cursor is
Then I would press TAB and enter []
and parinfer would put the end parentheses from above to the next line
oh i see. i never use parinfer but i can see why its not indenting. not sure how to help you with that though
I probably should just get used to the automatic indentation, seems to be generally a better way of writing Clojure
Thanks for your help !