Fork me on GitHub
#cider
<
2016-06-15
>
malabarba04:06:08

Try setting it to (lambda () 0)

malabarba04:06:40

I'm not 100% sure if the indent spec accepts a function, but it might.

richiardiandrea04:06:31

I'll try tomorrow thanks Malabarba

Lambda/Sierra14:06:03

How does clojure-defun-indents work?

Lambda/Sierra14:06:30

I tried setting it as a file-local variable but it doesn't seem to have any effect.

malabarba14:06:24

@stuartsierra: Looks like the way it's designed it won't work as a file-local variable.

malabarba14:06:32

It won't even work if you setq it either πŸ™‚

malabarba14:06:50

It'll only work by configuring it via the customize menu

malabarba14:06:41

Obviously, the variable's doc shouldn't say that: > This variable is safe as a file local variable if its value satisfies the predicate β€˜listp’.

malabarba14:06:39

@bozhidar I think this variable is left-over from a previous version of the indentation engine. We should either change the way it's used so that it works as a file-local, or make it obsolete and tell people to use define-clojure-indent instead.

malabarba14:06:21

@stuartsierra: You can still have file-local indent by putting something like this as a file-local eval: (define-clojure-indent (my-fn :defn) (some-def :defn))

Lambda/Sierra14:06:34

Yes, that's what I've been doing.

malabarba14:06:47

Ok then πŸ™‚

bozhidar15:06:50

guess we should make it obsolete

bozhidar15:06:15

define-clojure-ident is the way to go

bozhidar15:06:38

although we should have probably named this clojure-define-indentation πŸ™‚

richiardiandrea17:06:34

mmm no, I don't think (trace-handlers (lambda () 0) works here...

richiardiandrea17:06:32

the doc of clojure-indent-function is pretty clear:

The property value can be

- `defun', meaning indent `defun'-style;
- an integer N, meaning indent the first N arguments specially
  like ordinary function arguments and then indent any further
  arguments like a body;
- a function to call just as this function was called.
  If that function returns nil, that means it doesn't specify
  the indentation.
- a list, which is used by `clojure-backtracking-indent'.

richiardiandrea17:06:14

so I tried to return nil, but the minimum indendantation I get is 1 space, probably taking into consideration the initial paren

richiardiandrea17:06:30

(rf/trace-handlers 
 (rf/reghandler :reset-db app-mw
                [_ []]
                db/initial-state))

richiardiandrea17:06:53

with (trace-handlers (lambda () nil))

malabarba19:06:22

Returning nil means it doesn't specify indentation

malabarba19:06:29

that's not the same as specifying 0 indentation

malabarba19:06:48

that just means "not my problem, do the default"

malabarba19:06:56

@richiardiandrea: Try this instead: (define-clojure-indent (trace-handlers (lambda (&rest _) 0)))

malabarba19:06:19

I forgot the function has to take arguments

richiardiandrea19:06:52

Oh ok, I also opened an issue in clojure-mode to add :never-align

richiardiandrea19:06:10

I was playing with clojure-mode earlier

richiardiandrea19:06:12

It looks like that 0 is not directly the column shift

richiardiandrea19:06:34

So that is why I was thinking of adding a keyword to handle that case

richiardiandrea19:06:35

@malabarba: I checked the code and it looks like your option should work but for some reason (functionp method) returns nil here https://github.com/clojure-emacs/clojure-mode/blob/master/clojure-mode.el#L1238

richiardiandrea19:06:14

where method is the lambda (not an emacs expert here so maybe it does not match against lambdas?)

malabarba19:06:52

Odd. Can you see what's the value of method in that case?

richiardiandrea19:06:38

edebug returns lambda

richiardiandrea19:06:38

the doc says and returns nil for special forms

richiardiandrea19:06:52

again, dunno what this means in elisp though πŸ™‚

richiardiandrea19:06:17

ah @malabarba ok, lambda is a special form πŸ˜„

richiardiandrea19:06:28

everything makes sense now ahah

malabarba19:06:06

it might be a bug in our code

malabarba19:06:14

just found it

richiardiandrea19:06:32

I opened an issue, I can take care of the pr if you tell which is the right function πŸ˜‰

richiardiandrea19:06:21

but I still think that a :never-align option might be good

richiardiandrea19:06:31

so #'(lambda () ... should work right?

malabarba19:06:54

I don't think so

malabarba19:06:57

for the same reason

malabarba19:06:15

I've already written the fix

richiardiandrea19:06:22

great, I can try it out

malabarba19:06:35

If you'd like to write a couple of tests I can let you open the PR πŸ™‚

richiardiandrea20:06:09

I am adding the test

richiardiandrea20:06:32

@malabarba: no honey with (trace-handlers (lambda (_ _) 0))

malabarba20:06:10

it worked for me with (define-clojure-indent (trace-handlers (lambda (&rest _) 0)))

richiardiandrea20:06:23

I'll check again