Skip to content

cond-> indenting incompatible with common nested -> use case #419

Open

Description

@aengelberg

Expected behavior

(-> obj
    (cond->
      pred1
      (do-a-thing)
      pred2
      (do-another-thing)))

Actual behavior

(-> obj
    (cond->
        pred1
      (do-a-thing)
      pred2
      (do-another-thing)))

Environment & Version information

clojure-mode version information

clojure-mode (version 5.5.2)

Emacs version

24.5.1

Operating system

Mac OS X El Capitan 10.11.3

Activity

  1. MalloZup commented on Aug 5, 2019

    @MalloZup

    autogenerated with https://github.com/MalloZup/doghub: issue inactive since 450 days. Please update the issue or close it

  2. kommen commented on Aug 5, 2019

    @kommen
    Contributor

    I guess this is basically the same as #433

  3. j-cr commented on Dec 25, 2019

    @j-cr
    Contributor

    Setting its indent spec to 'defun solves the problem:

    • (define-clojure-indent (cond-> 1)) ; default:
    (-> obj
        (cond->
             pred1
          (do-a-thing)
          pred2
          (do-another-thing)))
    
    (cond-> obj
      pred1
      (do-a-thing)
      pred2
      (do-another-thing)) 
    
    • (define-clojure-indent (cond-> 'defun)):
    (-> obj
        (cond->
          pred1
          (do-a-thing)
          pred2
          (do-another-thing)))
    
    (cond-> obj
      pred1
      (do-a-thing)
      pred2
      (do-another-thing))
    
  4. j-cr commented on Dec 25, 2019

    @j-cr
    Contributor

    Doing (define-clojure-indent (as-> 'defun)) also sort of fixes #433:

    (as-> 42 x
      (+ x 1))
    
    (as-> (very-very-very-long-expr-prob-shouldnt-be-here)
      x
      (+ x 1))
    
    (-> 123
        (+ 1)
        (as-> x
          (+ x 1)
          (- 1 x)))
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions