1

I recently switched to emacs. Just wanted to see how it works and if it'll help with productivity.

Right now I'm working in Haskell, which means a lot of function composition with . operator.

I have a code block that looks like this

certainat :: Certain -> Maybe Double
certainat = join . fmap at . certainCalls . certainEffects

certainld :: Certain -> Maybe Double
certainld = join . fmap maybeIDFunctionCallld . certainCalls . certainEffects

certainxin :: Certain -> Maybe Double
certainxin = join . fmap insert . certainCalls . certainEffects

and I want to align entire block on .

Reading through wiki docs, I tried doing it with C-u M-x align-regexp .\(\) but the result was weird spacing between characters. Plus that only worked on one line.

What should I do?

1
  • 1
    What output do you expect?
    – choroba
    Nov 28, 2018 at 14:20

1 Answer 1

1

Running the same command with different parameters:

Complex align using regexp: \(\.\)
Parenthesis group to modify (justify if negative): -1
Amount of spacing (or column if negative): 0
Repeat throughout line? y

Output:

certainat :: Certain -> Maybe Double
certainat = join  . fmap at                    . certainCalls . certainEffects

certainld :: Certain -> Maybe Double
certainld = join  . fmap maybeIDFunctionCallld . certainCalls . certainEffects

certainxin :: Certain -> Maybe Double
certainxin = join . fmap insert                . certainCalls . certainEffects

Is that what you wanted?

2
  • Yes, that's exactly what I was looking for! Thank you! Also one more question if you wouldn't mind, is it possible to align the first word join and also align on .?
    – atis
    Nov 28, 2018 at 15:06
  • Just run align-regexp on join (or even =) without C-u before aligning on the dot.
    – choroba
    Nov 28, 2018 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.