emacs

Consider also joining #cider, #lsp and #inf-clojure, where most of the tool-specific discussions are happening.
Chris 2020-09-17T22:36:34.104500Z

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.

dpsutton 2020-09-17T22:45:29.106100Z

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

Chris 2020-09-17T22:47:24.106700Z

For me that is the command: indent-for-tab-command

dpsutton 2020-09-17T22:48:14.106900Z

and that's not indenting?

Chris 2020-09-17T22:49:05.107900Z

No, but only in Clojure source files. When I try to TAB on an empty line then nothing happens.

dpsutton 2020-09-17T22:49:25.108200Z

and if you disable clojure-mode can you indent?

Chris 2020-09-17T22:49:45.108800Z

Yes, I tried to delete clojure mode and afterwards it works

dpsutton 2020-09-17T22:50:03.109200Z

i was thinking with just m-x clojure-mode would turn it off

dpsutton 2020-09-17T22:50:23.109600Z

is it the same function when clojure-mode is enabled?

dpsutton 2020-09-17T22:50:43.110100Z

C-c h tab with clojure-mode is the same as a non-clojure mode buffer?

Chris 2020-09-17T22:52:45.111200Z

Yes, they are the same ... hmm

dpsutton 2020-09-17T22:53:03.112Z

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’.

dpsutton 2020-09-17T22:53:16.112400Z

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)))

Chris 2020-09-17T22:54:29.113200Z

Does that mean that actually „lisp-indent-line“ is called when outside of docstrings ?

dpsutton 2020-09-17T22:54:49.113400Z

yes exactly

Chris 2020-09-17T22:57:27.115800Z

I see! Thanks! I already spent quite some time on that, thanks to you I have a new direction which I can check.

dpsutton 2020-09-17T22:59:08.116800Z

can you post a form with | where your cursor is and what the form looks like before you indent it?

Chris 2020-09-17T23:00:54.117800Z

I don‘t completely understand. At the moment I can‘t do any indentation by myself

dpsutton 2020-09-17T23:02:19.118700Z

for instance, when i type

(let [thing 1])
when i press enter after the 1 i get it automatically indented
(let [thing 1
      <cursor>])

dpsutton 2020-09-17T23:02:33.119200Z

i don't indent anything, it just indents for me

Chris 2020-09-17T23:02:41.119600Z

Oh yes, that works quite well for me too

dpsutton 2020-09-17T23:02:59.120200Z

yeah. so i was wondering how you get into a state where indentation is necessary

dpsutton 2020-09-17T23:03:24.121300Z

and if i erase all of the spaces introduced for me and hit tab, it indents it back to the correct level

Chris 2020-09-17T23:04:15.121900Z

Maybe it is a bad habit. But sometimes I am in this situation:

(defn some-fn)
|

dpsutton 2020-09-17T23:04:49.122900Z

to me the only valid indentation level there is against the margin where your cursor is

Chris 2020-09-17T23:05:25.123900Z

Then I would press TAB and enter [] and parinfer would put the end parentheses from above to the next line

dpsutton 2020-09-17T23:06:07.124500Z

oh i see. i never use parinfer but i can see why its not indenting. not sure how to help you with that though

Chris 2020-09-17T23:07:53.126400Z

I probably should just get used to the automatic indentation, seems to be generally a better way of writing Clojure

Chris 2020-09-17T23:08:13.126700Z

Thanks for your help !